All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  2:47 ` Wang Weidong
  (?)
@ 2013-11-19  2:47 ` Wang Weidong
  -1 siblings, 0 replies; 48+ messages in thread
From: Wang Weidong @ 2013-11-19  2:47 UTC (permalink / raw)
  To: dccp

commit efe4208f ("ipv6: make lookups simpler and faster") remove
the daddr and rcv_saddr from struct ipv6_pinfo. When use memcpy
the ipv6_pinfo, we lose the sk_v6_daddr and sk_v6_rcv_saddr, so
use the sk_v6_copy_addrs when needed.

Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/dccp/ipv6.c     | 4 ++++
 net/ipv6/tcp_ipv6.c | 4 ++++
 net/sctp/ipv6.c     | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 4ac71ff..90182a8 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -465,6 +465,10 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
 		newnp = inet6_sk(newsk);
 
 		memcpy(newnp, np, sizeof(struct ipv6_pinfo));
+		/* Don't forget copy the rcv_saddr and daddr when
+		 * copy ipv6_pinfo.
+		 */
+		sk_v6_copy_addrs(newsk, sk);
 
 		ipv6_addr_set_v4mapped(newinet->inet_daddr, &newsk->sk_v6_daddr);
 
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 0740f93..83d011e 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1116,6 +1116,10 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
 		newtp = tcp_sk(newsk);
 
 		memcpy(newnp, np, sizeof(struct ipv6_pinfo));
+		/* Don't forget copy the rcv_saddr and daddr when
+		 * copy ipv6_pinfo.
+		 */
+		sk_v6_copy_addrs(newsk, sk);
 
 		ipv6_addr_set_v4mapped(newinet->inet_daddr, &newsk->sk_v6_daddr);
 
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 7567e6f..b76f143 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -656,6 +656,10 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk,
 	newnp = inet6_sk(newsk);
 
 	memcpy(newnp, np, sizeof(struct ipv6_pinfo));
+	/* Don't forget copy the rcv_saddr and daddr when
+	 * copy ipv6_pinfo.
+	 */
+	sk_v6_copy_addrs(newsk, sk);
 
 	/* Initialize sk's sport, dport, rcv_saddr and daddr for getsockname()
 	 * and getpeername().
-- 
1.7.12



^ permalink raw reply related	[flat|nested] 48+ messages in thread
* [PATCH 1/2] ipv6: add helper function for copy addrs from old sock
  2013-11-19  2:47 ` Wang Weidong
  (?)
@ 2013-11-19  2:47 ` Wang Weidong
  -1 siblings, 0 replies; 48+ messages in thread
From: Wang Weidong @ 2013-11-19  2:47 UTC (permalink / raw)
  To: dccp

Add sk_v6_copy_addrs for copying sk_v6_daddr and sk_v6_rcv_saddr, it
will be used in the coming patch.

Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 include/net/sock.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/net/sock.h b/include/net/sock.h
index e3a18ff..9be2b9f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -442,6 +442,12 @@ struct sock {
 #define SK_CAN_REUSE	1
 #define SK_FORCE_REUSE	2
 
+static inline void sk_v6_copy_addrs(struct sock *newsk, struct sock *oldsk)
+{
+	newsk->sk_v6_daddr = oldsk->sk_v6_daddr;
+	newsk->sk_v6_rcv_saddr = oldsk->sk_v6_rcv_saddr;
+}
+
 static inline int sk_peek_offset(struct sock *sk, int flags)
 {
 	if ((flags & MSG_PEEK) && (sk->sk_peek_off >= 0))
-- 
1.7.12



^ permalink raw reply related	[flat|nested] 48+ messages in thread
* [PATCH 0/2] ipv6: fix the missing copies when memcpy ipv6_pinfo
@ 2013-11-19  2:47 ` Wang Weidong
  0 siblings, 0 replies; 48+ messages in thread
From: Wang Weidong @ 2013-11-19  2:47 UTC (permalink / raw)
  To: dccp

This patch series include: add the helper function, use it when
memcpy struct ipv6_pinfo.

Wang Weidong (2):
  ipv6: add helper function for copy addrs from old sock
  ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo

 include/net/sock.h  | 6 ++++++
 net/dccp/ipv6.c     | 4 ++++
 net/ipv6/tcp_ipv6.c | 4 ++++
 net/sctp/ipv6.c     | 4 ++++
 4 files changed, 18 insertions(+)

-- 
1.7.12



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

end of thread, other threads:[~2013-11-19 15:25 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-19  2:47 [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo Wang Weidong
2013-11-19  2:47 ` Wang Weidong
2013-11-19  2:47 ` Wang Weidong
2013-11-19  3:14 ` Hannes Frederic Sowa
2013-11-19  3:14   ` Hannes Frederic Sowa
2013-11-19  3:14   ` Hannes Frederic Sowa
2013-11-19  3:32 ` wangweidong
2013-11-19  3:32   ` wangweidong
2013-11-19  3:32   ` wangweidong
2013-11-19  3:55 ` Eric Dumazet
2013-11-19  3:55   ` Eric Dumazet
2013-11-19  3:55   ` Eric Dumazet
2013-11-19  3:58 ` Eric Dumazet
2013-11-19  3:58   ` Eric Dumazet
2013-11-19  3:58   ` Eric Dumazet
2013-11-19  4:00 ` Eric Dumazet
2013-11-19  4:00   ` Eric Dumazet
2013-11-19  4:00   ` Eric Dumazet
2013-11-19  4:38 ` wangweidong
2013-11-19  4:38   ` wangweidong
2013-11-19  4:38   ` wangweidong
2013-11-19  4:44 ` wangweidong
2013-11-19  4:44   ` wangweidong
2013-11-19  4:44   ` wangweidong
2013-11-19 11:04 ` Daniel Borkmann
2013-11-19 11:04   ` Daniel Borkmann
2013-11-19 11:04   ` Daniel Borkmann
2013-11-19 11:09 ` wangweidong
2013-11-19 11:09   ` wangweidong
2013-11-19 11:09   ` wangweidong
2013-11-19 11:35 ` Daniel Borkmann
2013-11-19 11:35   ` Daniel Borkmann
2013-11-19 11:35   ` Daniel Borkmann
2013-11-19 14:23 ` Eric Dumazet
2013-11-19 14:23   ` Eric Dumazet
2013-11-19 14:23   ` Eric Dumazet
2013-11-19 14:26 ` Daniel Borkmann
2013-11-19 14:26   ` Daniel Borkmann
2013-11-19 14:26   ` Daniel Borkmann
2013-11-19 15:25 ` Vlad Yasevich
2013-11-19 15:25   ` Vlad Yasevich
2013-11-19 15:25   ` Vlad Yasevich
  -- strict thread matches above, loose matches on Subject: below --
2013-11-19  2:47 [PATCH 1/2] ipv6: add helper function for copy addrs from old sock Wang Weidong
2013-11-19  2:47 ` Wang Weidong
2013-11-19  2:47 ` Wang Weidong
2013-11-19  2:47 [PATCH 0/2] ipv6: fix the missing copies when memcpy ipv6_pinfo Wang Weidong
2013-11-19  2:47 ` Wang Weidong
2013-11-19  2:47 ` Wang Weidong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.