Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
XDP blog, post 1 gist 3
static __always_inline
uint8_t *parse_dname(struct cursor *c, uint8_t *pkt)
{
uint8_t *dname = c->pos;
int i;
for (i = 0; i < 128; i++) { /* Maximum 128 labels */
uint8_t o;
if (c->pos + 1 > c->end)
return 0;
o = *(uint8_t *)c->pos;
if ((o & 0xC0) == 0xC0) {
/* Compression label, Only back references! */
if ((o | 0x3F) >= (dname - pkt))
return 0;
/* Compression label is the last label of a dname. */
c->pos += 1;
break;
} else if (o & 0xC0)
/* Unknown label type */
return 0;
c->pos += o + 1;
if (!o)
break;
}
return dname;
}
@dtikhonov

This comment has been minimized.

Copy link

@dtikhonov dtikhonov commented Dec 15, 2020

Should be o & 0x3F on line 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment