diff options
author | Liping Zhang <liping.zhang@spreadtrum.com> | 2016-09-22 10:28:51 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-09-25 08:54:02 -0400 |
commit | d767ff2c84f19be1aa403762f34eebbb403caf6d (patch) | |
tree | fd0b02f9d67749c6ada59b7db5558e92ed5fd604 /net | |
parent | 8d11350f5f33378efc5f905bee325f3e76d6bcca (diff) |
netfilter: nft_ct: unnecessary to require dir when use ct l3proto/protocol
Currently, if the user want to match ct l3proto, we must specify the
direction, for example:
# nft add rule filter input ct original l3proto ipv4
^^^^^^^^
Otherwise, error message will be reported:
# nft add rule filter input ct l3proto ipv4
nft add rule filter input ct l3proto ipv4
<cmdline>:1:1-38: Error: Could not process rule: Invalid argument
add rule filter input ct l3proto ipv4
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Actually, there's no need to require NFTA_CT_DIRECTION attr, because
ct l3proto and protocol are unrelated to direction.
And for compatibility, even if the user specify the NFTA_CT_DIRECTION
attr, do not report error, just skip it.
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/nft_ct.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c index 51e180f2a003..825fbbc62f48 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c | |||
@@ -128,15 +128,18 @@ static void nft_ct_get_eval(const struct nft_expr *expr, | |||
128 | memcpy(dest, &count, sizeof(count)); | 128 | memcpy(dest, &count, sizeof(count)); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | case NFT_CT_L3PROTOCOL: | ||
132 | *dest = nf_ct_l3num(ct); | ||
133 | return; | ||
134 | case NFT_CT_PROTOCOL: | ||
135 | *dest = nf_ct_protonum(ct); | ||
136 | return; | ||
131 | default: | 137 | default: |
132 | break; | 138 | break; |
133 | } | 139 | } |
134 | 140 | ||
135 | tuple = &ct->tuplehash[priv->dir].tuple; | 141 | tuple = &ct->tuplehash[priv->dir].tuple; |
136 | switch (priv->key) { | 142 | switch (priv->key) { |
137 | case NFT_CT_L3PROTOCOL: | ||
138 | *dest = nf_ct_l3num(ct); | ||
139 | return; | ||
140 | case NFT_CT_SRC: | 143 | case NFT_CT_SRC: |
141 | memcpy(dest, tuple->src.u3.all, | 144 | memcpy(dest, tuple->src.u3.all, |
142 | nf_ct_l3num(ct) == NFPROTO_IPV4 ? 4 : 16); | 145 | nf_ct_l3num(ct) == NFPROTO_IPV4 ? 4 : 16); |
@@ -145,9 +148,6 @@ static void nft_ct_get_eval(const struct nft_expr *expr, | |||
145 | memcpy(dest, tuple->dst.u3.all, | 148 | memcpy(dest, tuple->dst.u3.all, |
146 | nf_ct_l3num(ct) == NFPROTO_IPV4 ? 4 : 16); | 149 | nf_ct_l3num(ct) == NFPROTO_IPV4 ? 4 : 16); |
147 | return; | 150 | return; |
148 | case NFT_CT_PROTOCOL: | ||
149 | *dest = nf_ct_protonum(ct); | ||
150 | return; | ||
151 | case NFT_CT_PROTO_SRC: | 151 | case NFT_CT_PROTO_SRC: |
152 | *dest = (__force __u16)tuple->src.u.all; | 152 | *dest = (__force __u16)tuple->src.u.all; |
153 | return; | 153 | return; |
@@ -283,8 +283,9 @@ static int nft_ct_get_init(const struct nft_ctx *ctx, | |||
283 | 283 | ||
284 | case NFT_CT_L3PROTOCOL: | 284 | case NFT_CT_L3PROTOCOL: |
285 | case NFT_CT_PROTOCOL: | 285 | case NFT_CT_PROTOCOL: |
286 | if (tb[NFTA_CT_DIRECTION] == NULL) | 286 | /* For compatibility, do not report error if NFTA_CT_DIRECTION |
287 | return -EINVAL; | 287 | * attribute is specified. |
288 | */ | ||
288 | len = sizeof(u8); | 289 | len = sizeof(u8); |
289 | break; | 290 | break; |
290 | case NFT_CT_SRC: | 291 | case NFT_CT_SRC: |
@@ -432,8 +433,6 @@ static int nft_ct_get_dump(struct sk_buff *skb, const struct nft_expr *expr) | |||
432 | goto nla_put_failure; | 433 | goto nla_put_failure; |
433 | 434 | ||
434 | switch (priv->key) { | 435 | switch (priv->key) { |
435 | case NFT_CT_L3PROTOCOL: | ||
436 | case NFT_CT_PROTOCOL: | ||
437 | case NFT_CT_SRC: | 436 | case NFT_CT_SRC: |
438 | case NFT_CT_DST: | 437 | case NFT_CT_DST: |
439 | case NFT_CT_PROTO_SRC: | 438 | case NFT_CT_PROTO_SRC: |