All of lore.kernel.org
 help / color / mirror / Atom feed
* [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: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich, nhorman
  Cc: dccp, netdev, linux-sctp, dingtianhong

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

* [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: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich, nhorman
  Cc: dccp, netdev, linux-sctp, dingtianhong

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

* [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

* [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: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich, nhorman
  Cc: dccp, netdev, linux-sctp, dingtianhong

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 1/2] ipv6: add helper function for copy addrs from old sock
@ 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: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich, nhorman
  Cc: dccp, netdev, linux-sctp, dingtianhong

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 1/2] ipv6: add helper function for copy addrs from old sock
@ 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

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 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: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich, nhorman
  Cc: dccp, netdev, linux-sctp, dingtianhong

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 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct 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: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich, nhorman
  Cc: dccp, netdev, linux-sctp, dingtianhong

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 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct 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

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  2:47   ` Wang Weidong
  (?)
@ 2013-11-19  3:14     ` Hannes Frederic Sowa
  -1 siblings, 0 replies; 48+ messages in thread
From: Hannes Frederic Sowa @ 2013-11-19  3:14 UTC (permalink / raw)
  To: Wang Weidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
> 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);
>  

Hmm, how did you spot this?

Greetings,

  Hannes

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  3:14     ` Hannes Frederic Sowa
  0 siblings, 0 replies; 48+ messages in thread
From: Hannes Frederic Sowa @ 2013-11-19  3:14 UTC (permalink / raw)
  To: Wang Weidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
> 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);
>  

Hmm, how did you spot this?

Greetings,

  Hannes


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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  3:14     ` Hannes Frederic Sowa
  0 siblings, 0 replies; 48+ messages in thread
From: Hannes Frederic Sowa @ 2013-11-19  3:14 UTC (permalink / raw)
  To: dccp

On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
> 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);
>  

Hmm, how did you spot this?

Greetings,

  Hannes


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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  3:14     ` Hannes Frederic Sowa
  (?)
@ 2013-11-19  3:32       ` wangweidong
  -1 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  3:32 UTC (permalink / raw)
  To: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>> 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);
>>  
> 
> Hmm, how did you spot this?
> 
> Greetings,
> 
>   Hannes
> 

When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
will read the sk_v6_rcv_saddr, and the value is not true.

> 
> .
> 

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  3:32       ` wangweidong
  0 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  3:32 UTC (permalink / raw)
  To: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>> 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);
>>  
> 
> Hmm, how did you spot this?
> 
> Greetings,
> 
>   Hannes
> 

When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
will read the sk_v6_rcv_saddr, and the value is not true.

> 
> .
> 



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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  3:32       ` wangweidong
  0 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  3:32 UTC (permalink / raw)
  To: dccp

On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>> 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);
>>  
> 
> Hmm, how did you spot this?
> 
> Greetings,
> 
>   Hannes
> 

When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
will read the sk_v6_rcv_saddr, and the value is not true.

> 
> .
> 



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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  2:47   ` Wang Weidong
  (?)
@ 2013-11-19  3:55     ` Eric Dumazet
  -1 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  3:55 UTC (permalink / raw)
  To: Wang Weidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On Tue, 2013-11-19 at 10:47 +0800, Wang Weidong wrote:
> 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);
>  


No idea why this patch is needed for TCP.
(btw you deal with v4mapped here, no mention of it in the changelog)

The fields were moved into generic socket, and generic socket is copied.

Are you seeing a real bug ?

Please elaborate, thanks !

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  3:55     ` Eric Dumazet
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  3:55 UTC (permalink / raw)
  To: Wang Weidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On Tue, 2013-11-19 at 10:47 +0800, Wang Weidong wrote:
> 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);
>  


No idea why this patch is needed for TCP.
(btw you deal with v4mapped here, no mention of it in the changelog)

The fields were moved into generic socket, and generic socket is copied.

Are you seeing a real bug ?

Please elaborate, thanks !




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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  3:55     ` Eric Dumazet
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  3:55 UTC (permalink / raw)
  To: dccp

On Tue, 2013-11-19 at 10:47 +0800, Wang Weidong wrote:
> 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);
>  


No idea why this patch is needed for TCP.
(btw you deal with v4mapped here, no mention of it in the changelog)

The fields were moved into generic socket, and generic socket is copied.

Are you seeing a real bug ?

Please elaborate, thanks !




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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  3:32       ` wangweidong
  (?)
@ 2013-11-19  3:58         ` Eric Dumazet
  -1 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  3:58 UTC (permalink / raw)
  To: wangweidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On Tue, 2013-11-19 at 11:32 +0800, wangweidong wrote:
> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
> > On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
> >> 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);
> >>  
> > 
> > Hmm, how did you spot this?
> > 
> > Greetings,
> > 
> >   Hannes
> > 
> 
> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
> will read the sk_v6_rcv_saddr, and the value is not true.

But sctp is not tcp ;)

sctp_copy_sock() is doing some clever/partial copy of the socket, so
please fix it ;)

No idea why it's not doing the normal copy of the socket.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  3:58         ` Eric Dumazet
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  3:58 UTC (permalink / raw)
  To: wangweidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On Tue, 2013-11-19 at 11:32 +0800, wangweidong wrote:
> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
> > On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
> >> 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);
> >>  
> > 
> > Hmm, how did you spot this?
> > 
> > Greetings,
> > 
> >   Hannes
> > 
> 
> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
> will read the sk_v6_rcv_saddr, and the value is not true.

But sctp is not tcp ;)

sctp_copy_sock() is doing some clever/partial copy of the socket, so
please fix it ;)

No idea why it's not doing the normal copy of the socket.




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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  3:58         ` Eric Dumazet
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  3:58 UTC (permalink / raw)
  To: dccp

On Tue, 2013-11-19 at 11:32 +0800, wangweidong wrote:
> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
> > On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
> >> 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);
> >>  
> > 
> > Hmm, how did you spot this?
> > 
> > Greetings,
> > 
> >   Hannes
> > 
> 
> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
> will read the sk_v6_rcv_saddr, and the value is not true.

But sctp is not tcp ;)

sctp_copy_sock() is doing some clever/partial copy of the socket, so
please fix it ;)

No idea why it's not doing the normal copy of the socket.




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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  3:58         ` Eric Dumazet
  (?)
@ 2013-11-19  4:00           ` Eric Dumazet
  -1 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  4:00 UTC (permalink / raw)
  To: wangweidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:

> But sctp is not tcp ;)
> 
> sctp_copy_sock() is doing some clever/partial copy of the socket, so
> please fix it ;)
> 
> No idea why it's not doing the normal copy of the socket.

BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
is broken for SCTP.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  4:00           ` Eric Dumazet
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  4:00 UTC (permalink / raw)
  To: wangweidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:

> But sctp is not tcp ;)
> 
> sctp_copy_sock() is doing some clever/partial copy of the socket, so
> please fix it ;)
> 
> No idea why it's not doing the normal copy of the socket.

BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
is broken for SCTP.





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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  4:00           ` Eric Dumazet
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19  4:00 UTC (permalink / raw)
  To: dccp

On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:

> But sctp is not tcp ;)
> 
> sctp_copy_sock() is doing some clever/partial copy of the socket, so
> please fix it ;)
> 
> No idea why it's not doing the normal copy of the socket.

BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
is broken for SCTP.





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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  3:55     ` Eric Dumazet
  (?)
@ 2013-11-19  4:38       ` wangweidong
  -1 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  4:38 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 2013/11/19 11:55, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 10:47 +0800, Wang Weidong wrote:
>> 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);
>>  
> 
> 
> No idea why this patch is needed for TCP.
> (btw you deal with v4mapped here, no mention of it in the changelog)
> 
> The fields were moved into generic socket, and generic socket is copied.
> 
> Are you seeing a real bug ?
> 
> Please elaborate, thanks !
> 

Hm, You are right. I am not careful to look over the generic socket whether it would be
copied. Sorry for that.
Thanks. 

> 
> 
> 
> 

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  4:38       ` wangweidong
  0 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  4:38 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 2013/11/19 11:55, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 10:47 +0800, Wang Weidong wrote:
>> 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);
>>  
> 
> 
> No idea why this patch is needed for TCP.
> (btw you deal with v4mapped here, no mention of it in the changelog)
> 
> The fields were moved into generic socket, and generic socket is copied.
> 
> Are you seeing a real bug ?
> 
> Please elaborate, thanks !
> 

Hm, You are right. I am not careful to look over the generic socket whether it would be
copied. Sorry for that.
Thanks. 

