Skip to content

Commit 802f327

Browse files
committed
Auto merge of #2152 - namib-project:nftables-musl, r=JohnTitor
Make netfilter constants available for musl Linux targets The netfilter constants added in #911 and #926 are currently only available for Linux targets using glibc because they weren't available in the musl-sanitized kernel headers at the time these PRs were made. With current versions of the sanitized headers, these constants are available, and this PR moves them to `unix/linux_like/linux/mod.rs` so that they can be used on targets using musl libc. The kernel header version currently set in `ci/install_musl.sh` already supports these constants, but has different values for e.g. `NFT_TABLE_MAXNAMELEN` than the ones that were already defined for glibc. It seems like the maximum name length for various netfilter objects has been changed in the kernel (the respective commits are [1](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/uapi/linux/netfilter/nf_tables.h?id=e46abbcc05aa8a16b0e7f5c94e86d11af9aa2770) [2](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/uapi/linux/netfilter/nf_tables.h?id=b7263e071aba736cea9e71cdf2e76dfa7aebd039) [3](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/uapi/linux/netfilter/nf_tables.h?id=387454901bd62022ac1b04e15bd8d4fcc60bbed4) and [4](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/include/uapi/linux/netfilter/nf_tables.h?id=615095752100748e221028fc96163c2b78185ae4)). To match these values with the ones that were already defined, this PR also updates the used kernel header version in `ci/install_musl.sh`.
2 parents e584862 + bf8378b commit 802f327

File tree

3 files changed

+193
-194
lines changed

3 files changed

+193
-194
lines changed

ci/install-musl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ cd ..
7979
rm -rf $MUSL
8080

8181
# Download, configure, build, and install musl-sanitized kernel headers:
82-
KERNEL_HEADER_VER="4.4.2-2"
82+
KERNEL_HEADER_VER="4.19.88"
8383
curl --retry 5 -L \
8484
"https://github.com/sabotage-linux/kernel-headers/archive/v${KERNEL_HEADER_VER}.tar.gz" | \
8585
tar xzf -

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 0 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -948,12 +948,6 @@ pub const TIOCM_RTS: ::c_int = 0x004;
948948
pub const TIOCM_CD: ::c_int = TIOCM_CAR;
949949
pub const TIOCM_RI: ::c_int = TIOCM_RNG;
950950

951-
pub const NF_NETDEV_INGRESS: ::c_int = 0;
952-
pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
953-
954-
pub const NFPROTO_INET: ::c_int = 1;
955-
pub const NFPROTO_NETDEV: ::c_int = 5;
956-
957951
// linux/keyctl.h
958952
pub const KEYCTL_DH_COMPUTE: u32 = 23;
959953
pub const KEYCTL_PKEY_QUERY: u32 = 24;
@@ -985,193 +979,6 @@ cfg_if! {
985979
}
986980
}
987981

