Skip to content

Instantly share code, notes, and snippets.

@DRiKE
DRiKE / xdpblog1-2-dnshdr.c
Created July 16, 2020 14:08
XDP blog, post 1 gist 2
struct dnshdr {
uint16_t id;
union {
struct {
uint8_t rd : 1;
uint8_t tc : 1;
uint8_t aa : 1;
uint8_t opcode : 4;
uint8_t qr : 1;
@DRiKE
DRiKE / fastbike_avoid_unpaved_gravel.brf
Last active August 29, 2023 13:34
brouter fastbike avoiding unpaved/gravel at all cost
#
# A fastbike could be a racing bike or a speed pedelec.
# But also at night or in rainy whether you might want
# to fallback to this one.
#
# Structure is similar to trekking.brf, see this for documenation.
#
---context:global # following code refers to global config
@DRiKE
DRiKE / xdp1-7-dns_says_no_final.c
Created July 16, 2020 18:35
XDP blog, post 1 gist 7
static __always_inline
void csum_remove_data(uint32_t *csum, struct cursor *c, uint16_t len)
{
if (c->pos + len <= c->end) {
*csum = bpf_csum_diff(c->pos, len, 0, 0, *csum);
c->pos += len;
}
}
int xdp_dns_says_no(struct xdp_md *ctx)