Commit 8101cd57 authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji

[IPV6] simplify functions related to RTF_ALLONLINK.

Simplify ipv6_get_saddr(), ipv6_dev_get_saddr() and
rt6_purge_dflt_routers().
Signed-off-by: default avatarHideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
parent 29098f0d
...@@ -67,8 +67,7 @@ extern int ipv6_get_saddr(struct dst_entry *dst, ...@@ -67,8 +67,7 @@ extern int ipv6_get_saddr(struct dst_entry *dst,
struct in6_addr *saddr); struct in6_addr *saddr);
extern int ipv6_dev_get_saddr(struct net_device *dev, extern int ipv6_dev_get_saddr(struct net_device *dev,
struct in6_addr *daddr, struct in6_addr *daddr,
struct in6_addr *saddr, struct in6_addr *saddr);
int onlink);
extern int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *); extern int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *);
extern int ipv6_rcv_saddr_equal(const struct sock *sk, extern int ipv6_rcv_saddr_equal(const struct sock *sk,
const struct sock *sk2); const struct sock *sk2);
......
...@@ -87,7 +87,7 @@ extern struct rt6_info * rt6_get_dflt_router(struct in6_addr *addr, ...@@ -87,7 +87,7 @@ extern struct rt6_info * rt6_get_dflt_router(struct in6_addr *addr,
extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr, extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr,
struct net_device *dev); struct net_device *dev);
extern void rt6_purge_dflt_routers(int lst_resort); extern void rt6_purge_dflt_routers(void);
extern void rt6_reset_dflt_pointer(struct rt6_info *rt); extern void rt6_reset_dflt_pointer(struct rt6_info *rt);
......
...@@ -760,7 +760,7 @@ static int inline ipv6_saddr_pref(const struct inet6_ifaddr *ifp, u8 invpref) ...@@ -760,7 +760,7 @@ static int inline ipv6_saddr_pref(const struct inet6_ifaddr *ifp, u8 invpref)
#endif #endif
int ipv6_dev_get_saddr(struct net_device *dev, int ipv6_dev_get_saddr(struct net_device *dev,
struct in6_addr *daddr, struct in6_addr *saddr, int onlink) struct in6_addr *daddr, struct in6_addr *saddr)
{ {
struct inet6_ifaddr *ifp = NULL; struct inet6_ifaddr *ifp = NULL;
struct inet6_ifaddr *match = NULL; struct inet6_ifaddr *match = NULL;
...@@ -769,10 +769,7 @@ int ipv6_dev_get_saddr(struct net_device *dev, ...@@ -769,10 +769,7 @@ int ipv6_dev_get_saddr(struct net_device *dev,
int err; int err;
int hiscore = -1, score; int hiscore = -1, score;
if (!onlink) scope = ipv6_addr_scope(daddr);
scope = ipv6_addr_scope(daddr);
else
scope = IFA_LINK;
/* /*
* known dev * known dev
...@@ -877,17 +874,7 @@ int ipv6_dev_get_saddr(struct net_device *dev, ...@@ -877,17 +874,7 @@ int ipv6_dev_get_saddr(struct net_device *dev,
int ipv6_get_saddr(struct dst_entry *dst, int ipv6_get_saddr(struct dst_entry *dst,
struct in6_addr *daddr, struct in6_addr *saddr) struct in6_addr *daddr, struct in6_addr *saddr)
{ {
struct rt6_info *rt; return ipv6_dev_get_saddr(dst ? dst->dev : NULL, daddr, saddr);
struct net_device *dev = NULL;
int onlink;
rt = (struct rt6_info *) dst;
if (rt)
dev = rt->rt6i_dev;
onlink = 0;
return ipv6_dev_get_saddr(dev, daddr, saddr, onlink);
} }
...@@ -3042,7 +3029,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, struct file * filp, ...@@ -3042,7 +3029,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
addrconf_forward_change(); addrconf_forward_change();
} }
if (*valp) if (*valp)
rt6_purge_dflt_routers(0); rt6_purge_dflt_routers();
} }
return ret; return ret;
...@@ -3096,7 +3083,7 @@ static int addrconf_sysctl_forward_strategy(ctl_table *table, ...@@ -3096,7 +3083,7 @@ static int addrconf_sysctl_forward_strategy(ctl_table *table,
} }
if (*valp) if (*valp)
rt6_purge_dflt_routers(0); rt6_purge_dflt_routers();
} else } else
*valp = new; *valp = new;
......
...@@ -396,7 +396,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, ...@@ -396,7 +396,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
src_addr = solicited_addr; src_addr = solicited_addr;
in6_ifa_put(ifp); in6_ifa_put(ifp);
} else { } else {
if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr, 0)) if (ipv6_dev_get_saddr(dev, daddr, &tmpaddr))
return; return;
src_addr = &tmpaddr; src_addr = &tmpaddr;
} }
...@@ -1026,7 +1026,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1026,7 +1026,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
* delete it * delete it
*/ */
rt6_purge_dflt_routers(0); rt6_purge_dflt_routers();
} }
if (rt) if (rt)
......
...@@ -1288,17 +1288,14 @@ struct rt6_info *rt6_add_dflt_router(struct in6_addr *gwaddr, ...@@ -1288,17 +1288,14 @@ struct rt6_info *rt6_add_dflt_router(struct in6_addr *gwaddr,
return rt6_get_dflt_router(gwaddr, dev); return rt6_get_dflt_router(gwaddr, dev);
} }
void rt6_purge_dflt_routers(int last_resort) void rt6_purge_dflt_routers(void)
{ {
struct rt6_info *rt; struct rt6_info *rt;
u32 flags;
flags = RTF_DEFAULT | RTF_ADDRCONF;
restart: restart:
read_lock_bh(&rt6_lock); read_lock_bh(&rt6_lock);
for (rt = ip6_routing_table.leaf; rt; rt = rt->u.next) { for (rt = ip6_routing_table.leaf; rt; rt = rt->u.next) {
if (rt->rt6i_flags & flags) { if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) {
dst_hold(&rt->u.dst); dst_hold(&rt->u.dst);
rt6_reset_dflt_pointer(NULL); rt6_reset_dflt_pointer(NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment