• Petr Machata's avatar
    net: rtnetlink: RTM_GETSTATS: Allow filtering inside nests · 46efc97b
    Petr Machata authored
    The filter_mask field of RTM_GETSTATS header determines which top-level
    attributes should be included in the netlink response. This saves
    processing time by only including the bits that the user cares about
    instead of always dumping everything. This is doubly important for
    HW-backed statistics that would typically require a trip to the device to
    fetch the stats.
    
    So far there was only one HW-backed stat suite per attribute. However,
    IFLA_STATS_LINK_OFFLOAD_XSTATS is a nest, and will gain a new stat suite in
    the following patches. It would therefore be advantageous to be able to
    filter within that nest, and select just one or the other HW-backed
    statistics suite.
    
    Extend rtnetlink so that RTM_GETSTATS permits attributes in the payload.
    The scheme is as follows:
    
        - RTM_GETSTATS
    	- struct if_stats_msg
    	- attr nest IFLA_STATS_GET_FILTERS
    	    - attr IFLA_STATS_LINK_OFFLOAD_XSTATS
    		- u32 filter_mask
    
    This scheme reuses the existing enumerators by nesting them in a dedicated
    context attribute. This is covered by policies as usual, therefore a
    gradual opt-in is possible. Currently only IFLA_STATS_LINK_OFFLOAD_XSTATS
    nest has filtering enabled, because for the SW counters the issue does not
    seem to be that important.
    
    rtnl_offload_xstats_get_size() and _fill() are extended to observe the
    requested filters.
    Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
    Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    46efc97b
rtnetlink.c 140 KB