> 
> 
> 
> 



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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  4:38       ` wangweidong
  0 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  4:38 UTC (permalink / raw)
  To: dccp

On 2013/11/19 11:55, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 10:47 +0800, Wang Weidong wrote:
>> 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);
>>  
> 
> 
> No idea why this patch is needed for TCP.
> (btw you deal with v4mapped here, no mention of it in the changelog)
> 
> The fields were moved into generic socket, and generic socket is copied.
> 
> Are you seeing a real bug ?
> 
> Please elaborate, thanks !
> 

Hm, You are right. I am not careful to look over the generic socket whether it would be
copied. Sorry for that.
Thanks. 

> 
> 
> 
> 



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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  4:00           ` Eric Dumazet
  (?)
@ 2013-11-19  4:44             ` wangweidong
  -1 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  4:44 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 2013/11/19 12:00, Eric Dumazet wrote:
> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
> 
>> But sctp is not tcp ;)
>>
>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>> please fix it ;)
>>
>> No idea why it's not doing the normal copy of the socket.
> 
> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> is broken for SCTP.
> 
> 
>

The dccp will copy the geniric socket, too. And You mean to say that only
add the copies in sctp_copy_sock(). 

Thanks. 
> 
> 
> 
> 

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  4:44             ` wangweidong
  0 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  4:44 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 2013/11/19 12:00, Eric Dumazet wrote:
> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
> 
>> But sctp is not tcp ;)
>>
>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>> please fix it ;)
>>
>> No idea why it's not doing the normal copy of the socket.
> 
> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> is broken for SCTP.
> 
> 
>

The dccp will copy the geniric socket, too. And You mean to say that only
add the copies in sctp_copy_sock(). 

Thanks. 
> 
> 
> 
> 



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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19  4:44             ` wangweidong
  0 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19  4:44 UTC (permalink / raw)
  To: dccp

On 2013/11/19 12:00, Eric Dumazet wrote:
> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
> 
>> But sctp is not tcp ;)
>>
>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>> please fix it ;)
>>
>> No idea why it's not doing the normal copy of the socket.
> 
> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> is broken for SCTP.
> 
> 
>

The dccp will copy the geniric socket, too. And You mean to say that only
add the copies in sctp_copy_sock(). 

Thanks. 
> 
> 
> 
> 



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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  3:32       ` wangweidong
  (?)
@ 2013-11-19 11:04         ` Daniel Borkmann
  -1 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 11:04 UTC (permalink / raw)
  To: wangweidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 11/19/2013 04:32 AM, wangweidong wrote:
> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
>> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>>> 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);
>>>
>>
>> Hmm, how did you spot this?
>>
>> Greetings,
>>
>>    Hannes
>>
>
> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
> will read the sk_v6_rcv_saddr, and the value is not true.

In SCTP code, "newsk->sk_v6_daddr = oldsk->sk_v6_daddr;" is redundant as it's already
done by "sctp_v6_to_sk_daddr(&asoc->peer.primary_addr, newsk);" for the primary path,
after we're doing the full copy of struct ipv6_pinfo to the new socket in
sctp_v6_create_accept_sk(). I've sent out an updated patch for SCTP.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 11:04         ` Daniel Borkmann
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 11:04 UTC (permalink / raw)
  To: wangweidong
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 11/19/2013 04:32 AM, wangweidong wrote:
> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
>> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>>> 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);
>>>
>>
>> Hmm, how did you spot this?
>>
>> Greetings,
>>
>>    Hannes
>>
>
> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
> will read the sk_v6_rcv_saddr, and the value is not true.

In SCTP code, "newsk->sk_v6_daddr = oldsk->sk_v6_daddr;" is redundant as it's already
done by "sctp_v6_to_sk_daddr(&asoc->peer.primary_addr, newsk);" for the primary path,
after we're doing the full copy of struct ipv6_pinfo to the new socket in
sctp_v6_create_accept_sk(). I've sent out an updated patch for SCTP.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 11:04         ` Daniel Borkmann
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 11:04 UTC (permalink / raw)
  To: dccp

On 11/19/2013 04:32 AM, wangweidong wrote:
> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
>> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>>> 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);
>>>
>>
>> Hmm, how did you spot this?
>>
>> Greetings,
>>
>>    Hannes
>>
>
> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
> will read the sk_v6_rcv_saddr, and the value is not true.

In SCTP code, "newsk->sk_v6_daddr = oldsk->sk_v6_daddr;" is redundant as it's already
done by "sctp_v6_to_sk_daddr(&asoc->peer.primary_addr, newsk);" for the primary path,
after we're doing the full copy of struct ipv6_pinfo to the new socket in
sctp_v6_create_accept_sk(). I've sent out an updated patch for SCTP.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19 11:04         ` Daniel Borkmann
  (?)
