Skip to content

Commit

Permalink
replace encoded domain name limit with max dns name limit
Browse files Browse the repository at this point in the history
  • Loading branch information
kubakukis14 committed Apr 6, 2024
1 parent d744110 commit 2776a99
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions collector/kernel/buffered_poller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ void BufferedPoller::handle_dns_message(message_metadata const &metadata, jb_age

send_a_aaaa_response = 1;
// truncate hostname */
sent_hostname_len = (hostname_len < MAX_ENCODED_DOMAIN_NAME) ? (u16)hostname_len : MAX_ENCODED_DOMAIN_NAME;
sent_hostname_len = (hostname_len < DNS_NAME_MAX_LENGTH) ? (u16)hostname_len : DNS_NAME_MAX_LENGTH;
sent_hostname = hostname_out + hostname_len - sent_hostname_len;
}

Expand Down Expand Up @@ -534,7 +534,7 @@ void BufferedPoller::timeout_dns_request(u64 timestamp_ns, const DnsRequests::Re
const char *hostname_out = req->first.name.c_str();
size_t hostname_len = req->first.name.size();

u16 sent_hostname_len = (hostname_len < MAX_ENCODED_DOMAIN_NAME) ? (u16)hostname_len : MAX_ENCODED_DOMAIN_NAME;
u16 sent_hostname_len = (hostname_len < DNS_NAME_MAX_LENGTH) ? (u16)hostname_len : DNS_NAME_MAX_LENGTH;

const char *sent_hostname = hostname_out + hostname_len - sent_hostname_len;

Expand Down
3 changes: 1 addition & 2 deletions collector/kernel/dns/dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ extern "C" {

#define DNS_NAME_MAX_LENGTH 256

#define MAX_ENCODED_DOMAIN_NAME 80
#define MAX_ENCODED_IP_ADDRS 16

#define MAX_ENCODED_DNS_MESSAGE \
(/* timestamp */ sizeof(u64) + /* jb message */ jb_ingest__dns_response__data_size + \
/* ip addrs */ (sizeof(u32) * MAX_ENCODED_IP_ADDRS) + /* DNS name */ MAX_ENCODED_DOMAIN_NAME)
/* ip addrs */ (sizeof(u32) * MAX_ENCODED_IP_ADDRS) + /* DNS name */ DNS_NAME_MAX_LENGTH)

int dns_name_length(const unsigned char *encoded, const unsigned char *abuf, int alen);

Expand Down
6 changes: 3 additions & 3 deletions render/ebpf_net.render
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ app ingest {
description "DNS A/AAAA record query response, with name, response address(es), and latency information"
severity 0
1: u32 sk_id
2: u16 total_dn_len // Total length of domain name without truncation (MAX_ENCODED_DOMAIN_NAME)
2: u16 total_dn_len // Total length of domain name without truncation (DNS_NAME_MAX_LENGTH)
3: string domain_name // Domain name being queried (possibly truncated)
4: string ipv4_addrs // IPv4 addresses corresponding to domain name 'dn'
5: string ipv6_addrs // IPv6 addresses corresponding to domain name 'dn'
Expand All @@ -1051,7 +1051,7 @@ app ingest {
description "A DNS A/AAAA record request timeout"
severity 0
1: u32 sk_id
2: u16 total_dn_len // Total length of domain name without truncation (MAX_ENCODED_DOMAIN_NAME)
2: u16 total_dn_len // Total length of domain name without truncation (DNS_NAME_MAX_LENGTH)
3: string domain_name // Domain name being queried (possibly truncated)
4: u64 timeout_ns // Timeout duration for request (in ns)
}
Expand All @@ -1065,7 +1065,7 @@ app ingest {
description "DNS A/AAAA record query response, with name, response address(es), and latency information, with direction"
severity 0
1: u32 sk_id
2: u16 total_dn_len // Total length of domain name without truncation (MAX_ENCODED_DOMAIN_NAME)
2: u16 total_dn_len // Total length of domain name without truncation (DNS_NAME_MAX_LENGTH)
3: string domain_name // Domain name being queried (possibly truncated)
4: string ipv4_addrs // IPv4 addresses corresponding to domain name 'dn'
5: string ipv6_addrs // IPv6 addresses corresponding to domain name 'dn'
Expand Down

0 comments on commit 2776a99

Please sign in to comment.