udhcpc: fix BPF filter. Hopefully fixes the root cause of 4598 and 6746
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 19 Feb 2014 13:17:11 +0000 (14:17 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 19 Feb 2014 13:17:11 +0000 (14:17 +0100)
Use a *signed* large positive value in BPF filter to indicate success.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/d6_dhcpc.c
networking/udhcp/dhcpc.c

index b0f0798e5e8104f5725d8479980c532ab2da5f11..044f04673da0477d456f39bb3381272f5ee076c0 100644 (file)
@@ -711,7 +711,7 @@ static int d6_raw_socket(int ifindex)
                /* jump to L3 if udp dport is CLIENT_PORT6, else to L4 */
                BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 68, 0, 1),
                /* L3: accept packet */
-               BPF_STMT(BPF_RET|BPF_K, 0xffffffff),
+               BPF_STMT(BPF_RET|BPF_K, 0x7fffffff),
                /* L4: discard packet */
                BPF_STMT(BPF_RET|BPF_K, 0),
        };
index bdb1e2b9b0ed7e8127911a0aa8a528af29797a17..25f18b35dccd6e927c192769ea46f5a336feca82 100644 (file)
@@ -1025,9 +1025,10 @@ static int udhcp_raw_socket(int ifindex)
                        BPF_STMT(BPF_LD|BPF_H|BPF_IND, 2),
                        /* jump to L3 if udp dport is CLIENT_PORT, else to L4 */
                        BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 68, 0, 1),
-                       /* L3: accept packet */
-                       BPF_STMT(BPF_RET|BPF_K, 0xffffffff),
-                       /* L4: discard packet */
+                       /* L3: accept packet ("accept 0x7fffffff bytes") */
+                       /* Accepting 0xffffffff works too but kernel 2.6.19 is buggy */
+                       BPF_STMT(BPF_RET|BPF_K, 0x7fffffff),
+                       /* L4: discard packet ("accept zero bytes") */
                        BPF_STMT(BPF_RET|BPF_K, 0),
                };
                static const struct sock_fprog filter_prog = {