linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sctp: delete addr based on sin6_scope_id
@ 2021-07-25 12:43 Chen Shen
  2021-07-25 23:01 ` Marcelo Ricardo Leitner
  0 siblings, 1 reply; 4+ messages in thread
From: Chen Shen @ 2021-07-25 12:43 UTC (permalink / raw)
  To: vyasevich, nhorman, marcelo.leitner, davem
  Cc: linux-sctp, netdev, linux-kernel, Chen Shen

sctp_inet6addr_event deletes 'addr' from 'local_addr_list' when setting
netdev down, but it has possibility to delete the incorroct entry (match
the first one with the same ipaddr, but the different 'ifindex'), if
there are some netdevs with the same 'local-link' ipaddr added already.
It should delete the entry depending on 'sin6_addr' and 'sin6_scope_id'
both, otherwise, the endpoint will call 'sctp_sf_ootb' if it can't find
the accroding association when receives 'heartbeat', and finally will
reply 'abort' which causes the test case for NOKIA SYSCOM GW failed.

For example:
1.when linux startup
the entries in local_addr_list:
ifindex:35 addr:fe80::40:43ff:fe80:0 (eths0.201)
ifindex:36 addr:fe80::40:43ff:fe80:0 (eths0.209)
ifindex:37 addr:fe80::40:43ff:fe80:0 (eths0.210)

the route table:
local fe80::40:43ff:fe80:0 dev eths0.201
local fe80::40:43ff:fe80:0 dev eths0.209
local fe80::40:43ff:fe80:0 dev eths0.210

2.after 'ifconfig eths0.209 down'
the entries in local_addr_list:
ifindex:36 addr:fe80::40:43ff:fe80:0 (eths0.209)
ifindex:37 addr:fe80::40:43ff:fe80:0 (eths0.210)

the route table:
local fe80::40:43ff:fe80:0 dev eths0.201
local fe80::40:43ff:fe80:0 dev eths0.210

3.asoc not found for src:[fe80::40:43ff:fe80:0]:37381 dst:[:1]:53335
::1->fe80::40:43ff:fe80:0 HEARTBEAT
fe80::40:43ff:fe80:0->::1 ABORT

Change-Id: I9fd4745a9a95489c62571c2764d37259c0209eff
Signed-off-by: Chen Shen <peterchenshen@gmail.com>
---
 net/sctp/ipv6.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 52c92b8d827f..66ebf1e3383d 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -100,7 +100,9 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
 					&net->sctp.local_addr_list, list) {
 			if (addr->a.sa.sa_family == AF_INET6 &&
 					ipv6_addr_equal(&addr->a.v6.sin6_addr,
-						&ifa->addr)) {
+						&ifa->addr) &&
+					addr->a.v6.sin6_scope_id ==
+						ifa->idev->dev->ifindex) {
 				sctp_addr_wq_mgmt(net, addr, SCTP_ADDR_DEL);
 				found = 1;
 				addr->valid = 0;
-- 
2.19.0


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

* Re: [PATCH] sctp: delete addr based on sin6_scope_id
  2021-07-25 12:43 [PATCH] sctp: delete addr based on sin6_scope_id Chen Shen
@ 2021-07-25 23:01 ` Marcelo Ricardo Leitner
  2021-07-26  5:47   ` [PATCH v2] " Chen Shen
  0 siblings, 1 reply; 4+ messages in thread
From: Marcelo Ricardo Leitner @ 2021-07-25 23:01 UTC (permalink / raw)
  To: Chen Shen; +Cc: vyasevich, nhorman, davem, linux-sctp, netdev, linux-kernel

Hi,

The fix is right, but a couple of small changes:

On Sun, Jul 25, 2021 at 08:43:39PM +0800, Chen Shen wrote:
> sctp_inet6addr_event deletes 'addr' from 'local_addr_list' when setting
> netdev down, but it has possibility to delete the incorroct entry (match
                                                          ^ typo

> the first one with the same ipaddr, but the different 'ifindex'), if
> there are some netdevs with the same 'local-link' ipaddr added already.
> It should delete the entry depending on 'sin6_addr' and 'sin6_scope_id'
> both, otherwise, the endpoint will call 'sctp_sf_ootb' if it can't find
> the accroding association when receives 'heartbeat', and finally will
         ^^ typo

> reply 'abort' which causes the test case for NOKIA SYSCOM GW failed.
> 
...
> diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
> index 52c92b8d827f..66ebf1e3383d 100644
> --- a/net/sctp/ipv6.c
> +++ b/net/sctp/ipv6.c
> @@ -100,7 +100,9 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
>  					&net->sctp.local_addr_list, list) {
>  			if (addr->a.sa.sa_family == AF_INET6 &&
>  					ipv6_addr_equal(&addr->a.v6.sin6_addr,
> -						&ifa->addr)) {
> +						&ifa->addr) &&
> +					addr->a.v6.sin6_scope_id ==
> +						ifa->idev->dev->ifindex) {

The indentation here is not right. It was wrong already, but lets
seize the moment and fix it. This is how it should look like:

 			if (addr->a.sa.sa_family == AF_INET6 &&
 			    ipv6_addr_equal(&addr->a.v6.sin6_addr,
					    &ifa->addr) &&
			    addr->a.v6.sin6_scope_id ==	ifa->idev->dev->ifindex) {

Thanks,
Marcelo

>  				sctp_addr_wq_mgmt(net, addr, SCTP_ADDR_DEL);
>  				found = 1;
>  				addr->valid = 0;
> -- 
> 2.19.0
> 

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

* [PATCH v2] sctp: delete addr based on sin6_scope_id
  2021-07-25 23:01 ` Marcelo Ricardo Leitner
