diff options
author | Thomas Graf <tgraf@suug.ch> | 2007-08-22 16:54:36 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:48:20 -0400 |
commit | 082a1ad573b76c8342c1da9d623aaeb5901e440b (patch) | |
tree | 9fe3248549913d1c770efab0c4107ad2af36b8cf /net/xfrm/xfrm_user.c | |
parent | 7b67c8575f1ed0d5fd7524a33d34f5c88c52a194 (diff) |
[XFRM] netlink: Use nlmsg_broadcast() and nlmsg_unicast()
This simplifies successful return codes from >0 to 0.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r-- | net/xfrm/xfrm_user.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index c9bb7210eb69..249940eaced8 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -800,8 +800,7 @@ static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
800 | if (IS_ERR(resp_skb)) { | 800 | if (IS_ERR(resp_skb)) { |
801 | err = PTR_ERR(resp_skb); | 801 | err = PTR_ERR(resp_skb); |
802 | } else { | 802 | } else { |
803 | err = netlink_unicast(xfrm_nl, resp_skb, | 803 | err = nlmsg_unicast(xfrm_nl, resp_skb, NETLINK_CB(skb).pid); |
804 | NETLINK_CB(skb).pid, MSG_DONTWAIT); | ||
805 | } | 804 | } |
806 | xfrm_state_put(x); | 805 | xfrm_state_put(x); |
807 | out_noput: | 806 | out_noput: |
@@ -882,8 +881,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
882 | goto out; | 881 | goto out; |
883 | } | 882 | } |
884 | 883 | ||
885 | err = netlink_unicast(xfrm_nl, resp_skb, | 884 | err = nlmsg_unicast(xfrm_nl, resp_skb, NETLINK_CB(skb).pid); |
886 | NETLINK_CB(skb).pid, MSG_DONTWAIT); | ||
887 | 885 | ||
888 | out: | 886 | out: |
889 | xfrm_state_put(x); | 887 | xfrm_state_put(x); |
@@ -1393,9 +1391,8 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1393 | if (IS_ERR(resp_skb)) { | 1391 | if (IS_ERR(resp_skb)) { |
1394 | err = PTR_ERR(resp_skb); | 1392 | err = PTR_ERR(resp_skb); |
1395 | } else { | 1393 | } else { |
1396 | err = netlink_unicast(xfrm_nl, resp_skb, | 1394 | err = nlmsg_unicast(xfrm_nl, resp_skb, |
1397 | NETLINK_CB(skb).pid, | 1395 | NETLINK_CB(skb).pid); |
1398 | MSG_DONTWAIT); | ||
1399 | } | 1396 | } |
1400 | } else { | 1397 | } else { |
1401 | xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid, | 1398 | xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid, |
@@ -1525,8 +1522,7 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1525 | 1522 | ||
1526 | if (build_aevent(r_skb, x, &c) < 0) | 1523 | if (build_aevent(r_skb, x, &c) < 0) |
1527 | BUG(); | 1524 | BUG(); |
1528 | err = netlink_unicast(xfrm_nl, r_skb, | 1525 | err = nlmsg_unicast(xfrm_nl, r_skb, NETLINK_CB(skb).pid); |
1529 | NETLINK_CB(skb).pid, MSG_DONTWAIT); | ||
1530 | spin_unlock_bh(&x->lock); | 1526 | spin_unlock_bh(&x->lock); |
1531 | xfrm_state_put(x); | 1527 | xfrm_state_put(x); |
1532 | return err; | 1528 | return err; |
@@ -1903,9 +1899,7 @@ static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type, | |||
1903 | if (build_migrate(skb, m, num_migrate, sel, dir, type) < 0) | 1899 | if (build_migrate(skb, m, num_migrate, sel, dir, type) < 0) |
1904 | BUG(); | 1900 | BUG(); |
1905 | 1901 | ||
1906 | NETLINK_CB(skb).dst_group = XFRMNLGRP_MIGRATE; | 1902 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_MIGRATE, GFP_ATOMIC); |
1907 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_MIGRATE, | ||
1908 | GFP_ATOMIC); | ||
1909 | } | 1903 | } |
1910 | #else | 1904 | #else |
1911 | static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type, | 1905 | static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type, |
@@ -2061,8 +2055,7 @@ static int xfrm_exp_state_notify(struct xfrm_state *x, struct km_event *c) | |||
2061 | if (build_expire(skb, x, c) < 0) | 2055 | if (build_expire(skb, x, c) < 0) |
2062 | BUG(); | 2056 | BUG(); |
2063 | 2057 | ||
2064 | NETLINK_CB(skb).dst_group = XFRMNLGRP_EXPIRE; | 2058 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_EXPIRE, GFP_ATOMIC); |
2065 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_EXPIRE, GFP_ATOMIC); | ||
2066 | } | 2059 | } |
2067 | 2060 | ||
2068 | static int xfrm_aevent_state_notify(struct xfrm_state *x, struct km_event *c) | 2061 | static int xfrm_aevent_state_notify(struct xfrm_state *x, struct km_event *c) |
@@ -2079,8 +2072,7 @@ static int xfrm_aevent_state_notify(struct xfrm_state *x, struct km_event *c) | |||
2079 | if (build_aevent(skb, x, c) < 0) | 2072 | if (build_aevent(skb, x, c) < 0) |
2080 | BUG(); | 2073 | BUG(); |
2081 | 2074 | ||
2082 | NETLINK_CB(skb).dst_group = XFRMNLGRP_AEVENTS; | 2075 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_AEVENTS, GFP_ATOMIC); |
2083 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_AEVENTS, GFP_ATOMIC); | ||
2084 | } | 2076 | } |
2085 | 2077 | ||
2086 | static int xfrm_notify_sa_flush(struct km_event *c) | 2078 | static int xfrm_notify_sa_flush(struct km_event *c) |
@@ -2105,8 +2097,7 @@ static int xfrm_notify_sa_flush(struct km_event *c) | |||
2105 | 2097 | ||
2106 | nlmsg_end(skb, nlh); | 2098 | nlmsg_end(skb, nlh); |
2107 | 2099 | ||
2108 | NETLINK_CB(skb).dst_group = XFRMNLGRP_SA; | 2100 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC); |
2109 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC); | ||
2110 | } | 2101 | } |
2111 | 2102 | ||
2112 | static inline int xfrm_sa_len(struct xfrm_state *x) | 2103 | static inline int xfrm_sa_len(struct xfrm_state *x) |
@@ -2175,8 +2166,7 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c) | |||
2175 | 2166 | ||
2176 | nlmsg_end(skb, nlh); | 2167 | nlmsg_end(skb, nlh); |
2177 | 2168 | ||
2178 | NETLINK_CB(skb).dst_group = XFRMNLGRP_SA; | 2169 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC); |
2179 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC); | ||
2180 | 2170 | ||
2181 | nlmsg_failure: | 2171 | nlmsg_failure: |
2182 | rtattr_failure: | 2172 | rtattr_failure: |
@@ -2262,8 +2252,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, | |||
2262 | if (build_acquire(skb, x, xt, xp, dir) < 0) | 2252 | if (build_acquire(skb, x, xt, xp, dir) < 0) |
2263 | BUG(); | 2253 | BUG(); |
2264 | 2254 | ||
2265 | NETLINK_CB(skb).dst_group = XFRMNLGRP_ACQUIRE; | 2255 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_ACQUIRE, GFP_ATOMIC); |
2266 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_ACQUIRE, GFP_ATOMIC); | ||
2267 | } | 2256 | } |
2268 | 2257 | ||
2269 | /* User gives us xfrm_user_policy_info followed by an array of 0 | 2258 | /* User gives us xfrm_user_policy_info followed by an array of 0 |
@@ -2371,8 +2360,7 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, struct km_eve | |||
2371 | if (build_polexpire(skb, xp, dir, c) < 0) | 2360 | if (build_polexpire(skb, xp, dir, c) < 0) |
2372 | BUG(); | 2361 | BUG(); |
2373 | 2362 | ||
2374 | NETLINK_CB(skb).dst_group = XFRMNLGRP_EXPIRE; | 2363 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_EXPIRE, GFP_ATOMIC); |
2375 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_EXPIRE, GFP_ATOMIC); | ||
2376 | } | 2364 | } |
2377 | 2365 | ||
2378 | static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c) | 2366 | static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c) |
@@ -2423,8 +2411,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event * | |||
2423 | 2411 | ||
2424 | nlmsg_end(skb, nlh); | 2412 | nlmsg_end(skb, nlh); |
2425 | 2413 | ||
2426 | NETLINK_CB(skb).dst_group = XFRMNLGRP_POLICY; | 2414 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_POLICY, GFP_ATOMIC); |
2427 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_POLICY, GFP_ATOMIC); | ||
2428 | 2415 | ||
2429 | nlmsg_failure: | 2416 | nlmsg_failure: |
2430 | rtattr_failure: | 2417 | rtattr_failure: |
@@ -2454,8 +2441,7 @@ static int xfrm_notify_policy_flush(struct km_event *c) | |||
2454 | 2441 | ||
2455 | nlmsg_end(skb, nlh); | 2442 | nlmsg_end(skb, nlh); |
2456 | 2443 | ||
2457 | NETLINK_CB(skb).dst_group = XFRMNLGRP_POLICY; | 2444 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_POLICY, GFP_ATOMIC); |
2458 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_POLICY, GFP_ATOMIC); | ||
2459 | 2445 | ||
2460 | nlmsg_failure: | 2446 | nlmsg_failure: |
2461 | kfree_skb(skb); | 2447 | kfree_skb(skb); |
@@ -2520,8 +2506,7 @@ static int xfrm_send_report(u8 proto, struct xfrm_selector *sel, | |||
2520 | if (build_report(skb, proto, sel, addr) < 0) | 2506 | if (build_report(skb, proto, sel, addr) < 0) |
2521 | BUG(); | 2507 | BUG(); |
2522 | 2508 | ||
2523 | NETLINK_CB(skb).dst_group = XFRMNLGRP_REPORT; | 2509 | return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_REPORT, GFP_ATOMIC); |
2524 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_REPORT, GFP_ATOMIC); | ||
2525 | } | 2510 | } |
2526 | 2511 | ||
2527 | static struct xfrm_mgr netlink_mgr = { | 2512 | static struct xfrm_mgr netlink_mgr = { |