From: wenxu <wenxu@ucloud.cn>
To: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Cc: nikolay@cumulusnetworks.com, bridge@lists.linux-foundation.org
Subject: Re: [PATCH] netfilter: nft_meta: fix bridge port vlan ID selector
Date: Wed, 3 Jul 2019 21:53:41 +0800 [thread overview]
Message-ID: <ecb6d9e8-7923-07ba-8940-c69fc251f4c3@ucloud.cn> (raw)
In-Reply-To: <20190703124040.19279-1-pablo@netfilter.org>
在 2019/7/3 20:40, Pablo Neira Ayuso 写道:
> 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);
I find the function br_vlan_get_pvid is ASSERT_RTNL();. But in this senario is under packet path.
> + 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);
next prev parent reply other threads:[~2019-07-03 13:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 12:40 [PATCH] netfilter: nft_meta: fix bridge port vlan ID selector Pablo Neira Ayuso
2019-07-03 12:42 ` 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 [this message]
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=ecb6d9e8-7923-07ba-8940-c69fc251f4c3@ucloud.cn \
--to=wenxu@ucloud.cn \
--cc=bridge@lists.linux-foundation.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=pablo@netfilter.org \
/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).