Lines Matching refs:w

43 	struct fib6_walker w;  member
63 static int fib6_walk(struct net *net, struct fib6_walker *w);
64 static int fib6_walk_continue(struct fib6_walker *w);
75 #define FOR_WALKERS(net, w) \ argument
76 list_for_each_entry(w, &(net)->ipv6.fib6_walkers, lh)
78 static void fib6_walker_link(struct net *net, struct fib6_walker *w) in fib6_walker_link() argument
81 list_add(&w->lh, &net->ipv6.fib6_walkers); in fib6_walker_link()
85 static void fib6_walker_unlink(struct net *net, struct fib6_walker *w) in fib6_walker_unlink() argument
88 list_del(&w->lh); in fib6_walker_unlink()
457 static int fib6_node_dump(struct fib6_walker *w) in fib6_node_dump() argument
461 err = fib6_rt_dump(w->leaf, w->args); in fib6_node_dump()
462 w->leaf = NULL; in fib6_node_dump()
467 struct fib6_walker *w) in fib6_table_dump() argument
471 w->root = &tb->tb6_root; in fib6_table_dump()
473 err = fib6_walk(net, w); in fib6_table_dump()
483 struct fib6_walker *w; in fib6_tables_dump() local
487 w = kzalloc(sizeof(*w), GFP_ATOMIC); in fib6_tables_dump()
488 if (!w) in fib6_tables_dump()
491 w->func = fib6_node_dump; in fib6_tables_dump()
495 w->args = &arg; in fib6_tables_dump()
502 err = fib6_table_dump(net, tb, w); in fib6_tables_dump()
509 kfree(w); in fib6_tables_dump()
515 static int fib6_dump_node(struct fib6_walker *w) in fib6_dump_node() argument
520 for_each_fib6_walker_rt(w) { in fib6_dump_node()
521 res = rt6_dump_route(rt, w->args, w->skip_in_node); in fib6_dump_node()
524 w->leaf = rt; in fib6_dump_node()
529 w->skip_in_node += res; in fib6_dump_node()
533 w->skip_in_node = 0; in fib6_dump_node()
545 w->leaf = NULL; in fib6_dump_node()
552 struct fib6_walker *w = (void *)cb->args[2]; in fib6_dump_end() local
554 if (w) { in fib6_dump_end()
557 fib6_walker_unlink(net, w); in fib6_dump_end()
560 kfree(w); in fib6_dump_end()
576 struct fib6_walker *w; in fib6_dump_table() local
579 w = (void *)cb->args[2]; in fib6_dump_table()
580 w->root = &table->tb6_root; in fib6_dump_table()
583 w->count = 0; in fib6_dump_table()
584 w->skip = 0; in fib6_dump_table()
585 w->skip_in_node = 0; in fib6_dump_table()
588 res = fib6_walk(net, w); in fib6_dump_table()
592 cb->args[5] = READ_ONCE(w->root->fn_sernum); in fib6_dump_table()
595 int sernum = READ_ONCE(w->root->fn_sernum); in fib6_dump_table()
599 w->state = FWS_INIT; in fib6_dump_table()
600 w->node = w->root; in fib6_dump_table()
601 w->skip = w->count; in fib6_dump_table()
602 w->skip_in_node = 0; in fib6_dump_table()
604 w->skip = 0; in fib6_dump_table()
607 res = fib6_walk_continue(w); in fib6_dump_table()
610 fib6_walker_unlink(net, w); in fib6_dump_table()
626 struct fib6_walker *w; in inet6_dump_fib() local
644 w = (void *)cb->args[2]; in inet6_dump_fib()
645 if (!w) { in inet6_dump_fib()
656 w = kzalloc(sizeof(*w), GFP_ATOMIC); in inet6_dump_fib()
657 if (!w) in inet6_dump_fib()
659 w->func = fib6_dump_node; in inet6_dump_fib()
660 cb->args[2] = (long)w; in inet6_dump_fib()
666 w->args = &arg; in inet6_dump_fib()
1784 struct fib6_walker *w; in fib6_repair_tree() local
1870 FOR_WALKERS(net, w) { in fib6_repair_tree()
1872 if (w->node == fn) { in fib6_repair_tree()
1873 RT6_TRACE("W %p adjusted by delnode 1, s=%d/%d\n", w, w->state, nstate); in fib6_repair_tree()
1874 w->node = pn; in fib6_repair_tree()
1875 w->state = nstate; in fib6_repair_tree()
1878 if (w->node == fn) { in fib6_repair_tree()
1879 w->node = child; in fib6_repair_tree()
1881 RT6_TRACE("W %p adjusted by delnode 2, s=%d\n", w, w->state); in fib6_repair_tree()
1882 w->state = w->state >= FWS_R ? FWS_U : FWS_INIT; in fib6_repair_tree()
1884 RT6_TRACE("W %p adjusted by delnode 2, s=%d\n", w, w->state); in fib6_repair_tree()
1885 w->state = w->state >= FWS_C ? FWS_U : FWS_INIT; in fib6_repair_tree()
1906 struct fib6_walker *w; in fib6_del_route() local
1960 FOR_WALKERS(net, w) { in fib6_del_route()
1961 if (w->state == FWS_C && w->leaf == rt) { in fib6_del_route()
1962 RT6_TRACE("walker %p adjusted by delroute\n", w); in fib6_del_route()
1963 w->leaf = rcu_dereference_protected(rt->fib6_next, in fib6_del_route()
1965 if (!w->leaf) in fib6_del_route()
1966 w->state = FWS_U; in fib6_del_route()
2062 static int fib6_walk_continue(struct fib6_walker *w) in fib6_walk_continue() argument
2067 WARN_ON_ONCE(!(w->root->fn_flags & RTN_TL_ROOT)); in fib6_walk_continue()
2070 fn = w->node; in fib6_walk_continue()
2074 switch (w->state) { in fib6_walk_continue()
2078 w->node = FIB6_SUBTREE(fn); in fib6_walk_continue()
2081 w->state = FWS_L; in fib6_walk_continue()
2087 w->node = left; in fib6_walk_continue()
2088 w->state = FWS_INIT; in fib6_walk_continue()
2091 w->state = FWS_R; in fib6_walk_continue()
2096 w->node = right; in fib6_walk_continue()
2097 w->state = FWS_INIT; in fib6_walk_continue()
2100 w->state = FWS_C; in fib6_walk_continue()
2101 w->leaf = rcu_dereference_protected(fn->leaf, 1); in fib6_walk_continue()
2104 if (w->leaf && fn->fn_flags & RTN_RTINFO) { in fib6_walk_continue()
2107 if (w->skip) { in fib6_walk_continue()
2108 w->skip--; in fib6_walk_continue()
2112 err = w->func(w); in fib6_walk_continue()
2116 w->count++; in fib6_walk_continue()
2120 w->state = FWS_U; in fib6_walk_continue()
2123 if (fn == w->root) in fib6_walk_continue()
2128 w->node = pn; in fib6_walk_continue()
2132 w->state = FWS_L; in fib6_walk_continue()
2137 w->state = FWS_R; in fib6_walk_continue()
2141 w->state = FWS_C; in fib6_walk_continue()
2142 w->leaf = rcu_dereference_protected(w->node->leaf, 1); in fib6_walk_continue()
2152 static int fib6_walk(struct net *net, struct fib6_walker *w) in fib6_walk() argument
2156 w->state = FWS_INIT; in fib6_walk()
2157 w->node = w->root; in fib6_walk()
2159 fib6_walker_link(net, w); in fib6_walk()
2160 res = fib6_walk_continue(w); in fib6_walk()
2162 fib6_walker_unlink(net, w); in fib6_walk()
2166 static int fib6_clean_node(struct fib6_walker *w) in fib6_clean_node() argument
2170 struct fib6_cleaner *c = container_of(w, struct fib6_cleaner, w); in fib6_clean_node()
2177 READ_ONCE(w->node->fn_sernum) != c->sernum) in fib6_clean_node()
2178 WRITE_ONCE(w->node->fn_sernum, c->sernum); in fib6_clean_node()
2182 w->leaf = NULL; in fib6_clean_node()
2186 for_each_fib6_walker_rt(w) { in fib6_clean_node()
2189 w->leaf = rt; in fib6_clean_node()
2210 w->leaf = rt; in fib6_clean_node()
2229 c.w.root = root; in fib6_clean_tree()
2230 c.w.func = fib6_clean_node; in fib6_clean_tree()
2231 c.w.count = 0; in fib6_clean_tree()
2232 c.w.skip = 0; in fib6_clean_tree()
2233 c.w.skip_in_node = 0; in fib6_clean_tree()
2240 fib6_walk(net, &c.w); in fib6_clean_tree()
2514 iter->w.leaf = NULL; in ipv6_route_native_seq_show()
2518 static int ipv6_route_yield(struct fib6_walker *w) in ipv6_route_yield() argument
2520 struct ipv6_route_iter *iter = w->args; in ipv6_route_yield()
2526 iter->w.leaf = rcu_dereference_protected( in ipv6_route_yield()
2527 iter->w.leaf->fib6_next, in ipv6_route_yield()
2530 if (!iter->skip && iter->w.leaf) in ipv6_route_yield()
2532 } while (iter->w.leaf); in ipv6_route_yield()
2540 memset(&iter->w, 0, sizeof(iter->w)); in ipv6_route_seq_setup_walk()
2541 iter->w.func = ipv6_route_yield; in ipv6_route_seq_setup_walk()
2542 iter->w.root = &iter->tbl->tb6_root; in ipv6_route_seq_setup_walk()
2543 iter->w.state = FWS_INIT; in ipv6_route_seq_setup_walk()
2544 iter->w.node = iter->w.root; in ipv6_route_seq_setup_walk()
2545 iter->w.args = iter; in ipv6_route_seq_setup_walk()
2546 iter->sernum = READ_ONCE(iter->w.root->fn_sernum); in ipv6_route_seq_setup_walk()
2547 INIT_LIST_HEAD(&iter->w.lh); in ipv6_route_seq_setup_walk()
2548 fib6_walker_link(net, &iter->w); in ipv6_route_seq_setup_walk()
2574 int sernum = READ_ONCE(iter->w.root->fn_sernum); in ipv6_route_check_sernum()
2578 iter->w.state = FWS_INIT; in ipv6_route_check_sernum()
2579 iter->w.node = iter->w.root; in ipv6_route_check_sernum()
2580 WARN_ON(iter->w.skip); in ipv6_route_check_sernum()
2581 iter->w.skip = iter->w.count; in ipv6_route_check_sernum()
2603 r = fib6_walk_continue(&iter->w); in ipv6_route_seq_next()
2606 return iter->w.leaf; in ipv6_route_seq_next()
2608 fib6_walker_unlink(net, &iter->w); in ipv6_route_seq_next()
2611 fib6_walker_unlink(net, &iter->w); in ipv6_route_seq_next()
2643 struct fib6_walker *w = &iter->w; in ipv6_route_iter_active() local
2644 return w->node && !(w->state == FWS_U && w->node == w->root); in ipv6_route_iter_active()
2654 fib6_walker_unlink(net, &iter->w); in ipv6_route_native_seq_stop()
2684 iter->w.leaf = NULL; in ipv6_route_seq_show()