• Petr Machata's avatar
    nexthop: Strongly-type context of rtm_dump_nexthop() · a6fbbaa6
    Petr Machata authored
    The dump operations need to keep state from one invocation to another. A
    scratch area is dedicated for this purpose in the passed-in argument, cb,
    namely via two aliased arrays, struct netlink_callback.args and .ctx.
    
    Dumping of buckets will end up having to iterate over next hops as well,
    and it would be nice to be able to reuse the iteration logic with the NH
    dumper. The fact that the logic currently relies on fixed index to the
    .args array, and the indices would have to be coordinated between the two
    dumpers, makes this somewhat awkward.
    
    To make the access patters clearer, introduce a helper struct with a NH
    index, and instead of using the .args array directly, use it through this
    structure.
    Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
    Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    a6fbbaa6
nexthop.c 51.3 KB