aboutsummaryrefslogtreecommitdiffstats
path: root/net/key/af_key.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/key/af_key.c')
-rw-r--r--net/key/af_key.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 143d46f6329a..7969f8a716df 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -655,7 +655,8 @@ static inline int pfkey_mode_to_xfrm(int mode)
655 } 655 }
656} 656}
657 657
658static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys, int hsc) 658static struct sk_buff *__pfkey_xfrm_state2msg(struct xfrm_state *x,
659 int add_keys, int hsc)
659{ 660{
660 struct sk_buff *skb; 661 struct sk_buff *skb;
661 struct sadb_msg *hdr; 662 struct sadb_msg *hdr;
@@ -1009,6 +1010,24 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
1009 return skb; 1010 return skb;
1010} 1011}
1011 1012
1013
1014static inline struct sk_buff *pfkey_xfrm_state2msg(struct xfrm_state *x)
1015{
1016 struct sk_buff *skb;
1017
1018 spin_lock_bh(&x->lock);
1019 skb = __pfkey_xfrm_state2msg(x, 1, 3);
1020 spin_unlock_bh(&x->lock);
1021
1022 return skb;
1023}
1024
1025static inline struct sk_buff *pfkey_xfrm_state2msg_expire(struct xfrm_state *x,
1026 int hsc)
1027{
1028 return __pfkey_xfrm_state2msg(x, 0, hsc);
1029}
1030
1012static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr, 1031static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
1013 void **ext_hdrs) 1032 void **ext_hdrs)
1014{ 1033{
@@ -1322,7 +1341,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
1322 } 1341 }
1323 1342
1324 err = xfrm_alloc_spi(x, min_spi, max_spi); 1343 err = xfrm_alloc_spi(x, min_spi, max_spi);
1325 resp_skb = err ? ERR_PTR(err) : pfkey_xfrm_state2msg(x, 0, 3); 1344 resp_skb = err ? ERR_PTR(err) : pfkey_xfrm_state2msg(x);
1326 1345
1327 if (IS_ERR(resp_skb)) { 1346 if (IS_ERR(resp_skb)) {
1328 xfrm_state_put(x); 1347 xfrm_state_put(x);
@@ -1412,12 +1431,8 @@ static int key_notify_sa(struct xfrm_state *x, struct km_event *c)
1412{ 1431{
1413 struct sk_buff *skb; 1432 struct sk_buff *skb;
1414 struct sadb_msg *hdr; 1433 struct sadb_msg *hdr;
1415 int hsc = 3;
1416
1417 if (c->event == XFRM_MSG_DELSA)
1418 hsc = 0;
1419 1434
1420 skb = pfkey_xfrm_state2msg(x, 0, hsc); 1435 skb = pfkey_xfrm_state2msg(x);
1421 1436
1422 if (IS_ERR(skb)) 1437 if (IS_ERR(skb))
1423 return PTR_ERR(skb); 1438 return PTR_ERR(skb);
@@ -1529,7 +1544,7 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
1529 if (x == NULL) 1544 if (x == NULL)
1530 return -ESRCH; 1545 return -ESRCH;
1531 1546
1532 out_skb = pfkey_xfrm_state2msg(x, 1, 3); 1547 out_skb = pfkey_xfrm_state2msg(x);
1533 proto = x->id.proto; 1548 proto = x->id.proto;
1534 xfrm_state_put(x); 1549 xfrm_state_put(x);
1535 if (IS_ERR(out_skb)) 1550 if (IS_ERR(out_skb))
@@ -1709,7 +1724,7 @@ static int dump_sa(struct xfrm_state *x, int count, void *ptr)
1709 struct sk_buff *out_skb; 1724 struct sk_buff *out_skb;
1710 struct sadb_msg *out_hdr; 1725 struct sadb_msg *out_hdr;
1711 1726
1712 out_skb = pfkey_xfrm_state2msg(x, 1, 3); 1727 out_skb = pfkey_xfrm_state2msg(x);
1713 if (IS_ERR(out_skb)) 1728 if (IS_ERR(out_skb))
1714 return PTR_ERR(out_skb); 1729 return PTR_ERR(out_skb);
1715 1730
@@ -2910,7 +2925,7 @@ static int key_notify_sa_expire(struct xfrm_state *x, struct km_event *c)
2910 else 2925 else
2911 hsc = 1; 2926 hsc = 1;
2912 2927
2913 out_skb = pfkey_xfrm_state2msg(x, 0, hsc); 2928 out_skb = pfkey_xfrm_state2msg_expire(x, hsc);
2914 if (IS_ERR(out_skb)) 2929 if (IS_ERR(out_skb))
2915 return PTR_ERR(out_skb); 2930 return PTR_ERR(out_skb);
2916 2931