ipv6: Add support for RTA_PREFSRC
Subsystems (3)
PATCH 1/1 ipv6: Add support for RTA_PREFSRC
From: Daniel Walter <[email protected]>
[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.
---
patch should apply clean against linux-2.3.39 HEAD
include/linux/ipv6_route.h | 1 + include/net/ip6_fib.h | 2 + include/net/ip6_route.h | 1 + net/ipv6/addrconf.c | 2 + net/ipv6/ip6_output.c | 12 +++++-- net/ipv6/route.c | 68 ++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 79 insertions(+), 7 deletions(-)
include/linux/ipv6_route.h +1 -0
@@ -44,6 +44,7 @@struct in6_rtmsg {struct in6_addr rtmsg_dst;struct in6_addr rtmsg_src; +struct in6_addr rtmsg_prefsrc;struct in6_addr rtmsg_gateway;__u32 rtmsg_type;__u16 rtmsg_dst_len;
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 +65 -3
100 lines not on this page · raw message
From: Daniel Walter <[email protected]>
[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.
---
patch should apply clean against linux-2.3.39 HEAD
include/linux/ipv6_route.h | 1 + include/net/ip6_fib.h | 2 + include/net/ip6_route.h | 1 + net/ipv6/addrconf.c | 2 + net/ipv6/ip6_output.c | 12 +++++-- net/ipv6/route.c | 68 ++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 79 insertions(+), 7 deletions(-)
include/linux/ipv6_route.h +1 -0
@@ -44,6 +44,7 @@struct in6_rtmsg {struct in6_addr rtmsg_dst;struct in6_addr rtmsg_src; +struct in6_addr rtmsg_prefsrc;struct in6_addr rtmsg_gateway;__u32 rtmsg_type;__u16 rtmsg_dst_len;
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 +65 -3
100 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 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.
include/linux/ipv6_route.h +1 -0
@@ -44,6 +44,7 @@struct in6_rtmsg {struct in6_addr rtmsg_dst;struct in6_addr rtmsg_src; +struct in6_addr rtmsg_prefsrc;struct in6_addr rtmsg_gateway;__u32 rtmsg_type;__u16 rtmsg_dst_len;
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 +65 -3
100 lines not on this page · raw message