* [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags
@ 2016-08-17 10:53 Nikolay Aleksandrov
2016-08-17 10:53 ` [PATCH net-next 1/2] net: bridge: consolidate bridge and port linkxstats calls Nikolay Aleksandrov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2016-08-17 10:53 UTC (permalink / raw)
To: netdev; +Cc: roopa, davem, stephen, bridge, Nikolay Aleksandrov
Hi,
This set adds the ability to export vlan stats per-port. Patch 01 makes
that possible by consolidating the bridge and port linkxstats calls. Then
patch 02 allows to dump the vlan entry flags in order to be able to
distinguish between bridge and port vlan entries when dumping the master
device vlan stats. That is needed because that call was implemented when
the stats API didn't have slave dumping capabilities and it dumps all vlan
stats (for both bridge and port entries). We also need it in order to print
the vlan flags when dumping the stats.
Cheers,
Nik
Nikolay Aleksandrov (2):
net: bridge: consolidate bridge and port linkxstats calls
net: bridge: export vlan flags with the stats
include/uapi/linux/if_bridge.h | 2 +-
net/bridge/br_netlink.c | 115 ++++++++++++++---------------------------
2 files changed, 41 insertions(+), 76 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next 1/2] net: bridge: consolidate bridge and port linkxstats calls
2016-08-17 10:53 [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags Nikolay Aleksandrov
@ 2016-08-17 10:53 ` Nikolay Aleksandrov
2016-08-17 10:53 ` [PATCH net-next 2/2] net: bridge: export vlan flags with the stats Nikolay Aleksandrov
2016-08-19 6:19 ` [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2016-08-17 10:53 UTC (permalink / raw)
To: netdev; +Cc: roopa, davem, stephen, bridge, Nikolay Aleksandrov
In the bridge driver we usually have the same function working for both
port and bridge. In order to follow that logic and also avoid code
duplication, consolidate the bridge_ and brport_ linkxstats calls into
one since they share most of their code. As a side effect this allows us
to dump the vlan stats also via the slave call which is in preparation for
the upcoming per-port vlan stats and vlan flag dumping.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
net/bridge/br_netlink.c | 114 +++++++++++++++++-------------------------------
1 file changed, 39 insertions(+), 75 deletions(-)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index f2a29e467e78..493ab9b3d51a 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1245,14 +1245,30 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
return 0;
}
-static size_t bridge_get_linkxstats_size(const struct net_device *dev)
+static size_t br_get_linkxstats_size(const struct net_device *dev, int attr)
{
- struct net_bridge *br = netdev_priv(dev);
+ struct net_bridge_port *p = NULL;
struct net_bridge_vlan_group *vg;
struct net_bridge_vlan *v;
+ struct net_bridge *br;
int numvls = 0;
- vg = br_vlan_group(br);
+ switch (attr) {
+ case IFLA_STATS_LINK_XSTATS:
+ br = netdev_priv(dev);
+ vg = br_vlan_group(br);
+ break;
+ case IFLA_STATS_LINK_XSTATS_SLAVE:
+ p = br_port_get_rtnl(dev);
+ if (!p)
+ return 0;
+ br = p->br;
+ vg = nbp_vlan_group(p);
+ break;
+ default:
+ return 0;
+ }
+
if (vg) {
/* we need to count all, even placeholder entries */
list_for_each_entry(v, &vg->vlan_list, vlist)
@@ -1264,44 +1280,38 @@ static size_t bridge_get_linkxstats_size(const struct net_device *dev)
nla_total_size(0);
}
-static size_t brport_get_linkxstats_size(const struct net_device *dev)
-{
- return nla_total_size(sizeof(struct br_mcast_stats)) +
- nla_total_size(0);
-}
-
-static size_t br_get_linkxstats_size(const struct net_device *dev, int attr)
+static int br_fill_linkxstats(struct sk_buff *skb,
+ const struct net_device *dev,
+ int *prividx, int attr)
{
- size_t retsize = 0;
+ struct nlattr *nla __maybe_unused;
+ struct net_bridge_port *p = NULL;
+ struct net_bridge_vlan_group *vg;
+ struct net_bridge_vlan *v;
+ struct net_bridge *br;
+ struct nlattr *nest;
+ int vl_idx = 0;
switch (attr) {
case IFLA_STATS_LINK_XSTATS:
- retsize = bridge_get_linkxstats_size(dev);
+ br = netdev_priv(dev);
+ vg = br_vlan_group(br);
break;
case IFLA_STATS_LINK_XSTATS_SLAVE:
- retsize = brport_get_linkxstats_size(dev);
+ p = br_port_get_rtnl(dev);
+ if (!p)
+ return 0;
+ br = p->br;
+ vg = nbp_vlan_group(p);
break;
+ default:
+ return -EINVAL;
}
- return retsize;
-}
-
-static int bridge_fill_linkxstats(struct sk_buff *skb,
- const struct net_device *dev,
- int *prividx)
-{
- struct net_bridge *br = netdev_priv(dev);
- struct nlattr *nla __maybe_unused;
- struct net_bridge_vlan_group *vg;
- struct net_bridge_vlan *v;
- struct nlattr *nest;
- int vl_idx = 0;
-
nest = nla_nest_start(skb, LINK_XSTATS_TYPE_BRIDGE);
if (!nest)
return -EMSGSIZE;
- vg = br_vlan_group(br);
if (vg) {
list_for_each_entry(v, &vg->vlan_list, vlist) {
struct bridge_vlan_xstats vxi;
@@ -1329,7 +1339,7 @@ static int bridge_fill_linkxstats(struct sk_buff *skb,
BRIDGE_XSTATS_PAD);
if (!nla)
goto nla_put_failure;
- br_multicast_get_stats(br, NULL, nla_data(nla));
+ br_multicast_get_stats(br, p, nla_data(nla));
}
#endif
nla_nest_end(skb, nest);
@@ -1344,52 +1354,6 @@ nla_put_failure:
return -EMSGSIZE;
}
-static int brport_fill_linkxstats(struct sk_buff *skb,
- const struct net_device *dev,
- int *prividx)
-{
- struct net_bridge_port *p = br_port_get_rtnl(dev);
- struct nlattr *nla __maybe_unused;
- struct nlattr *nest;
-
- if (!p)
- return 0;
-
- nest = nla_nest_start(skb, LINK_XSTATS_TYPE_BRIDGE);
- if (!nest)
- return -EMSGSIZE;
-#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
- nla = nla_reserve_64bit(skb, BRIDGE_XSTATS_MCAST,
- sizeof(struct br_mcast_stats),
- BRIDGE_XSTATS_PAD);
- if (!nla) {
- nla_nest_end(skb, nest);
- return -EMSGSIZE;
- }
- br_multicast_get_stats(p->br, p, nla_data(nla));
-#endif
- nla_nest_end(skb, nest);
-
- return 0;
-}
-
-static int br_fill_linkxstats(struct sk_buff *skb, const struct net_device *dev,
- int *prividx, int attr)
-{
- int ret = -EINVAL;
-
- switch (attr) {
- case IFLA_STATS_LINK_XSTATS:
- ret = bridge_fill_linkxstats(skb, dev, prividx);
- break;
- case IFLA_STATS_LINK_XSTATS_SLAVE:
- ret = brport_fill_linkxstats(skb, dev, prividx);
- break;
- }
-
- return ret;
-}
-
static struct rtnl_af_ops br_af_ops __read_mostly = {
.family = AF_BRIDGE,
.get_link_af_size = br_get_link_af_size_filtered,
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next 2/2] net: bridge: export vlan flags with the stats
2016-08-17 10:53 [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags Nikolay Aleksandrov
2016-08-17 10:53 ` [PATCH net-next 1/2] net: bridge: consolidate bridge and port linkxstats calls Nikolay Aleksandrov
@ 2016-08-17 10:53 ` Nikolay Aleksandrov
2016-08-19 6:19 ` [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2016-08-17 10:53 UTC (permalink / raw)
To: netdev; +Cc: roopa, davem, stephen, bridge, Nikolay Aleksandrov
Use one of the vlan xstats padding fields to export the vlan flags. This is
needed in order to be able to distinguish between master (bridge) and port
vlan entries in user-space when dumping the bridge vlan stats.
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
include/uapi/linux/if_bridge.h | 2 +-
net/bridge/br_netlink.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
index c186f64fffca..ab92bca6d448 100644
--- a/include/uapi/linux/if_bridge.h
+++ b/include/uapi/linux/if_bridge.h
@@ -140,7 +140,7 @@ struct bridge_vlan_xstats {
__u64 tx_bytes;
__u64 tx_packets;
__u16 vid;
- __u16 pad1;
+ __u16 flags;
__u32 pad2;
};
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 493ab9b3d51a..872d4c0deb59 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1321,6 +1321,7 @@ static int br_fill_linkxstats(struct sk_buff *skb,
continue;
memset(&vxi, 0, sizeof(vxi));
vxi.vid = v->vid;
+ vxi.flags = v->flags;
br_vlan_get_stats(v, &stats);
vxi.rx_bytes = stats.rx_bytes;
vxi.rx_packets = stats.rx_packets;
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags
2016-08-17 10:53 [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags Nikolay Aleksandrov
2016-08-17 10:53 ` [PATCH net-next 1/2] net: bridge: consolidate bridge and port linkxstats calls Nikolay Aleksandrov
2016-08-17 10:53 ` [PATCH net-next 2/2] net: bridge: export vlan flags with the stats Nikolay Aleksandrov
@ 2016-08-19 6:19 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-08-19 6:19 UTC (permalink / raw)
To: nikolay; +Cc: netdev, roopa, stephen, bridge
From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Date: Wed, 17 Aug 2016 12:53:08 +0200
> This set adds the ability to export vlan stats per-port. Patch 01 makes
> that possible by consolidating the bridge and port linkxstats calls. Then
> patch 02 allows to dump the vlan entry flags in order to be able to
> distinguish between bridge and port vlan entries when dumping the master
> device vlan stats. That is needed because that call was implemented when
> the stats API didn't have slave dumping capabilities and it dumps all vlan
> stats (for both bridge and port entries). We also need it in order to print
> the vlan flags when dumping the stats.
Series applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-19 6:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-17 10:53 [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags Nikolay Aleksandrov
2016-08-17 10:53 ` [PATCH net-next 1/2] net: bridge: consolidate bridge and port linkxstats calls Nikolay Aleksandrov
2016-08-17 10:53 ` [PATCH net-next 2/2] net: bridge: export vlan flags with the stats Nikolay Aleksandrov
2016-08-19 6:19 ` [PATCH net-next 0/2] net: bridge: export vlan stats per-port with flags David Miller
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).