Skip to contentSkip to conversation

ipv6: RTA_PREFSRC support for ipv6 route source address selection

PATCH In review Daniel Walter 2 participants 3 messages Apr 11, 2011 – Apr 12, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: RTA_PREFSRC support for ipv6 route source address selection

[ipv6] Add support for RTA_PREFSRC

This patch allows a user to select the preferred source address for a specific IPv6-Route. It can be set via a netlink message setting RTA_PREFSRC to a valid IPv6 address which must be up on the device the route will be bound to.

---
Repost patch, after fixing some issues pointed out on netdev@ applies clean against current linux-2.6 HEAD

 include/net/ip6_fib.h   |    2 +
 include/net/ip6_route.h |    7 ++++
 net/ipv6/addrconf.c     |    2 +
 net/ipv6/ip6_output.c   |    8 ++--
 net/ipv6/route.c        |   72 +++++++++++++++++++++++++++++++++++++++++++++--
 5 files changed, 84 insertions(+), 7 deletions(-)

---

include/net/ip6_fib.h +2 -0
index bc3cde0..98348d5 100644
@@ -42,6 +42,7 @@ struct fib6_config {
 
 	struct in6_addr	fc_dst;
 	struct in6_addr	fc_src;
+	struct in6_addr	fc_prefsrc;
 	struct in6_addr	fc_gateway;
 
 	unsigned long	fc_expires;
@@ -107,6 +108,7 @@ struct rt6_info {
 	struct rt6key			rt6i_dst ____cacheline_aligned_in_smp;
 	u32				rt6i_flags;
 	struct rt6key			rt6i_src;
+	struct rt6key			rt6i_prefsrc;
 	u32				rt6i_metric;
 	u32				rt6i_peer_genid;
 
include/net/ip6_route.h +7 -0
index c850e5f..86b1cb4 100644
@@ -84,6 +84,12 @@ extern int			ip6_route_add(struct fib6_config *cfg);
 extern int			ip6_ins_rt(struct rt6_info *);
 extern int			ip6_del_rt(struct rt6_info *);
 
+extern int			ip6_route_get_saddr(struct net *net,
+						    struct rt6_info *rt,
+						    struct in6_addr *daddr,
+						    unsigned int prefs,
+						    struct in6_addr *saddr);
+
 extern struct rt6_info		*rt6_lookup(struct net *net,
 					    const struct in6_addr *daddr,
 					    const struct in6_addr *saddr,
@@ -141,6 +147,7 @@ struct rt6_rtnl_dump_arg {
 extern int rt6_dump_route(struct rt6_info *rt, void *p_arg);
 extern void rt6_ifdown(struct net *net, struct net_device *dev);
 extern void rt6_mtu_change(struct net_device *dev, unsigned mtu);
+extern void rt6_remove_prefsrc(struct inet6_ifaddr *ifp);
 
 
 /*
net/ipv6/addrconf.c +2 -0
index 3daaf3c..26f9e14 100644
@@ -825,6 +825,8 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
 		dst_release(&rt->dst);
 	}
 
+	/* clean up prefsrc entries */
+	rt6_remove_prefsrc(ifp);
 out:
 	in6_ifa_put(ifp);
 }
net/ipv6/ip6_output.c +4 -4
index 1820887..0ce081b 100644
@@ -930,10 +930,10 @@ static int ip6_dst_lookup_tail(struct sock *sk,
 		goto out_err_release;
 
 	if (ipv6_addr_any(&fl6->saddr)) {
-		err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
-					 &fl6->daddr,
-					 sk ? inet6_sk(sk)->srcprefs : 0,
-					 &fl6->saddr);
+		struct rt6_info *rt = (struct rt6_info *) *dst;
+		err = ip6_route_get_saddr(net, rt, dst,
+					  sk ? inet6_sk(sk)->srcprefs : 0,
+					  &fl6->saddr);
 		if (err)
 			goto out_err_release;
 	}
net/ipv6/route.c +69 -3

100 lines not on this page · raw message

Barracuda Networks AG
Vorsitzender des Aufsichtsrates/ Chairman of the supervisory board: Dean Drako Vorstand/ Executive Board: Dr. Wieland Alge, Mag. Guenter Klausner Sitz der Gesellschaft/ Registered office: 6020 Innsbruck, Austria Handelsgericht Innsbruck Firmenbuch/ Registration Number: 184392s UID-Nr/ VAT Number: ATU47509003

Diese Nachricht und allfaellige angehaengte Dokumente sind vertraulich und nur fuer den/die Adressaten bestimmt. Sollten Sie nicht der beabsichtigte Adressat sein, ist jede Offenlegung, Weiterleitung oder sonstige Verwendung dieser Information nicht gestattet. In diesem Fall bitten wir, den Absender zu verstaendigen und die Information zu vernichten. Fuer Uebermittlungsfehler oder sonstige Irrtuemer bei Uebermittlung besteht keine Haftung.

This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the material. The sender does not accept liability for any errors or omissions as a result of the transmission.

Barracuda Networks solutions are now available as virtual appliances. Visit www.barracudanetworks.com/vx for more information.

maintainer
#1 lore raw

From: Daniel Walter <[email protected]>
Date: Mon, 11 Apr 2011 09:03:29 +0200

Quoted 9 lines

[ipv6] Add support for RTA_PREFSRC

This patch allows a user to select the preferred source address for a specific IPv6-Route. It can be set via a netlink message setting RTA_PREFSRC to a valid IPv6 address which must be up on the device the route will be bound to.

Ok, I can live with this, applied, thanks!

maintainer
#2 lore raw

From: David Miller <[email protected]>
Date: Tue, 12 Apr 2011 15:05:11 -0700 (PDT)

Quoted 11 lines

From: Daniel Walter <[email protected]>
Date: Mon, 11 Apr 2011 09:03:29 +0200

Quoted 8 lines

[ipv6] Add support for RTA_PREFSRC

This patch allows a user to select the preferred source address for a specific IPv6-Route. It can be set via a netlink message setting RTA_PREFSRC to a valid IPv6 address which must be up on the device the route will be bound to.

Quoted 3 lines
Quoted 1 line

Ok, I can live with this, applied, thanks!

Sorry, I had to revert.

Please fix this warning, test your patch, and resubmit it.

net/ipv6/ip6_output.c: In function ‘ip6_dst_lookup_tail’:
net/ipv6/ip6_output.c:936: warning: passing argument 3 of ‘ip6_route_get_saddr’ from incompatible pointer type include/net/ip6_route.h:87: note: expected ‘struct in6_addr *’ but argument is of type ‘struct dst_entry **’

Thanks.