Netdev Archive on lore.kernel.org
 help / Atom feed
* [PATCH] net: fix IPv6 prefix route residue
@ 2019-02-03  6:10 Zhiqiang Liu
  2019-02-03 17:04 ` David Miller
  2019-02-11  2:57 ` [PATCH v2] " Zhiqiang Liu
  0 siblings, 2 replies; 7+ messages in thread
From: Zhiqiang Liu @ 2019-02-03  6:10 UTC (permalink / raw)
  To: davem, kuznet, yoshfuji, 0xeffeff, edumazet
  Cc: netdev, mingfangsen, zhangwenhao8, wangxiaogang3, zhoukang7

From: Zhiqiang Liu <liuzhiqiang26@huawei.com>

Follow those steps:
 # ip addr add 2001:123::1/32 dev eth0
 # ip addr add 2001:123:456::2/64 dev eth0
 # ip addr del 2001:123::1/32 dev eth0
 # ip addr del 2001:123:456::2/64 dev eth0
and then prefix route of 2001:123::1/32 will still exist.

This is because ipv6_prefix_equal in check_cleanup_prefix_route
func does not check whether two IPv6 addresses have the same
prefix length. If the prefix of one address starts with another
shorter address prefix, even through their prefix lengths are
different, the return value of ipv6_prefix_equal is true.

