aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_trie.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r--net/ipv4/fib_trie.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 4b02d14e7ab9..5cb72786a8af 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -22,8 +22,6 @@
22 * IP-address lookup using LC-tries. Stefan Nilsson and Gunnar Karlsson 22 * IP-address lookup using LC-tries. Stefan Nilsson and Gunnar Karlsson
23 * IEEE Journal on Selected Areas in Communications, 17(6):1083-1092, June 1999 23 * IEEE Journal on Selected Areas in Communications, 17(6):1083-1092, June 1999
24 * 24 *
25 * Version: $Id: fib_trie.c,v 1.3 2005/06/08 14:20:01 robert Exp $
26 *
27 * 25 *
28 * Code from fib_hash has been reused which includes the following header: 26 * Code from fib_hash has been reused which includes the following header:
29 * 27 *
@@ -1273,7 +1271,7 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1273 1271
1274 fib_release_info(fi_drop); 1272 fib_release_info(fi_drop);
1275 if (state & FA_S_ACCESSED) 1273 if (state & FA_S_ACCESSED)
1276 rt_cache_flush(-1); 1274 rt_cache_flush(cfg->fc_nlinfo.nl_net, -1);
1277 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, 1275 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen,
1278 tb->tb_id, &cfg->fc_nlinfo, NLM_F_REPLACE); 1276 tb->tb_id, &cfg->fc_nlinfo, NLM_F_REPLACE);
1279 1277
@@ -1318,7 +1316,7 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1318 list_add_tail_rcu(&new_fa->fa_list, 1316 list_add_tail_rcu(&new_fa->fa_list,
1319 (fa ? &fa->fa_list : fa_head)); 1317 (fa ? &fa->fa_list : fa_head));
1320 1318
1321 rt_cache_flush(-1); 1319 rt_cache_flush(cfg->fc_nlinfo.nl_net, -1);
1322 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id, 1320 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id,
1323 &cfg->fc_nlinfo, 0); 1321 &cfg->fc_nlinfo, 0);
1324succeeded: 1322succeeded:
@@ -1359,17 +1357,17 @@ static int check_leaf(struct trie *t, struct leaf *l,
1359 t->stats.semantic_match_miss++; 1357 t->stats.semantic_match_miss++;
1360#endif 1358#endif
1361 if (err <= 0) 1359 if (err <= 0)
1362 return plen; 1360 return err;
1363 } 1361 }
1364 1362
1365 return -1; 1363 return 1;
1366} 1364}
1367 1365
1368static int fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, 1366static int fn_trie_lookup(struct fib_table *tb, const struct flowi *flp,
1369 struct fib_result *res) 1367 struct fib_result *res)
1370{ 1368{
1371 struct trie *t = (struct trie *) tb->tb_data; 1369 struct trie *t = (struct trie *) tb->tb_data;
1372 int plen, ret = 0; 1370 int ret;
1373 struct node *n; 1371 struct node *n;
1374 struct tnode *pn; 1372 struct tnode *pn;
1375 int pos, bits; 1373 int pos, bits;
@@ -1393,10 +1391,7 @@ static int fn_trie_lookup(struct fib_table *tb, const struct flowi *flp,
1393 1391
1394 /* Just a leaf? */ 1392 /* Just a leaf? */
1395 if (IS_LEAF(n)) { 1393 if (IS_LEAF(n)) {
1396 plen = check_leaf(t, (struct leaf *)n, key, flp, res); 1394 ret = check_leaf(t, (struct leaf *)n, key, flp, res);
1397 if (plen < 0)
1398 goto failed;
1399 ret = 0;
1400 goto found; 1395 goto found;
1401 } 1396 }
1402 1397
@@ -1421,11 +1416,9 @@ static int fn_trie_lookup(struct fib_table *tb, const struct flowi *flp,
1421 } 1416 }
1422 1417
1423 if (IS_LEAF(n)) { 1418 if (IS_LEAF(n)) {
1424 plen = check_leaf(t, (struct leaf *)n, key, flp, res); 1419 ret = check_leaf(t, (struct leaf *)n, key, flp, res);
1425 if (plen < 0) 1420 if (ret > 0)
1426 goto backtrace; 1421 goto backtrace;
1427
1428 ret = 0;
1429 goto found; 1422 goto found;
1430 } 1423 }
1431 1424
@@ -1666,7 +1659,7 @@ static int fn_trie_delete(struct fib_table *tb, struct fib_config *cfg)
1666 trie_leaf_remove(t, l); 1659 trie_leaf_remove(t, l);
1667 1660
1668 if (fa->fa_state & FA_S_ACCESSED) 1661 if (fa->fa_state & FA_S_ACCESSED)
1669 rt_cache_flush(-1); 1662 rt_cache_flush(cfg->fc_nlinfo.nl_net, -1);
1670 1663
1671 fib_release_info(fa->fa_info); 1664 fib_release_info(fa->fa_info);
1672 alias_free_mem_rcu(fa); 1665 alias_free_mem_rcu(fa);
@@ -2258,25 +2251,7 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2258 2251
2259static int fib_triestat_seq_open(struct inode *inode, struct file *file) 2252static int fib_triestat_seq_open(struct inode *inode, struct file *file)
2260{ 2253{
2261 int err; 2254 return single_open_net(inode, file, fib_triestat_seq_show);
2262 struct net *net;
2263
2264 net = get_proc_net(inode);
2265 if (net == NULL)
2266 return -ENXIO;
2267 err = single_open(file, fib_triestat_seq_show, net);
2268 if (err < 0) {
2269 put_net(net);
2270 return err;
2271 }
2272 return 0;
2273}
2274
2275static int fib_triestat_seq_release(struct inode *ino, struct file *f)
2276{
2277 struct seq_file *seq = f->private_data;
2278 put_net(seq->private);
2279 return single_release(ino, f);
2280} 2255}
2281 2256
2282static const struct file_operations fib_triestat_fops = { 2257static const struct file_operations fib_triestat_fops = {
@@ -2284,7 +2259,7 @@ static const struct file_operations fib_triestat_fops = {
2284 .open = fib_triestat_seq_open, 2259 .open = fib_triestat_seq_open,
2285 .read = seq_read, 2260 .read = seq_read,
2286 .llseek = seq_lseek, 2261 .llseek = seq_lseek,
2287 .release = fib_triestat_seq_release, 2262 .release = single_release_net,
2288}; 2263};
2289 2264
2290static struct node *fib_trie_get_idx(struct seq_file *seq, loff_t pos) 2265static struct node *fib_trie_get_idx(struct seq_file *seq, loff_t pos)