From: wenxu@ucloud.cn
To: pablo@netfilter.org, nikolay@cumulusnetworks.com
Cc: netfilter-devel@vger.kernel.org, bridge@lists.linux-foundation.org
Subject: [PATCH 3/7 nf-next] bridge: add br_vlan_get_pvid_rcu()
Date: Thu, 4 Jul 2019 15:22:31 +0800 [thread overview]
Message-ID: <1562224955-3979-3-git-send-email-wenxu@ucloud.cn> (raw)
In-Reply-To: <1562224955-3979-1-git-send-email-wenxu@ucloud.cn>
From: wenxu <wenxu@ucloud.cn>
This new function allows you to fetch bridge pvid from packet path.
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
include/linux/if_bridge.h | 6 ++++++
net/bridge/br_vlan.c | 19 +++++++++++++++----
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
index f3fab5d..950db1d 100644
--- a/include/linux/if_bridge.h
+++ b/include/linux/if_bridge.h
@@ -88,6 +88,7 @@ static inline bool br_multicast_router(const struct net_device *dev)
#if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_VLAN_FILTERING)
bool br_vlan_enabled(const struct net_device *dev);
int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid);
+int br_vlan_get_pvid_rcu(const struct net_device *dev, u16 *p_pvid);
int br_vlan_get_info(const struct net_device *dev, u16 vid,
struct bridge_vlan_info *p_vinfo);
#else
@@ -101,6 +102,11 @@ static inline int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
return -EINVAL;
}
+static inline int br_vlan_get_pvid_rcu(const struct net_device *dev, u16 *p_pvid)
+{
+ return -EINVAL;
+}
+
static inline int br_vlan_get_info(const struct net_device *dev, u16 vid,
struct bridge_vlan_info *p_vinfo)
{
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index f47f526..8d97b91 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -1227,13 +1227,11 @@ void br_vlan_get_stats(const struct net_bridge_vlan *v,
}
}
-int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
+static int __br_vlan_get_pvid(const struct net_device *dev,
+ struct net_bridge_port *p, u16 *p_pvid)
{
struct net_bridge_vlan_group *vg;
- struct net_bridge_port *p;
- ASSERT_RTNL();
- p = br_port_get_check_rtnl(dev);
if (p)
vg = nbp_vlan_group(p);
else if (netif_is_bridge_master(dev))
@@ -1244,8 +1242,21 @@ int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
*p_pvid = br_get_pvid(vg);
return 0;
}
+
+int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
+{
+ ASSERT_RTNL();
+
+ return __br_vlan_get_pvid(dev, br_port_get_check_rtnl(dev), p_pvid);
+}
EXPORT_SYMBOL_GPL(br_vlan_get_pvid);
+int br_vlan_get_pvid_rcu(const struct net_device *dev, u16 *p_pvid)
+{
+ return __br_vlan_get_pvid(dev, br_port_get_check_rcu(dev), p_pvid);
+}
+EXPORT_SYMBOL_GPL(br_vlan_get_pvid_rcu);
+
int br_vlan_get_info(const struct net_device *dev, u16 vid,
struct bridge_vlan_info *p_vinfo)
{
--
1.8.3.1
next prev parent reply other threads:[~2019-07-04 7:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-04 7:22 [PATCH 1/7 nf-next] netfilter: separate bridge meta key from nft_meta into meta_bridge wenxu
2019-07-04 7:22 ` [PATCH 2/7 nf-next] netfilter: nft_meta_bridge: Remove the br_private.h header wenxu
2019-07-05 8:18 ` Nikolay Aleksandrov
2019-07-04 7:22 ` wenxu [this message]
2019-07-05 8:23 ` [PATCH 3/7 nf-next] bridge: add br_vlan_get_pvid_rcu() Nikolay Aleksandrov
2019-07-04 7:22 ` [PATCH 4/7 nf-next] netfilter: nft_meta_bridge: add NFT_META_BRI_IIFPVID support wenxu
2019-07-05 8:24 ` Nikolay Aleksandrov
2019-07-04 7:22 ` [PATCH 5/7 nf-next] bridge: add br_vlan_get_proto() wenxu
2019-07-05 8:25 ` Nikolay Aleksandrov
2019-07-04 7:22 ` [PATCH 6/7 nf-next] netfilter: nft_meta_bridge: Add NFT_META_BRI_IIFVPROTO support wenxu
2019-07-05 8:28 ` Nikolay Aleksandrov
2019-07-04 7:22 ` [PATCH 7/7 nf-next] netfilter:nft_meta: add NFT_META_VLAN support wenxu
2019-07-05 8:34 ` Nikolay Aleksandrov
2019-07-05 8:59 ` Nikolay Aleksandrov
2019-07-05 8:16 ` [PATCH 1/7 nf-next] netfilter: separate bridge meta key from nft_meta into meta_bridge Nikolay Aleksandrov
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=1562224955-3979-3-git-send-email-wenxu@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).