Skip to content

Commit 2942e90

Browse files
tgrafDavid S. Miller
authored and
David S. Miller
committed
[RTNETLINK]: Use rtnl_unicast() for rtnetlink unicasts
Signed-off-by: Thomas Graf <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f8d8fda commit 2942e90

File tree

8 files changed

+20
-24
lines changed

8 files changed

+20
-24
lines changed

include/linux/rtnetlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ struct rtnetlink_link
584584

585585
extern struct rtnetlink_link * rtnetlink_links[NPROTO];
586586
extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo);
587+
extern int rtnl_unicast(struct sk_buff *skb, u32 pid);
587588
extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
588589

589590
extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);

net/core/rtnetlink.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ int rtnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo)
166166
return err;
167167
}
168168

169+
int rtnl_unicast(struct sk_buff *skb, u32 pid)
170+
{
171+
return nlmsg_unicast(rtnl, skb, pid);
172+
}
173+
169174
int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics)
170175
{
171176
struct rtattr *mx = (struct rtattr*)skb->tail;
@@ -574,9 +579,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
574579
goto errout;
575580
}
576581

577-
err = netlink_unicast(rtnl, skb, NETLINK_CB(skb).pid, MSG_DONTWAIT);
578-
if (err > 0)
579-
err = 0;
582+
err = rtnl_unicast(skb, NETLINK_CB(skb).pid);
580583
errout:
581584
kfree(iw_buf);
582585
dev_put(dev);
@@ -825,3 +828,4 @@ EXPORT_SYMBOL(rtnl);
825828
EXPORT_SYMBOL(rtnl_lock);
826829
EXPORT_SYMBOL(rtnl_trylock);
827830
EXPORT_SYMBOL(rtnl_unlock);
831+
EXPORT_SYMBOL(rtnl_unicast);

net/decnet/dn_route.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,9 +1611,7 @@ int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void *arg)
16111611
goto out_free;
16121612
}
16131613

1614-
err = netlink_unicast(rtnl, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
1615-
1616-
return err;
1614+
return rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
16171615

16181616
out_free:
16191617
kfree_skb(skb);

net/ipv4/ipmr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ static void ipmr_destroy_unres(struct mfc_cache *c)
312312
e = NLMSG_DATA(nlh);
313313
e->error = -ETIMEDOUT;
314314
memset(&e->msg, 0, sizeof(e->msg));
315-
netlink_unicast(rtnl, skb, NETLINK_CB(skb).dst_pid, MSG_DONTWAIT);
315+
316+
rtnl_unicast(skb, NETLINK_CB(skb).pid);
316317
} else
317318
kfree_skb(skb);
318319
}
@@ -512,7 +513,6 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
512513

513514
while((skb=__skb_dequeue(&uc->mfc_un.unres.unresolved))) {
514515
if (skb->nh.iph->version == 0) {
515-
int err;
516516
struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
517517

518518
if (ipmr_fill_mroute(skb, c, NLMSG_DATA(nlh)) > 0) {
@@ -525,7 +525,8 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
525525
e->error = -EMSGSIZE;
526526
memset(&e->msg, 0, sizeof(e->msg));
527527
}
528-
err = netlink_unicast(rtnl, skb, NETLINK_CB(skb).dst_pid, MSG_DONTWAIT);
528+
529+
rtnl_unicast(skb, NETLINK_CB(skb).pid);
529530
} else
530531
ip_mr_forward(skb, c, 0);
531532
}

net/ipv4/route.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,10 +2809,9 @@ int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
28092809
goto out_free;
28102810
}
28112811

2812-
err = netlink_unicast(rtnl, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
2813-
if (err > 0)
2814-
err = 0;
2815-
out: return err;
2812+
err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
2813+
out:
2814+
return err;
28162815

28172816
out_free:
28182817
kfree_skb(skb);

net/ipv6/addrconf.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3268,9 +3268,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb,
32683268
goto out_free;
32693269
}
32703270

3271-
err = netlink_unicast(rtnl, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
3272-
if (err > 0)
3273-
err = 0;
3271+
err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
32743272
out:
32753273
in6_ifa_put(ifa);
32763274
return err;

net/ipv6/route.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,9 +2044,7 @@ int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
20442044
goto out_free;
20452045
}
20462046

2047-
err = netlink_unicast(rtnl, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
2048-
if (err > 0)
2049-
err = 0;
2047+
err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
20502048
out:
20512049
return err;
20522050
out_free:

net/sched/act_api.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ static int
459459
act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event)
460460
{
461461
struct sk_buff *skb;
462-
int err = 0;
463462

464463
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
465464
if (!skb)
@@ -468,10 +467,8 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event)
468467
kfree_skb(skb);
469468
return -EINVAL;
470469
}
471-
err = netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
472-
if (err > 0)
473-
err = 0;
474-
return err;
470+
471+
return rtnl_unicast(skb, pid);
475472
}
476473

477474
static struct tc_action *

0 commit comments

Comments
 (0)