@ 2013-11-19 11:09           ` wangweidong
  -1 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19 11:09 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 2013/11/19 19:04, Daniel Borkmann wrote:
> On 11/19/2013 04:32 AM, wangweidong wrote:
>> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
>>> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>>>> 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);
>>>>
>>>
>>> Hmm, how did you spot this?
>>>
>>> Greetings,
>>>
>>>    Hannes
>>>
>>
>> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
>> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
>> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
>> will read the sk_v6_rcv_saddr, and the value is not true.
> 
> In SCTP code, "newsk->sk_v6_daddr = oldsk->sk_v6_daddr;" is redundant as it's already
> done by "sctp_v6_to_sk_daddr(&asoc->peer.primary_addr, newsk);" for the primary path,
> after we're doing the full copy of struct ipv6_pinfo to the new socket in
> sctp_v6_create_accept_sk(). I've sent out an updated patch for SCTP.
> 

Yeah, I had seen it. And I Acked-by it.
Thanks. 

> .
> 

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 11:09           ` wangweidong
  0 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19 11:09 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, vyasevich,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 2013/11/19 19:04, Daniel Borkmann wrote:
> On 11/19/2013 04:32 AM, wangweidong wrote:
>> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
>>> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>>>> 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);
>>>>
>>>
>>> Hmm, how did you spot this?
>>>
>>> Greetings,
>>>
>>>    Hannes
>>>
>>
>> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
>> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
>> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
>> will read the sk_v6_rcv_saddr, and the value is not true.
> 
> In SCTP code, "newsk->sk_v6_daddr = oldsk->sk_v6_daddr;" is redundant as it's already
> done by "sctp_v6_to_sk_daddr(&asoc->peer.primary_addr, newsk);" for the primary path,
> after we're doing the full copy of struct ipv6_pinfo to the new socket in
> sctp_v6_create_accept_sk(). I've sent out an updated patch for SCTP.
> 

Yeah, I had seen it. And I Acked-by it.
Thanks. 

> .
> 



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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 11:09           ` wangweidong
  0 siblings, 0 replies; 48+ messages in thread
From: wangweidong @ 2013-11-19 11:09 UTC (permalink / raw)
  To: dccp

On 2013/11/19 19:04, Daniel Borkmann wrote:
> On 11/19/2013 04:32 AM, wangweidong wrote:
>> On 2013/11/19 11:14, Hannes Frederic Sowa wrote:
>>> On Tue, Nov 19, 2013 at 10:47:27AM +0800, Wang Weidong wrote:
>>>> 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);
>>>>
>>>
>>> Hmm, how did you spot this?
>>>
>>> Greetings,
>>>
>>>    Hannes
>>>
>>
>> When I did the lksctp-tools(1.0.15)/src/func_tests/test_getname_v6, I got a Segmentation fault.
>> So I try to resolve it. I found the sctp_accept will call sctp_v6_create_accept_sk in IPV6,
>> the function will memcpy the ipv6_pinfo, and not copy the sk_v6_rcv_saddr. But the getsockname
>> will read the sk_v6_rcv_saddr, and the value is not true.
> 
> In SCTP code, "newsk->sk_v6_daddr = oldsk->sk_v6_daddr;" is redundant as it's already
> done by "sctp_v6_to_sk_daddr(&asoc->peer.primary_addr, newsk);" for the primary path,
> after we're doing the full copy of struct ipv6_pinfo to the new socket in
> sctp_v6_create_accept_sk(). I've sent out an updated patch for SCTP.
> 

Yeah, I had seen it. And I Acked-by it.
Thanks. 

> .
> 



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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19  4:00           ` Eric Dumazet
  (?)
@ 2013-11-19 11:35             ` Daniel Borkmann
  -1 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 11:35 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: wangweidong, davem, gerrit, kuznet, jmorris, yoshfuji, kaber,
	vyasevich, nhorman, dccp, netdev, linux-sctp, dingtianhong

On 11/19/2013 05:00 AM, Eric Dumazet wrote:
> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>
>> But sctp is not tcp ;)
>>
>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>> please fix it ;)
>>
>> No idea why it's not doing the normal copy of the socket.
>
> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> is broken for SCTP.

Yep, indeed. Looking into it ...

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 11:35             ` Daniel Borkmann
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 11:35 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: wangweidong, davem, gerrit, kuznet, jmorris, yoshfuji, kaber,
	vyasevich, nhorman, dccp, netdev, linux-sctp, dingtianhong

