]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft: Do not combine inverted payload matches
authorSriram Rajagopalan <bglsriram@gmail.com>
Wed, 13 Mar 2024 09:04:37 +0000 (02:04 -0700)
committerPhil Sutter <phil@nwl.cc>
Tue, 19 Mar 2024 15:57:48 +0000 (16:57 +0100)
Fixed the issue with combining the payload in case of invert filter for
tcp src and dst ports.

Signed-off-by: Sriram Rajagopalan <sriramr@arista.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/nft.c

index ee63c3dc42ed400ef86e954cbca0bce9dc0cb012..884cc77e647ba850677a2503f2c6b19705dad259 100644 (file)
@@ -1307,14 +1307,12 @@ static int add_nft_tcpudp(struct nft_handle *h,struct nftnl_rule *r,
        uint8_t reg;
        int ret;
 
-       if (src[0] && src[0] == src[1] &&
+       if (!invert_src &&
+           src[0] && src[0] == src[1] &&
            dst[0] && dst[0] == dst[1] &&
            invert_src == invert_dst) {
                uint32_t combined = dst[0] | (src[0] << 16);
 
-               if (invert_src)
-                       op = NFT_CMP_NEQ;
-
                expr = gen_payload(h, NFT_PAYLOAD_TRANSPORT_HEADER, 0, 4, &reg);
                if (!expr)
                        return -ENOMEM;