Browse Source

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.
Jan-Philipp Litza 7 years ago
parent
commit
3f4b01c18b
1 changed files with 1 additions and 1 deletions
  1. 1 1
      package/gluon-radv-filterd/src/gluon-radv-filterd.c

+ 1 - 1
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),