Skip to content

Commit 12f3b38

Browse files
committed
linux: add missing netfilter definitions
Fill in missing constants available as of Linux v5.18. The relevant UAPI headers are - nfnetlink.h - nfnetlink_log.h - nfnetlink_queue.h
1 parent 2a1d103 commit 12f3b38

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

libc-test/build.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,6 +3190,21 @@ fn test_linux(target: &str) {
31903190
// Added in Linux 5.14
31913191
"FUTEX_LOCK_PI2" => true,
31923192

3193+
// FIXME: Parts of netfilter/nfnetlink*.h require more recent kernel headers:
3194+
| "NFNL_SUBSYS_HOOK" // v5.14+
3195+
| "NFNL_SUBSYS_COUNT" // bumped in v5.14
3196+
| "NFQA_VLAN" // v4.7+
3197+
| "NFQA_L2HDR" // v4.7+
3198+
| "NFQA_PRIORITY" // v5.18+
3199+
| "NFQA_VLAN_UNSPEC" // v4.7+
3200+
| "NFQA_VLAN_PROTO" // v4.7+
3201+
| "NFQA_VLAN_TCI" // v4.7+
3202+
| "NFULA_VLAN" // v5.4+
3203+
| "NFULA_L2HDR" // v5.4+
3204+
| "NFULA_VLAN_UNSPEC" // v5.4+
3205+
| "NFULA_VLAN_PROTO" // v5.4+
3206+
| "NFULA_VLAN_TCI" => true, // v5.4+
3207+
31933208
_ => false,
31943209
}
31953210
});

src/unix/linux_like/linux/mod.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,6 +2086,7 @@ pub const NFNLGRP_CONNTRACK_EXP_UPDATE: ::c_int = 5;
20862086
pub const NFNLGRP_CONNTRACK_EXP_DESTROY: ::c_int = 6;
20872087
pub const NFNLGRP_NFTABLES: ::c_int = 7;
20882088
pub const NFNLGRP_ACCT_QUOTA: ::c_int = 8;
2089+
pub const NFNLGRP_NFTRACE: ::c_int = 9;
20892090

20902091
pub const NFNETLINK_V0: ::c_int = 0;
20912092

@@ -2101,15 +2102,23 @@ pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: ::c_int = 8;
21012102
pub const NFNL_SUBSYS_CTHELPER: ::c_int = 9;
21022103
pub const NFNL_SUBSYS_NFTABLES: ::c_int = 10;
21032104
pub const NFNL_SUBSYS_NFT_COMPAT: ::c_int = 11;
2104-
pub const NFNL_SUBSYS_COUNT: ::c_int = 12;
2105+
pub const NFNL_SUBSYS_HOOK: ::c_int = 12;
2106+
pub const NFNL_SUBSYS_COUNT: ::c_int = 13;
21052107

21062108
pub const NFNL_MSG_BATCH_BEGIN: ::c_int = NLMSG_MIN_TYPE;
21072109
pub const NFNL_MSG_BATCH_END: ::c_int = NLMSG_MIN_TYPE + 1;
21082110

2111+
pub const NFNL_BATCH_UNSPEC: ::c_int = 0;
2112+
pub const NFNL_BATCH_GENID: ::c_int = 1;
2113+
21092114
// linux/netfilter/nfnetlink_log.h
21102115
pub const NFULNL_MSG_PACKET: ::c_int = 0;
21112116
pub const NFULNL_MSG_CONFIG: ::c_int = 1;
21122117

2118+
pub const NFULA_VLAN_UNSPEC: ::c_int = 0;
2119+
pub const NFULA_VLAN_PROTO: ::c_int = 1;
2120+
pub const NFULA_VLAN_TCI: ::c_int = 2;
2121+
21132122
pub const NFULA_UNSPEC: ::c_int = 0;
21142123
pub const NFULA_PACKET_HDR: ::c_int = 1;
21152124
pub const NFULA_MARK: ::c_int = 2;
@@ -2130,6 +2139,8 @@ pub const NFULA_HWHEADER: ::c_int = 16;
21302139
pub const NFULA_HWLEN: ::c_int = 17;
21312140
pub const NFULA_CT: ::c_int = 18;
21322141
pub const NFULA_CT_INFO: ::c_int = 19;
2142+
pub const NFULA_VLAN: ::c_int = 20;
2143+
pub const NFULA_L2HDR: ::c_int = 21;
21332144

21342145
pub const NFULNL_CFG_CMD_NONE: ::c_int = 0;
21352146
pub const NFULNL_CFG_CMD_BIND: ::c_int = 1;
@@ -2153,7 +2164,7 @@ pub const NFULNL_CFG_F_SEQ: ::c_int = 0x0001;
21532164
pub const NFULNL_CFG_F_SEQ_GLOBAL: ::c_int = 0x0002;
21542165
pub const NFULNL_CFG_F_CONNTRACK: ::c_int = 0x0004;
21552166

2156-
// linux/netfilter/nfnetlink_log.h
2167+
// linux/netfilter/nfnetlink_queue.h
21572168
pub const NFQNL_MSG_PACKET: ::c_int = 0;
21582169
pub const NFQNL_MSG_VERDICT: ::c_int = 1;
21592170
pub const NFQNL_MSG_CONFIG: ::c_int = 2;
@@ -2178,18 +2189,13 @@ pub const NFQA_EXP: ::c_int = 15;
21782189
pub const NFQA_UID: ::c_int = 16;
21792190
pub const NFQA_GID: ::c_int = 17;
21802191
pub const NFQA_SECCTX: ::c_int = 18;
2181-
/*
2182-
FIXME: These are not yet available in musl sanitized kernel headers and
2183-
make the tests fail. Enable them once musl has them.
2184-
2185-
See https://github.com/rust-lang/libc/pull/1628 for more details.
21862192
pub const NFQA_VLAN: ::c_int = 19;
21872193
pub const NFQA_L2HDR: ::c_int = 20;
2194+
pub const NFQA_PRIORITY: ::c_int = 21;
21882195

21892196
pub const NFQA_VLAN_UNSPEC: ::c_int = 0;
21902197
pub const NFQA_VLAN_PROTO: ::c_int = 1;
21912198
pub const NFQA_VLAN_TCI: ::c_int = 2;
2192-
*/
21932199

21942200
pub const NFQNL_CFG_CMD_NONE: ::c_int = 0;
21952201
pub const NFQNL_CFG_CMD_BIND: ::c_int = 1;
@@ -2219,6 +2225,8 @@ pub const NFQA_SKB_CSUMNOTREADY: ::c_int = 0x0001;
22192225
pub const NFQA_SKB_GSO: ::c_int = 0x0002;
22202226
pub const NFQA_SKB_CSUM_NOTVERIFIED: ::c_int = 0x0004;
22212227

2228+
// linux/genetlink.h
2229+
22222230
pub const GENL_NAMSIZ: ::c_int = 16;
22232231

22242232
pub const GENL_MIN_ID: ::c_int = NLMSG_MIN_TYPE;

0 commit comments

Comments
 (0)