netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sctp: check dst validity after IPsec operations
@ 2012-09-06 17:40 Nicolas Dichtel
  2012-09-06 16:04 ` Vlad Yasevich
  2012-09-06 18:10 ` David Miller
  0 siblings, 2 replies; 52+ messages in thread
From: Nicolas Dichtel @ 2012-09-06 17:40 UTC (permalink / raw)
  To: vyasevich, sri, linux-sctp; +Cc: netdev, Nicolas Dichtel

dst stored in struct sctp_transport needs to be recalculated when ipsec policy
are updated. We use flow_cache_genid for that.

For example, if a SCTP connection is established and then an IPsec policy is
set, the old SCTP flow will not be updated and thus will not use the new
IPsec policy.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 include/net/sctp/sctp.h    | 3 ++-
 include/net/sctp/structs.h | 3 +++
 net/sctp/ipv6.c            | 1 +
 net/sctp/protocol.c        | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 9c6414f..3267246 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -712,7 +712,8 @@ static inline void sctp_v4_map_v6(union sctp_addr *addr)
  */
 static inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t)
 {
-	if (t->dst && !dst_check(t->dst, 0)) {
+	if ((t->dst && !dst_check(t->dst, 0)) ||
+	    (t->flow_cache_genid != atomic_read(&flow_cache_genid))) {
 		dst_release(t->dst);
 		t->dst = NULL;
 	}
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 0fef00f..9dab882 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -948,6 +948,9 @@ struct sctp_transport {
 
 	/* 64-bit random number sent with heartbeat. */
 	__u64 hb_nonce;
+
+	/* used to check validity of dst */
+	__u32 flow_cache_genid;
 };
 
 struct sctp_transport *sctp_transport_new(struct net *, const union sctp_addr *,
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index ea14cb4..2ed7410 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -349,6 +349,7 @@ out:
 		struct rt6_info *rt;
 		rt = (struct rt6_info *)dst;
 		t->dst = dst;
+		t->flow_cache_genid = atomic_read(&flow_cache_genid);
 		SCTP_DEBUG_PRINTK("rt6_dst:%pI6 rt6_src:%pI6\n",
 			&rt->rt6i_dst.addr, &fl6->saddr);
 	} else {
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 2d51842..4795a1a 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -512,6 +512,7 @@ out_unlock:
 	rcu_read_unlock();
 out:
 	t->dst = dst;
+	t->flow_cache_genid = atomic_read(&flow_cache_genid);
 	if (dst)
 		SCTP_DEBUG_PRINTK("rt_dst:%pI4, rt_src:%pI4\n",
 				  &fl4->daddr, &fl4->saddr);
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2012-09-22 16:49 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-06 17:40 [PATCH] sctp: check dst validity after IPsec operations Nicolas Dichtel
2012-09-06 16:04 ` Vlad Yasevich
2012-09-06 16:40   ` Nicolas Dichtel
2012-09-06 17:03     ` Vlad Yasevich
2012-09-07 12:24       ` Nicolas Dichtel
2012-09-07 12:07   ` Nicolas Dichtel
2012-09-06 18:10 ` David Miller
2012-09-07 13:47   ` Nicolas Dichtel
2012-09-07 15:57     ` [PATCH RFC net-next 0/2] Take care of xfrm policy when checking dst entries Nicolas Dichtel
2012-09-07 15:57       ` [PATCH 1/2] dst: take into account policy update on check() Nicolas Dichtel
2012-09-07 14:20         ` Vlad Yasevich
2012-09-07 14:35         ` Eric Dumazet
2012-09-07 14:47           ` Nicolas Dichtel
2012-09-07 15:09             ` Eric Dumazet
2012-09-07 15:13               ` Nicolas Dichtel
2012-09-07 15:21                 ` Eric Dumazet
2012-09-07 18:48                   ` David Miller
2012-09-07 18:48                 ` David Miller
2012-09-10 12:47                   ` Nicolas Dichtel
2012-09-10 13:10                     ` Eric Dumazet
2012-09-10 13:22                   ` [PATCH net-next v2] Take care of xfrm policy when checking dst entries Nicolas Dichtel
2012-09-10 13:22                     ` [PATCH net-next v2 1/4] netns: move net->ipv4.rt_genid to net->rt_genid Nicolas Dichtel
2012-09-10 13:22                     ` [PATCH net-next v2 2/4] xfrm: invalidate dst on policy insertion/deletion Nicolas Dichtel
2012-09-10 14:21                       ` Vlad Yasevich
2012-09-10 14:56                         ` Nicolas Dichtel
2012-09-11  8:09                           ` [PATCH net-next v3 0/4] Take care of xfrm policy when checking dst entries Nicolas Dichtel
2012-09-11  8:09                             ` [PATCH net-next v3 1/4] netns: move net->ipv4.rt_genid to net->rt_genid Nicolas Dichtel
2012-09-11  8:09                             ` [PATCH net-next v3 2/4] xfrm: invalidate dst on policy insertion/deletion Nicolas Dichtel
2012-09-11  8:09                             ` [PATCH net-next v3 3/4] ipv6: use net->rt_genid to check dst validity Nicolas Dichtel
2012-09-11  8:09                             ` [PATCH net-next v3 4/4] ipv6: use DST_* macro to set obselete field Nicolas Dichtel
2012-09-12  7:40                               ` Eric Dumazet
2012-09-17 16:49                             ` [PATCH net-next v3 0/4] Take care of xfrm policy when checking dst entries David Miller
2012-09-17 18:14                               ` Vlad Yasevich
2012-09-17 18:25                                 ` David Miller
2012-09-17 19:52                                   ` Nicolas Dichtel
2012-09-17 19:54                                     ` David Miller
2012-09-18 20:08                                       ` David Miller
2012-09-10 13:22                     ` [PATCH net-next v2 3/4] ipv6: use net->rt_genid to check dst validity Nicolas Dichtel
2012-09-10 14:29                       ` Vlad Yasevich
2012-09-10 14:34                         ` Nicolas Dichtel
2012-09-10 14:43                           ` Vlad Yasevich
2012-09-10 14:44                             ` Nicolas Dichtel
2012-09-10 13:22                     ` [PATCH net-next v2 4/4] ipv6: use DST_* macro to set obselete field Nicolas Dichtel
2012-09-10 14:35                     ` [PATCH net-next v2] Take care of xfrm policy when checking dst entries Vlad Yasevich
2012-09-10 14:38                       ` Nicolas Dichtel
2012-09-10 17:18                       ` David Miller
2012-09-10 17:59                         ` Vlad Yasevich
2012-09-10 18:01                           ` David Miller
2012-09-22 16:49                             ` Jan Engelhardt
2012-09-07 14:51           ` [PATCH 1/2] dst: take into account policy update on check() Vlad Yasevich
2012-09-07 15:08             ` Eric Dumazet
2012-09-07 15:57       ` [PATCH 2/2] ipv6: remove rt6i_flow_cache_genid field in rt6_info Nicolas Dichtel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).