@ 2021-07-26  5:47   ` Chen Shen
  2021-07-26 11:40     ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 4+ messages in thread
From: Chen Shen @ 2021-07-26  5:47 UTC (permalink / raw)
  To: marcelo.leitner
  Cc: vyasevich, nhorman, davem, linux-sctp, netdev, linux-kernel, Chen Shen

sctp_inet6addr_event deletes 'addr' from 'local_addr_list' when setting
netdev down, but it is possible to delete the incorrect entry (match
the first one with the same ipaddr, but the different 'ifindex'), if
there are some netdevs with the same 'local-link' ipaddr added already.
It should delete the entry depending on 'sin6_addr' and 'sin6_scope_id'
both. otherwise, the endpoint will call 'sctp_sf_ootb' if it can't find
the according association when receives 'heartbeat', and finally will
reply 'abort'.

For example:
1.when linux startup
the entries in local_addr_list:
ifindex:35 addr:fe80::40:43ff:fe80:0 (eths0.201)
ifindex:36 addr:fe80::40:43ff:fe80:0 (eths0.209)
ifindex:37 addr:fe80::40:43ff:fe80:0 (eths0.210)

the route table:
local fe80::40:43ff:fe80:0 dev eths0.201
local fe80::40:43ff:fe80:0 dev eths0.209
local fe80::40:43ff:fe80:0 dev eths0.210

2.after 'ifconfig eths0.209 down'
the entries in local_addr_list:
ifindex:36 addr:fe80::40:43ff:fe80:0 (eths0.209)
ifindex:37 addr:fe80::40:43ff:fe80:0 (eths0.210)

the route table:
local fe80::40:43ff:fe80:0 dev eths0.201
local fe80::40:43ff:fe80:0 dev eths0.210

3.asoc not found for src:[fe80::40:43ff:fe80:0]:37381 dst:[:1]:53335
::1->fe80::40:43ff:fe80:0 HEARTBEAT
fe80::40:43ff:fe80:0->::1 ABORT

Signed-off-by: Chen Shen <peterchenshen@gmail.com>
---
 net/sctp/ipv6.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 52c92b8d827f..f5f54229b055 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -99,8 +99,9 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
 		list_for_each_entry_safe(addr, temp,
 					&net->sctp.local_addr_list, list) {
 			if (addr->a.sa.sa_family == AF_INET6 &&
-					ipv6_addr_equal(&addr->a.v6.sin6_addr,
-						&ifa->addr)) {
+			    ipv6_addr_equal(&addr->a.v6.sin6_addr,
+					    &ifa->addr) &&
+			    addr->a.v6.sin6_scope_id == ifa->idev->dev->ifindex) {
 				sctp_addr_wq_mgmt(net, addr, SCTP_ADDR_DEL);
 				found = 1;
 				addr->valid = 0;
-- 
2.19.0


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

* Re: [PATCH v2] sctp: delete addr based on sin6_scope_id
  2021-07-26  5:47   ` [PATCH v2] " Chen Shen
@ 2021-07-26 11:40     ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-26 11:40 UTC (permalink / raw)
  To: Chen Shen
  Cc: marcelo.leitner, vyasevich, nhorman, davem, linux-sctp, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Mon, 26 Jul 2021 13:47:34 +0800 you wrote:
> sctp_inet6addr_event deletes 'addr' from 'local_addr_list' when setting
> netdev down, but it is possible to delete the incorrect entry (match
> the first one with the same ipaddr, but the different 'ifindex'), if
> there are some netdevs with the same 'local-link' ipaddr added already.
> It should delete the entry depending on 'sin6_addr' and 'sin6_scope_id'
> both. otherwise, the endpoint will call 'sctp_sf_ootb' if it can't find
> the according association when receives 'heartbeat', and finally will
> reply 'abort'.
> 
> [...]

Here is the summary with links:
  - [v2] sctp: delete addr based on sin6_scope_id
    https://git.kernel.org/netdev/net/c/2ebda0271483

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-07-26 11:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-25 12:43 [PATCH] sctp: delete addr based on sin6_scope_id Chen Shen
2021-07-25 23:01 ` Marcelo Ricardo Leitner
2021-07-26  5:47   ` [PATCH v2] " Chen Shen
2021-07-26 11:40     ` patchwork-bot+netdevbpf

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).