Skip to content

Commit 4cf7257

Browse files
committed
feat: add missing netfilter consts
1 parent acc7bb1 commit 4cf7257

File tree

5 files changed

+124
-6
lines changed

5 files changed

+124
-6
lines changed

libc-test/build.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,8 @@ fn test_android(target: &str) {
16311631
"linux/netfilter/nfnetlink_log.h",
16321632
"linux/netfilter/nfnetlink_queue.h",
16331633
"linux/netfilter/nf_tables.h",
1634+
"linux/netfilter_arp.h",
1635+
"linux/netfilter_bridge.h",
16341636
"linux/netfilter_ipv4.h",
16351637
"linux/netfilter_ipv6.h",
16361638
"linux/netfilter_ipv6/ip6_tables.h",
@@ -3419,6 +3421,8 @@ fn test_linux(target: &str) {
34193421
"linux/netfilter/nfnetlink_log.h",
34203422
"linux/netfilter/nfnetlink_queue.h",
34213423
"linux/netfilter/nf_tables.h",
3424+
"linux/netfilter_arp.h",
3425+
"linux/netfilter_bridge.h",
34223426
"linux/netfilter_ipv4.h",
34233427
"linux/netfilter_ipv6.h",
34243428
"linux/netfilter_ipv6/ip6_tables.h",
@@ -3935,9 +3939,17 @@ fn test_linux(target: &str) {
39353939
| "MINSIGSTKSZ"
39363940
if gnu => true,
39373941

3942+
// FIXME: Linux >= 5.10:
3943+
// https://github.com/torvalds/linux/commit/d25e2e9388eda61b6e298585024ee3355f50c493
3944+
"NF_INET_INGRESS" if musl => true,
3945+
3946+
// FIXME: Linux >= 5.16:
3947+
// https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96
3948+
"NF_NETDEV_EGRESS" if musl => true,
3949+
39383950
// FIXME: Linux >= 5.16 changed its value:
39393951
// https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96
3940-
"NF_NETDEV_NUMHOOKS" => true,
3952+
"NF_NETDEV_NUMHOOKS" if musl => true,
39413953

39423954
// FIXME: requires Linux >= 5.6:
39433955
| "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
@@ -1692,8 +1692,29 @@ NFULNL_COPY_PACKET
16921692
NFULNL_MSG_CONFIG
16931693
NFULNL_MSG_PACKET
16941694
NF_ACCEPT
1695+
NF_ARP
1696+
NF_ARP_FORWARD
1697+
NF_ARP_IN
1698+
NF_ARP_NUMHOOKS
1699+
NF_ARP_OUT
1700+
NF_BR_BROUTING
1701+
NF_BR_FORWARD
1702+
NF_BR_LOCAL_IN
1703+
NF_BR_LOCAL_OUT
1704+
NF_BR_NUMHOOKS
1705+
NF_BR_POST_ROUTING
1706+
NF_BR_PRE_ROUTING
1707+
NF_BR_PRI_BRNF
1708+
NF_BR_PRI_FILTER_BRIDGED
1709+
NF_BR_PRI_FILTER_OTHER
1710+
NF_BR_PRI_FIRST
1711+
NF_BR_PRI_LAST
1712+
NF_BR_PRI_NAT_DST_BRIDGED
1713+
NF_BR_PRI_NAT_DST_OTHER
1714+
NF_BR_PRI_NAT_SRC
16951715
NF_DROP
16961716
NF_INET_FORWARD
1717+
NF_INET_INGRESS
16971718
NF_INET_LOCAL_IN
16981719
NF_INET_LOCAL_OUT
16991720
NF_INET_NUMHOOKS
@@ -1715,6 +1736,7 @@ NF_IP6_PRI_MANGLE
17151736
NF_IP6_PRI_NAT_DST
17161737
NF_IP6_PRI_NAT_SRC
17171738
NF_IP6_PRI_RAW
1739+
NF_IP6_PRI_RAW_BEFORE_DEFRAG
17181740
NF_IP6_PRI_SECURITY
17191741
NF_IP6_PRI_SELINUX_FIRST
17201742
NF_IP6_PRI_SELINUX_LAST
@@ -1735,10 +1757,12 @@ NF_IP_PRI_MANGLE
17351757
NF_IP_PRI_NAT_DST
17361758
NF_IP_PRI_NAT_SRC
17371759
NF_IP_PRI_RAW
1760+
NF_IP_PRI_RAW_BEFORE_DEFRAG
17381761
NF_IP_PRI_SECURITY
17391762
NF_IP_PRI_SELINUX_FIRST
17401763
NF_IP_PRI_SELINUX_LAST
17411764
NF_MAX_VERDICT
1765+
NF_NETDEV_EGRESS
17421766
NF_QUEUE
17431767
NF_REPEAT
17441768
NF_STOLEN

src/unix/linux_like/android/mod.rs

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

23152316
pub const NF_NETDEV_INGRESS: ::c_int = 0;
2316-
pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
2317+
pub const NF_NETDEV_EGRESS: ::c_int = 1;
2318+
pub const NF_NETDEV_NUMHOOKS: ::c_int = 2;
23172319

23182320
pub const NFPROTO_UNSPEC: ::c_int = 0;
23192321
pub const NFPROTO_INET: ::c_int = 1;
@@ -2325,6 +2327,31 @@ pub const NFPROTO_IPV6: ::c_int = 10;
23252327
pub const NFPROTO_DECNET: ::c_int = 12;
23262328
pub const NFPROTO_NUMPROTO: ::c_int = 13;
23272329

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

23362363
pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
2364+
pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
23372365
pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
23382366
pub const NF_IP_PRI_RAW: ::c_int = -300;
23392367
pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
@@ -2357,6 +2385,7 @@ pub const NF_IP6_POST_ROUTING: ::c_int = 4;
23572385
pub const NF_IP6_NUMHOOKS: ::c_int = 5;
23582386

23592387
pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
2388+
pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
23602389
pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
23612390
pub const NF_IP6_PRI_RAW: ::c_int = -300;
23622391
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
@@ -3288,20 +3288,47 @@ pub const NF_INET_FORWARD: ::c_int = 2;
32883288
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
32893289
pub const NF_INET_POST_ROUTING: ::c_int = 4;
32903290
pub const NF_INET_NUMHOOKS: ::c_int = 5;
3291+
pub const NF_INET_INGRESS: ::c_int = NF_INET_NUMHOOKS;
3292+
3293+
pub const NF_NETDEV_INGRESS: ::c_int = 0;
3294+
pub const NF_NETDEV_EGRESS: ::c_int = 1;
3295+
pub const NF_NETDEV_NUMHOOKS: ::c_int = 2;
32913296

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

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

33063333
// linux/netfilter_ipv4.h
33073334
pub const NF_IP_PRE_ROUTING: ::c_int = 0;
@@ -3312,6 +3339,7 @@ pub const NF_IP_POST_ROUTING: ::c_int = 4;
33123339
pub const NF_IP_NUMHOOKS: ::c_int = 5;
33133340

33143341
pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
3342+
pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
33153343
pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
33163344
pub const NF_IP_PRI_RAW: ::c_int = -300;
33173345
pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
@@ -3335,6 +3363,7 @@ pub const NF_IP6_POST_ROUTING: ::c_int = 4;
33353363
pub const NF_IP6_NUMHOOKS: ::c_int = 5;
33363364

33373365
pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
3366+
pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450;
33383367
pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
33393368
pub const NF_IP6_PRI_RAW: ::c_int = -300;
33403369
pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225;

0 commit comments

Comments
 (0)