On 11/19/2013 05:00 AM, Eric Dumazet wrote:
> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>
>> But sctp is not tcp ;)
>>
>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>> please fix it ;)
>>
>> No idea why it's not doing the normal copy of the socket.
>
> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> is broken for SCTP.

Yep, indeed. Looking into it ...

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 11:35             ` Daniel Borkmann
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 11:35 UTC (permalink / raw)
  To: dccp

On 11/19/2013 05:00 AM, Eric Dumazet wrote:
> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>
>> But sctp is not tcp ;)
>>
>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>> please fix it ;)
>>
>> No idea why it's not doing the normal copy of the socket.
>
> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> is broken for SCTP.

Yep, indeed. Looking into it ...

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19 11:35             ` Daniel Borkmann
  (?)
@ 2013-11-19 14:23               ` Eric Dumazet
  -1 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19 14:23 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: wangweidong, davem, gerrit, kuznet, jmorris, yoshfuji, kaber,
	vyasevich, nhorman, dccp, netdev, linux-sctp, dingtianhong

On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
> > On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
> >
> >> But sctp is not tcp ;)
> >>
> >> sctp_copy_sock() is doing some clever/partial copy of the socket, so
> >> please fix it ;)
> >>
> >> No idea why it's not doing the normal copy of the socket.
> >
> > BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> > is broken for SCTP.
> 
> Yep, indeed. Looking into it ...

It might be the time to finally use inet_csk_clone_lock() in SCTP.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 14:23               ` Eric Dumazet
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19 14:23 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: wangweidong, davem, gerrit, kuznet, jmorris, yoshfuji, kaber,
	vyasevich, nhorman, dccp, netdev, linux-sctp, dingtianhong

On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
> > On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
> >
> >> But sctp is not tcp ;)
> >>
> >> sctp_copy_sock() is doing some clever/partial copy of the socket, so
> >> please fix it ;)
> >>
> >> No idea why it's not doing the normal copy of the socket.
> >
> > BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> > is broken for SCTP.
> 
> Yep, indeed. Looking into it ...

It might be the time to finally use inet_csk_clone_lock() in SCTP.




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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 14:23               ` Eric Dumazet
  0 siblings, 0 replies; 48+ messages in thread
From: Eric Dumazet @ 2013-11-19 14:23 UTC (permalink / raw)
  To: dccp

On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
> > On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
> >
> >> But sctp is not tcp ;)
> >>
> >> sctp_copy_sock() is doing some clever/partial copy of the socket, so
> >> please fix it ;)
> >>
> >> No idea why it's not doing the normal copy of the socket.
> >
> > BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
> > is broken for SCTP.
> 
> Yep, indeed. Looking into it ...

It might be the time to finally use inet_csk_clone_lock() in SCTP.




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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19 14:23               ` Eric Dumazet
  (?)
@ 2013-11-19 14:26                 ` Daniel Borkmann
  -1 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 14:26 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: wangweidong, davem, gerrit, kuznet, jmorris, yoshfuji, kaber,
	vyasevich, nhorman, dccp, netdev, linux-sctp, dingtianhong

On 11/19/2013 03:23 PM, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
>> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
>>> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>>>
>>>> But sctp is not tcp ;)
>>>>
>>>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>>>> please fix it ;)
>>>>
>>>> No idea why it's not doing the normal copy of the socket.
>>>
>>> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
>>> is broken for SCTP.
>>
>> Yep, indeed. Looking into it ...
>
> It might be the time to finally use inet_csk_clone_lock() in SCTP.

I agree, this would be a good consolidation. We should do that for net-next
if that's possible.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 14:26                 ` Daniel Borkmann
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 14:26 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: wangweidong, davem, gerrit, kuznet, jmorris, yoshfuji, kaber,
	vyasevich, nhorman, dccp, netdev, linux-sctp, dingtianhong

On 11/19/2013 03:23 PM, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
>> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
>>> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>>>
>>>> But sctp is not tcp ;)
>>>>
>>>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>>>> please fix it ;)
>>>>
>>>> No idea why it's not doing the normal copy of the socket.
>>>
>>> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
>>> is broken for SCTP.
>>
>> Yep, indeed. Looking into it ...
>
> It might be the time to finally use inet_csk_clone_lock() in SCTP.

