diff options
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_policy.c | 83 | ||||
-rw-r--r-- | net/xfrm/xfrm_state.c | 12 | ||||
-rw-r--r-- | net/xfrm/xfrm_user.c | 77 |
3 files changed, 88 insertions, 84 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 387848e90078..f4e0a6a148a5 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -42,13 +42,12 @@ static DEFINE_SPINLOCK(xfrm_policy_sk_bundle_lock); | |||
42 | static struct dst_entry *xfrm_policy_sk_bundles; | 42 | static struct dst_entry *xfrm_policy_sk_bundles; |
43 | static DEFINE_RWLOCK(xfrm_policy_lock); | 43 | static DEFINE_RWLOCK(xfrm_policy_lock); |
44 | 44 | ||
45 | static DEFINE_RWLOCK(xfrm_policy_afinfo_lock); | 45 | static DEFINE_SPINLOCK(xfrm_policy_afinfo_lock); |
46 | static struct xfrm_policy_afinfo *xfrm_policy_afinfo[NPROTO]; | 46 | static struct xfrm_policy_afinfo __rcu *xfrm_policy_afinfo[NPROTO] |
47 | __read_mostly; | ||
47 | 48 | ||
48 | static struct kmem_cache *xfrm_dst_cache __read_mostly; | 49 | static struct kmem_cache *xfrm_dst_cache __read_mostly; |
49 | 50 | ||
50 | static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family); | ||
51 | static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo); | ||
52 | static void xfrm_init_pmtu(struct dst_entry *dst); | 51 | static void xfrm_init_pmtu(struct dst_entry *dst); |
53 | static int stale_bundle(struct dst_entry *dst); | 52 | static int stale_bundle(struct dst_entry *dst); |
54 | static int xfrm_bundle_ok(struct xfrm_dst *xdst); | 53 | static int xfrm_bundle_ok(struct xfrm_dst *xdst); |
@@ -95,6 +94,24 @@ bool xfrm_selector_match(const struct xfrm_selector *sel, const struct flowi *fl | |||
95 | return false; | 94 | return false; |
96 | } | 95 | } |
97 | 96 | ||
97 | static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family) | ||
98 | { | ||
99 | struct xfrm_policy_afinfo *afinfo; | ||
100 | |||
101 | if (unlikely(family >= NPROTO)) | ||
102 | return NULL; | ||
103 | rcu_read_lock(); | ||
104 | afinfo = rcu_dereference(xfrm_policy_afinfo[family]); | ||
105 | if (unlikely(!afinfo)) | ||
106 | rcu_read_unlock(); | ||
107 | return afinfo; | ||
108 | } | ||
109 | |||
110 | static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo) | ||
111 | { | ||
112 | rcu_read_unlock(); | ||
113 | } | ||
114 | |||
98 | static inline struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, | 115 | static inline struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, |
99 | const xfrm_address_t *saddr, | 116 | const xfrm_address_t *saddr, |
100 | const xfrm_address_t *daddr, | 117 | const xfrm_address_t *daddr, |
@@ -2421,7 +2438,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) | |||
2421 | return -EINVAL; | 2438 | return -EINVAL; |
2422 | if (unlikely(afinfo->family >= NPROTO)) | 2439 | if (unlikely(afinfo->family >= NPROTO)) |
2423 | return -EAFNOSUPPORT; | 2440 | return -EAFNOSUPPORT; |
2424 | write_lock_bh(&xfrm_policy_afinfo_lock); | 2441 | spin_lock(&xfrm_policy_afinfo_lock); |
2425 | if (unlikely(xfrm_policy_afinfo[afinfo->family] != NULL)) | 2442 | if (unlikely(xfrm_policy_afinfo[afinfo->family] != NULL)) |
2426 | err = -ENOBUFS; | 2443 | err = -ENOBUFS; |
2427 | else { | 2444 | else { |
@@ -2442,9 +2459,9 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) | |||
2442 | dst_ops->neigh_lookup = xfrm_neigh_lookup; | 2459 | dst_ops->neigh_lookup = xfrm_neigh_lookup; |
2443 | if (likely(afinfo->garbage_collect == NULL)) | 2460 | if (likely(afinfo->garbage_collect == NULL)) |
2444 | afinfo->garbage_collect = xfrm_garbage_collect_deferred; | 2461 | afinfo->garbage_collect = xfrm_garbage_collect_deferred; |
2445 | xfrm_policy_afinfo[afinfo->family] = afinfo; | 2462 | rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo); |
2446 | } | 2463 | } |
2447 | write_unlock_bh(&xfrm_policy_afinfo_lock); | 2464 | spin_unlock(&xfrm_policy_afinfo_lock); |
2448 | 2465 | ||
2449 | rtnl_lock(); | 2466 | rtnl_lock(); |
2450 | for_each_net(net) { | 2467 | for_each_net(net) { |
@@ -2477,21 +2494,26 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo) | |||
2477 | return -EINVAL; | 2494 | return -EINVAL; |
2478 | if (unlikely(afinfo->family >= NPROTO)) | 2495 | if (unlikely(afinfo->family >= NPROTO)) |
2479 | return -EAFNOSUPPORT; | 2496 | return -EAFNOSUPPORT; |
2480 | write_lock_bh(&xfrm_policy_afinfo_lock); | 2497 | spin_lock(&xfrm_policy_afinfo_lock); |
2481 | if (likely(xfrm_policy_afinfo[afinfo->family] != NULL)) { | 2498 | if (likely(xfrm_policy_afinfo[afinfo->family] != NULL)) { |
2482 | if (unlikely(xfrm_policy_afinfo[afinfo->family] != afinfo)) | 2499 | if (unlikely(xfrm_policy_afinfo[afinfo->family] != afinfo)) |
2483 | err = -EINVAL; | 2500 | err = -EINVAL; |
2484 | else { | 2501 | else |
2485 | struct dst_ops *dst_ops = afinfo->dst_ops; | 2502 | RCU_INIT_POINTER(xfrm_policy_afinfo[afinfo->family], |
2486 | xfrm_policy_afinfo[afinfo->family] = NULL; | 2503 | NULL); |
2487 | dst_ops->kmem_cachep = NULL; | 2504 | } |
2488 | dst_ops->check = NULL; | 2505 | spin_unlock(&xfrm_policy_afinfo_lock); |
2489 | dst_ops->negative_advice = NULL; | 2506 | if (!err) { |
2490 | dst_ops->link_failure = NULL; | 2507 | struct dst_ops *dst_ops = afinfo->dst_ops; |
2491 | afinfo->garbage_collect = NULL; | 2508 | |
2492 | } | 2509 | synchronize_rcu(); |
2510 | |||
2511 | dst_ops->kmem_cachep = NULL; | ||
2512 | dst_ops->check = NULL; | ||
2513 | dst_ops->negative_advice = NULL; | ||
2514 | dst_ops->link_failure = NULL; | ||
2515 | afinfo->garbage_collect = NULL; | ||
2493 | } | 2516 | } |
2494 | write_unlock_bh(&xfrm_policy_afinfo_lock); | ||
2495 | return err; | 2517 | return err; |
2496 | } | 2518 | } |
2497 | EXPORT_SYMBOL(xfrm_policy_unregister_afinfo); | 2519 | EXPORT_SYMBOL(xfrm_policy_unregister_afinfo); |
@@ -2500,33 +2522,16 @@ static void __net_init xfrm_dst_ops_init(struct net *net) | |||
2500 | { | 2522 | { |
2501 | struct xfrm_policy_afinfo *afinfo; | 2523 | struct xfrm_policy_afinfo *afinfo; |
2502 | 2524 | ||
2503 | read_lock_bh(&xfrm_policy_afinfo_lock); | 2525 | rcu_read_lock(); |
2504 | afinfo = xfrm_policy_afinfo[AF_INET]; | 2526 | afinfo = rcu_dereference(xfrm_policy_afinfo[AF_INET]); |
2505 | if (afinfo) | 2527 | if (afinfo) |
2506 | net->xfrm.xfrm4_dst_ops = *afinfo->dst_ops; | 2528 | net->xfrm.xfrm4_dst_ops = *afinfo->dst_ops; |
2507 | #if IS_ENABLED(CONFIG_IPV6) | 2529 | #if IS_ENABLED(CONFIG_IPV6) |
2508 | afinfo = xfrm_policy_afinfo[AF_INET6]; | 2530 | afinfo = rcu_dereference(xfrm_policy_afinfo[AF_INET6]); |
2509 | if (afinfo) | 2531 | if (afinfo) |
2510 | net->xfrm.xfrm6_dst_ops = *afinfo->dst_ops; | 2532 | net->xfrm.xfrm6_dst_ops = *afinfo->dst_ops; |
2511 | #endif | 2533 | #endif |
2512 | read_unlock_bh(&xfrm_policy_afinfo_lock); | 2534 | rcu_read_unlock(); |
2513 | } | ||
2514 | |||
2515 | static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family) | ||
2516 | { | ||
2517 | struct xfrm_policy_afinfo *afinfo; | ||
2518 | if (unlikely(family >= NPROTO)) | ||
2519 | return NULL; | ||
2520 | read_lock(&xfrm_policy_afinfo_lock); | ||
2521 | afinfo = xfrm_policy_afinfo[family]; | ||
2522 | if (unlikely(!afinfo)) | ||
2523 | read_unlock(&xfrm_policy_afinfo_lock); | ||
2524 | return afinfo; | ||
2525 | } | ||
2526 | |||
2527 | static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo) | ||
2528 | { | ||
2529 | read_unlock(&xfrm_policy_afinfo_lock); | ||
2530 | } | 2535 | } |
2531 | 2536 | ||
2532 | static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr) | 2537 | static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr) |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 210be48d8ae3..105f2062ed1a 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -166,7 +166,7 @@ static DEFINE_SPINLOCK(xfrm_state_gc_lock); | |||
166 | int __xfrm_state_delete(struct xfrm_state *x); | 166 | int __xfrm_state_delete(struct xfrm_state *x); |
167 | 167 | ||
168 | int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); | 168 | int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); |
169 | void km_state_expired(struct xfrm_state *x, int hard, u32 pid); | 169 | void km_state_expired(struct xfrm_state *x, int hard, u32 portid); |
170 | 170 | ||
171 | static struct xfrm_state_afinfo *xfrm_state_lock_afinfo(unsigned int family) | 171 | static struct xfrm_state_afinfo *xfrm_state_lock_afinfo(unsigned int family) |
172 | { | 172 | { |
@@ -1674,13 +1674,13 @@ void km_state_notify(struct xfrm_state *x, const struct km_event *c) | |||
1674 | EXPORT_SYMBOL(km_policy_notify); | 1674 | EXPORT_SYMBOL(km_policy_notify); |
1675 | EXPORT_SYMBOL(km_state_notify); | 1675 | EXPORT_SYMBOL(km_state_notify); |
1676 | 1676 | ||
1677 | void km_state_expired(struct xfrm_state *x, int hard, u32 pid) | 1677 | void km_state_expired(struct xfrm_state *x, int hard, u32 portid) |
1678 | { | 1678 | { |
1679 | struct net *net = xs_net(x); | 1679 | struct net *net = xs_net(x); |
1680 | struct km_event c; | 1680 | struct km_event c; |
1681 | 1681 | ||
1682 | c.data.hard = hard; | 1682 | c.data.hard = hard; |
1683 | c.pid = pid; | 1683 | c.portid = portid; |
1684 | c.event = XFRM_MSG_EXPIRE; | 1684 | c.event = XFRM_MSG_EXPIRE; |
1685 | km_state_notify(x, &c); | 1685 | km_state_notify(x, &c); |
1686 | 1686 | ||
@@ -1700,7 +1700,7 @@ int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol) | |||
1700 | 1700 | ||
1701 | read_lock(&xfrm_km_lock); | 1701 | read_lock(&xfrm_km_lock); |
1702 | list_for_each_entry(km, &xfrm_km_list, list) { | 1702 | list_for_each_entry(km, &xfrm_km_list, list) { |
1703 | acqret = km->acquire(x, t, pol, XFRM_POLICY_OUT); | 1703 | acqret = km->acquire(x, t, pol); |
1704 | if (!acqret) | 1704 | if (!acqret) |
1705 | err = acqret; | 1705 | err = acqret; |
1706 | } | 1706 | } |
@@ -1726,13 +1726,13 @@ int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport) | |||
1726 | } | 1726 | } |
1727 | EXPORT_SYMBOL(km_new_mapping); | 1727 | EXPORT_SYMBOL(km_new_mapping); |
1728 | 1728 | ||
1729 | void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 pid) | 1729 | void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 portid) |
1730 | { | 1730 | { |
1731 | struct net *net = xp_net(pol); | 1731 | struct net *net = xp_net(pol); |
1732 | struct km_event c; | 1732 | struct km_event c; |
1733 | 1733 | ||
1734 | c.data.hard = hard; | 1734 | c.data.hard = hard; |
1735 | c.pid = pid; | 1735 | c.portid = portid; |
1736 | c.event = XFRM_MSG_POLEXPIRE; | 1736 | c.event = XFRM_MSG_POLEXPIRE; |
1737 | km_policy_notify(pol, dir, &c); | 1737 | km_policy_notify(pol, dir, &c); |
1738 | 1738 | ||
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 289f4bf18ff0..94a2a1f726f9 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -623,7 +623,7 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
623 | } | 623 | } |
624 | 624 | ||
625 | c.seq = nlh->nlmsg_seq; | 625 | c.seq = nlh->nlmsg_seq; |
626 | c.pid = nlh->nlmsg_pid; | 626 | c.portid = nlh->nlmsg_pid; |
627 | c.event = nlh->nlmsg_type; | 627 | c.event = nlh->nlmsg_type; |
628 | 628 | ||
629 | km_state_notify(x, &c); | 629 | km_state_notify(x, &c); |
@@ -696,7 +696,7 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
696 | goto out; | 696 | goto out; |
697 | 697 | ||
698 | c.seq = nlh->nlmsg_seq; | 698 | c.seq = nlh->nlmsg_seq; |
699 | c.pid = nlh->nlmsg_pid; | 699 | c.portid = nlh->nlmsg_pid; |
700 | c.event = nlh->nlmsg_type; | 700 | c.event = nlh->nlmsg_type; |
701 | km_state_notify(x, &c); | 701 | km_state_notify(x, &c); |
702 | 702 | ||
@@ -847,7 +847,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr) | |||
847 | struct nlmsghdr *nlh; | 847 | struct nlmsghdr *nlh; |
848 | int err; | 848 | int err; |
849 | 849 | ||
850 | nlh = nlmsg_put(skb, NETLINK_CB(in_skb).pid, sp->nlmsg_seq, | 850 | nlh = nlmsg_put(skb, NETLINK_CB(in_skb).portid, sp->nlmsg_seq, |
851 | XFRM_MSG_NEWSA, sizeof(*p), sp->nlmsg_flags); | 851 | XFRM_MSG_NEWSA, sizeof(*p), sp->nlmsg_flags); |
852 | if (nlh == NULL) | 852 | if (nlh == NULL) |
853 | return -EMSGSIZE; | 853 | return -EMSGSIZE; |
@@ -927,7 +927,7 @@ static inline size_t xfrm_spdinfo_msgsize(void) | |||
927 | } | 927 | } |
928 | 928 | ||
929 | static int build_spdinfo(struct sk_buff *skb, struct net *net, | 929 | static int build_spdinfo(struct sk_buff *skb, struct net *net, |
930 | u32 pid, u32 seq, u32 flags) | 930 | u32 portid, u32 seq, u32 flags) |
931 | { | 931 | { |
932 | struct xfrmk_spdinfo si; | 932 | struct xfrmk_spdinfo si; |
933 | struct xfrmu_spdinfo spc; | 933 | struct xfrmu_spdinfo spc; |
@@ -936,7 +936,7 @@ static int build_spdinfo(struct sk_buff *skb, struct net *net, | |||
936 | int err; | 936 | int err; |
937 | u32 *f; | 937 | u32 *f; |
938 | 938 | ||
939 | nlh = nlmsg_put(skb, pid, seq, XFRM_MSG_NEWSPDINFO, sizeof(u32), 0); | 939 | nlh = nlmsg_put(skb, portid, seq, XFRM_MSG_NEWSPDINFO, sizeof(u32), 0); |
940 | if (nlh == NULL) /* shouldn't really happen ... */ | 940 | if (nlh == NULL) /* shouldn't really happen ... */ |
941 | return -EMSGSIZE; | 941 | return -EMSGSIZE; |
942 | 942 | ||
@@ -969,17 +969,17 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
969 | struct net *net = sock_net(skb->sk); | 969 | struct net *net = sock_net(skb->sk); |
970 | struct sk_buff *r_skb; | 970 | struct sk_buff *r_skb; |
971 | u32 *flags = nlmsg_data(nlh); | 971 | u32 *flags = nlmsg_data(nlh); |
972 | u32 spid = NETLINK_CB(skb).pid; | 972 | u32 sportid = NETLINK_CB(skb).portid; |
973 | u32 seq = nlh->nlmsg_seq; | 973 | u32 seq = nlh->nlmsg_seq; |
974 | 974 | ||
975 | r_skb = nlmsg_new(xfrm_spdinfo_msgsize(), GFP_ATOMIC); | 975 | r_skb = nlmsg_new(xfrm_spdinfo_msgsize(), GFP_ATOMIC); |
976 | if (r_skb == NULL) | 976 | if (r_skb == NULL) |
977 | return -ENOMEM; | 977 | return -ENOMEM; |
978 | 978 | ||
979 | if (build_spdinfo(r_skb, net, spid, seq, *flags) < 0) | 979 | if (build_spdinfo(r_skb, net, sportid, seq, *flags) < 0) |
980 | BUG(); | 980 | BUG(); |
981 | 981 | ||
982 | return nlmsg_unicast(net->xfrm.nlsk, r_skb, spid); | 982 | return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid); |
983 | } | 983 | } |
984 | 984 | ||
985 | static inline size_t xfrm_sadinfo_msgsize(void) | 985 | static inline size_t xfrm_sadinfo_msgsize(void) |
@@ -990,7 +990,7 @@ static inline size_t xfrm_sadinfo_msgsize(void) | |||
990 | } | 990 | } |
991 | 991 | ||
992 | static int build_sadinfo(struct sk_buff *skb, struct net *net, | 992 | static int build_sadinfo(struct sk_buff *skb, struct net *net, |
993 | u32 pid, u32 seq, u32 flags) | 993 | u32 portid, u32 seq, u32 flags) |
994 | { | 994 | { |
995 | struct xfrmk_sadinfo si; | 995 | struct xfrmk_sadinfo si; |
996 | struct xfrmu_sadhinfo sh; | 996 | struct xfrmu_sadhinfo sh; |
@@ -998,7 +998,7 @@ static int build_sadinfo(struct sk_buff *skb, struct net *net, | |||
998 | int err; | 998 | int err; |
999 | u32 *f; | 999 | u32 *f; |
1000 | 1000 | ||
1001 | nlh = nlmsg_put(skb, pid, seq, XFRM_MSG_NEWSADINFO, sizeof(u32), 0); | 1001 | nlh = nlmsg_put(skb, portid, seq, XFRM_MSG_NEWSADINFO, sizeof(u32), 0); |
1002 | if (nlh == NULL) /* shouldn't really happen ... */ | 1002 | if (nlh == NULL) /* shouldn't really happen ... */ |
1003 | return -EMSGSIZE; | 1003 | return -EMSGSIZE; |
1004 | 1004 | ||
@@ -1026,17 +1026,17 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1026 | struct net *net = sock_net(skb->sk); | 1026 | struct net *net = sock_net(skb->sk); |
1027 | struct sk_buff *r_skb; | 1027 | struct sk_buff *r_skb; |
1028 | u32 *flags = nlmsg_data(nlh); | 1028 | u32 *flags = nlmsg_data(nlh); |
1029 | u32 spid = NETLINK_CB(skb).pid; | 1029 | u32 sportid = NETLINK_CB(skb).portid; |
1030 | u32 seq = nlh->nlmsg_seq; | 1030 | u32 seq = nlh->nlmsg_seq; |
1031 | 1031 | ||
1032 | r_skb = nlmsg_new(xfrm_sadinfo_msgsize(), GFP_ATOMIC); | 1032 | r_skb = nlmsg_new(xfrm_sadinfo_msgsize(), GFP_ATOMIC); |
1033 | if (r_skb == NULL) | 1033 | if (r_skb == NULL) |
1034 | return -ENOMEM; | 1034 | return -ENOMEM; |
1035 | 1035 | ||
1036 | if (build_sadinfo(r_skb, net, spid, seq, *flags) < 0) | 1036 | if (build_sadinfo(r_skb, net, sportid, seq, *flags) < 0) |
1037 | BUG(); | 1037 | BUG(); |
1038 | 1038 | ||
1039 | return nlmsg_unicast(net->xfrm.nlsk, r_skb, spid); | 1039 | return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid); |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh, | 1042 | static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh, |
@@ -1056,7 +1056,7 @@ static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1056 | if (IS_ERR(resp_skb)) { | 1056 | if (IS_ERR(resp_skb)) { |
1057 | err = PTR_ERR(resp_skb); | 1057 | err = PTR_ERR(resp_skb); |
1058 | } else { | 1058 | } else { |
1059 | err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).pid); | 1059 | err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid); |
1060 | } | 1060 | } |
1061 | xfrm_state_put(x); | 1061 | xfrm_state_put(x); |
1062 | out_noput: | 1062 | out_noput: |
@@ -1137,7 +1137,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1137 | goto out; | 1137 | goto out; |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).pid); | 1140 | err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid); |
1141 | 1141 | ||
1142 | out: | 1142 | out: |
1143 | xfrm_state_put(x); | 1143 | xfrm_state_put(x); |
@@ -1425,7 +1425,7 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1425 | 1425 | ||
1426 | c.event = nlh->nlmsg_type; | 1426 | c.event = nlh->nlmsg_type; |
1427 | c.seq = nlh->nlmsg_seq; | 1427 | c.seq = nlh->nlmsg_seq; |
1428 | c.pid = nlh->nlmsg_pid; | 1428 | c.portid = nlh->nlmsg_pid; |
1429 | km_policy_notify(xp, p->dir, &c); | 1429 | km_policy_notify(xp, p->dir, &c); |
1430 | 1430 | ||
1431 | xfrm_pol_put(xp); | 1431 | xfrm_pol_put(xp); |
@@ -1511,7 +1511,7 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr | |||
1511 | struct nlmsghdr *nlh; | 1511 | struct nlmsghdr *nlh; |
1512 | int err; | 1512 | int err; |
1513 | 1513 | ||
1514 | nlh = nlmsg_put(skb, NETLINK_CB(in_skb).pid, sp->nlmsg_seq, | 1514 | nlh = nlmsg_put(skb, NETLINK_CB(in_skb).portid, sp->nlmsg_seq, |
1515 | XFRM_MSG_NEWPOLICY, sizeof(*p), sp->nlmsg_flags); | 1515 | XFRM_MSG_NEWPOLICY, sizeof(*p), sp->nlmsg_flags); |
1516 | if (nlh == NULL) | 1516 | if (nlh == NULL) |
1517 | return -EMSGSIZE; | 1517 | return -EMSGSIZE; |
@@ -1648,7 +1648,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1648 | err = PTR_ERR(resp_skb); | 1648 | err = PTR_ERR(resp_skb); |
1649 | } else { | 1649 | } else { |
1650 | err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, | 1650 | err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, |
1651 | NETLINK_CB(skb).pid); | 1651 | NETLINK_CB(skb).portid); |
1652 | } | 1652 | } |
1653 | } else { | 1653 | } else { |
1654 | uid_t loginuid = audit_get_loginuid(current); | 1654 | uid_t loginuid = audit_get_loginuid(current); |
@@ -1665,7 +1665,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1665 | c.data.byid = p->index; | 1665 | c.data.byid = p->index; |
1666 | c.event = nlh->nlmsg_type; | 1666 | c.event = nlh->nlmsg_type; |
1667 | c.seq = nlh->nlmsg_seq; | 1667 | c.seq = nlh->nlmsg_seq; |
1668 | c.pid = nlh->nlmsg_pid; | 1668 | c.portid = nlh->nlmsg_pid; |
1669 | km_policy_notify(xp, p->dir, &c); | 1669 | km_policy_notify(xp, p->dir, &c); |
1670 | } | 1670 | } |
1671 | 1671 | ||
@@ -1695,7 +1695,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1695 | c.data.proto = p->proto; | 1695 | c.data.proto = p->proto; |
1696 | c.event = nlh->nlmsg_type; | 1696 | c.event = nlh->nlmsg_type; |
1697 | c.seq = nlh->nlmsg_seq; | 1697 | c.seq = nlh->nlmsg_seq; |
1698 | c.pid = nlh->nlmsg_pid; | 1698 | c.portid = nlh->nlmsg_pid; |
1699 | c.net = net; | 1699 | c.net = net; |
1700 | km_state_notify(NULL, &c); | 1700 | km_state_notify(NULL, &c); |
1701 | 1701 | ||
@@ -1722,7 +1722,7 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, const struct | |||
1722 | struct nlmsghdr *nlh; | 1722 | struct nlmsghdr *nlh; |
1723 | int err; | 1723 | int err; |
1724 | 1724 | ||
1725 | nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id), 0); | 1725 | nlh = nlmsg_put(skb, c->portid, c->seq, XFRM_MSG_NEWAE, sizeof(*id), 0); |
1726 | if (nlh == NULL) | 1726 | if (nlh == NULL) |
1727 | return -EMSGSIZE; | 1727 | return -EMSGSIZE; |
1728 | 1728 | ||
@@ -1804,11 +1804,11 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1804 | spin_lock_bh(&x->lock); | 1804 | spin_lock_bh(&x->lock); |
1805 | c.data.aevent = p->flags; | 1805 | c.data.aevent = p->flags; |
1806 | c.seq = nlh->nlmsg_seq; | 1806 | c.seq = nlh->nlmsg_seq; |
1807 | c.pid = nlh->nlmsg_pid; | 1807 | c.portid = nlh->nlmsg_pid; |
1808 | 1808 | ||
1809 | if (build_aevent(r_skb, x, &c) < 0) | 1809 | if (build_aevent(r_skb, x, &c) < 0) |
1810 | BUG(); | 1810 | BUG(); |
1811 | err = nlmsg_unicast(net->xfrm.nlsk, r_skb, NETLINK_CB(skb).pid); | 1811 | err = nlmsg_unicast(net->xfrm.nlsk, r_skb, NETLINK_CB(skb).portid); |
1812 | spin_unlock_bh(&x->lock); | 1812 | spin_unlock_bh(&x->lock); |
1813 | xfrm_state_put(x); | 1813 | xfrm_state_put(x); |
1814 | return err; | 1814 | return err; |
@@ -1854,7 +1854,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1854 | 1854 | ||
1855 | c.event = nlh->nlmsg_type; | 1855 | c.event = nlh->nlmsg_type; |
1856 | c.seq = nlh->nlmsg_seq; | 1856 | c.seq = nlh->nlmsg_seq; |
1857 | c.pid = nlh->nlmsg_pid; | 1857 | c.portid = nlh->nlmsg_pid; |
1858 | c.data.aevent = XFRM_AE_CU; | 1858 | c.data.aevent = XFRM_AE_CU; |
1859 | km_state_notify(x, &c); | 1859 | km_state_notify(x, &c); |
1860 | err = 0; | 1860 | err = 0; |
@@ -1889,7 +1889,7 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1889 | c.data.type = type; | 1889 | c.data.type = type; |
1890 | c.event = nlh->nlmsg_type; | 1890 | c.event = nlh->nlmsg_type; |
1891 | c.seq = nlh->nlmsg_seq; | 1891 | c.seq = nlh->nlmsg_seq; |
1892 | c.pid = nlh->nlmsg_pid; | 1892 | c.portid = nlh->nlmsg_pid; |
1893 | c.net = net; | 1893 | c.net = net; |
1894 | km_policy_notify(NULL, 0, &c); | 1894 | km_policy_notify(NULL, 0, &c); |
1895 | return 0; | 1895 | return 0; |
@@ -1957,7 +1957,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1957 | // reset the timers here? | 1957 | // reset the timers here? |
1958 | WARN(1, "Dont know what to do with soft policy expire\n"); | 1958 | WARN(1, "Dont know what to do with soft policy expire\n"); |
1959 | } | 1959 | } |
1960 | km_policy_expired(xp, p->dir, up->hard, current->pid); | 1960 | km_policy_expired(xp, p->dir, up->hard, nlh->nlmsg_pid); |
1961 | 1961 | ||
1962 | out: | 1962 | out: |
1963 | xfrm_pol_put(xp); | 1963 | xfrm_pol_put(xp); |
@@ -1985,7 +1985,7 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1985 | err = -EINVAL; | 1985 | err = -EINVAL; |
1986 | if (x->km.state != XFRM_STATE_VALID) | 1986 | if (x->km.state != XFRM_STATE_VALID) |
1987 | goto out; | 1987 | goto out; |
1988 | km_state_expired(x, ue->hard, current->pid); | 1988 | km_state_expired(x, ue->hard, nlh->nlmsg_pid); |
1989 | 1989 | ||
1990 | if (ue->hard) { | 1990 | if (ue->hard) { |
1991 | uid_t loginuid = audit_get_loginuid(current); | 1991 | uid_t loginuid = audit_get_loginuid(current); |
@@ -2397,7 +2397,7 @@ static int build_expire(struct sk_buff *skb, struct xfrm_state *x, const struct | |||
2397 | struct nlmsghdr *nlh; | 2397 | struct nlmsghdr *nlh; |
2398 | int err; | 2398 | int err; |
2399 | 2399 | ||
2400 | nlh = nlmsg_put(skb, c->pid, 0, XFRM_MSG_EXPIRE, sizeof(*ue), 0); | 2400 | nlh = nlmsg_put(skb, c->portid, 0, XFRM_MSG_EXPIRE, sizeof(*ue), 0); |
2401 | if (nlh == NULL) | 2401 | if (nlh == NULL) |
2402 | return -EMSGSIZE; | 2402 | return -EMSGSIZE; |
2403 | 2403 | ||
@@ -2456,7 +2456,7 @@ static int xfrm_notify_sa_flush(const struct km_event *c) | |||
2456 | if (skb == NULL) | 2456 | if (skb == NULL) |
2457 | return -ENOMEM; | 2457 | return -ENOMEM; |
2458 | 2458 | ||
2459 | nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_FLUSHSA, sizeof(*p), 0); | 2459 | nlh = nlmsg_put(skb, c->portid, c->seq, XFRM_MSG_FLUSHSA, sizeof(*p), 0); |
2460 | if (nlh == NULL) { | 2460 | if (nlh == NULL) { |
2461 | kfree_skb(skb); | 2461 | kfree_skb(skb); |
2462 | return -EMSGSIZE; | 2462 | return -EMSGSIZE; |
@@ -2524,7 +2524,7 @@ static int xfrm_notify_sa(struct xfrm_state *x, const struct km_event *c) | |||
2524 | if (skb == NULL) | 2524 | if (skb == NULL) |
2525 | return -ENOMEM; | 2525 | return -ENOMEM; |
2526 | 2526 | ||
2527 | nlh = nlmsg_put(skb, c->pid, c->seq, c->event, headlen, 0); | 2527 | nlh = nlmsg_put(skb, c->portid, c->seq, c->event, headlen, 0); |
2528 | err = -EMSGSIZE; | 2528 | err = -EMSGSIZE; |
2529 | if (nlh == NULL) | 2529 | if (nlh == NULL) |
2530 | goto out_free_skb; | 2530 | goto out_free_skb; |
@@ -2594,8 +2594,7 @@ static inline size_t xfrm_acquire_msgsize(struct xfrm_state *x, | |||
2594 | } | 2594 | } |
2595 | 2595 | ||
2596 | static int build_acquire(struct sk_buff *skb, struct xfrm_state *x, | 2596 | static int build_acquire(struct sk_buff *skb, struct xfrm_state *x, |
2597 | struct xfrm_tmpl *xt, struct xfrm_policy *xp, | 2597 | struct xfrm_tmpl *xt, struct xfrm_policy *xp) |
2598 | int dir) | ||
2599 | { | 2598 | { |
2600 | __u32 seq = xfrm_get_acqseq(); | 2599 | __u32 seq = xfrm_get_acqseq(); |
2601 | struct xfrm_user_acquire *ua; | 2600 | struct xfrm_user_acquire *ua; |
@@ -2610,7 +2609,7 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x, | |||
2610 | memcpy(&ua->id, &x->id, sizeof(ua->id)); | 2609 | memcpy(&ua->id, &x->id, sizeof(ua->id)); |
2611 | memcpy(&ua->saddr, &x->props.saddr, sizeof(ua->saddr)); | 2610 | memcpy(&ua->saddr, &x->props.saddr, sizeof(ua->saddr)); |
2612 | memcpy(&ua->sel, &x->sel, sizeof(ua->sel)); | 2611 | memcpy(&ua->sel, &x->sel, sizeof(ua->sel)); |
2613 | copy_to_user_policy(xp, &ua->policy, dir); | 2612 | copy_to_user_policy(xp, &ua->policy, XFRM_POLICY_OUT); |
2614 | ua->aalgos = xt->aalgos; | 2613 | ua->aalgos = xt->aalgos; |
2615 | ua->ealgos = xt->ealgos; | 2614 | ua->ealgos = xt->ealgos; |
2616 | ua->calgos = xt->calgos; | 2615 | ua->calgos = xt->calgos; |
@@ -2632,7 +2631,7 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x, | |||
2632 | } | 2631 | } |
2633 | 2632 | ||
2634 | static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, | 2633 | static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, |
2635 | struct xfrm_policy *xp, int dir) | 2634 | struct xfrm_policy *xp) |
2636 | { | 2635 | { |
2637 | struct net *net = xs_net(x); | 2636 | struct net *net = xs_net(x); |
2638 | struct sk_buff *skb; | 2637 | struct sk_buff *skb; |
@@ -2641,7 +2640,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, | |||
2641 | if (skb == NULL) | 2640 | if (skb == NULL) |
2642 | return -ENOMEM; | 2641 | return -ENOMEM; |
2643 | 2642 | ||
2644 | if (build_acquire(skb, x, xt, xp, dir) < 0) | 2643 | if (build_acquire(skb, x, xt, xp) < 0) |
2645 | BUG(); | 2644 | BUG(); |
2646 | 2645 | ||
2647 | return nlmsg_multicast(net->xfrm.nlsk, skb, 0, XFRMNLGRP_ACQUIRE, GFP_ATOMIC); | 2646 | return nlmsg_multicast(net->xfrm.nlsk, skb, 0, XFRMNLGRP_ACQUIRE, GFP_ATOMIC); |
@@ -2724,7 +2723,7 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp, | |||
2724 | struct nlmsghdr *nlh; | 2723 | struct nlmsghdr *nlh; |
2725 | int err; | 2724 | int err; |
2726 | 2725 | ||
2727 | nlh = nlmsg_put(skb, c->pid, 0, XFRM_MSG_POLEXPIRE, sizeof(*upe), 0); | 2726 | nlh = nlmsg_put(skb, c->portid, 0, XFRM_MSG_POLEXPIRE, sizeof(*upe), 0); |
2728 | if (nlh == NULL) | 2727 | if (nlh == NULL) |
2729 | return -EMSGSIZE; | 2728 | return -EMSGSIZE; |
2730 | 2729 | ||
@@ -2784,7 +2783,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, const struct km_e | |||
2784 | if (skb == NULL) | 2783 | if (skb == NULL) |
2785 | return -ENOMEM; | 2784 | return -ENOMEM; |
2786 | 2785 | ||
2787 | nlh = nlmsg_put(skb, c->pid, c->seq, c->event, headlen, 0); | 2786 | nlh = nlmsg_put(skb, c->portid, c->seq, c->event, headlen, 0); |
2788 | err = -EMSGSIZE; | 2787 | err = -EMSGSIZE; |
2789 | if (nlh == NULL) | 2788 | if (nlh == NULL) |
2790 | goto out_free_skb; | 2789 | goto out_free_skb; |
@@ -2838,7 +2837,7 @@ static int xfrm_notify_policy_flush(const struct km_event *c) | |||
2838 | if (skb == NULL) | 2837 | if (skb == NULL) |
2839 | return -ENOMEM; | 2838 | return -ENOMEM; |
2840 | 2839 | ||
2841 | nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_FLUSHPOLICY, 0, 0); | 2840 | nlh = nlmsg_put(skb, c->portid, c->seq, XFRM_MSG_FLUSHPOLICY, 0, 0); |
2842 | err = -EMSGSIZE; | 2841 | err = -EMSGSIZE; |
2843 | if (nlh == NULL) | 2842 | if (nlh == NULL) |
2844 | goto out_free_skb; | 2843 | goto out_free_skb; |
@@ -2991,7 +2990,7 @@ static int __net_init xfrm_user_net_init(struct net *net) | |||
2991 | .input = xfrm_netlink_rcv, | 2990 | .input = xfrm_netlink_rcv, |
2992 | }; | 2991 | }; |
2993 | 2992 | ||
2994 | nlsk = netlink_kernel_create(net, NETLINK_XFRM, THIS_MODULE, &cfg); | 2993 | nlsk = netlink_kernel_create(net, NETLINK_XFRM, &cfg); |
2995 | if (nlsk == NULL) | 2994 | if (nlsk == NULL) |
2996 | return -ENOMEM; | 2995 | return -ENOMEM; |
2997 | net->xfrm.nlsk_stash = nlsk; /* Don't set to NULL */ | 2996 | net->xfrm.nlsk_stash = nlsk; /* Don't set to NULL */ |