netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv6: do not add link-local address if one already exists
@ 2014-08-10 19:56 Roy Marples
  2014-08-10 20:37 ` Hannes Frederic Sowa
  2014-08-11  0:27 ` YOSHIFUJI Hideaki
  0 siblings, 2 replies; 7+ messages in thread
From: Roy Marples @ 2014-08-10 19:56 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller" <davem@davemloft.net>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	Patrick McHardy

[-- Attachment #1: Type: text/plain, Size: 510 bytes --]

Hi

Currently the kernel will always add an IPv6 link-local address
based on the hardware address when the interface is brought up.
This is probably based on the assumption that userland would
never add one before the interface is brought up.

However, one at least one userland application (dhcpcd) does this so
it can implement RFC7217 which can be used for link-local addresses
as well.

Attached is a patch which checks to see if a link-local address exists
before indiscriminately adding one.

Thanks

Roy

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: linux-ipv6-onelladdr.diff --]
[-- Type: text/x-diff; name=linux-ipv6-onelladdr.diff, Size: 598 bytes --]

This allows userland to set a possibly different link-local address
like say one based on RFC7217.

Signed-off-by: Roy Marples <roy@marples.name>

--- net/ipv6/addrconf.c.orig	2014-08-10 19:39:50.377073417 +0000
+++ net/ipv6/addrconf.c	2014-08-10 20:19:03.139002051 +0000
@@ -2751,6 +2751,11 @@ static void addrconf_dev_config(struct n
 	if (IS_ERR(idev))
 		return;
 
+	/* If we already have a link-local address, don't bother
+	 * adding a new one. */
+	if (ipv6_get_lladdr(dev, &addr, 0) == 0)
+		return;
+
 	memset(&addr, 0, sizeof(struct in6_addr));
 	addr.s6_addr32[0] = htonl(0xFE800000);
 

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

* Re: [PATCH] ipv6: do not add link-local address if one already exists
  2014-08-10 19:56 [PATCH] ipv6: do not add link-local address if one already exists Roy Marples
@ 2014-08-10 20:37 ` Hannes Frederic Sowa
  2014-08-11  0:05   ` Roy Marples
  2014-08-11  0:27 ` YOSHIFUJI Hideaki
  1 sibling, 1 reply; 7+ messages in thread
From: Hannes Frederic Sowa @ 2014-08-10 20:37 UTC (permalink / raw)
  To: Roy Marples
  Cc: netdev, David S. Miller" <davem@davemloft.net>,
	Alexey Kuznetsov  <kuznet@ms2.inr.ac.ru>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	 Patrick McHardy

Hi,

On So, 2014-08-10 at 19:56 +0000, Roy Marples wrote:
> Currently the kernel will always add an IPv6 link-local address
> based on the hardware address when the interface is brought up.
> This is probably based on the assumption that userland would
> never add one before the interface is brought up.
> 
> However, one at least one userland application (dhcpcd) does this so
> it can implement RFC7217 which can be used for link-local addresses
> as well.
> 
> Attached is a patch which checks to see if a link-local address exists
> before indiscriminately adding one.

Please have a look at:
https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=bc91b0f07ada5535427373a4e2050877bcc12218

This was recently implemented just for this specific case.

Bye,
Hannes

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

* Re: [PATCH] ipv6: do not add link-local address if one already exists
  2014-08-10 20:37 ` Hannes Frederic Sowa
@ 2014-08-11  0:05   ` Roy Marples
  2014-08-11  0:11     ` Hannes Frederic Sowa
  0 siblings, 1 reply; 7+ messages in thread
From: Roy Marples @ 2014-08-11  0:05 UTC (permalink / raw)
  To: Hannes Frederic Sowa
  Cc: netdev, "David S. Miller\, Alexey Kuznetsov "",
	Hideaki YOSHIFUJI, "Patrick, McHardy,
	 <kaber@trash.net>

Hi

On 2014-08-10 20:37, Hannes Frederic Sowa wrote:
> On So, 2014-08-10 at 19:56 +0000, Roy Marples wrote:
>> Currently the kernel will always add an IPv6 link-local address
>> based on the hardware address when the interface is brought up.
>> This is probably based on the assumption that userland would
>> never add one before the interface is brought up.
>> 
>> However, one at least one userland application (dhcpcd) does this so
>> it can implement RFC7217 which can be used for link-local addresses
>> as well.
>> 
>> Attached is a patch which checks to see if a link-local address exists
>> before indiscriminately adding one.
> 
> Please have a look at:
> https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=bc91b0f07ada5535427373a4e2050877bcc12218
> 
> This was recently implemented just for this specific case.

Is that tunable available in /proc or /sys?
I'm not overly keen on adding a netlink call just for that in dhcpcd, it 
would be a lot of bloat compared to the kernel patch.

Roy

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

* Re: [PATCH] ipv6: do not add link-local address if one already exists
  2014-08-11  0:05   ` Roy Marples
@ 2014-08-11  0:11     ` Hannes Frederic Sowa
  2014-08-11 21:22       ` Roy Marples
  0 siblings, 1 reply; 7+ messages in thread
From: Hannes Frederic Sowa @ 2014-08-11  0:11 UTC (permalink / raw)
  To: Roy Marples
  Cc: netdev, "David S. Miller\, Alexey Kuznetsov "",
	Hideaki YOSHIFUJI, Patrick, McHardy, kaber

On Mo, 2014-08-11 at 00:05 +0000, Roy Marples wrote:
> Hi
> 
> On 2014-08-10 20:37, Hannes Frederic Sowa wrote:
> > On So, 2014-08-10 at 19:56 +0000, Roy Marples wrote:
> >> Currently the kernel will always add an IPv6 link-local address
> >> based on the hardware address when the interface is brought up.
> >> This is probably based on the assumption that userland would
> >> never add one before the interface is brought up.
> >> 
> >> However, one at least one userland application (dhcpcd) does this so
> >> it can implement RFC7217 which can be used for link-local addresses
> >> as well.
> >> 
> >> Attached is a patch which checks to see if a link-local address exists
> >> before indiscriminately adding one.
> > 
> > Please have a look at:
> > https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=bc91b0f07ada5535427373a4e2050877bcc12218
> > 
> > This was recently implemented just for this specific case.
> 
> Is that tunable available in /proc or /sys?
> I'm not overly keen on adding a netlink call just for that in dhcpcd, it 
> would be a lot of bloat compared to the kernel patch.

Can you call iproute via a script? Would that fit your needs?
https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/commit/?h=net-next&id=ff7c20844049be836c10087cb2418b99ff36ca2b

Bye,
Hannes

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

* Re: [PATCH] ipv6: do not add link-local address if one already exists
  2014-08-10 19:56 [PATCH] ipv6: do not add link-local address if one already exists Roy Marples
  2014-08-10 20:37 ` Hannes Frederic Sowa
@ 2014-08-11  0:27 ` YOSHIFUJI Hideaki
  1 sibling, 0 replies; 7+ messages in thread
From: YOSHIFUJI Hideaki @ 2014-08-11  0:27 UTC (permalink / raw)
  To: Roy Marples, netdev
  Cc: hideaki.yoshifuji, David S. Miller",
	Alexey Kuznetsov, Hideaki YOSHIFUJI, Patrick McHardy

Hello.

Roy Marples wrote:
> Hi
>
> Currently the kernel will always add an IPv6 link-local address
> based on the hardware address when the interface is brought up.
> This is probably based on the assumption that userland would
> never add one before the interface is brought up.
>
> However, one at least one userland application (dhcpcd) does this so
> it can implement RFC7217 which can be used for link-local addresses
> as well.
>
> Attached is a patch which checks to see if a link-local address exists
> before indiscriminately adding one.

Well, I think this is incomplete, for example, we will continue generating
global address from eui64.

I think we should implement such functionality through "if token" bits.

--yoshfuji

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

* Re: [PATCH] ipv6: do not add link-local address if one already exists
  2014-08-11  0:11     ` Hannes Frederic Sowa
@ 2014-08-11 21:22       ` Roy Marples
  2014-08-13 17:10         ` Jiri Pirko
  0 siblings, 1 reply; 7+ messages in thread
From: Roy Marples @ 2014-08-11 21:22 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: netdev

Hi

On 2014-08-11 01:11, Hannes Frederic Sowa wrote:
> On Mo, 2014-08-11 at 00:05 +0000, Roy Marples wrote:
>> On 2014-08-10 20:37, Hannes Frederic Sowa wrote:
>> > On So, 2014-08-10 at 19:56 +0000, Roy Marples wrote:
>> >> Currently the kernel will always add an IPv6 link-local address
>> >> based on the hardware address when the interface is brought up.
>> >> This is probably based on the assumption that userland would
>> >> never add one before the interface is brought up.
>> >>
>> >> However, one at least one userland application (dhcpcd) does this so
>> >> it can implement RFC7217 which can be used for link-local addresses
>> >> as well.
>> >>
>> >> Attached is a patch which checks to see if a link-local address exists
>> >> before indiscriminately adding one.
>> >
>> > Please have a look at:
>> > https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=bc91b0f07ada5535427373a4e2050877bcc12218
>> >
>> > This was recently implemented just for this specific case.
>> 
>> Is that tunable available in /proc or /sys?
>> I'm not overly keen on adding a netlink call just for that in dhcpcd, 
>> it
>> would be a lot of bloat compared to the kernel patch.
> 
> Can you call iproute via a script? Would that fit your needs?
> https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/commit/?h=net-next&id=ff7c20844049be836c10087cb2418b99ff36ca2b

Not really as there is no guarantee iproute2 is installed on the host.
For now, I've added a netlink call at the expense of around 400 bytes.

Thanks

Roy

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

* Re: [PATCH] ipv6: do not add link-local address if one already exists
  2014-08-11 21:22       ` Roy Marples
@ 2014-08-13 17:10         ` Jiri Pirko
  0 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2014-08-13 17:10 UTC (permalink / raw)
  To: Roy Marples; +Cc: Hannes Frederic Sowa, netdev

Mon, Aug 11, 2014 at 11:22:04PM CEST, roy@marples.name wrote:
>Hi
>
>On 2014-08-11 01:11, Hannes Frederic Sowa wrote:
>>On Mo, 2014-08-11 at 00:05 +0000, Roy Marples wrote:
>>>On 2014-08-10 20:37, Hannes Frederic Sowa wrote:
>>>> On So, 2014-08-10 at 19:56 +0000, Roy Marples wrote:
>>>>> Currently the kernel will always add an IPv6 link-local address
>>>>> based on the hardware address when the interface is brought up.
>>>>> This is probably based on the assumption that userland would
>>>>> never add one before the interface is brought up.
>>>>>
>>>>> However, one at least one userland application (dhcpcd) does this so
>>>>> it can implement RFC7217 which can be used for link-local addresses
>>>>> as well.
>>>>>
>>>>> Attached is a patch which checks to see if a link-local address exists
>>>>> before indiscriminately adding one.
>>>>
>>>> Please have a look at:
>>>> https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=bc91b0f07ada5535427373a4e2050877bcc12218
>>>>
>>>> This was recently implemented just for this specific case.
>>>
>>>Is that tunable available in /proc or /sys?
>>>I'm not overly keen on adding a netlink call just for that in dhcpcd, it
>>>would be a lot of bloat compared to the kernel patch.
>>
>>Can you call iproute via a script? Would that fit your needs?
>>https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/commit/?h=net-next&id=ff7c20844049be836c10087cb2418b99ff36ca2b
>
>Not really as there is no guarantee iproute2 is installed on the host.
>For now, I've added a netlink call at the expense of around 400 bytes.

The iface to idev->addr_gen_mode can be certainly added to sysfs. Feel
free to do so.


>
>Thanks
>
>Roy
>--
>To unsubscribe from this list: send the line "unsubscribe netdev" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-08-13 17:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-10 19:56 [PATCH] ipv6: do not add link-local address if one already exists Roy Marples
2014-08-10 20:37 ` Hannes Frederic Sowa
2014-08-11  0:05   ` Roy Marples
2014-08-11  0:11     ` Hannes Frederic Sowa
2014-08-11 21:22       ` Roy Marples
2014-08-13 17:10         ` Jiri Pirko
2014-08-11  0:27 ` YOSHIFUJI Hideaki

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