• Ido Schimmel's avatar
    mlxsw: spectrum_mr: Publish multicast route after writing it to the device · 3e3c8daf
    Ido Schimmel authored
    The driver periodically traverses the linked list of multicast routes
    and updates the kernel about packets and bytes statistics from each
    multicast route. These statistics are read from a counter associated
    with the route when it is written to the device.
    
    Currently, multicast routes are published via this linked list before
    they are associated with a counter. Despite that, it is not possible for
    the driver to access an invalid counter because the delayed work that
    reads the statistics and multicast route addition / deletion are
    mutually exclusive using RTNL.
    
    In order to be able to remove RTNL, the list needs to be protected by a
    dedicated lock, but any route published via the list must have an
    associated counter, otherwise the driver will access an invalid counter.
    
    Solve this by re-ordering the operations during multicast route addition
    so that the route is only added to the linked list after it was written
    to the device. Similarly, during deletion the route is first removed
    from the linked list before its deletion from the device.
    Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
    Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    3e3c8daf
spectrum_mr.c 29.2 KB