I agree, this would be a good consolidation. We should do that for net-next
if that's possible.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 14:26                 ` Daniel Borkmann
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Borkmann @ 2013-11-19 14:26 UTC (permalink / raw)
  To: dccp

On 11/19/2013 03:23 PM, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
>> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
>>> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>>>
>>>> But sctp is not tcp ;)
>>>>
>>>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>>>> please fix it ;)
>>>>
>>>> No idea why it's not doing the normal copy of the socket.
>>>
>>> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
>>> is broken for SCTP.
>>
>> Yep, indeed. Looking into it ...
>
> It might be the time to finally use inet_csk_clone_lock() in SCTP.

I agree, this would be a good consolidation. We should do that for net-next
if that's possible.

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
  2013-11-19 14:23               ` Eric Dumazet
  (?)
@ 2013-11-19 15:25                 ` Vlad Yasevich
  -1 siblings, 0 replies; 48+ messages in thread
From: Vlad Yasevich @ 2013-11-19 15:25 UTC (permalink / raw)
  To: Eric Dumazet, Daniel Borkmann
  Cc: wangweidong, davem, gerrit, kuznet, jmorris, yoshfuji, kaber,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 11/19/2013 09:23 AM, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
>> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
>>> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>>>
>>>> But sctp is not tcp ;)
>>>>
>>>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>>>> please fix it ;)
>>>>
>>>> No idea why it's not doing the normal copy of the socket.
>>>
>>> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
>>> is broken for SCTP.
>>
>> Yep, indeed. Looking into it ...
> 
> It might be the time to finally use inet_csk_clone_lock() in SCTP.
> 
> 

I can see sk_clone_lock() since SCTP doesn't use icsk sockets.  Need
to study the code a bit.

-vlad

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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 15:25                 ` Vlad Yasevich
  0 siblings, 0 replies; 48+ messages in thread
From: Vlad Yasevich @ 2013-11-19 15:25 UTC (permalink / raw)
  To: Eric Dumazet, Daniel Borkmann
  Cc: wangweidong, davem, gerrit, kuznet, jmorris, yoshfuji, kaber,
	nhorman, dccp, netdev, linux-sctp, dingtianhong

On 11/19/2013 09:23 AM, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
>> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
>>> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>>>
>>>> But sctp is not tcp ;)
>>>>
>>>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>>>> please fix it ;)
>>>>
>>>> No idea why it's not doing the normal copy of the socket.
>>>
>>> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
>>> is broken for SCTP.
>>
>> Yep, indeed. Looking into it ...
> 
> It might be the time to finally use inet_csk_clone_lock() in SCTP.
> 
> 

I can see sk_clone_lock() since SCTP doesn't use icsk sockets.  Need
to study the code a bit.

-vlad


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

* Re: [PATCH 2/2] ipv6: use sk_v6_copy_addrs when memcpy struct ipv6_pinfo
@ 2013-11-19 15:25                 ` Vlad Yasevich
  0 siblings, 0 replies; 48+ messages in thread
From: Vlad Yasevich @ 2013-11-19 15:25 UTC (permalink / raw)
  To: dccp

On 11/19/2013 09:23 AM, Eric Dumazet wrote:
> On Tue, 2013-11-19 at 12:35 +0100, Daniel Borkmann wrote:
>> On 11/19/2013 05:00 AM, Eric Dumazet wrote:
>>> On Mon, 2013-11-18 at 19:58 -0800, Eric Dumazet wrote:
>>>
>>>> But sctp is not tcp ;)
>>>>
>>>> sctp_copy_sock() is doing some clever/partial copy of the socket, so
>>>> please fix it ;)
>>>>
>>>> No idea why it's not doing the normal copy of the socket.
>>>
>>> BTW, not doing the full copy means for example that SO_MAX_PACING_RATE
>>> is broken for SCTP.
>>
>> Yep, indeed. Looking into it ...
> 
> It might be the time to finally use inet_csk_clone_lock() in SCTP.
> 
> 

I can see sk_clone_lock() since SCTP doesn't use icsk sockets.  Need
to study the code a bit.

-vlad


^ 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 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
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 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: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:44           ` wangweidong
2013-11-19  4:44             ` wangweidong
2013-11-19  4:44             ` 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
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  3:55   ` Eric Dumazet
2013-11-19  3:55     ` Eric Dumazet
2013-11-19  3:55     ` Eric Dumazet
2013-11-19  4:38     ` wangweidong
2013-11-19  4:38       ` wangweidong
2013-11-19  4:38       ` wangweidong

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.