From 5b34931a97e45b08d91552a13d4826bf88698dfc Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Fri, 26 May 2017 23:16:24 +0200 Subject: [PATCH] gluon-radv-filterd: Fix bug in BPF router lifetime filter The router lifetime field actually is 2 bytes long, but we only checked the first one, thus falsely discarding RAs with router lifetime < 256 seconds. --- package/gluon-radv-filterd/src/gluon-radv-filterd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/gluon-radv-filterd/src/gluon-radv-filterd.c b/package/gluon-radv-filterd/src/gluon-radv-filterd.c index b6804dbc..5a2075d4 100644 --- a/package/gluon-radv-filterd/src/gluon-radv-filterd.c +++ b/package/gluon-radv-filterd/src/gluon-radv-filterd.c @@ -192,7 +192,7 @@ static int init_packet_socket(unsigned int ifindex) { BPF_STMT(BPF_LD|BPF_B|BPF_ABS, sizeof(struct ip6_hdr) + offsetof(struct nd_router_advert, nd_ra_code)), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 0, 0, 3), // check that this is a default route (lifetime > 0) - BPF_STMT(BPF_LD|BPF_B|BPF_ABS, sizeof(struct ip6_hdr) + offsetof(struct nd_router_advert, nd_ra_router_lifetime)), + BPF_STMT(BPF_LD|BPF_H|BPF_ABS, sizeof(struct ip6_hdr) + offsetof(struct nd_router_advert, nd_ra_router_lifetime)), BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 0, 1, 0), // return true BPF_STMT(BPF_RET|BPF_K, 0xffffffff),