summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-05-03 02:27:06 (GMT)
committerDavid S. Miller <davem@davemloft.net>2016-05-03 02:27:06 (GMT)
commite8194d4fa00dae2ff24983b82780ed0949eaf2fd (patch)
tree21fd3ce2e442872d56b118959936170c35a91771 /include
parentd1ac3b16d535019b7da6fd81d81a469e72d5c3dd (diff)
parenta60c090361ea211625c27052dbbc11c5222e20e4 (diff)
downloadlinux-e8194d4fa00dae2ff24983b82780ed0949eaf2fd.tar.xz
Merge branch 'bridge-per-vlan-stats'
Nikolay Aleksandrov says: ==================== bridge: per-vlan stats This set adds support for bridge per-vlan statistics. In order to be able to dump statistics for many vlans we need a way to continue dumping after reaching maximum size, thus patches 01 and 02 extend the new stats API with a per-device extended link stats attribute and callback which can save its local state and continue where it left off afterwards. I considered using the already existing "fill_xstats" callback but it gets confusing since we need to separate the linkinfo dump from the new stats api dump and adding a flag/argument to do that just looks messy. I don't think the rtnl_link_ops size is an issue, so adding these seemed like the cleaner approach. Patches 03 and 04 add the stats support and netlink dump support respectively. The stats accounting is controlled via a bridge option which is default off, thus the performance impact is kept minimal. I've tested this set with both old and modified iproute2, kmemleak on and some traffic stress tests while adding/removing vlans and ports. v3: - drop the RCU pvid patch and remove one pointer fetch as requested - make stats accounting optional with default to off, the option is in the same cache line as vlan_proto and vlan_enabled, so it is already fetched before the fast path check thus the performance impact is minimal, this also allows us to avoid one vlan lookup and return early when using pvid - rebased and retested v2: - Improve the error checking, rename lidx to prividx and save the current idx user instead of restricting it to one in patch 01 - squash patch 02 into 01 and remove the restriction - add callback descriptions, improve the size calculation and change the xstats message structure to have an embedding level per rtnl link type so we can avoid one call to get the link type (and thus filter on it) and also each link type can now have any number of private attributes inside - fix a problem where the vlan stats are not dumped if the bridge has 0 vlans on it but has vlans on the ports, add bridge link type private attributes and also add paddings for future extensions to avoid at least a few netlink attributes and improve struct alignment - drop the is_skb_forwardable argument constifying patch as it's not needed anymore, but it's a nice cleanup which I'll send separately ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/rtnetlink.h7
-rw-r--r--include/uapi/linux/if_bridge.h18
-rw-r--r--include/uapi/linux/if_link.h14
3 files changed, 39 insertions, 0 deletions
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 2f87c1b..006a7b8 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -47,6 +47,9 @@ static inline int rtnl_msg_family(const struct nlmsghdr *nlh)
* @get_num_rx_queues: Function to determine number of receive queues
* to create when creating a new device.
* @get_link_net: Function to get the i/o netns of the device
+ * @get_linkxstats_size: Function to calculate the required room for
+ * dumping device-specific extended link stats
+ * @fill_linkxstats: Function to dump device-specific extended link stats
*/
struct rtnl_link_ops {
struct list_head list;
@@ -95,6 +98,10 @@ struct rtnl_link_ops {
const struct net_device *dev,
const struct net_device *slave_dev);
struct net *(*get_link_net)(const struct net_device *dev);
+ size_t (*get_linkxstats_size)(const struct net_device *dev);
+ int (*fill_linkxstats)(struct sk_buff *skb,
+ const struct net_device *dev,
+ int *prividx);
};
int __rtnl_link_register(struct rtnl_link_ops *ops);
diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
index 0536eef..397d503 100644
--- a/include/uapi/linux/if_bridge.h
+++ b/include/uapi/linux/if_bridge.h
@@ -134,6 +134,16 @@ struct bridge_vlan_info {
__u16 vid;
};
+struct bridge_vlan_xstats {
+ __u64 rx_bytes;
+ __u64 rx_packets;
+ __u64 tx_bytes;
+ __u64 tx_packets;
+ __u16 vid;
+ __u16 pad1;
+ __u32 pad2;
+};
+
/* Bridge multicast database attributes
* [MDBA_MDB] = {
* [MDBA_MDB_ENTRY] = {
@@ -233,4 +243,12 @@ enum {
};
#define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
+/* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
+enum {
+ BRIDGE_XSTATS_UNSPEC,
+ BRIDGE_XSTATS_VLAN,
+ __BRIDGE_XSTATS_MAX
+};
+#define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
+
#endif /* _UAPI_LINUX_IF_BRIDGE_H */
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 3e80974..d2d7fd4 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -272,6 +272,7 @@ enum {
IFLA_BR_NF_CALL_ARPTABLES,
IFLA_BR_VLAN_DEFAULT_PVID,
IFLA_BR_PAD,
+ IFLA_BR_VLAN_STATS_ENABLED,
__IFLA_BR_MAX,
};
@@ -810,6 +811,7 @@ struct if_stats_msg {
enum {
IFLA_STATS_UNSPEC, /* also used as 64bit pad attribute */
IFLA_STATS_LINK_64,
+ IFLA_STATS_LINK_XSTATS,
__IFLA_STATS_MAX,
};
@@ -817,4 +819,16 @@ enum {
#define IFLA_STATS_FILTER_BIT(ATTR) (1 << (ATTR - 1))
+/* These are embedded into IFLA_STATS_LINK_XSTATS:
+ * [IFLA_STATS_LINK_XSTATS]
+ * -> [LINK_XSTATS_TYPE_xxx]
+ * -> [rtnl link type specific attributes]
+ */
+enum {
+ LINK_XSTATS_TYPE_UNSPEC,
+ LINK_XSTATS_TYPE_BRIDGE,
+ __LINK_XSTATS_TYPE_MAX
+};
+#define LINK_XSTATS_TYPE_MAX (__LINK_XSTATS_TYPE_MAX - 1)
+
#endif /* _UAPI_LINUX_IF_LINK_H */