Skip to content

Commit 1e48aac

Browse files
committed
Merge branch 'ipv6-simplify-rt6_fill_node'
David Ahern says: ==================== net: ipv6: simplify rt6_fill_node Remove a couple of unnecessary input arguments to rt6_fill_node. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1ce463d + f8cfe2c commit 1e48aac

File tree

3 files changed

+21
-36
lines changed

3 files changed

+21
-36
lines changed

include/linux/mroute6.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct mfc6_cache {
116116

117117
struct rtmsg;
118118
extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
119-
struct rtmsg *rtm, int nowait, u32 portid);
119+
struct rtmsg *rtm, u32 portid);
120120

121121
#ifdef CONFIG_IPV6_MROUTE
122122
extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb);

net/ipv6/ip6mr.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ static int __ip6mr_fill_mroute(struct mr6_table *mrt, struct sk_buff *skb,
22882288
}
22892289

22902290
int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,
2291-
int nowait, u32 portid)
2291+
u32 portid)
22922292
{
22932293
int err;
22942294
struct mr6_table *mrt;
@@ -2315,11 +2315,6 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,
23152315
struct net_device *dev;
23162316
int vif;
23172317

2318-
if (nowait) {
2319-
read_unlock(&mrt_lock);
2320-
return -EAGAIN;
2321-
}
2322-
23232318
dev = skb->dev;
23242319
if (!dev || (vif = ip6mr_find_vif(mrt, dev)) < 0) {
23252320
read_unlock(&mrt_lock);
@@ -2357,7 +2352,7 @@ int ip6mr_get_route(struct net *net, struct sk_buff *skb, struct rtmsg *rtm,
23572352
return err;
23582353
}
23592354

2360-
if (!nowait && (rtm->rtm_flags&RTM_F_NOTIFY))
2355+
if (rtm->rtm_flags & RTM_F_NOTIFY)
23612356
cache->mfc_flags |= MFC_NOTIFY;
23622357

23632358
err = __ip6mr_fill_mroute(mrt, skb, cache, rtm);

net/ipv6/route.c

Lines changed: 18 additions & 28 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, int nowait, 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;
@@ -3261,19 +3254,12 @@ static int rt6_fill_node(struct net *net,
32613254
if (iif) {
32623255
#ifdef CONFIG_IPV6_MROUTE
32633256
if (ipv6_addr_is_multicast(&rt->rt6i_dst.addr)) {
3264-
int err = ip6mr_get_route(net, skb, rtm, nowait,
3265-
portid);
3266-
3267-
if (err <= 0) {
3268-
if (!nowait) {
3269-
if (err == 0)
3270-
return 0;
3271-
goto nla_put_failure;
3272-
} else {
3273-
if (err == -EMSGSIZE)
3274-
goto nla_put_failure;
3275-
}
3276-
}
3257+
int err = ip6mr_get_route(net, skb, rtm, portid);
3258+
3259+
if (err == 0)
3260+
return 0;
3261+
if (err < 0)
3262+
goto nla_put_failure;
32773263
} else
32783264
#endif
32793265
if (nla_put_u32(skb, RTA_IIF, iif))
@@ -3331,18 +3317,22 @@ static int rt6_fill_node(struct net *net,
33313317
int rt6_dump_route(struct rt6_info *rt, void *p_arg)
33323318
{
33333319
struct rt6_rtnl_dump_arg *arg = (struct rt6_rtnl_dump_arg *) p_arg;
3334-
int prefix;
33353320

33363321
if (nlmsg_len(arg->cb->nlh) >= sizeof(struct rtmsg)) {
33373322
struct rtmsg *rtm = nlmsg_data(arg->cb->nlh);
3338-
prefix = (rtm->rtm_flags & RTM_F_PREFIX) != 0;
3339-
} else
3340-
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+
}
33413331

33423332
return rt6_fill_node(arg->net,
33433333
arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
33443334
NETLINK_CB(arg->cb->skb).portid, arg->cb->nlh->nlmsg_seq,
3345-
prefix, 0, NLM_F_MULTI);
3335+
NLM_F_MULTI);
33463336
}
33473337

33483338
static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
@@ -3433,7 +3423,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
34333423

34343424
err = rt6_fill_node(net, skb, rt, &fl6.daddr, &fl6.saddr, iif,
34353425
RTM_NEWROUTE, NETLINK_CB(in_skb).portid,
3436-
nlh->nlmsg_seq, 0, 0, 0);
3426+
nlh->nlmsg_seq, 0);
34373427
if (err < 0) {
34383428
kfree_skb(skb);
34393429
goto errout;
@@ -3460,7 +3450,7 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info,
34603450
goto errout;
34613451

34623452
err = rt6_fill_node(net, skb, rt, NULL, NULL, 0,
3463-
event, info->portid, seq, 0, 0, nlm_flags);
3453+
event, info->portid, seq, nlm_flags);
34643454
if (err < 0) {
34653455
/* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
34663456
WARN_ON(err == -EMSGSIZE);

0 commit comments

Comments
 (0)