提交 7cc48263 编写于 作者: E Eric Dumazet 提交者: David S. Miller

[IPV6]: Convert ipv6 route to use the new dst_entry 'next' pointer

This patch removes the next pointer from 'struct rt6_info.u' union,
and renames u.next to u.dst.rt6_next.
Signed-off-by: NEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 093c2ca4
...@@ -83,7 +83,6 @@ struct rt6_info ...@@ -83,7 +83,6 @@ struct rt6_info
{ {
union { union {
struct dst_entry dst; struct dst_entry dst;
struct rt6_info *next;
} u; } u;
struct inet6_dev *rt6i_idev; struct inet6_dev *rt6i_idev;
......
...@@ -298,7 +298,7 @@ static int fib6_dump_node(struct fib6_walker_t *w) ...@@ -298,7 +298,7 @@ static int fib6_dump_node(struct fib6_walker_t *w)
int res; int res;
struct rt6_info *rt; struct rt6_info *rt;
for (rt = w->leaf; rt; rt = rt->u.next) { for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
res = rt6_dump_route(rt, w->args); res = rt6_dump_route(rt, w->args);
if (res < 0) { if (res < 0) {
/* Frame is full, suspend walking */ /* Frame is full, suspend walking */
...@@ -624,11 +624,11 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, ...@@ -624,11 +624,11 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
fn->leaf == &ip6_null_entry && fn->leaf == &ip6_null_entry &&
!(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){ !(rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) ){
fn->leaf = rt; fn->leaf = rt;
rt->u.next = NULL; rt->u.dst.rt6_next = NULL;
goto out; goto out;
} }
for (iter = fn->leaf; iter; iter=iter->u.next) { for (iter = fn->leaf; iter; iter=iter->u.dst.rt6_next) {
/* /*
* Search for duplicates * Search for duplicates
*/ */
...@@ -656,7 +656,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, ...@@ -656,7 +656,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
if (iter->rt6i_metric > rt->rt6i_metric) if (iter->rt6i_metric > rt->rt6i_metric)
break; break;
ins = &iter->u.next; ins = &iter->u.dst.rt6_next;
} }
/* /*
...@@ -664,7 +664,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, ...@@ -664,7 +664,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
*/ */
out: out:
rt->u.next = iter; rt->u.dst.rt6_next = iter;
*ins = rt; *ins = rt;
rt->rt6i_node = fn; rt->rt6i_node = fn;
atomic_inc(&rt->rt6i_ref); atomic_inc(&rt->rt6i_ref);
...@@ -1105,7 +1105,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, ...@@ -1105,7 +1105,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
RT6_TRACE("fib6_del_route\n"); RT6_TRACE("fib6_del_route\n");
/* Unlink it */ /* Unlink it */
*rtp = rt->u.next; *rtp = rt->u.dst.rt6_next;
rt->rt6i_node = NULL; rt->rt6i_node = NULL;
rt6_stats.fib_rt_entries--; rt6_stats.fib_rt_entries--;
rt6_stats.fib_discarded_routes++; rt6_stats.fib_discarded_routes++;
...@@ -1115,14 +1115,14 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, ...@@ -1115,14 +1115,14 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
FOR_WALKERS(w) { FOR_WALKERS(w) {
if (w->state == FWS_C && w->leaf == rt) { if (w->state == FWS_C && w->leaf == rt) {
RT6_TRACE("walker %p adjusted by delroute\n", w); RT6_TRACE("walker %p adjusted by delroute\n", w);
w->leaf = rt->u.next; w->leaf = rt->u.dst.rt6_next;
if (w->leaf == NULL) if (w->leaf == NULL)
w->state = FWS_U; w->state = FWS_U;
} }
} }
read_unlock(&fib6_walker_lock); read_unlock(&fib6_walker_lock);
rt->u.next = NULL; rt->u.dst.rt6_next = NULL;
if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT) if (fn->leaf == NULL && fn->fn_flags&RTN_TL_ROOT)
fn->leaf = &ip6_null_entry; fn->leaf = &ip6_null_entry;
...@@ -1190,7 +1190,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info) ...@@ -1190,7 +1190,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
* Walk the leaf entries looking for ourself * Walk the leaf entries looking for ourself
*/ */
for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.next) { for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.dst.rt6_next) {
if (*rtp == rt) { if (*rtp == rt) {
fib6_del_route(fn, rtp, info); fib6_del_route(fn, rtp, info);
return 0; return 0;
...@@ -1317,7 +1317,7 @@ static int fib6_clean_node(struct fib6_walker_t *w) ...@@ -1317,7 +1317,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
struct rt6_info *rt; struct rt6_info *rt;
struct fib6_cleaner_t *c = (struct fib6_cleaner_t*)w; struct fib6_cleaner_t *c = (struct fib6_cleaner_t*)w;
for (rt = w->leaf; rt; rt = rt->u.next) { for (rt = w->leaf; rt; rt = rt->u.dst.rt6_next) {
res = c->func(rt, c->arg); res = c->func(rt, c->arg);
if (res < 0) { if (res < 0) {
w->leaf = rt; w->leaf = rt;
......
...@@ -243,7 +243,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt, ...@@ -243,7 +243,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt,
struct rt6_info *sprt; struct rt6_info *sprt;
if (oif) { if (oif) {
for (sprt = rt; sprt; sprt = sprt->u.next) { for (sprt = rt; sprt; sprt = sprt->u.dst.rt6_next) {
struct net_device *dev = sprt->rt6i_dev; struct net_device *dev = sprt->rt6i_dev;
if (dev->ifindex == oif) if (dev->ifindex == oif)
return sprt; return sprt;
...@@ -376,7 +376,7 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif, ...@@ -376,7 +376,7 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
for (rt = rt0, metric = rt0->rt6i_metric; for (rt = rt0, metric = rt0->rt6i_metric;
rt && rt->rt6i_metric == metric && (!last || rt != rt0); rt && rt->rt6i_metric == metric && (!last || rt != rt0);
rt = rt->u.next) { rt = rt->u.dst.rt6_next) {
int m; int m;
if (rt6_check_expired(rt)) if (rt6_check_expired(rt))
...@@ -404,9 +404,9 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif, ...@@ -404,9 +404,9 @@ static struct rt6_info *rt6_select(struct rt6_info **head, int oif,
/* no entries matched; do round-robin */ /* no entries matched; do round-robin */
static DEFINE_SPINLOCK(lock); static DEFINE_SPINLOCK(lock);
spin_lock(&lock); spin_lock(&lock);
*head = rt0->u.next; *head = rt0->u.dst.rt6_next;
rt0->u.next = last->u.next; rt0->u.dst.rt6_next = last->u.dst.rt6_next;
last->u.next = rt0; last->u.dst.rt6_next = rt0;
spin_unlock(&lock); spin_unlock(&lock);
} }
...@@ -1278,7 +1278,7 @@ static int ip6_route_del(struct fib6_config *cfg) ...@@ -1278,7 +1278,7 @@ static int ip6_route_del(struct fib6_config *cfg)
&cfg->fc_src, cfg->fc_src_len); &cfg->fc_src, cfg->fc_src_len);
if (fn) { if (fn) {
for (rt = fn->leaf; rt; rt = rt->u.next) { for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
if (cfg->fc_ifindex && if (cfg->fc_ifindex &&
(rt->rt6i_dev == NULL || (rt->rt6i_dev == NULL ||
rt->rt6i_dev->ifindex != cfg->fc_ifindex)) rt->rt6i_dev->ifindex != cfg->fc_ifindex))
...@@ -1329,7 +1329,7 @@ static struct rt6_info *__ip6_route_redirect(struct fib6_table *table, ...@@ -1329,7 +1329,7 @@ static struct rt6_info *__ip6_route_redirect(struct fib6_table *table,
read_lock_bh(&table->tb6_lock); read_lock_bh(&table->tb6_lock);
fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src);
restart: restart:
for (rt = fn->leaf; rt; rt = rt->u.next) { for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
/* /*
* Current route is on-link; redirect is always invalid. * Current route is on-link; redirect is always invalid.
* *
...@@ -1590,7 +1590,7 @@ static struct rt6_info *rt6_get_route_info(struct in6_addr *prefix, int prefixle ...@@ -1590,7 +1590,7 @@ static struct rt6_info *rt6_get_route_info(struct in6_addr *prefix, int prefixle
if (!fn) if (!fn)
goto out; goto out;
for (rt = fn->leaf; rt; rt = rt->u.next) { for (rt = fn->leaf; rt; rt = rt->u.dst.rt6_next) {
if (rt->rt6i_dev->ifindex != ifindex) if (rt->rt6i_dev->ifindex != ifindex)
continue; continue;
if ((rt->rt6i_flags & (RTF_ROUTEINFO|RTF_GATEWAY)) != (RTF_ROUTEINFO|RTF_GATEWAY)) if ((rt->rt6i_flags & (RTF_ROUTEINFO|RTF_GATEWAY)) != (RTF_ROUTEINFO|RTF_GATEWAY))
...@@ -1641,7 +1641,7 @@ struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *d ...@@ -1641,7 +1641,7 @@ struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *d
return NULL; return NULL;
write_lock_bh(&table->tb6_lock); write_lock_bh(&table->tb6_lock);
for (rt = table->tb6_root.leaf; rt; rt=rt->u.next) { for (rt = table->tb6_root.leaf; rt; rt=rt->u.dst.rt6_next) {
if (dev == rt->rt6i_dev && if (dev == rt->rt6i_dev &&
((rt->rt6i_flags & (RTF_ADDRCONF | RTF_DEFAULT)) == (RTF_ADDRCONF | RTF_DEFAULT)) && ((rt->rt6i_flags & (RTF_ADDRCONF | RTF_DEFAULT)) == (RTF_ADDRCONF | RTF_DEFAULT)) &&
ipv6_addr_equal(&rt->rt6i_gateway, addr)) ipv6_addr_equal(&rt->rt6i_gateway, addr))
...@@ -1684,7 +1684,7 @@ void rt6_purge_dflt_routers(void) ...@@ -1684,7 +1684,7 @@ void rt6_purge_dflt_routers(void)
restart: restart:
read_lock_bh(&table->tb6_lock); read_lock_bh(&table->tb6_lock);
for (rt = table->tb6_root.leaf; rt; rt = rt->u.next) { for (rt = table->tb6_root.leaf; rt; rt = rt->u.dst.rt6_next) {
if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) { if (rt->rt6i_flags & (RTF_DEFAULT | RTF_ADDRCONF)) {
dst_hold(&rt->u.dst); dst_hold(&rt->u.dst);
read_unlock_bh(&table->tb6_lock); read_unlock_bh(&table->tb6_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册