988-
// linux/netfilter/nf_tables.h
989-
pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256;
990-
pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256;
991-
pub const NFT_SET_MAXNAMELEN: ::c_int = 256;
992-
pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256;
993-
pub const NFT_USERDATA_MAXLEN: ::c_int = 256;
994-
995-
pub const NFT_REG_VERDICT: ::c_int = 0;
996-
pub const NFT_REG_1: ::c_int = 1;
997-
pub const NFT_REG_2: ::c_int = 2;
998-
pub const NFT_REG_3: ::c_int = 3;
999-
pub const NFT_REG_4: ::c_int = 4;
1000-
pub const __NFT_REG_MAX: ::c_int = 5;
1001-
pub const NFT_REG32_00: ::c_int = 8;
1002-
pub const NFT_REG32_01: ::c_int = 9;
1003-
pub const NFT_REG32_02: ::c_int = 10;
1004-
pub const NFT_REG32_03: ::c_int = 11;
1005-
pub const NFT_REG32_04: ::c_int = 12;
1006-
pub const NFT_REG32_05: ::c_int = 13;
1007-
pub const NFT_REG32_06: ::c_int = 14;
1008-
pub const NFT_REG32_07: ::c_int = 15;
1009-
pub const NFT_REG32_08: ::c_int = 16;
1010-
pub const NFT_REG32_09: ::c_int = 17;
1011-
pub const NFT_REG32_10: ::c_int = 18;
1012-
pub const NFT_REG32_11: ::c_int = 19;
1013-
pub const NFT_REG32_12: ::c_int = 20;
1014-
pub const NFT_REG32_13: ::c_int = 21;
1015-
pub const NFT_REG32_14: ::c_int = 22;
1016-
pub const NFT_REG32_15: ::c_int = 23;
1017-
1018-
pub const NFT_REG_SIZE: ::c_int = 16;
1019-
pub const NFT_REG32_SIZE: ::c_int = 4;
1020-
1021-
pub const NFT_CONTINUE: ::c_int = -1;
1022-
pub const NFT_BREAK: ::c_int = -2;
1023-
pub const NFT_JUMP: ::c_int = -3;
1024-
pub const NFT_GOTO: ::c_int = -4;
1025-
pub const NFT_RETURN: ::c_int = -5;
1026-
1027-
pub const NFT_MSG_NEWTABLE: ::c_int = 0;
1028-
pub const NFT_MSG_GETTABLE: ::c_int = 1;
1029-
pub const NFT_MSG_DELTABLE: ::c_int = 2;
1030-
pub const NFT_MSG_NEWCHAIN: ::c_int = 3;
1031-
pub const NFT_MSG_GETCHAIN: ::c_int = 4;
1032-
pub const NFT_MSG_DELCHAIN: ::c_int = 5;
1033-
pub const NFT_MSG_NEWRULE: ::c_int = 6;
1034-
pub const NFT_MSG_GETRULE: ::c_int = 7;
1035-
pub const NFT_MSG_DELRULE: ::c_int = 8;
1036-
pub const NFT_MSG_NEWSET: ::c_int = 9;
1037-
pub const NFT_MSG_GETSET: ::c_int = 10;
1038-
pub const NFT_MSG_DELSET: ::c_int = 11;
1039-
pub const NFT_MSG_NEWSETELEM: ::c_int = 12;
1040-
pub const NFT_MSG_GETSETELEM: ::c_int = 13;
1041-
pub const NFT_MSG_DELSETELEM: ::c_int = 14;
1042-
pub const NFT_MSG_NEWGEN: ::c_int = 15;
1043-
pub const NFT_MSG_GETGEN: ::c_int = 16;
1044-
pub const NFT_MSG_TRACE: ::c_int = 17;
1045-
cfg_if! {
1046-
if #[cfg(not(target_arch = "sparc64"))] {
1047-
pub const NFT_MSG_NEWOBJ: ::c_int = 18;
1048-
pub const NFT_MSG_GETOBJ: ::c_int = 19;
1049-
pub const NFT_MSG_DELOBJ: ::c_int = 20;
1050-
pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21;
1051-
}
1052-
}
1053-
pub const NFT_MSG_MAX: ::c_int = 25;
1054-
1055-
pub const NFT_SET_ANONYMOUS: ::c_int = 0x1;
1056-
pub const NFT_SET_CONSTANT: ::c_int = 0x2;
1057-
pub const NFT_SET_INTERVAL: ::c_int = 0x4;
1058-
pub const NFT_SET_MAP: ::c_int = 0x8;
1059-
pub const NFT_SET_TIMEOUT: ::c_int = 0x10;
1060-
pub const NFT_SET_EVAL: ::c_int = 0x20;
1061-
1062-
pub const NFT_SET_POL_PERFORMANCE: ::c_int = 0;
1063-
pub const NFT_SET_POL_MEMORY: ::c_int = 1;
1064-
1065-
pub const NFT_SET_ELEM_INTERVAL_END: ::c_int = 0x1;
1066-
1067-
pub const NFT_DATA_VALUE: ::c_uint = 0;
1068-
pub const NFT_DATA_VERDICT: ::c_uint = 0xffffff00;
1069-
1070-
pub const NFT_DATA_RESERVED_MASK: ::c_uint = 0xffffff00;
1071-
1072-
pub const NFT_DATA_VALUE_MAXLEN: ::c_int = 64;
1073-
1074-
pub const NFT_BYTEORDER_NTOH: ::c_int = 0;
1075-
pub const NFT_BYTEORDER_HTON: ::c_int = 1;
1076-
1077-
pub const NFT_CMP_EQ: ::c_int = 0;
1078-
pub const NFT_CMP_NEQ: ::c_int = 1;
1079-
pub const NFT_CMP_LT: ::c_int = 2;
1080-
pub const NFT_CMP_LTE: ::c_int = 3;
1081-
pub const NFT_CMP_GT: ::c_int = 4;
1082-
pub const NFT_CMP_GTE: ::c_int = 5;
1083-
1084-
pub const NFT_RANGE_EQ: ::c_int = 0;
1085-
pub const NFT_RANGE_NEQ: ::c_int = 1;
1086-
1087-
pub const NFT_LOOKUP_F_INV: ::c_int = 1 << 0;
1088-
1089-
pub const NFT_DYNSET_OP_ADD: ::c_int = 0;
1090-
pub const NFT_DYNSET_OP_UPDATE: ::c_int = 1;
1091-
1092-
pub const NFT_DYNSET_F_INV: ::c_int = 1 << 0;
1093-
1094-
pub const NFT_PAYLOAD_LL_HEADER: ::c_int = 0;
1095-
pub const NFT_PAYLOAD_NETWORK_HEADER: ::c_int = 1;
1096-
pub const NFT_PAYLOAD_TRANSPORT_HEADER: ::c_int = 2;
1097-
1098-
pub const NFT_PAYLOAD_CSUM_NONE: ::c_int = 0;
1099-
pub const NFT_PAYLOAD_CSUM_INET: ::c_int = 1;
1100-
1101-
pub const NFT_META_LEN: ::c_int = 0;
1102-
pub const NFT_META_PROTOCOL: ::c_int = 1;
1103-
pub const NFT_META_PRIORITY: ::c_int = 2;
1104-
pub const NFT_META_MARK: ::c_int = 3;
1105-
pub const NFT_META_IIF: ::c_int = 4;
1106-
pub const NFT_META_OIF: ::c_int = 5;
1107-
pub const NFT_META_IIFNAME: ::c_int = 6;
1108-
pub const NFT_META_OIFNAME: ::c_int = 7;
1109-
pub const NFT_META_IIFTYPE: ::c_int = 8;
1110-
pub const NFT_META_OIFTYPE: ::c_int = 9;
1111-
pub const NFT_META_SKUID: ::c_int = 10;
1112-
pub const NFT_META_SKGID: ::c_int = 11;
1113-
pub const NFT_META_NFTRACE: ::c_int = 12;
1114-
pub const NFT_META_RTCLASSID: ::c_int = 13;
1115-
pub const NFT_META_SECMARK: ::c_int = 14;
1116-
pub const NFT_META_NFPROTO: ::c_int = 15;
1117-
pub const NFT_META_L4PROTO: ::c_int = 16;
1118-
pub const NFT_META_BRI_IIFNAME: ::c_int = 17;
1119-
pub const NFT_META_BRI_OIFNAME: ::c_int = 18;
1120-
pub const NFT_META_PKTTYPE: ::c_int = 19;
1121-
pub const NFT_META_CPU: ::c_int = 20;
1122-
pub const NFT_META_IIFGROUP: ::c_int = 21;
1123-
pub const NFT_META_OIFGROUP: ::c_int = 22;
1124-
pub const NFT_META_CGROUP: ::c_int = 23;
1125-
pub const NFT_META_PRANDOM: ::c_int = 24;
1126-
1127-
pub const NFT_CT_STATE: ::c_int = 0;
1128-
pub const NFT_CT_DIRECTION: ::c_int = 1;
1129-
pub const NFT_CT_STATUS: ::c_int = 2;
1130-
pub const NFT_CT_MARK: ::c_int = 3;
1131-
pub const NFT_CT_SECMARK: ::c_int = 4;
1132-
pub const NFT_CT_EXPIRATION: ::c_int = 5;
1133-
pub const NFT_CT_HELPER: ::c_int = 6;
1134-
pub const NFT_CT_L3PROTOCOL: ::c_int = 7;
1135-
pub const NFT_CT_SRC: ::c_int = 8;
1136-
pub const NFT_CT_DST: ::c_int = 9;
1137-
pub const NFT_CT_PROTOCOL: ::c_int = 10;
1138-
pub const NFT_CT_PROTO_SRC: ::c_int = 11;
1139-
pub const NFT_CT_PROTO_DST: ::c_int = 12;
1140-
pub const NFT_CT_LABELS: ::c_int = 13;
1141-
pub const NFT_CT_PKTS: ::c_int = 14;
1142-
pub const NFT_CT_BYTES: ::c_int = 15;
1143-
1144-
pub const NFT_LIMIT_PKTS: ::c_int = 0;
1145-
pub const NFT_LIMIT_PKT_BYTES: ::c_int = 1;
1146-
1147-
pub const NFT_LIMIT_F_INV: ::c_int = 1 << 0;
1148-
1149-
pub const NFT_QUEUE_FLAG_BYPASS: ::c_int = 0x01;
1150-
pub const NFT_QUEUE_FLAG_CPU_FANOUT: ::c_int = 0x02;
1151-
pub const NFT_QUEUE_FLAG_MASK: ::c_int = 0x03;
1152-
1153-
pub const NFT_QUOTA_F_INV: ::c_int = 1 << 0;
1154-
1155-
pub const NFT_REJECT_ICMP_UNREACH: ::c_int = 0;
1156-
pub const NFT_REJECT_TCP_RST: ::c_int = 1;
1157-
pub const NFT_REJECT_ICMPX_UNREACH: ::c_int = 2;
1158-
1159-
pub const NFT_REJECT_ICMPX_NO_ROUTE: ::c_int = 0;
1160-
pub const NFT_REJECT_ICMPX_PORT_UNREACH: ::c_int = 1;
1161-
pub const NFT_REJECT_ICMPX_HOST_UNREACH: ::c_int = 2;
1162-
pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: ::c_int = 3;
1163-
1164-
pub const NFT_NAT_SNAT: ::c_int = 0;
1165-
pub const NFT_NAT_DNAT: ::c_int = 1;
1166-
1167-
pub const NFT_TRACETYPE_UNSPEC: ::c_int = 0;
1168-
pub const NFT_TRACETYPE_POLICY: ::c_int = 1;
1169-
pub const NFT_TRACETYPE_RETURN: ::c_int = 2;
1170-
pub const NFT_TRACETYPE_RULE: ::c_int = 3;
1171-
1172-
pub const NFT_NG_INCREMENTAL: ::c_int = 0;
1173-
pub const NFT_NG_RANDOM: ::c_int = 1;
1174-
1175982
pub const M_MXFAST: ::c_int = 1;
1176983
pub const M_NLBLKS: ::c_int = 2;
1177984
pub const M_GRAIN: ::c_int = 3;

0 commit comments

Comments
 (0)