Skip to content

Commit e948217

Browse files
pmachatakuba-moo
authored andcommitted
nexthop: Add a callback parameter to rtm_dump_walk_nexthops()
In order to allow different handling for next-hop tree dumper and for bucket dumper, parameterize the next-hop tree walker with a callback. Add rtm_dump_nexthop_cb() with just the bits relevant for next-hop tree dumping. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent cbee180 commit e948217

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

net/ipv4/nexthop.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,9 +2083,11 @@ static int rtm_dump_walk_nexthops(struct sk_buff *skb,
20832083
struct netlink_callback *cb,
20842084
struct rb_root *root,
20852085
struct rtm_dump_nh_ctx *ctx,
2086-
struct nh_dump_filter *filter)
2086+
int (*nh_cb)(struct sk_buff *skb,
2087+
struct netlink_callback *cb,
2088+
struct nexthop *nh, void *data),
2089+
void *data)
20872090
{
2088-
struct nhmsg *nhm = nlmsg_data(cb->nlh);
20892091
struct rb_node *node;
20902092
int idx = 0, s_idx;
20912093
int err;
@@ -2098,14 +2100,9 @@ static int rtm_dump_walk_nexthops(struct sk_buff *skb,
20982100
goto cont;
20992101

21002102
nh = rb_entry(node, struct nexthop, rb_node);
2101-
if (nh_dump_filtered(nh, filter, nhm->nh_family))
2102-
goto cont;
2103-
21042103
ctx->idx = idx;
2105-
err = nh_fill_node(skb, nh, RTM_NEWNEXTHOP,
2106-
NETLINK_CB(cb->skb).portid,
2107-
cb->nlh->nlmsg_seq, NLM_F_MULTI);
2108-
if (err < 0)
2104+
err = nh_cb(skb, cb, nh, data);
2105+
if (err)
21092106
return err;
21102107
cont:
21112108
idx++;
@@ -2115,6 +2112,20 @@ static int rtm_dump_walk_nexthops(struct sk_buff *skb,
21152112
return 0;
21162113
}
21172114

2115+
static int rtm_dump_nexthop_cb(struct sk_buff *skb, struct netlink_callback *cb,
2116+
struct nexthop *nh, void *data)
2117+
{
2118+
struct nhmsg *nhm = nlmsg_data(cb->nlh);
2119+
struct nh_dump_filter *filter = data;
2120+
2121+
if (nh_dump_filtered(nh, filter, nhm->nh_family))
2122+
return 0;
2123+
2124+
return nh_fill_node(skb, nh, RTM_NEWNEXTHOP,
2125+
NETLINK_CB(cb->skb).portid,
2126+
cb->nlh->nlmsg_seq, NLM_F_MULTI);
2127+
}
2128+
21182129
/* rtnl */
21192130
static int rtm_dump_nexthop(struct sk_buff *skb, struct netlink_callback *cb)
21202131
{
@@ -2128,7 +2139,8 @@ static int rtm_dump_nexthop(struct sk_buff *skb, struct netlink_callback *cb)
21282139
if (err < 0)
21292140
return err;
21302141

2131-
err = rtm_dump_walk_nexthops(skb, cb, root, ctx, &filter);
2142+
err = rtm_dump_walk_nexthops(skb, cb, root, ctx,
2143+
&rtm_dump_nexthop_cb, &filter);
21322144
if (err < 0) {
21332145
if (likely(skb->len))
21342146
goto out;

0 commit comments

Comments
 (0)