Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
XDP blog, post 1 gist 5
static __always_inline
int udp_dns_reply(struct cursor *c)
{
struct udphdr *udp;
struct dnshdr *dns;
if (!(udp = parse_udphdr(c))|| udp->dest != __bpf_htons(DNS_PORT)
|| !(dns = parse_dnshdr(c)))
return -1;
uint8_t *qname;
struct dns_qrr *qrr;
if (dns->flags.as_bits_and_pieces.qr
|| dns->qdcount != __bpf_htons(1)
|| dns->ancount || dns->nscount
|| dns->arcount > __bpf_htons(1)
|| !(qname = parse_dname(c, (void *)dns))
|| !(qrr = parse_dns_qrr(c)))
return -1;
// we continue below
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment