netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses
@ 2013-11-14 12:51 Nicolas Dichtel
  2013-11-14 12:51 ` [PATCH net 2/3] sit: link local routes are missing Nicolas Dichtel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nicolas Dichtel @ 2013-11-14 12:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel

When the local IPv4 endpoint is wilcard (0.0.0.0), the prefix length is
correctly set, ie 64 if the address is a link local one or 96 if the address is
a v4 mapped one.
But when the local endpoint is specified, the prefix length is set to 128 for
both kind of address. This patch fix this wrong prefix length.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/addrconf.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index cd3fb301da38..4e558e5e0e42 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2555,7 +2555,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
 	struct in6_addr addr;
 	struct net_device *dev;
 	struct net *net = dev_net(idev->dev);
-	int scope;
+	int scope, plen;
 
 	ASSERT_RTNL();
 
@@ -2565,12 +2565,14 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
 	if (idev->dev->flags&IFF_POINTOPOINT) {
 		addr.s6_addr32[0] = htonl(0xfe800000);
 		scope = IFA_LINK;
+		plen = 64;
 	} else {
 		scope = IPV6_ADDR_COMPATv4;
+		plen = 96;
 	}
 
 	if (addr.s6_addr32[3]) {
-		add_addr(idev, &addr, 128, scope);
+		add_addr(idev, &addr, plen, scope);
 		return;
 	}
 
@@ -2582,7 +2584,6 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
 			int flag = scope;
 
 			for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
-				int plen;
 
 				addr.s6_addr32[3] = ifa->ifa_local;
 
@@ -2593,10 +2594,6 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
 						continue;
 					flag |= IFA_HOST;
 				}
-				if (idev->dev->flags&IFF_POINTOPOINT)
-					plen = 64;
-				else
-					plen = 96;
 
 				add_addr(idev, &addr, plen, flag);
 			}
-- 
1.8.4.1

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

* [PATCH net 2/3] sit: link local routes are missing
  2013-11-14 12:51 [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses Nicolas Dichtel
@ 2013-11-14 12:51 ` Nicolas Dichtel
  2013-11-14 21:59   ` David Miller
  2013-11-14 12:51 ` [PATCH net 3/3] sit/gre6: don't try to add the same route two times Nicolas Dichtel
  2013-11-14 21:59 ` [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Nicolas Dichtel @ 2013-11-14 12:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel

When a link local address was added to a sit interface, the corresponding route
was not configured. This breaks routing protocols that use the link local
address, like OSPFv3.

To ease the code reading, I remove sit_route_add(), which only adds v4 mapped
routes, and add this kind of route directly in sit_add_v4_addrs(). Thus link
local and v4 mapped routes are configured in the same place.

Reported-by: Li Hongjun <hongjun.li@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/addrconf.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 4e558e5e0e42..237bceb74c4e 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2006,23 +2006,6 @@ static void addrconf_add_mroute(struct net_device *dev)
 	ip6_route_add(&cfg);
 }
 
-#if IS_ENABLED(CONFIG_IPV6_SIT)
-static void sit_route_add(struct net_device *dev)
-{
-	struct fib6_config cfg = {
-		.fc_table = RT6_TABLE_MAIN,
-		.fc_metric = IP6_RT_PRIO_ADDRCONF,
-		.fc_ifindex = dev->ifindex,
-		.fc_dst_len = 96,
-		.fc_flags = RTF_UP | RTF_NONEXTHOP,
-		.fc_nlinfo.nl_net = dev_net(dev),
-	};
-
-	/* prefix length - 96 bits "::d.d.d.d" */
-	ip6_route_add(&cfg);
-}
-#endif
-
 static struct inet6_dev *addrconf_add_dev(struct net_device *dev)
 {
 	struct inet6_dev *idev;
@@ -2556,6 +2539,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
 	struct net_device *dev;
 	struct net *net = dev_net(idev->dev);
 	int scope, plen;
+	u32 pflags = 0;
 
 	ASSERT_RTNL();
 
@@ -2569,10 +2553,12 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
 	} else {
 		scope = IPV6_ADDR_COMPATv4;
 		plen = 96;
+		pflags |= RTF_NONEXTHOP;
 	}
 
 	if (addr.s6_addr32[3]) {
 		add_addr(idev, &addr, plen, scope);
+		addrconf_prefix_route(&addr, plen, idev->dev, 0, pflags);
 		return;
 	}
 
@@ -2596,6 +2582,8 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
 				}
 
 				add_addr(idev, &addr, plen, flag);
+				addrconf_prefix_route(&addr, plen, idev->dev, 0,
+						      pflags);
 			}
 		}
 	}
@@ -2731,8 +2719,6 @@ static void addrconf_sit_config(struct net_device *dev)
 
 	if (dev->flags&IFF_POINTOPOINT)
 		addrconf_add_mroute(dev);
-	else
-		sit_route_add(dev);
 }
 #endif
 
-- 
1.8.4.1

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

* [PATCH net 3/3] sit/gre6: don't try to add the same route two times
  2013-11-14 12:51 [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses Nicolas Dichtel
  2013-11-14 12:51 ` [PATCH net 2/3] sit: link local routes are missing Nicolas Dichtel
