Skip to content

Commit f8cfe2c

Browse files
David Aherndavem330
authored andcommitted
net: ipv6: remove prefix arg to rt6_fill_node
The prefix arg to rt6_fill_node is non-0 in only 1 path - rt6_dump_route where a user is requesting a prefix only dump. Simplify rt6_fill_node by removing the prefix arg and moving the prefix check to rt6_dump_route. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fd61c6b commit f8cfe2c

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

net/ipv6/route.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,21 +3169,14 @@ static int rt6_fill_node(struct net *net,
31693169
struct sk_buff *skb, struct rt6_info *rt,
31703170
struct in6_addr *dst, struct in6_addr *src,
31713171
int iif, int type, u32 portid, u32 seq,
3172-
int prefix, unsigned int flags)
3172+
unsigned int flags)
31733173
{
31743174
u32 metrics[RTAX_MAX];
31753175
struct rtmsg *rtm;
31763176
struct nlmsghdr *nlh;
31773177
long expires;
31783178
u32 table;
31793179

3180-
if (prefix) { /* user wants prefix routes only */
3181-
if (!(rt->rt6i_flags & RTF_PREFIX_RT)) {
3182-
/* success since this is not a prefix route */
3183-
return 1;
3184-
}
3185-
}
3186-
31873180
nlh = nlmsg_put(skb, portid, seq, type, sizeof(*rtm), flags);
31883181
if (!nlh)
31893182
return -EMSGSIZE;
@@ -3324,18 +3317,22 @@ static int rt6_fill_node(struct net *net,
33243317
int rt6_dump_route(struct rt6_info *rt, void *p_arg)
33253318
{
33263319
struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
3327-
int prefix;
33283320

33293321
if (nlmsg_len(arg->cb->nlh) >= sizeof(struct rtmsg)) {
33303322
struct rtmsg *rtm = nlmsg_data(arg->cb->nlh);
3331-
prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
3332-
} else
3333-
prefix = 0;
3323+
3324+
/* user wants prefix routes only */
3325+
if (rtm->rtm_flags & RTM_F_PREFIX &&
3326+
!(rt->rt6i_flags & RTF_PREFIX_RT)) {
3327+
/* success since this is not a prefix route */
3328+
return 1;
3329+
}
3330+
}
33343331

33353332
return rt6_fill_node(arg->net,
33363333
arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
33373334
NETLINK_CB(arg->cb->skb).portid, arg->cb->nlh->nlmsg_seq,
3338-
prefix, NLM_F_MULTI);
3335+
NLM_F_MULTI);
33393336
}
33403337

33413338
static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
@@ -3426,7 +3423,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
34263423

34273424
err = rt6_fill_node(net, skb, rt, &fl6.daddr, &fl6.saddr, iif,
34283425
RTM_NEWROUTE, NETLINK_CB(in_skb).portid,
3429-
nlh->nlmsg_seq, 0, 0);
3426+
nlh->nlmsg_seq, 0);
34303427
if (err < 0) {
34313428
kfree_skb(skb);
34323429
goto errout;
@@ -3453,7 +3450,7 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info,
34533450
goto errout;
34543451

34553452
err = rt6_fill_node(net, skb, rt, NULL, NULL, 0,
3456-
event, info->portid, seq, 0, nlm_flags);
3453+
event, info->portid, seq, nlm_flags);
34573454
if (err < 0) {
34583455
/* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
34593456
WARN_ON(err == -EMSGSIZE);

0 commit comments

Comments
 (0)