Skip to content

Commit 94b2cfe

Browse files
strssndktndavem330
authored andcommitted
ipv6: minor fib6 cleanups like type safety, bool conversion, inline removal
Also renamed struct fib6_walker_t to fib6_walker and enum fib_walk_state_t to fib6_walk_state as recommended by Cong Wang. Cc: Cong Wang <cwang@twopensource.com> Cc: YOSHIFUJI Hideaki <hideaki@yoshifuji.org> Cc: Martin Lau <kafai@fb.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1ff0dc9 commit 94b2cfe

2 files changed

Lines changed: 45 additions & 44 deletions

File tree

‎include/net/ip6_fib.h‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,25 @@ static inline void ip6_rt_put(struct rt6_info *rt)
202202
dst_release(&rt->dst);
203203
}
204204

205-
struct fib6_walker_t {
205+
enum fib6_walk_state {
206+
#ifdef CONFIG_IPV6_SUBTREES
207+
FWS_S,
208+
#endif
209+
FWS_L,
210+
FWS_R,
211+
FWS_C,
212+
FWS_U
213+
};
214+
215+
struct fib6_walker {
206216
struct list_head lh;
207217
struct fib6_node *root, *node;
208218
struct rt6_info *leaf;
209-
unsigned char state;
210-
unsigned char prune;
219+
enum fib6_walk_state state;
220+
bool prune;
211221
unsigned int skip;
212222
unsigned int count;
213-
int (*func)(struct fib6_walker_t *);
223+
int (*func)(struct fib6_walker *);
214224
void *args;
215225
};
216226

‎net/ipv6/ip6_fib.c‎

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,8 @@
4646

4747
static struct kmem_cache *fib6_node_kmem __read_mostly;
4848

49-
enum fib_walk_state_t {
50-
#ifdef CONFIG_IPV6_SUBTREES
51-
FWS_S,
52-
#endif
53-
FWS_L,
54-
FWS_R,
55-
FWS_C,
56-
FWS_U
57-
};
58-
59-
struct fib6_cleaner_t {
60-
struct fib6_walker_t w;
49+
struct fib6_cleaner {
50+
struct fib6_walker w;
6151
struct net *net;
6252
int (*func)(struct rt6_info *, void *arg);
6353
void *arg;
@@ -74,8 +64,8 @@ static DEFINE_RWLOCK(fib6_walker_lock);
7464
static void fib6_prune_clones(struct net *net, struct fib6_node *fn);
7565
static struct rt6_info *fib6_find_prefix(struct net *net, struct fib6_node *fn);
7666
static struct fib6_node *fib6_repair_tree(struct net *net, struct fib6_node *fn);
77-
static int fib6_walk(struct fib6_walker_t *w);
78-
static int fib6_walk_continue(struct fib6_walker_t *w);
67+
static int fib6_walk(struct fib6_walker *w);
68+
static int fib6_walk_continue(struct fib6_walker *w);
7969

8070
/*
8171
* A routing update causes an increase of the serial number on the
@@ -91,20 +81,21 @@ static void fib6_gc_timer_cb(unsigned long arg);
9181
static LIST_HEAD(fib6_walkers);
9282
#define FOR_WALKERS(w) list_for_each_entry(w, &fib6_walkers, lh)
9383

94-
static inline void fib6_walker_link(struct fib6_walker_t *w)
84+
static void fib6_walker_link(struct fib6_walker *w)
9585
{
9686
write_lock_bh(&fib6_walker_lock);
9787
list_add(&w->lh, &fib6_walkers);
9888
write_unlock_bh(&fib6_walker_lock);
9989
}
10090

101-
static inline void fib6_walker_unlink(struct fib6_walker_t *w)
91+
static void fib6_walker_unlink(struct fib6_walker *w)
10292
{
10393
write_lock_bh(&fib6_walker_lock);
10494
list_del(&w->lh);
10595
write_unlock_bh(&fib6_walker_lock);
10696
}
107-
static __inline__ u32 fib6_new_sernum(void)
97+
98+
static u32 fib6_new_sernum(void)
10899
{
109100
u32 n = ++rt_sernum;
110101
if ((__s32)n <= 0)
@@ -128,7 +119,7 @@ static __inline__ u32 fib6_new_sernum(void)
128119
# define BITOP_BE32_SWIZZLE 0
129120
#endif
130121

131-
static __inline__ __be32 addr_bit_set(const void *token, int fn_bit)
122+
static __be32 addr_bit_set(const void *token, int fn_bit)
132123
{
133124
const __be32 *addr = token;
134125
/*
@@ -142,7 +133,7 @@ static __inline__ __be32 addr_bit_set(const void *token, int fn_bit)
142133
addr[fn_bit >> 5];
143134
}
144135

145-
static __inline__ struct fib6_node *node_alloc(void)
136+
static struct fib6_node *node_alloc(void)
146137
{
147138
struct fib6_node *fn;
148139

@@ -151,12 +142,12 @@ static __inline__ struct fib6_node *node_alloc(void)
151142
return fn;
152143
}
153144

154-
static __inline__ void node_free(struct fib6_node *fn)
145+
static void node_free(struct fib6_node *fn)
155146
{
156147
kmem_cache_free(fib6_node_kmem, fn);
157148
}
158149

159-
static __inline__ void rt6_release(struct rt6_info *rt)
150+
static void rt6_release(struct rt6_info *rt)
160151
{
161152
if (atomic_dec_and_test(&rt->rt6i_ref))
162153
dst_free(&rt->dst);
@@ -267,7 +258,7 @@ static void __net_init fib6_tables_init(struct net *net)
267258

268259
#endif
269260

270-
static int fib6_dump_node(struct fib6_walker_t *w)
261+
static int fib6_dump_node(struct fib6_walker *w)
271262
{
272263
int res;
273264
struct rt6_info *rt;
@@ -287,7 +278,7 @@ static int fib6_dump_node(struct fib6_walker_t *w)
287278

288279
static void fib6_dump_end(struct netlink_callback *cb)
289280
{
290-
struct fib6_walker_t *w = (void *)cb->args[2];
281+
struct fib6_walker *w = (void *)cb->args[2];
291282

292283
if (w) {
293284
if (cb->args[4]) {
@@ -310,7 +301,7 @@ static int fib6_dump_done(struct netlink_callback *cb)
310301
static int fib6_dump_table(struct fib6_table *table, struct sk_buff *skb,
311302
struct netlink_callback *cb)
312303
{
313-
struct fib6_walker_t *w;
304+
struct fib6_walker *w;
314305
int res;
315306

316307
w = (void *)cb->args[2];
@@ -355,7 +346,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
355346
unsigned int h, s_h;
356347
unsigned int e = 0, s_e;
357348
struct rt6_rtnl_dump_arg arg;
358-
struct fib6_walker_t *w;
349+
struct fib6_walker *w;
359350
struct fib6_table *tb;
360351
struct hlist_head *head;
361352
int res = 0;
@@ -627,7 +618,7 @@ static struct fib6_node *fib6_add_1(struct fib6_node *root,
627618
return ln;
628619
}
629620

630-
static inline bool rt6_qualify_for_ecmp(struct rt6_info *rt)
621+
static bool rt6_qualify_for_ecmp(struct rt6_info *rt)
631622
{
632623
return (rt->rt6i_flags & (RTF_GATEWAY|RTF_ADDRCONF|RTF_DYNAMIC)) ==
633624
RTF_GATEWAY;
@@ -820,7 +811,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
820811
return 0;
821812
}
822813

823-
static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt)
814+
static void fib6_start_gc(struct net *net, struct rt6_info *rt)
824815
{
825816
if (!timer_pending(&net->ipv6.ip6_fib_timer) &&
826817
(rt->rt6i_flags & (RTF_EXPIRES | RTF_CACHE)))
@@ -1174,7 +1165,7 @@ static struct fib6_node *fib6_repair_tree(struct net *net,
11741165
int children;
11751166
int nstate;
11761167
struct fib6_node *child, *pn;
1177-
struct fib6_walker_t *w;
1168+
struct fib6_walker *w;
11781169
int iter = 0;
11791170

11801171
for (;;) {
@@ -1276,7 +1267,7 @@ static struct fib6_node *fib6_repair_tree(struct net *net,
12761267
static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
12771268
struct nl_info *info)
12781269
{
1279-
struct fib6_walker_t *w;
1270+
struct fib6_walker *w;
12801271
struct rt6_info *rt = *rtp;
12811272
struct net *net = info->nl_net;
12821273

@@ -1414,7 +1405,7 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info)
14141405
* <0 -> walk is terminated by an error.
14151406
*/
14161407

1417-
static int fib6_walk_continue(struct fib6_walker_t *w)
1408+
static int fib6_walk_continue(struct fib6_walker *w)
14181409
{
14191410
struct fib6_node *fn, *pn;
14201411

@@ -1498,7 +1489,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w)
14981489
}
14991490
}
15001491

1501-
static int fib6_walk(struct fib6_walker_t *w)
1492+
static int fib6_walk(struct fib6_walker *w)
15021493
{
15031494
int res;
15041495

@@ -1512,11 +1503,11 @@ static int fib6_walk(struct fib6_walker_t *w)
15121503
return res;
15131504
}
15141505

1515-
static int fib6_clean_node(struct fib6_walker_t *w)
1506+
static int fib6_clean_node(struct fib6_walker *w)
15161507
{
15171508
int res;
15181509
struct rt6_info *rt;
1519-
struct fib6_cleaner_t *c = container_of(w, struct fib6_cleaner_t, w);
1510+
struct fib6_cleaner *c = container_of(w, struct fib6_cleaner, w);
15201511
struct nl_info info = {
15211512
.nl_net = c->net,
15221513
};
@@ -1554,9 +1545,9 @@ static int fib6_clean_node(struct fib6_walker_t *w)
15541545

15551546
static void fib6_clean_tree(struct net *net, struct fib6_node *root,
15561547
int (*func)(struct rt6_info *, void *arg),
1557-
int prune, void *arg)
1548+
bool prune, void *arg)
15581549
{
1559-
struct fib6_cleaner_t c;
1550+
struct fib6_cleaner c;
15601551

15611552
c.w.root = root;
15621553
c.w.func = fib6_clean_node;
@@ -1583,7 +1574,7 @@ void fib6_clean_all(struct net *net, int (*func)(struct rt6_info *, void *arg),
15831574
hlist_for_each_entry_rcu(table, head, tb6_hlist) {
15841575
write_lock_bh(&table->tb6_lock);
15851576
fib6_clean_tree(net, &table->tb6_root,
1586-
func, 0, arg);
1577+
func, false, arg);
15871578
write_unlock_bh(&table->tb6_lock);
15881579
}
15891580
}
@@ -1602,7 +1593,7 @@ static int fib6_prune_clone(struct rt6_info *rt, void *arg)
16021593

16031594
static void fib6_prune_clones(struct net *net, struct fib6_node *fn)
16041595
{
1605-
fib6_clean_tree(net, fn, fib6_prune_clone, 1, NULL);
1596+
fib6_clean_tree(net, fn, fib6_prune_clone, true, NULL);
16061597
}
16071598

16081599
static int fib6_update_sernum(struct rt6_info *rt, void *arg)
@@ -1828,7 +1819,7 @@ void fib6_gc_cleanup(void)
18281819

18291820
struct ipv6_route_iter {
18301821
struct seq_net_private p;
1831-
struct fib6_walker_t w;
1822+
struct fib6_walker w;
18321823
loff_t skip;
18331824
struct fib6_table *tbl;
18341825
__u32 sernum;
@@ -1859,7 +1850,7 @@ static int ipv6_route_seq_show(struct seq_file *seq, void *v)
18591850
return 0;
18601851
}
18611852

1862-
static int ipv6_route_yield(struct fib6_walker_t *w)
1853+
static int ipv6_route_yield(struct fib6_walker *w)
18631854
{
18641855
struct ipv6_route_iter *iter = w->args;
18651856

@@ -1980,7 +1971,7 @@ static void *ipv6_route_seq_start(struct seq_file *seq, loff_t *pos)
19801971

19811972
static bool ipv6_route_iter_active(struct ipv6_route_iter *iter)
19821973
{
1983-
struct fib6_walker_t *w = &iter->w;
1974+
struct fib6_walker *w = &iter->w;
19841975
return w->node && !(w->state == FWS_U && w->node == w->root);
19851976
}
19861977

0 commit comments

Comments
 (0)