ipv6: Add support for RTA_PREFSRC
Subsystems (3)
David Miller
maintainerYou can't change the layout of "struct in6_rtmsg", as that structure is explicitly exported to user space and changing it will break every application out there.
Quoted 3 lines · David Miller
You can't change the layout of "struct
in6_rtmsg", as that structure is explicitly exported to user space and changing it will break every application out there.
Hi,
I've kicked support for setting the preferred source via ioctl, to keep "struct in6_rtmsg" untouched.
This reduces the RTA_PREFSRC support to netlink only, unless we break the struct.
Do you see any other way around this problem?
regards,
daniel
---
include/net/ip6_fib.h +2 -0
@@ -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 +1 -0
@@ -141,6 +141,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
@@ -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 +8 -4
@@ -930,10 +930,14 @@ 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; +if (rt->rt6i_prefsrc.plen) +ipv6_addr_copy (&fl6->saddr, &rt->rt6i_prefsrc.addr); +else + err =ipv6_dev_get_saddr (net,ip6_dst_idev (*dst)->dev, + &fl6->daddr, + sk ?inet6_sk (sk)->srcprefs :0 , + &fl6->saddr);if (err) goto out_err_release; }
net/ipv6/route.c +64 -3
93 lines not on this page · raw message
Daniel Walter
Software Engineer
Barracuda Networks AG
Eduard-Bodem-Gasse 1
6020 Innsbruck
Austria
Phone: +43 (0) 508 100
Fax: +43 508 100 20
eMail: mailto:[email protected]
Web: www.barracudanetworks.com, www.phion.com
Barracuda Networks solutions are now available as virtual appliances. Visit www.barracudanetworks.com/vx for more information.
David Miller
maintainerFrom: Daniel Walter <[email protected]>
Date: Mon, 4 Apr 2011 09:56:44 +0200
Quoted 5 lines
Quoted 3 lines · David Miller
You can't change the layout of "struct
in6_rtmsg", as that structure is explicitly exported to user space and changing it will break every application out there.
Quoted 8 lines
Hi,
I've kicked support for setting the preferred source via ioctl, to keep "struct
in6_rtmsg" untouched.
This reduces theRTA_PREFSRCsupport to netlink only, unless we break the struct.Do you see any other way around this problem?
This is fine, adding new feature support to deprecated things like the ioctl routing calls is undesirable anyways.
Since you do the prefsrc extraction in at least two places, make a helper function that does the whole "if prefsrc.plen use prefsrc, else use ipv6_dev_get_saddr()"
This would be akin to ipv4's FIB_RES_PREFSRC
Quoted 17 lines · David Miller
From: Daniel Walter <[email protected]>
Date: Mon, 4 Apr 2011 09:56:44 +0200Quoted 5 lines
Quoted 3 lines · David Miller
You can't change the layout of "struct
in6_rtmsg", as that structure is explicitly exported to user space and changing it will break every application out there.Quoted 8 lines
Hi,
I've kicked support for setting the preferred source via ioctl, to keep "struct
in6_rtmsg" untouched.
This reduces theRTA_PREFSRCsupport to netlink only, unless we break the struct.Do you see any other way around this problem?
Quoted 8 lines
This is fine, adding new feature support to deprecated things like the ioctl routing calls is undesirable anyways.
Since you do the prefsrc extraction in at least two places, make a helper function that does the whole "if prefsrc.plen use prefsrc, else use
ipv6_dev_get_saddr()"This would be akin to ipv4's
FIB_RES_PREFSRC
Hi,
I've moved the extraction into a helper function as suggested and did some cleanup.
---
include/net/ip6_fib.h +2 -0
@@ -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
@@ -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
@@ -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
@@ -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 solutions are now available as virtual appliances. Visit www.barracudanetworks.com/vx for more information.
David Miller
maintainerFrom: Daniel Walter <[email protected]>
Date: Thu, 7 Apr 2011 11:23:57 +0200
Quoted 25 lines · David Miller
Quoted 24 lines
From: Daniel Walter <[email protected]>
Date: Mon, 4 Apr 2011 09:56:44 +0200Quoted 5 lines
Quoted 3 lines · David Miller
You can't change the layout of "struct
in6_rtmsg", as that structure is explicitly exported to user space and changing it will break every application out there.Quoted 8 lines
Hi,
I've kicked support for setting the preferred source via ioctl, to keep "struct
in6_rtmsg" untouched.
This reduces theRTA_PREFSRCsupport to netlink only, unless we break the struct.Do you see any other way around this problem?
This is fine, adding new feature support to deprecated things like the ioctl routing calls is undesirable anyways.
Since you do the prefsrc extraction in at least two places, make a helper function that does the whole "if prefsrc.plen use prefsrc, else use
ipv6_dev_get_saddr()"
Quoted 5 lines
Quoted 1 line
This would be akin to ipv4's
FIB_RES_PREFSRCHi,
I've moved the extraction into a helper function as suggested and did some cleanup.
Daniel, please, when you submit new versions of patches do make a full and complete resubmission.
This means, write a new email, provide a full commit message, proper Subject, and Signed-off-by: lines.
Don't just reply to my request with a new patch, that doesn't work and your changes won't get tracked properly.
Quoted 5 lines · David Miller
From: Daniel Walter <[email protected]>
Date: Mon, 4 Apr 2011 09:56:44 +0200Quoted 2 lines
This reduces the
RTA_PREFSRCsupport to netlink only, unless we break the struct.
[..]
Quoted 5 lines
Since you do the prefsrc extraction in at least two places, make a helper function that does the whole "if prefsrc.plen use prefsrc, else use
ipv6_dev_get_saddr()"This would be akin to ipv4's
FIB_RES_PREFSRC
OK, I'll bite.
Whats wrong with using ipv6 addrlabels to pick the desired address, and, if there is a problem, why is it not fixable?
Just wondering...
Quoted 11 lines · Florian Westphal
Quoted 5 lines · David Miller
From: Daniel Walter <[email protected]>
Date: Mon, 4 Apr 2011 09:56:44 +0200Quoted 2 lines
This reduces the
RTA_PREFSRCsupport to netlink only, unless we break the struct.[..]
Quoted 4 lines
Since you do the prefsrc extraction in at least two places, make a helper function that does the whole "if prefsrc.plen use prefsrc, else use
ipv6_dev_get_saddr()"
Quoted 8 lines
Quoted 1 line
This would be akin to ipv4's
FIB_RES_PREFSRCOK, I'll bite.
Whats wrong with using ipv6 addrlabels to pick the desired address, and, if there is a problem, why is it not fixable?
Just wondering...
Hi,
As far as I've understood addrlabels, they allow me to define the overall preferred source. As soon I want to select the default src only for a given route, addrlabels cannot do the job. for example:
ip-addresses on eth0
2001:0DB8::1/64
2001:0DB8::2/64
routes
2001:0DB8::/64
2001:0DB8:0:dead::/64 via 2001:0DB8::1234/64
addrlabel allow me to set the default source address to 2001:0DB8::1 for both routes. with pref_src selection one is able to set the default outgoing address for each route to the needed address, which may be 2001:0DB8::1 for the first route, and 2001:0DB8::2 for the remaining.
Please feel free to correct me if I misunderstood something.
--
Barracuda Networks solutions are now available as virtual appliances. Visit www.barracudanetworks.com/vx for more information.
Quoted 23 lines · Daniel Walter
Quoted 9 lines · Florian Westphal
Quoted 1 line · David Miller
This would be akin to ipv4's
FIB_RES_PREFSRCOK, I'll bite.
Whats wrong with using ipv6 addrlabels to pick the desired address, and, if there is a problem, why is it not fixable?
Just wondering...
Hi,
As far as I've understood addrlabels, they allow me to define the overall preferred source. As soon I want to select the default src only for a given route, addrlabels cannot do the job. for example:
ip-addresses on eth0
2001:0DB8::1/64
2001:0DB8::2/64
routes
2001:0DB8::/64
2001:0DB8:0:dead::/64 via 2001:0DB8::1234/64
Quoted 6 lines
addrlabel allow me to set the default source address to 2001:0DB8::1 for both routes. with
pref_srcselection one is able to set the default outgoing address for each route to the needed address, which may be 2001:0DB8::1 for the first route, and 2001:0DB8::2 for the remaining.Please feel free to correct me if I misunderstood something.
ip addrlabel add label 1000 prefix 2001:db8::1 ip addrlabel add label 1000 prefix 2001:db8::/64 ip addrlabel add label 1001 prefix 2001:db8::2 ip addrlabel add label 1001 prefix 2001:0DB8:0:dead::/64
ip route add 2001:db8:0:dead::/64 via 2001:db8::1234
This should tell the stack to pick 2001:db8::1 as the source address when talking to 2001:db8::/64, and to use 2001:db8::2 when talking to 2001:0DB8:0:dead::42.