Here I add a check of whether two addresses have the same prefix
to decide whether their prefixes are equal.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reported-by: Wenhao Zhang <zhangwenhao8@huawei.com>
---
 net/ipv6/addrconf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 84c3588..5742443 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1165,7 +1165,8 @@ enum cleanup_prefix_rt_t {
 	list_for_each_entry(ifa, &idev->addr_list, if_list) {
 		if (ifa == ifp)
 			continue;
-		if (!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
+		if (ifa->prefix_len != ifp->prefix_len ||
+			!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
 				       ifp->prefix_len))
 			continue;
 		if (ifa->flags & (IFA_F_PERMANENT | IFA_F_NOPREFIXROUTE))
-- 
1.8.3.1


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

* Re: [PATCH] net: fix IPv6 prefix route residue
  2019-02-03  6:10 [PATCH] net: fix IPv6 prefix route residue Zhiqiang Liu
@ 2019-02-03 17:04 ` David Miller
  2019-02-05  3:21   ` David Ahern
  2019-02-11  2:57 ` [PATCH v2] " Zhiqiang Liu
  1 sibling, 1 reply; 7+ messages in thread
From: David Miller @ 2019-02-03 17:04 UTC (permalink / raw)
  To: liuzhiqiang26
  Cc: kuznet, yoshfuji, 0xeffeff, edumazet, netdev, mingfangsen,
	zhangwenhao8, wangxiaogang3, zhoukang7

From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Date: Sun, 3 Feb 2019 14:10:31 +0800

> @@ -1165,7 +1165,8 @@ enum cleanup_prefix_rt_t {
>  	list_for_each_entry(ifa, &idev->addr_list, if_list) {
>  		if (ifa == ifp)
>  			continue;
> -		if (!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
> +		if (ifa->prefix_len != ifp->prefix_len ||
> +			!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
>  				       ifp->prefix_len))

Please fix the indentation of this conditional, it should be:

		if (ifa->prefix_len != ifp->prefix_len ||
		    !ipv6_prefix_equal(&ifa->addr, &ifp->addr,
				       ifp->prefix_len))

Thank you.

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

* Re: [PATCH] net: fix IPv6 prefix route residue
  2019-02-03 17:04 ` David Miller
@ 2019-02-05  3:21   ` David Ahern
  2019-02-11  2:36     ` Zhiqiang Liu
  0 siblings, 1 reply; 7+ messages in thread
From: David Ahern @ 2019-02-05  3:21 UTC (permalink / raw)
  To: David Miller, liuzhiqiang26
  Cc: kuznet, yoshfuji, 0xeffeff, edumazet, netdev, mingfangsen,
	zhangwenhao8, wangxiaogang3, zhoukang7

On 2/3/19 9:04 AM, David Miller wrote:
> From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Date: Sun, 3 Feb 2019 14:10:31 +0800
> 
>> @@ -1165,7 +1165,8 @@ enum cleanup_prefix_rt_t {
>>  	list_for_each_entry(ifa, &idev->addr_list, if_list) {
>>  		if (ifa == ifp)
>>  			continue;
>> -		if (!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
>> +		if (ifa->prefix_len != ifp->prefix_len ||
>> +			!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
>>  				       ifp->prefix_len))
> 
> Please fix the indentation of this conditional, it should be:
> 
> 		if (ifa->prefix_len != ifp->prefix_len ||
> 		    !ipv6_prefix_equal(&ifa->addr, &ifp->addr,
> 				       ifp->prefix_len))
> 
> Thank you.
> 

Needs a Fixes tag too.

Fixes: 5b84efecb7d9 ("ipv6 addrconf: don't cleanup prefix route for
IFA_F_NOPREFIXROUTE")

and cc to that author Thomas Haller <thaller@redhat.com>

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

* Re: [PATCH] net: fix IPv6 prefix route residue
  2019-02-05  3:21   ` David Ahern
@ 2019-02-11  2:36     ` Zhiqiang Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Zhiqiang Liu @ 2019-02-11  2:36 UTC (permalink / raw)
  To: David Ahern, David Miller
  Cc: thaller, yoshfuji, 0xeffeff, edumazet, netdev, mingfangsen,
	zhangwenhao8, wangxiaogang3, zhoukang7, kuznet

> On 2/3/19 9:04 AM, David Miller wrote:
>> From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> Date: Sun, 3 Feb 2019 14:10:31 +0800
>>
>>> @@ -1165,7 +1165,8 @@ enum cleanup_prefix_rt_t {
>>>  	list_for_each_entry(ifa, &idev->addr_list, if_list) {
>>>  		if (ifa == ifp)
>>>  			continue;
>>> -		if (!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
>>> +		if (ifa->prefix_len != ifp->prefix_len ||
>>> +			!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
>>>  				       ifp->prefix_len))
>>
>> Please fix the indentation of this conditional, it should be:
>>
>> 		if (ifa->prefix_len != ifp->prefix_len ||
>> 		    !ipv6_prefix_equal(&ifa->addr, &ifp->addr,
>> 				       ifp->prefix_len))
>>
>> Thank you.
Thank you for your suggestion. I have fixed the indentation of the
conditional. In addition, I have used the checkpatch.pl script to check the
patch.
>>
> 
> Needs a Fixes tag too.
> 
> Fixes: 5b84efecb7d9 ("ipv6 addrconf: don't cleanup prefix route for
> IFA_F_NOPREFIXROUTE")
> 
> and cc to that author Thomas Haller <thaller@redhat.com>
> 
> .
> 
Thank you. The Fixes tag is added in the v2 patch.







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

* [PATCH v2] net: fix IPv6 prefix route residue
  2019-02-03  6:10 [PATCH] net: fix IPv6 prefix route residue Zhiqiang Liu
  2019-02-03 17:04 ` David Miller
@ 2019-02-11  2:57 ` " Zhiqiang Liu
  2019-02-12  4:38   ` David Miller
  1 sibling, 1 reply; 7+ messages in thread
From: Zhiqiang Liu @ 2019-02-11  2:57 UTC (permalink / raw)
  To: davem, kuznet, yoshfuji, 0xeffeff, edumazet
  Cc: netdev, mingfangsen, zhangwenhao8, wangxiaogang3, zhoukang7,
	dsahern, thaller, maowenan

From: Zhiqiang Liu <liuzhiqiang26@huawei.com>

Follow those steps:
 # ip addr add 2001:123::1/32 dev eth0
 # ip addr add 2001:123:456::2/64 dev eth0
 # ip addr del 2001:123::1/32 dev eth0
 # ip addr del 2001:123:456::2/64 dev eth0
and then prefix route of 2001:123::1/32 will still exist.

This is because ipv6_prefix_equal in check_cleanup_prefix_route
func does not check whether two IPv6 addresses have the same
prefix length. If the prefix of one address starts with another
shorter address prefix, even though their prefix lengths are
different, the return value of ipv6_prefix_equal is true.

Here I add a check of whether two addresses have the same prefix
to decide whether their prefixes are equal.

Fixes: 5b84efecb7d9 ("ipv6 addrconf: don't cleanup prefix route
for IFA_F_NOPREFIXROUTE")
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reported-by: Wenhao Zhang <zhangwenhao8@huawei.com>
---
V1->V2:
- fix the indentation of the condition
- add Fixes tag

 net/ipv6/addrconf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 84c3588..72ffd3d 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1165,7 +1165,8 @@ enum cleanup_prefix_rt_t {
 	list_for_each_entry(ifa, &idev->addr_list, if_list) {
 		if (ifa == ifp)
 			continue;
-		if (!ipv6_prefix_equal(&ifa->addr, &ifp->addr,
+		if (ifa->prefix_len != ifp->prefix_len ||
+		    !ipv6_prefix_equal(&ifa->addr, &ifp->addr,
 				       ifp->prefix_len))
 			continue;
 		if (ifa->flags & (IFA_F_PERMANENT | IFA_F_NOPREFIXROUTE))
-- 
1.8.3.1




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

* Re: [PATCH v2] net: fix IPv6 prefix route residue
  2019-02-11  2:57 ` [PATCH v2] " Zhiqiang Liu
@ 2019-02-12  4:38   ` David Miller
  2019-02-12  7:43     ` Zhiqiang Liu
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2019-02-12  4:38 UTC (permalink / raw)
  To: liuzhiqiang26
  Cc: kuznet, yoshfuji, 0xeffeff, edumazet, netdev, mingfangsen,
	zhangwenhao8, wangxiaogang3, zhoukang7, dsahern, thaller,
	maowenan

From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Date: Mon, 11 Feb 2019 10:57:46 +0800

> From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> 
> Follow those steps:
>  # ip addr add 2001:123::1/32 dev eth0
>  # ip addr add 2001:123:456::2/64 dev eth0
>  # ip addr del 2001:123::1/32 dev eth0
>  # ip addr del 2001:123:456::2/64 dev eth0
> and then prefix route of 2001:123::1/32 will still exist.
> 
> This is because ipv6_prefix_equal in check_cleanup_prefix_route
> func does not check whether two IPv6 addresses have the same
> prefix length. If the prefix of one address starts with another
> shorter address prefix, even though their prefix lengths are
> different, the return value of ipv6_prefix_equal is true.
> 
> Here I add a check of whether two addresses have the same prefix
> to decide whether their prefixes are equal.
> 
> Fixes: 5b84efecb7d9 ("ipv6 addrconf: don't cleanup prefix route
> for IFA_F_NOPREFIXROUTE")
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Reported-by: Wenhao Zhang <zhangwenhao8@huawei.com>

Applied and queued up for -stable.

Please do not split up long Fixes: tag lines, keep the entire tag on
one line only.

I fixed it up for you this time.

Thanks.

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

* Re: [PATCH v2] net: fix IPv6 prefix route residue
  2019-02-12  4:38   ` David Miller
@ 2019-02-12  7:43     ` Zhiqiang Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Zhiqiang Liu @ 2019-02-12  7:43 UTC (permalink / raw)
  To: David Miller
  Cc: kuznet, yoshfuji, 0xeffeff, edumazet, netdev, mingfangsen,
	zhangwenhao8, wangxiaogang3, zhoukang7, dsahern, thaller,
	maowenan

> From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Date: Mon, 11 Feb 2019 10:57:46 +0800
> 
>> From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>>
>> Follow those steps:
>>  # ip addr add 2001:123::1/32 dev eth0
>>  # ip addr add 2001:123:456::2/64 dev eth0
>>  # ip addr del 2001:123::1/32 dev eth0
>>  # ip addr del 2001:123:456::2/64 dev eth0
>> and then prefix route of 2001:123::1/32 will still exist.
>>
>> This is because ipv6_prefix_equal in check_cleanup_prefix_route
>> func does not check whether two IPv6 addresses have the same
>> prefix length. If the prefix of one address starts with another
>> shorter address prefix, even though their prefix lengths are
>> different, the return value of ipv6_prefix_equal is true.
>>
>> Here I add a check of whether two addresses have the same prefix
>> to decide whether their prefixes are equal.
>>
>> Fixes: 5b84efecb7d9 ("ipv6 addrconf: don't cleanup prefix route
>> for IFA_F_NOPREFIXROUTE")
>> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> Reported-by: Wenhao Zhang <zhangwenhao8@huawei.com>
> 
> Applied and queued up for -stable.Thank you for applying the patch.
> 
> Please do not split up long Fixes: tag lines, keep the entire tag on
> one line only.
> 
> I fixed it up for you this time.
> 
> Thanks.
This is the first patch in my life. Thank you and David Ahern again.


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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-03  6:10 [PATCH] net: fix IPv6 prefix route residue Zhiqiang Liu
2019-02-03 17:04 ` David Miller
2019-02-05  3:21   ` David Ahern
2019-02-11  2:36     ` Zhiqiang Liu
2019-02-11  2:57 ` [PATCH v2] " Zhiqiang Liu
2019-02-12  4:38   ` David Miller
2019-02-12  7:43     ` Zhiqiang Liu

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org netdev@archiver.kernel.org
	public-inbox-index netdev


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox