nft: use payload matching for layer 4 protocol
Pablo Neira Ayuso
maintainerPATCH 1/1 nft: use payload matching for layer 4 protocol
This is an IPv4 header, which does not require the special handling as in IPv6, use the payload matching instead of meta l4proto which is slightly faster in this case.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- iptables/nft-ipv4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
iptables/nft-ipv4.c +2 -1
@@ -61,7 +61,8 @@ static int nft_ipv4_add(struct nft_handle *h, struct nftnl_rule *r,if (cs->fw.ip.proto !=0 ) { op =nft_invflags2cmp (cs->fw.ip.invflags,XT_INV_PROTO ); -add_l4proto (h, r, cs->fw.ip.proto, op); +add_proto (h, r, offsetof(struct iphdr , protocol), +sizeof (uint8_t ), cs->fw.ip.proto, op); }if (cs->fw.ip.flags &IPT_F_FRAG ) {
Signature · 1 line
2.30.2
Phil Sutter
reviewerQuoted 3 lines · Pablo Neira Ayuso
This is an IPv4 header, which does not require the special handling as in IPv6, use the payload matching instead of meta l4proto which is slightly faster in this case.
Interestingly, xlate code did this distinction between IPv4 and IPv6 already. So using a payload match here is actually more consistent.
Patch applied, thanks!