@ 2013-11-14 12:51 ` Nicolas Dichtel
  2013-11-14 21:59   ` David Miller
  2013-11-14 21:59 ` [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Nicolas Dichtel @ 2013-11-14 12:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, Nicolas Dichtel

addrconf_add_linklocal() already adds the link local route, so there is no
reason to add it before calling this function.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv6/addrconf.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 237bceb74c4e..cfc47b364e51 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2709,7 +2709,6 @@ static void addrconf_sit_config(struct net_device *dev)
 		struct in6_addr addr;
 
 		ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-		addrconf_prefix_route(&addr, 64, dev, 0, 0);
 		if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
 			addrconf_add_linklocal(idev, &addr);
 		return;
@@ -2736,8 +2735,6 @@ static void addrconf_gre_config(struct net_device *dev)
 	}
 
 	ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
-	addrconf_prefix_route(&addr, 64, dev, 0, 0);
-
 	if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
 		addrconf_add_linklocal(idev, &addr);
 }
-- 
1.8.4.1

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

* Re: [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses
  2013-11-14 12:51 [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses Nicolas Dichtel
  2013-11-14 12:51 ` [PATCH net 2/3] sit: link local routes are missing Nicolas Dichtel
  2013-11-14 12:51 ` [PATCH net 3/3] sit/gre6: don't try to add the same route two times Nicolas Dichtel
@ 2013-11-14 21:59 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-11-14 21:59 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Thu, 14 Nov 2013 13:51:05 +0100

> When the local IPv4 endpoint is wilcard (0.0.0.0), the prefix length is
> correctly set, ie 64 if the address is a link local one or 96 if the address is
> a v4 mapped one.
> But when the local endpoint is specified, the prefix length is set to 128 for
> both kind of address. This patch fix this wrong prefix length.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied.

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

* Re: [PATCH net 2/3] sit: link local routes are missing
  2013-11-14 12:51 ` [PATCH net 2/3] sit: link local routes are missing Nicolas Dichtel
@ 2013-11-14 21:59   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-11-14 21:59 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Thu, 14 Nov 2013 13:51:06 +0100

> When a link local address was added to a sit interface, the corresponding route
> was not configured. This breaks routing protocols that use the link local
> address, like OSPFv3.
> 
> To ease the code reading, I remove sit_route_add(), which only adds v4 mapped
> routes, and add this kind of route directly in sit_add_v4_addrs(). Thus link
> local and v4 mapped routes are configured in the same place.
> 
> Reported-by: Li Hongjun <hongjun.li@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied.

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

* Re: [PATCH net 3/3] sit/gre6: don't try to add the same route two times
  2013-11-14 12:51 ` [PATCH net 3/3] sit/gre6: don't try to add the same route two times Nicolas Dichtel
@ 2013-11-14 21:59   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-11-14 21:59 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Thu, 14 Nov 2013 13:51:07 +0100

> addrconf_add_linklocal() already adds the link local route, so there is no
> reason to add it before calling this function.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied.

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

end of thread, other threads:[~2013-11-14 21:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-14 12:51 [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses Nicolas Dichtel
2013-11-14 12:51 ` [PATCH net 2/3] sit: link local routes are missing Nicolas Dichtel
2013-11-14 21:59   ` David Miller
2013-11-14 12:51 ` [PATCH net 3/3] sit/gre6: don't try to add the same route two times Nicolas Dichtel
2013-11-14 21:59   ` David Miller
2013-11-14 21:59 ` [PATCH net 1/3] sit: fix prefix length of ll and v4mapped addresses David Miller

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