netfilter: nft_ct: make l3 protocol field optional for timeout object
authorHarsha Sharma <harshasharmaiitr@gmail.com>
Fri, 10 Aug 2018 17:22:37 +0000 (22:52 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Aug 2018 17:37:08 +0000 (19:37 +0200)
If l3 protocol value is not specified for ct timeout object then use the
value from nft_ctx protocol family.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_ct.c

index 4855d4ce1c8f8529ddbca1e61b86b1e88276f30a..26a8baebd0722c30746edf8f4c91308efb83373a 100644 (file)
@@ -832,12 +832,13 @@ static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx,
        __u8 l4num;
        int ret;
 
-       if (!tb[NFTA_CT_TIMEOUT_L3PROTO] ||
-           !tb[NFTA_CT_TIMEOUT_L4PROTO] ||
+       if (!tb[NFTA_CT_TIMEOUT_L4PROTO] ||
            !tb[NFTA_CT_TIMEOUT_DATA])
                return -EINVAL;
 
-       l3num = ntohs(nla_get_be16(tb[NFTA_CT_TIMEOUT_L3PROTO]));
+       if (tb[NFTA_CT_TIMEOUT_L3PROTO])
+               l3num = ntohs(nla_get_be16(tb[NFTA_CT_TIMEOUT_L3PROTO]));
+
        l4num = nla_get_u8(tb[NFTA_CT_TIMEOUT_L4PROTO]);
        priv->l4proto = l4num;