aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2016-01-12 05:01:12 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-01-12 05:01:12 -0500
commit1f16f116b01c110db20ab808562c8b8bc3ee3d6e (patch)
tree44db563f64cf5f8d62af8f99a61e2b248c44ea3a /include/net
parent03724ac3d48f8f0e3caf1d30fa134f8fd96c94e2 (diff)
parentf9eccf24615672896dc13251410c3f2f33a14f95 (diff)
Merge branches 'clockevents/4.4-fixes' and 'clockevents/4.5-fixes' of http://git.linaro.org/people/daniel.lezcano/linux into timers/urgent
Pull in fixes from Daniel Lezcano: - Fix the vt8500 timer leading to a system lock up when dealing with too small delta (Roman Volkov) - Select the CLKSRC_MMIO when the fsl_ftm_timer is enabled with COMPILE_TEST (Daniel Lezcano) - Prevent to compile timers using the 'iomem' API when the architecture has not HAS_IOMEM set (Richard Weinberger)
Diffstat (limited to 'include/net')
-rw-r--r--include/net/af_unix.h1
-rw-r--r--include/net/dst.h33
-rw-r--r--include/net/inet_sock.h27
-rw-r--r--include/net/inetpeer.h1
-rw-r--r--include/net/ip6_route.h17
-rw-r--r--include/net/ipv6.h22
-rw-r--r--include/net/mac80211.h6
-rw-r--r--include/net/ndisc.h3
-rw-r--r--include/net/sch_generic.h3
-rw-r--r--include/net/sctp/structs.h17
-rw-r--r--include/net/sock.h39
-rw-r--r--include/net/vxlan.h2
-rw-r--r--include/net/xfrm.h25
13 files changed, 147 insertions, 49 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index b36d837c701e..2a91a0561a47 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -62,6 +62,7 @@ struct unix_sock {
62#define UNIX_GC_CANDIDATE 0 62#define UNIX_GC_CANDIDATE 0
63#define UNIX_GC_MAYBE_CYCLE 1 63#define UNIX_GC_MAYBE_CYCLE 1
64 struct socket_wq peer_wq; 64 struct socket_wq peer_wq;
65 wait_queue_t peer_wake;
65}; 66};
66 67
67static inline struct unix_sock *unix_sk(const struct sock *sk) 68static inline struct unix_sock *unix_sk(const struct sock *sk)
diff --git a/include/net/dst.h b/include/net/dst.h
index 1279f9b09791..c7329dcd90cc 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -322,6 +322,39 @@ static inline void skb_dst_force(struct sk_buff *skb)
322 } 322 }
323} 323}
324 324
325/**
326 * dst_hold_safe - Take a reference on a dst if possible
327 * @dst: pointer to dst entry
328 *
329 * This helper returns false if it could not safely
330 * take a reference on a dst.
331 */
332static inline bool dst_hold_safe(struct dst_entry *dst)
333{
334 if (dst->flags & DST_NOCACHE)
335 return atomic_inc_not_zero(&dst->__refcnt);
336 dst_hold(dst);
337 return true;
338}
339
340/**
341 * skb_dst_force_safe - makes sure skb dst is refcounted
342 * @skb: buffer
343 *
344 * If dst is not yet refcounted and not destroyed, grab a ref on it.
345 */
346static inline void skb_dst_force_safe(struct sk_buff *skb)
347{
348 if (skb_dst_is_noref(skb)) {
349 struct dst_entry *dst = skb_dst(skb);
350
351 if (!dst_hold_safe(dst))
352 dst = NULL;
353
354 skb->_skb_refdst = (unsigned long)dst;
355 }
356}
357
325 358
326/** 359/**
327 * __skb_tunnel_rx - prepare skb for rx reinsert 360 * __skb_tunnel_rx - prepare skb for rx reinsert
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 2134e6d815bc..625bdf95d673 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -210,18 +210,37 @@ struct inet_sock {
210#define IP_CMSG_ORIGDSTADDR BIT(6) 210#define IP_CMSG_ORIGDSTADDR BIT(6)
211#define IP_CMSG_CHECKSUM BIT(7) 211#define IP_CMSG_CHECKSUM BIT(7)
212 212
213/* SYNACK messages might be attached to request sockets. 213/**
214 * sk_to_full_sk - Access to a full socket
215 * @sk: pointer to a socket
216 *
217 * SYNACK messages might be attached to request sockets.
214 * Some places want to reach the listener in this case. 218 * Some places want to reach the listener in this case.
215 */ 219 */
216static inline struct sock *skb_to_full_sk(const struct sk_buff *skb) 220static inline struct sock *sk_to_full_sk(struct sock *sk)
217{ 221{
218 struct sock *sk = skb->sk; 222#ifdef CONFIG_INET
219
220 if (sk && sk->sk_state == TCP_NEW_SYN_RECV) 223 if (sk && sk->sk_state == TCP_NEW_SYN_RECV)
221 sk = inet_reqsk(sk)->rsk_listener; 224 sk = inet_reqsk(sk)->rsk_listener;
225#endif
226 return sk;
227}
228
229/* sk_to_full_sk() variant with a const argument */
230static inline const struct sock *sk_const_to_full_sk(const struct sock *sk)
231{
232#ifdef CONFIG_INET
233 if (sk && sk->sk_state == TCP_NEW_SYN_RECV)
234 sk = ((const struct request_sock *)sk)->rsk_listener;
235#endif
222 return sk; 236 return sk;
223} 237}
224 238
239static inline struct sock *skb_to_full_sk(const struct sk_buff *skb)
240{
241 return sk_to_full_sk(skb->sk);
242}
243
225static inline struct inet_sock *inet_sk(const struct sock *sk) 244static inline struct inet_sock *inet_sk(const struct sock *sk)
226{ 245{
227 return (struct inet_sock *)sk; 246 return (struct inet_sock *)sk;
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index 4a6009d4486b..235c7811a86a 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -78,6 +78,7 @@ void inet_initpeers(void) __init;
78static inline void inetpeer_set_addr_v4(struct inetpeer_addr *iaddr, __be32 ip) 78static inline void inetpeer_set_addr_v4(struct inetpeer_addr *iaddr, __be32 ip)
79{ 79{
80 iaddr->a4.addr = ip; 80 iaddr->a4.addr = ip;
81 iaddr->a4.vif = 0;
81 iaddr->family = AF_INET; 82 iaddr->family = AF_INET;
82} 83}
83 84
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 2bfb2ad2fab1..877f682989b8 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -133,27 +133,18 @@ void rt6_clean_tohost(struct net *net, struct in6_addr *gateway);
133/* 133/*
134 * Store a destination cache entry in a socket 134 * Store a destination cache entry in a socket
135 */ 135 */
136static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst, 136static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
137 const struct in6_addr *daddr, 137 const struct in6_addr *daddr,
138 const struct in6_addr *saddr) 138 const struct in6_addr *saddr)
139{ 139{
140 struct ipv6_pinfo *np = inet6_sk(sk); 140 struct ipv6_pinfo *np = inet6_sk(sk);
141 struct rt6_info *rt = (struct rt6_info *) dst;
142 141
142 np->dst_cookie = rt6_get_cookie((struct rt6_info *)dst);
143 sk_setup_caps(sk, dst); 143 sk_setup_caps(sk, dst);
144 np->daddr_cache = daddr; 144 np->daddr_cache = daddr;
145#ifdef CONFIG_IPV6_SUBTREES 145#ifdef CONFIG_IPV6_SUBTREES
146 np->saddr_cache = saddr; 146 np->saddr_cache = saddr;
147#endif 147#endif
148 np->dst_cookie = rt6_get_cookie(rt);
149}
150
151static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
152 struct in6_addr *daddr, struct in6_addr *saddr)
153{
154 spin_lock(&sk->sk_dst_lock);
155 __ip6_dst_store(sk, dst, daddr, saddr);
156 spin_unlock(&sk->sk_dst_lock);
157} 148}
158 149
159static inline bool ipv6_unicast_destination(const struct sk_buff *skb) 150static inline bool ipv6_unicast_destination(const struct sk_buff *skb)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index e1a10b0ac0b0..9a5c9f013784 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -205,6 +205,7 @@ extern rwlock_t ip6_ra_lock;
205 */ 205 */
206 206
207struct ipv6_txoptions { 207struct ipv6_txoptions {
208 atomic_t refcnt;
208 /* Length of this structure */ 209 /* Length of this structure */
209 int tot_len; 210 int tot_len;
210 211
@@ -217,7 +218,7 @@ struct ipv6_txoptions {
217 struct ipv6_opt_hdr *dst0opt; 218 struct ipv6_opt_hdr *dst0opt;
218 struct ipv6_rt_hdr *srcrt; /* Routing Header */ 219 struct ipv6_rt_hdr *srcrt; /* Routing Header */
219 struct ipv6_opt_hdr *dst1opt; 220 struct ipv6_opt_hdr *dst1opt;
220 221 struct rcu_head rcu;
221 /* Option buffer, as read by IPV6_PKTOPTIONS, starts here. */ 222 /* Option buffer, as read by IPV6_PKTOPTIONS, starts here. */
222}; 223};
223 224
@@ -252,6 +253,24 @@ struct ipv6_fl_socklist {
252 struct rcu_head rcu; 253 struct rcu_head rcu;
253}; 254};
254 255
256static inline struct ipv6_txoptions *txopt_get(const struct ipv6_pinfo *np)
257{
258 struct ipv6_txoptions *opt;
259
260 rcu_read_lock();
261 opt = rcu_dereference(np->opt);
262 if (opt && !atomic_inc_not_zero(&opt->refcnt))
263 opt = NULL;
264 rcu_read_unlock();
265 return opt;
266}
267
268static inline void txopt_put(struct ipv6_txoptions *opt)
269{
270 if (opt && atomic_dec_and_test(&opt->refcnt))
271 kfree_rcu(opt, rcu);
272}
273
255struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, __be32 label); 274struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, __be32 label);
256struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space, 275struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space,
257 struct ip6_flowlabel *fl, 276 struct ip6_flowlabel *fl,
@@ -490,6 +509,7 @@ struct ip6_create_arg {
490 u32 user; 509 u32 user;
491 const struct in6_addr *src; 510 const struct in6_addr *src;
492 const struct in6_addr *dst; 511 const struct in6_addr *dst;
512 int iif;
493 u8 ecn; 513 u8 ecn;
494}; 514};
495 515
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 82045fca388b..760bc4d5a2cf 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2003,8 +2003,10 @@ enum ieee80211_hw_flags {
2003 * it shouldn't be set. 2003 * it shouldn't be set.
2004 * 2004 *
2005 * @max_tx_aggregation_subframes: maximum number of subframes in an 2005 * @max_tx_aggregation_subframes: maximum number of subframes in an
2006 * aggregate an HT driver will transmit, used by the peer as a 2006 * aggregate an HT driver will transmit. Though ADDBA will advertise
2007 * hint to size its reorder buffer. 2007 * a constant value of 64 as some older APs can crash if the window
2008 * size is smaller (an example is LinkSys WRT120N with FW v1.0.07
2009 * build 002 Jun 18 2012).
2008 * 2010 *
2009 * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX 2011 * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX
2010 * (if %IEEE80211_HW_QUEUE_CONTROL is set) 2012 * (if %IEEE80211_HW_QUEUE_CONTROL is set)
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index bf3937431030..2d8edaad29cb 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -181,8 +181,7 @@ void ndisc_cleanup(void);
181int ndisc_rcv(struct sk_buff *skb); 181int ndisc_rcv(struct sk_buff *skb);
182 182
183void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit, 183void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
184 const struct in6_addr *daddr, const struct in6_addr *saddr, 184 const struct in6_addr *daddr, const struct in6_addr *saddr);
185 struct sk_buff *oskb);
186 185
187void ndisc_send_rs(struct net_device *dev, 186void ndisc_send_rs(struct net_device *dev,
188 const struct in6_addr *saddr, const struct in6_addr *daddr); 187 const struct in6_addr *saddr, const struct in6_addr *daddr);
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 4c79ce8c1f92..b2a8e6338576 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -61,6 +61,9 @@ struct Qdisc {
61 */ 61 */
62#define TCQ_F_WARN_NONWC (1 << 16) 62#define TCQ_F_WARN_NONWC (1 << 16)
63#define TCQ_F_CPUSTATS 0x20 /* run using percpu statistics */ 63#define TCQ_F_CPUSTATS 0x20 /* run using percpu statistics */
64#define TCQ_F_NOPARENT 0x40 /* root of its hierarchy :
65 * qdisc_tree_decrease_qlen() should stop.
66 */
64 u32 limit; 67 u32 limit;
65 const struct Qdisc_ops *ops; 68 const struct Qdisc_ops *ops;
66 struct qdisc_size_table __rcu *stab; 69 struct qdisc_size_table __rcu *stab;
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 495c87e367b3..eea9bdeecba2 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -775,10 +775,10 @@ struct sctp_transport {
775 hb_sent:1, 775 hb_sent:1,
776 776
777 /* Is the Path MTU update pending on this tranport */ 777 /* Is the Path MTU update pending on this tranport */
778 pmtu_pending:1; 778 pmtu_pending:1,
779 779
780 /* Has this transport moved the ctsn since we last sacked */ 780 /* Has this transport moved the ctsn since we last sacked */
781 __u32 sack_generation; 781 sack_generation:1;
782 u32 dst_cookie; 782 u32 dst_cookie;
783 783
784 struct flowi fl; 784 struct flowi fl;
@@ -1482,19 +1482,20 @@ struct sctp_association {
1482 prsctp_capable:1, /* Can peer do PR-SCTP? */ 1482 prsctp_capable:1, /* Can peer do PR-SCTP? */
1483 auth_capable:1; /* Is peer doing SCTP-AUTH? */ 1483 auth_capable:1; /* Is peer doing SCTP-AUTH? */
1484 1484
1485 /* Ack State : This flag indicates if the next received 1485 /* sack_needed : This flag indicates if the next received
1486 * : packet is to be responded to with a 1486 * : packet is to be responded to with a
1487 * : SACK. This is initializedto 0. When a packet 1487 * : SACK. This is initialized to 0. When a packet
1488 * : is received it is incremented. If this value 1488 * : is received sack_cnt is incremented. If this value
1489 * : reaches 2 or more, a SACK is sent and the 1489 * : reaches 2 or more, a SACK is sent and the
1490 * : value is reset to 0. Note: This is used only 1490 * : value is reset to 0. Note: This is used only
1491 * : when no DATA chunks are received out of 1491 * : when no DATA chunks are received out of
1492 * : order. When DATA chunks are out of order, 1492 * : order. When DATA chunks are out of order,
1493 * : SACK's are not delayed (see Section 6). 1493 * : SACK's are not delayed (see Section 6).
1494 */ 1494 */
1495 __u8 sack_needed; /* Do we need to sack the peer? */ 1495 __u8 sack_needed:1, /* Do we need to sack the peer? */
1496 sack_generation:1,
1497 zero_window_announced:1;
1496 __u32 sack_cnt; 1498 __u32 sack_cnt;
1497 __u32 sack_generation;
1498 1499
1499 __u32 adaptation_ind; /* Adaptation Code point. */ 1500 __u32 adaptation_ind; /* Adaptation Code point. */
1500 1501
diff --git a/include/net/sock.h b/include/net/sock.h
index 7f89e4ba18d1..14d3c0734007 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -254,7 +254,6 @@ struct cg_proto;
254 * @sk_wq: sock wait queue and async head 254 * @sk_wq: sock wait queue and async head
255 * @sk_rx_dst: receive input route used by early demux 255 * @sk_rx_dst: receive input route used by early demux
256 * @sk_dst_cache: destination cache 256 * @sk_dst_cache: destination cache
257 * @sk_dst_lock: destination cache lock
258 * @sk_policy: flow policy 257 * @sk_policy: flow policy
259 * @sk_receive_queue: incoming packets 258 * @sk_receive_queue: incoming packets
260 * @sk_wmem_alloc: transmit queue bytes committed 259 * @sk_wmem_alloc: transmit queue bytes committed
@@ -384,14 +383,16 @@ struct sock {
384 int sk_rcvbuf; 383 int sk_rcvbuf;
385 384
386 struct sk_filter __rcu *sk_filter; 385 struct sk_filter __rcu *sk_filter;
387 struct socket_wq __rcu *sk_wq; 386 union {
388 387 struct socket_wq __rcu *sk_wq;
388 struct socket_wq *sk_wq_raw;
389 };
389#ifdef CONFIG_XFRM 390#ifdef CONFIG_XFRM
390 struct xfrm_policy *sk_policy[2]; 391 struct xfrm_policy __rcu *sk_policy[2];
391#endif 392#endif
392 struct dst_entry *sk_rx_dst; 393 struct dst_entry *sk_rx_dst;
393 struct dst_entry __rcu *sk_dst_cache; 394 struct dst_entry __rcu *sk_dst_cache;
394 spinlock_t sk_dst_lock; 395 /* Note: 32bit hole on 64bit arches */
395 atomic_t sk_wmem_alloc; 396 atomic_t sk_wmem_alloc;
396 atomic_t sk_omem_alloc; 397 atomic_t sk_omem_alloc;
397 int sk_sndbuf; 398 int sk_sndbuf;
@@ -403,6 +404,7 @@ struct sock {
403 sk_userlocks : 4, 404 sk_userlocks : 4,
404 sk_protocol : 8, 405 sk_protocol : 8,
405 sk_type : 16; 406 sk_type : 16;
407#define SK_PROTOCOL_MAX U8_MAX
406 kmemcheck_bitfield_end(flags); 408 kmemcheck_bitfield_end(flags);
407 int sk_wmem_queued; 409 int sk_wmem_queued;
408 gfp_t sk_allocation; 410 gfp_t sk_allocation;
@@ -739,6 +741,8 @@ enum sock_flags {
739 SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */ 741 SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */
740}; 742};
741 743
744#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
745
742static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) 746static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
743{ 747{
744 nsk->sk_flags = osk->sk_flags; 748 nsk->sk_flags = osk->sk_flags;
@@ -813,7 +817,7 @@ void sk_stream_write_space(struct sock *sk);
813static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb) 817static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb)
814{ 818{
815 /* dont let skb dst not refcounted, we are going to leave rcu lock */ 819 /* dont let skb dst not refcounted, we are going to leave rcu lock */
816 skb_dst_force(skb); 820 skb_dst_force_safe(skb);
817 821
818 if (!sk->sk_backlog.tail) 822 if (!sk->sk_backlog.tail)
819 sk->sk_backlog.head = skb; 823 sk->sk_backlog.head = skb;
@@ -2005,10 +2009,27 @@ static inline unsigned long sock_wspace(struct sock *sk)
2005 return amt; 2009 return amt;
2006} 2010}
2007 2011
2008static inline void sk_wake_async(struct sock *sk, int how, int band) 2012/* Note:
2013 * We use sk->sk_wq_raw, from contexts knowing this
2014 * pointer is not NULL and cannot disappear/change.
2015 */
2016static inline void sk_set_bit(int nr, struct sock *sk)
2017{
2018 set_bit(nr, &sk->sk_wq_raw->flags);
2019}
2020
2021static inline void sk_clear_bit(int nr, struct sock *sk)
2022{
2023 clear_bit(nr, &sk->sk_wq_raw->flags);
2024}
2025
2026static inline void sk_wake_async(const struct sock *sk, int how, int band)
2009{ 2027{
2010 if (sock_flag(sk, SOCK_FASYNC)) 2028 if (sock_flag(sk, SOCK_FASYNC)) {
2011 sock_wake_async(sk->sk_socket, how, band); 2029 rcu_read_lock();
2030 sock_wake_async(rcu_dereference(sk->sk_wq), how, band);
2031 rcu_read_unlock();
2032 }
2012} 2033}
2013 2034
2014/* Since sk_{r,w}mem_alloc sums skb->truesize, even a small frame might 2035/* Since sk_{r,w}mem_alloc sums skb->truesize, even a small frame might
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index c1c899c3a51b..e289ada6adf6 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -79,7 +79,7 @@ struct vxlanhdr {
79}; 79};
80 80
81/* VXLAN header flags. */ 81/* VXLAN header flags. */
82#define VXLAN_HF_RCO BIT(24) 82#define VXLAN_HF_RCO BIT(21)
83#define VXLAN_HF_VNI BIT(27) 83#define VXLAN_HF_VNI BIT(27)
84#define VXLAN_HF_GBP BIT(31) 84#define VXLAN_HF_GBP BIT(31)
85 85
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 4a9c21f9b4ea..d6f6e5006ee9 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -548,6 +548,7 @@ struct xfrm_policy {
548 u16 family; 548 u16 family;
549 struct xfrm_sec_ctx *security; 549 struct xfrm_sec_ctx *security;
550 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; 550 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
551 struct rcu_head rcu;
551}; 552};
552 553
553static inline struct net *xp_net(const struct xfrm_policy *xp) 554static inline struct net *xp_net(const struct xfrm_policy *xp)
@@ -1141,12 +1142,14 @@ static inline int xfrm6_route_forward(struct sk_buff *skb)
1141 return xfrm_route_forward(skb, AF_INET6); 1142 return xfrm_route_forward(skb, AF_INET6);
1142} 1143}
1143 1144
1144int __xfrm_sk_clone_policy(struct sock *sk); 1145int __xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk);
1145 1146
1146static inline int xfrm_sk_clone_policy(struct sock *sk) 1147static inline int xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk)
1147{ 1148{
1148 if (unlikely(sk->sk_policy[0] || sk->sk_policy[1])) 1149 sk->sk_policy[0] = NULL;
1149 return __xfrm_sk_clone_policy(sk); 1150 sk->sk_policy[1] = NULL;
1151 if (unlikely(osk->sk_policy[0] || osk->sk_policy[1]))
1152 return __xfrm_sk_clone_policy(sk, osk);
1150 return 0; 1153 return 0;
1151} 1154}
1152 1155
@@ -1154,12 +1157,16 @@ int xfrm_policy_delete(struct xfrm_policy *pol, int dir);
1154 1157
1155static inline void xfrm_sk_free_policy(struct sock *sk) 1158static inline void xfrm_sk_free_policy(struct sock *sk)
1156{ 1159{
1157 if (unlikely(sk->sk_policy[0] != NULL)) { 1160 struct xfrm_policy *pol;
1158 xfrm_policy_delete(sk->sk_policy[0], XFRM_POLICY_MAX); 1161
1162 pol = rcu_dereference_protected(sk->sk_policy[0], 1);
1163 if (unlikely(pol != NULL)) {
1164 xfrm_policy_delete(pol, XFRM_POLICY_MAX);
1159 sk->sk_policy[0] = NULL; 1165 sk->sk_policy[0] = NULL;
1160 } 1166 }
1161 if (unlikely(sk->sk_policy[1] != NULL)) { 1167 pol = rcu_dereference_protected(sk->sk_policy[1], 1);
1162 xfrm_policy_delete(sk->sk_policy[1], XFRM_POLICY_MAX+1); 1168 if (unlikely(pol != NULL)) {
1169 xfrm_policy_delete(pol, XFRM_POLICY_MAX+1);
1163 sk->sk_policy[1] = NULL; 1170 sk->sk_policy[1] = NULL;
1164 } 1171 }
1165} 1172}
@@ -1169,7 +1176,7 @@ void xfrm_garbage_collect(struct net *net);
1169#else 1176#else
1170 1177
1171static inline void xfrm_sk_free_policy(struct sock *sk) {} 1178static inline void xfrm_sk_free_policy(struct sock *sk) {}
1172static inline int xfrm_sk_clone_policy(struct sock *sk) { return 0; } 1179static inline int xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk) { return 0; }
1173static inline int xfrm6_route_forward(struct sk_buff *skb) { return 1; } 1180static inline int xfrm6_route_forward(struct sk_buff *skb) { return 1; }
1174static inline int xfrm4_route_forward(struct sk_buff *skb) { return 1; } 1181static inline int xfrm4_route_forward(struct sk_buff *skb) { return 1; }
1175static inline int xfrm6_policy_check(struct sock *sk, int dir, struct sk_buff *skb) 1182static inline int xfrm6_policy_check(struct sock *sk, int dir, struct sk_buff *skb)