]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
netfilter: nft_nat: allow to specify layer 4 protocol NAT only
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 20 Jul 2021 16:22:50 +0000 (18:22 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 23 Jul 2021 12:18:03 +0000 (14:18 +0200)
nft_nat reports a bogus EAFNOSUPPORT if no layer 3 information is specified.

Fixes: d07db9884a5f ("netfilter: nf_tables: introduce nft_validate_register_load()")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_nat.c

index 0840c635b752e30b6cf015ae3b931546c7897b62..be1595d6979d8107098921a9cc6675c38b53e3b2 100644 (file)
@@ -201,7 +201,9 @@ static int nft_nat_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
                alen = sizeof_field(struct nf_nat_range, min_addr.ip6);
                break;
        default:
-               return -EAFNOSUPPORT;
+               if (tb[NFTA_NAT_REG_ADDR_MIN])
+                       return -EAFNOSUPPORT;
+               break;
        }
        priv->family = family;