Skip to content

Commit d1df54e

Browse files
authored
Merge pull request #3734 from my4ng/netfilter
feat: add missing netfilter consts
2 parents f3262e6 + 7000471 commit d1df54e

File tree

5 files changed

+123
-7
lines changed

5 files changed

+123
-7
lines changed

libc-test/build.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,8 @@ fn test_android(target: &str) {
16351635
"linux/netfilter/nfnetlink_log.h",
16361636
"linux/netfilter/nfnetlink_queue.h",
16371637
"linux/netfilter/nf_tables.h",
1638+
"linux/netfilter_arp.h",
1639+
"linux/netfilter_bridge.h",
16381640
"linux/netfilter_ipv4.h",
16391641
"linux/netfilter_ipv6.h",
16401642
"linux/netfilter_ipv6/ip6_tables.h",
@@ -3442,6 +3444,8 @@ fn test_linux(target: &str) {
34423444
"linux/netfilter/nfnetlink_log.h",
34433445
"linux/netfilter/nfnetlink_queue.h",
34443446
"linux/netfilter/nf_tables.h",
3447+
"linux/netfilter_arp.h",
3448+
"linux/netfilter_bridge.h",
34453449
"linux/netfilter_ipv4.h",
34463450
"linux/netfilter_ipv6.h",
34473451
"linux/netfilter_ipv6/ip6_tables.h",
@@ -3958,9 +3962,15 @@ fn test_linux(target: &str) {
39583962
| "MINSIGSTKSZ"
39593963
if gnu => true,
39603964

3961-
// FIXME: Linux >= 5.16 changed its value:
3965+
// FIXME: Linux >= 5.10:
3966+
// https://github.com/torvalds/linux/commit/d25e2e9388eda61b6e298585024ee3355f50c493
3967+
"NF_INET_INGRESS" if musl => true,
3968+
3969+
// FIXME: Linux >= 5.16:
39623970
// https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96
3963-
"NF_NETDEV_NUMHOOKS" => true,
3971+
"NF_NETDEV_EGRESS" if musl || sparc64 => true,
3972+
// value changed
3973+
"NF_NETDEV_NUMHOOKS" if musl || sparc64 => true,
39643974

39653975
// FIXME: requires Linux >= 5.6:
39663976
| "RESOLVE_BENEATH"

libc-test/semver/android.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,8 +1644,29 @@ NFULNL_COPY_PACKET
16441644
NFULNL_MSG_CONFIG
16451645
NFULNL_MSG_PACKET
16461646
NF_ACCEPT
1647+
NF_ARP
1648+
NF_ARP_FORWARD
1649+
NF_ARP_IN
1650+
NF_ARP_NUMHOOKS
1651+
NF_ARP_OUT
1652+
NF_BR_BROUTING
1653+
NF_BR_FORWARD
1654+
NF_BR_LOCAL_IN
1655+
NF_BR_LOCAL_OUT
1656+
NF_BR_NUMHOOKS
1657+
NF_BR_POST_ROUTING
1658+
NF_BR_PRE_ROUTING
1659+
NF_BR_PRI_BRNF
1660+
NF_BR_PRI_FILTER_BRIDGED
1661+
NF_BR_PRI_FILTER_OTHER
1662+
NF_BR_PRI_FIRST
1663+
NF_BR_PRI_LAST
1664+
NF_BR_PRI_NAT_DST_BRIDGED
1665+
NF_BR_PRI_NAT_DST_OTHER
1666+
NF_BR_PRI_NAT_SRC
16471667
NF_DROP
16481668
NF_INET_FORWARD
1669+
NF_INET_INGRESS
16491670
NF_INET_LOCAL_IN
16501671
NF_INET_LOCAL_OUT
16511672
NF_INET_NUMHOOKS
@@ -1667,6 +1688,7 @@ NF_IP6_PRI_MANGLE
16671688
NF_IP6_PRI_NAT_DST
16681689
NF_IP6_PRI_NAT_SRC
16691690
NF_IP6_PRI_RAW
1691+
NF_IP6_PRI_RAW_BEFORE_DEFRAG
16701692
NF_IP6_PRI_SECURITY
16711693
NF_IP6_PRI_SELINUX_FIRST
16721694
NF_IP6_PRI_SELINUX_LAST
@@ -1687,10 +1709,12 @@ NF_IP_PRI_MANGLE
16871709
NF_IP_PRI_NAT_DST
16881710
NF_IP_PRI_NAT_SRC
16891711
NF_IP_PRI_RAW
1712+
NF_IP_PRI_RAW_BEFORE_DEFRAG
16901713
NF_IP_PRI_SECURITY
16911714
NF_IP_PRI_SELINUX_FIRST
16921715
NF_IP_PRI_SELINUX_LAST
16931716
NF_MAX_VERDICT
1717+
NF_NETDEV_EGRESS
16941718
NF_NETDEV_INGRESS
16951719
NF_NETDEV_NUMHOOKS
16961720
NF_QUEUE

libc-test/semver/linux.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,8 +1693,29 @@ NFULNL_COPY_PACKET
16931693
NFULNL_MSG_CONFIG
16941694
NFULNL_MSG_PACKET
16951695
NF_ACCEPT
1696+
NF_ARP
1697+
NF_ARP_FORWARD
1698+
NF_ARP_IN
1699+
NF_ARP_NUMHOOKS
1700+
NF_ARP_OUT
1701+
NF_BR_BROUTING
1702+
NF_BR_FORWARD
1703+
NF_BR_LOCAL_IN
1704+
NF_BR_LOCAL_OUT
1705+
NF_BR_NUMHOOKS
1706+
NF_BR_POST_ROUTING
1707+
NF_BR_PRE_ROUTING
1708+
NF_BR_PRI_BRNF
1709+
NF_BR_PRI_FILTER_BRIDGED
1710+
NF_BR_PRI_FILTER_OTHER
1711+
NF_BR_PRI_FIRST
1712+
NF_BR_PRI_LAST
1713+
NF_BR_PRI_NAT_DST_BRIDGED
1714+
NF_BR_PRI_NAT_DST_OTHER
1715+
NF_BR_PRI_NAT_SRC
16961716
NF_DROP
16971717
NF_INET_FORWARD
1718+
NF_INET_INGRESS
16981719
NF_INET_LOCAL_IN
16991720
NF_INET_LOCAL_OUT
17001721
NF_INET_NUMHOOKS
@@ -1716,6 +1737,7 @@ NF_IP6_PRI_MANGLE
17161737
NF_IP6_PRI_NAT_DST
17171738
NF_IP6_PRI_NAT_SRC
17181739
NF_IP6_PRI_RAW
1740+
NF_IP6_PRI_RAW_BEFORE_DEFRAG
17191741
NF_IP6_PRI_SECURITY
17201742
NF_IP6_PRI_SELINUX_FIRST
17211743
NF_IP6_PRI_SELINUX_LAST
@@ -1736,10 +1758,12 @@ NF_IP_PRI_MANGLE
17361758
NF_IP_PRI_NAT_DST
17371759
NF_IP_PRI_NAT_SRC
17381760
NF_IP_PRI_RAW
1761+
NF_IP_PRI_RAW_BEFORE_DEFRAG
17391762
NF_IP_PRI_SECURITY
17401763
NF_IP_PRI_SELINUX_FIRST
17411764
NF_IP_PRI_SELINUX_LAST
17421765
NF_MAX_VERDICT
1766+
NF_NETDEV_EGRESS
17431767
NF_QUEUE
17441768
NF_REPEAT
17451769
NF_STOLEN

src/unix/linux_like/android/mod.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,9 +2312,11 @@ pub const NF_INET_FORWARD: ::c_int = 2;
23122312
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
23132313
pub const NF_INET_POST_ROUTING: ::c_int = 4;
23142314
pub const NF_INET_NUMHOOKS: ::c_int = 5;
2315+
pub const NF_INET_INGRESS: ::c_int = NF_INET_NUMHOOKS;
23152316

23162317
pub const NF_NETDEV_INGRESS: ::c_int = 0;
2317-
pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
2318+
pub const NF_NETDEV_EGRESS: ::c_int = 1;
2319+
pub const NF_NETDEV_NUMHOOKS: ::c_int = 2;
23182320

23192321
pub const NFPROTO_UNSPEC: ::c_int = 0;
23202322
pub const NFPROTO_INET: ::c_int = 1;
@@ -2326,6 +2328,31 @@ pub const NFPROTO_IPV6: ::c_int = 10;
23262328
pub const NFPROTO_DECNET: ::c_int = 12;
23272329
pub const NFPROTO_NUMPROTO: ::c_int = 13;
23282330

2331+
// linux/netfilter_arp.h
2332+
pub const NF_ARP: ::c_int = 0;
2333+
pub const NF_ARP_IN: ::c_int = 0;
2334+
pub const NF_ARP_OUT: ::c_int = 1;
2335+
pub const NF_ARP_FORWARD: ::c_int = 2;
2336+
pub const NF_ARP_NUMHOOKS: ::c_int = 3;
2337+
2338+
// linux/netfilter_bridge.h
2339+
pub const NF_BR_PRE_ROUTING: ::c_int = 0;
2340+
pub const NF_BR_LOCAL_IN: ::c_int = 1;
2341+
pub const NF_BR_FORWARD: ::c_int = 2;
2342+
pub const NF_BR_LOCAL_OUT: ::c_int = 3;
2343+
pub const NF_BR_POST_ROUTING: ::c_int = 4;
2344+
pub const NF_BR_BROUTING: ::c_int = 5;
2345+
pub const NF_BR_NUMHOOKS: ::c_int = 6;
2346+
2347+
pub const NF_BR_PRI_FIRST: ::c_int = ::INT_MIN;
2348+
pub const NF_BR_PRI_NAT_DST_BRIDGED: ::c_int = -300;
2349+
pub const NF_BR_PRI_FILTER_BRIDGED: ::c_int = -200;
2350+
pub const NF_BR_PRI_BRNF: ::c_int = 0;
2351+
pub const NF_BR_PRI_NAT_DST_OTHER: ::c_int = 100;
2352+
pub const NF_BR_PRI_FILTER_OTHER: ::c_int = 200;
2353+
pub const NF_BR_PRI_NAT_SRC: ::c_int = 300;
2354+
pub const NF_BR_PRI_LAST: ::c_int = ::INT_MAX;
2355+
23292356
// linux/netfilter_ipv4.h
23302357
pub const NF_IP_PRE_ROUTING: ::c_int = 0;
23312358
pub const NF_IP_LOCAL_IN: ::c_int = 1;
@@ -2335,6 +2362,7 @@ pub const NF_IP_POST_ROUTING: ::c_int = 4;
23352362
pub const NF_IP_NUMHOOKS: ::c_int = 5;
23362363

23372364
pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
2365+
pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
23382366
pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
23392367
pub const NF_IP_PRI_RAW: ::c_int = -300;
23402368
pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
@@ -2358,6 +2386,7 @@ pub const NF_IP6_POST_ROUTING: ::c_int = 4;
23582386
pub const NF_IP6_NUMHOOKS: ::c_int = 5;
23592387

23602388
pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
2389+
pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
23612390
pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
23622391
pub const NF_IP6_PRI_RAW: ::c_int = -300;
23632392
pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225;

src/unix/linux_like/linux/mod.rs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,20 +3289,47 @@ pub const NF_INET_FORWARD: ::c_int = 2;
32893289
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
32903290
pub const NF_INET_POST_ROUTING: ::c_int = 4;
32913291
pub const NF_INET_NUMHOOKS: ::c_int = 5;
3292+
pub const NF_INET_INGRESS: ::c_int = NF_INET_NUMHOOKS;
3293+
3294+
pub const NF_NETDEV_INGRESS: ::c_int = 0;
3295+
pub const NF_NETDEV_EGRESS: ::c_int = 1;
3296+
pub const NF_NETDEV_NUMHOOKS: ::c_int = 2;
32923297

32933298
// Some NFPROTO are not compatible with musl and are defined in submodules.
32943299
pub const NFPROTO_UNSPEC: ::c_int = 0;
3300+
pub const NFPROTO_INET: ::c_int = 1;
32953301
pub const NFPROTO_IPV4: ::c_int = 2;
32963302
pub const NFPROTO_ARP: ::c_int = 3;
3303+
pub const NFPROTO_NETDEV: ::c_int = 5;
32973304
pub const NFPROTO_BRIDGE: ::c_int = 7;
32983305
pub const NFPROTO_IPV6: ::c_int = 10;
32993306
pub const NFPROTO_DECNET: ::c_int = 12;
33003307
pub const NFPROTO_NUMPROTO: ::c_int = 13;
3301-
pub const NFPROTO_INET: ::c_int = 1;
3302-
pub const NFPROTO_NETDEV: ::c_int = 5;
33033308

3304-
pub const NF_NETDEV_INGRESS: ::c_int = 0;
3305-
pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
3309+
// linux/netfilter_arp.h
3310+
pub const NF_ARP: ::c_int = 0;
3311+
pub const NF_ARP_IN: ::c_int = 0;
3312+
pub const NF_ARP_OUT: ::c_int = 1;
3313+
pub const NF_ARP_FORWARD: ::c_int = 2;
3314+
pub const NF_ARP_NUMHOOKS: ::c_int = 3;
3315+
3316+
// linux/netfilter_bridge.h
3317+
pub const NF_BR_PRE_ROUTING: ::c_int = 0;
3318+
pub const NF_BR_LOCAL_IN: ::c_int = 1;
3319+
pub const NF_BR_FORWARD: ::c_int = 2;
3320+
pub const NF_BR_LOCAL_OUT: ::c_int = 3;
3321+
pub const NF_BR_POST_ROUTING: ::c_int = 4;
3322+
pub const NF_BR_BROUTING: ::c_int = 5;
3323+
pub const NF_BR_NUMHOOKS: ::c_int = 6;
3324+
3325+
pub const NF_BR_PRI_FIRST: ::c_int = ::INT_MIN;
3326+
pub const NF_BR_PRI_NAT_DST_BRIDGED: ::c_int = -300;
3327+
pub const NF_BR_PRI_FILTER_BRIDGED: ::c_int = -200;
3328+
pub const NF_BR_PRI_BRNF: ::c_int = 0;
3329+
pub const NF_BR_PRI_NAT_DST_OTHER: ::c_int = 100;
3330+
pub const NF_BR_PRI_FILTER_OTHER: ::c_int = 200;
3331+
pub const NF_BR_PRI_NAT_SRC: ::c_int = 300;
3332+
pub const NF_BR_PRI_LAST: ::c_int = ::INT_MAX;
33063333

33073334
// linux/netfilter_ipv4.h
33083335
pub const NF_IP_PRE_ROUTING: ::c_int = 0;
@@ -3313,6 +3340,7 @@ pub const NF_IP_POST_ROUTING: ::c_int = 4;
33133340
pub const NF_IP_NUMHOOKS: ::c_int = 5;
33143341

33153342
pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
3343+
pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
33163344
pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
33173345
pub const NF_IP_PRI_RAW: ::c_int = -300;
33183346
pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
@@ -3336,6 +3364,7 @@ pub const NF_IP6_POST_ROUTING: ::c_int = 4;
33363364
pub const NF_IP6_NUMHOOKS: ::c_int = 5;
33373365

33383366
pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
3367+
pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
33393368
pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
33403369
pub const NF_IP6_PRI_RAW: ::c_int = -300;
33413370
pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225;

0 commit comments

Comments
 (0)