This patch adds stats support for the currently used IGMP/MLD types by the bridge. The stats are per-port (plus one stat per-bridge) and per-direction (RX/TX). The stats are exported via netlink via the new linkxstats API (RTM_GETSTATS). In order to minimize the performance impact, a new option is used to enable/disable the stats - multicast_stats_enabled, similar to the recent vlan stats. Also in order to avoid multiple IGMP/MLD type lookups and checks, we make use of the current "igmp" member of the bridge private skb->cb region to record the type on Rx (both host-generated and external packets pass by multicast_rcv()). We can do that since the igmp member was used as a boolean and all the valid IGMP/MLD types are positive values. The normal bridge fast-path is not affected at all, the only affected paths are the flooding ones and since we make use of the IGMP/MLD type, we can quickly determine if the packet should be counted using cache-hot data (cb's igmp member). We add counters for: * IGMP Queries * IGMP Leaves * IGMP v1/v2/v3 reports * MLD Queries * MLD Leaves * MLD v1/v2 reports These are invaluable when monitoring or debugging complex multicast setups with bridges.
Showing the changes to include/uapi/linux (2 of 10 files). Show all
Unified · Split
| @@ -247,8 +247,34 @@ enum { · 246 unmodified lines | ||
| 247 | 247 | enum { |
| 248 | 248 | BRIDGE_XSTATS_UNSPEC, |
| 249 | 249 | BRIDGE_XSTATS_VLAN, |
| 250 | + BRIDGE_XSTATS_MCAST, | |
| 251 | + BRIDGE_XSTATS_PAD, | |
| 250 | 252 | __BRIDGE_XSTATS_MAX |
| 251 | 253 | }; |
| 252 | 254 | #define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1) |
| 253 | 255 | |
| 256 | +enum { | |
| 257 | + BR_MCAST_DIR_RX, | |
| 258 | + BR_MCAST_DIR_TX, | |
| 259 | + BR_MCAST_DIR_SIZE | |
| 260 | +}; | |
| 261 | + | |
| 262 | +/* IGMP/MLD statistics */ | |
| 263 | +struct br_mcast_stats { | |
| 264 | + __u64 igmp_queries[BR_MCAST_DIR_SIZE]; | |
| 265 | + __u64 igmp_leaves[BR_MCAST_DIR_SIZE]; | |
| 266 | + __u64 igmp_v1reports[BR_MCAST_DIR_SIZE]; | |
| 267 | + __u64 igmp_v2reports[BR_MCAST_DIR_SIZE]; | |
| 268 | + __u64 igmp_v3reports[BR_MCAST_DIR_SIZE]; | |
| 269 | + __u64 igmp_parse_errors; | |
| 270 | + | |
| 271 | + __u64 mld_queries[BR_MCAST_DIR_SIZE]; | |
| 272 | + __u64 mld_leaves[BR_MCAST_DIR_SIZE]; | |
| 273 | + __u64 mld_v1reports[BR_MCAST_DIR_SIZE]; | |
| 274 | + __u64 mld_v2reports[BR_MCAST_DIR_SIZE]; | |
| 275 | + __u64 mld_parse_errors; | |
| 276 | + | |
| 277 | + __u64 mcast_bytes[BR_MCAST_DIR_SIZE]; | |
| 278 | + __u64 mcast_packets[BR_MCAST_DIR_SIZE]; | |
| 279 | +}; | |
| 254 | 280 | #endif /* _UAPI_LINUX_IF_BRIDGE_H */ |
| @@ -273,6 +273,7 @@ enum { · 272 unmodified lines | ||
| 273 | 273 | IFLA_BR_VLAN_DEFAULT_PVID, |
| 274 | 274 | IFLA_BR_PAD, |
| 275 | 275 | IFLA_BR_VLAN_STATS_ENABLED, |
| 276 | + IFLA_BR_MCAST_STATS_ENABLED, | |
| 276 | 277 | __IFLA_BR_MAX, |
| 277 | 278 | }; |
| 278 | 279 | |