From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: wenxu@ucloud.cn, nikolay@cumulusnetworks.com,
bridge@lists.linux-foundation.org
Subject: [PATCH] netfilter: nft_meta: fix bridge port vlan ID selector
Date: Wed, 3 Jul 2019 14:40:40 +0200 [thread overview]
Message-ID: <20190703124040.19279-1-pablo@netfilter.org> (raw)
Use br_vlan_enabled() and br_vlan_get_pvid() helpers as Nikolay
suggests.
Rename NFT_META_BRI_PVID to NFT_META_BRI_IIFPVID before this patch hits
the 5.3 release cycle, to leave room for matching for the output bridge
port in the future.
Reported-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Fixes: da4f10a4265b ("netfilter: nft_meta: add NFT_META_BRI_PVID support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/uapi/linux/netfilter/nf_tables.h | 4 ++--
net/netfilter/nft_meta.c | 17 ++++++++++-------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 8859535031e2..8a1bd0b1ec8c 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -795,7 +795,7 @@ enum nft_exthdr_attributes {
* @NFT_META_SECPATH: boolean, secpath_exists (!!skb->sp)
* @NFT_META_IIFKIND: packet input interface kind name (dev->rtnl_link_ops->kind)
* @NFT_META_OIFKIND: packet output interface kind name (dev->rtnl_link_ops->kind)
- * @NFT_META_BRI_PVID: packet input bridge port pvid
+ * @NFT_META_BRI_IIFPVID: packet input bridge port pvid
*/
enum nft_meta_keys {
NFT_META_LEN,
@@ -826,7 +826,7 @@ enum nft_meta_keys {
NFT_META_SECPATH,
NFT_META_IIFKIND,
NFT_META_OIFKIND,
- NFT_META_BRI_PVID,
+ NFT_META_BRI_IIFPVID,
};
/**
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 4f8116de70f8..b8d8adc0852e 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -240,14 +240,17 @@ void nft_meta_get_eval(const struct nft_expr *expr,
goto err;
strncpy((char *)dest, p->br->dev->name, IFNAMSIZ);
return;
- case NFT_META_BRI_PVID:
+ case NFT_META_BRI_IIFPVID: {
+ u16 p_pvid;
+
if (in == NULL || (p = br_port_get_rtnl_rcu(in)) == NULL)
goto err;
- if (br_opt_get(p->br, BROPT_VLAN_ENABLED)) {
- nft_reg_store16(dest, br_get_pvid(nbp_vlan_group_rcu(p)));
- return;
- }
- goto err;
+ if (!br_vlan_enabled(in))
+ goto err;
+ br_vlan_get_pvid(in, &p_pvid);
+ nft_reg_store16(dest, p_pvid);
+ return;
+ }
#endif
case NFT_META_IIFKIND:
if (in == NULL || in->rtnl_link_ops == NULL)
@@ -375,7 +378,7 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
return -EOPNOTSUPP;
len = IFNAMSIZ;
break;
- case NFT_META_BRI_PVID:
+ case NFT_META_BRI_IIFPVID:
if (ctx->family != NFPROTO_BRIDGE)
return -EOPNOTSUPP;
len = sizeof(u16);
--
2.11.0
next reply other threads:[~2019-07-03 12:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 12:40 Pablo Neira Ayuso [this message]
2019-07-03 12:42 ` [PATCH] netfilter: nft_meta: fix bridge port vlan ID selector Nikolay Aleksandrov
2019-07-03 12:48 ` Nikolay Aleksandrov
2019-07-03 12:53 ` Nikolay Aleksandrov
2019-07-03 12:58 ` Nikolay Aleksandrov
2019-07-03 13:53 ` wenxu
2019-07-03 14:15 ` Pablo Neira Ayuso
2019-07-03 14:52 ` Nikolay Aleksandrov
2019-07-03 14:59 ` wenxu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190703124040.19279-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=bridge@lists.linux-foundation.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=wenxu@ucloud.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).