aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet/dn_table.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 14:38:13 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 14:38:13 -0500
commitcb18eccff48ef3986d1072964590bce6fec705fb (patch)
tree777fb1d15e0281341e1e02c9803d989538d346f2 /net/decnet/dn_table.c
parentc827ba4cb49a30ce581201fd0ba2be77cde412c7 (diff)
parent5ef213f6842277ee1df5659f59fac0ffc9beb411 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (45 commits) [IPV4]: Restore multipath routing after rt_next changes. [XFRM] IPV6: Fix outbound RO transformation which is broken by IPsec tunnel patch. [NET]: Reorder fields of struct dst_entry [DECNET]: Convert decnet route to use the new dst_entry 'next' pointer [IPV6]: Convert ipv6 route to use the new dst_entry 'next' pointer [IPV4]: Convert ipv4 route to use the new dst_entry 'next' pointer [NET]: Introduce union in struct dst_entry to hold 'next' pointer [DECNET]: fix misannotation of linkinfo_dn [DECNET]: FRA_{DST,SRC} are le16 for decnet [UDP]: UDP can use sk_hash to speedup lookups [NET]: Fix whitespace errors. [NET] XFRM: Fix whitespace errors. [NET] X25: Fix whitespace errors. [NET] WANROUTER: Fix whitespace errors. [NET] UNIX: Fix whitespace errors. [NET] TIPC: Fix whitespace errors. [NET] SUNRPC: Fix whitespace errors. [NET] SCTP: Fix whitespace errors. [NET] SCHED: Fix whitespace errors. [NET] RXRPC: Fix whitespace errors. ...
Diffstat (limited to 'net/decnet/dn_table.c')
-rw-r--r--net/decnet/dn_table.c238
1 files changed, 119 insertions, 119 deletions
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index 720501e1ae20..780a141f8342 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -60,7 +60,7 @@ struct dn_hash
60#define dz_prefix(key,dz) ((key).datum) 60#define dz_prefix(key,dz) ((key).datum)
61 61
62#define for_nexthops(fi) { int nhsel; const struct dn_fib_nh *nh;\ 62#define for_nexthops(fi) { int nhsel; const struct dn_fib_nh *nh;\
63 for(nhsel = 0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++) 63 for(nhsel = 0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++)
64 64
65#define endfor_nexthops(fi) } 65#define endfor_nexthops(fi) }
66 66
@@ -290,82 +290,82 @@ static inline size_t dn_fib_nlmsg_size(struct dn_fib_info *fi)
290} 290}
291 291
292static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, 292static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
293 u32 tb_id, u8 type, u8 scope, void *dst, int dst_len, 293 u32 tb_id, u8 type, u8 scope, void *dst, int dst_len,
294 struct dn_fib_info *fi, unsigned int flags) 294 struct dn_fib_info *fi, unsigned int flags)
295{ 295{
296 struct rtmsg *rtm; 296 struct rtmsg *rtm;
297 struct nlmsghdr *nlh; 297 struct nlmsghdr *nlh;
298 unsigned char *b = skb->tail; 298 unsigned char *b = skb->tail;
299 299
300 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags); 300 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags);
301 rtm = NLMSG_DATA(nlh); 301 rtm = NLMSG_DATA(nlh);
302 rtm->rtm_family = AF_DECnet; 302 rtm->rtm_family = AF_DECnet;
303 rtm->rtm_dst_len = dst_len; 303 rtm->rtm_dst_len = dst_len;
304 rtm->rtm_src_len = 0; 304 rtm->rtm_src_len = 0;
305 rtm->rtm_tos = 0; 305 rtm->rtm_tos = 0;
306 rtm->rtm_table = tb_id; 306 rtm->rtm_table = tb_id;
307 RTA_PUT_U32(skb, RTA_TABLE, tb_id); 307 RTA_PUT_U32(skb, RTA_TABLE, tb_id);
308 rtm->rtm_flags = fi->fib_flags; 308 rtm->rtm_flags = fi->fib_flags;
309 rtm->rtm_scope = scope; 309 rtm->rtm_scope = scope;
310 rtm->rtm_type = type; 310 rtm->rtm_type = type;
311 if (rtm->rtm_dst_len) 311 if (rtm->rtm_dst_len)
312 RTA_PUT(skb, RTA_DST, 2, dst); 312 RTA_PUT(skb, RTA_DST, 2, dst);
313 rtm->rtm_protocol = fi->fib_protocol; 313 rtm->rtm_protocol = fi->fib_protocol;
314 if (fi->fib_priority) 314 if (fi->fib_priority)
315 RTA_PUT(skb, RTA_PRIORITY, 4, &fi->fib_priority); 315 RTA_PUT(skb, RTA_PRIORITY, 4, &fi->fib_priority);
316 if (rtnetlink_put_metrics(skb, fi->fib_metrics) < 0) 316 if (rtnetlink_put_metrics(skb, fi->fib_metrics) < 0)
317 goto rtattr_failure; 317 goto rtattr_failure;
318 if (fi->fib_nhs == 1) { 318 if (fi->fib_nhs == 1) {
319 if (fi->fib_nh->nh_gw) 319 if (fi->fib_nh->nh_gw)
320 RTA_PUT(skb, RTA_GATEWAY, 2, &fi->fib_nh->nh_gw); 320 RTA_PUT(skb, RTA_GATEWAY, 2, &fi->fib_nh->nh_gw);
321 if (fi->fib_nh->nh_oif) 321 if (fi->fib_nh->nh_oif)
322 RTA_PUT(skb, RTA_OIF, sizeof(int), &fi->fib_nh->nh_oif); 322 RTA_PUT(skb, RTA_OIF, sizeof(int), &fi->fib_nh->nh_oif);
323 } 323 }
324 if (fi->fib_nhs > 1) { 324 if (fi->fib_nhs > 1) {
325 struct rtnexthop *nhp; 325 struct rtnexthop *nhp;
326 struct rtattr *mp_head; 326 struct rtattr *mp_head;
327 if (skb_tailroom(skb) <= RTA_SPACE(0)) 327 if (skb_tailroom(skb) <= RTA_SPACE(0))
328 goto rtattr_failure; 328 goto rtattr_failure;
329 mp_head = (struct rtattr *)skb_put(skb, RTA_SPACE(0)); 329 mp_head = (struct rtattr *)skb_put(skb, RTA_SPACE(0));
330 330
331 for_nexthops(fi) { 331 for_nexthops(fi) {
332 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4)) 332 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4))
333 goto rtattr_failure; 333 goto rtattr_failure;
334 nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp))); 334 nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp)));
335 nhp->rtnh_flags = nh->nh_flags & 0xFF; 335 nhp->rtnh_flags = nh->nh_flags & 0xFF;
336 nhp->rtnh_hops = nh->nh_weight - 1; 336 nhp->rtnh_hops = nh->nh_weight - 1;
337 nhp->rtnh_ifindex = nh->nh_oif; 337 nhp->rtnh_ifindex = nh->nh_oif;
338 if (nh->nh_gw) 338 if (nh->nh_gw)
339 RTA_PUT(skb, RTA_GATEWAY, 2, &nh->nh_gw); 339 RTA_PUT(skb, RTA_GATEWAY, 2, &nh->nh_gw);
340 nhp->rtnh_len = skb->tail - (unsigned char *)nhp; 340 nhp->rtnh_len = skb->tail - (unsigned char *)nhp;
341 } endfor_nexthops(fi); 341 } endfor_nexthops(fi);
342 mp_head->rta_type = RTA_MULTIPATH; 342 mp_head->rta_type = RTA_MULTIPATH;
343 mp_head->rta_len = skb->tail - (u8*)mp_head; 343 mp_head->rta_len = skb->tail - (u8*)mp_head;
344 } 344 }
345 345
346 nlh->nlmsg_len = skb->tail - b; 346 nlh->nlmsg_len = skb->tail - b;
347 return skb->len; 347 return skb->len;
348 348
349 349
350nlmsg_failure: 350nlmsg_failure:
351rtattr_failure: 351rtattr_failure:
352 skb_trim(skb, b - skb->data); 352 skb_trim(skb, b - skb->data);
353 return -EMSGSIZE; 353 return -EMSGSIZE;
354} 354}
355 355
356 356
357static void dn_rtmsg_fib(int event, struct dn_fib_node *f, int z, u32 tb_id, 357static void dn_rtmsg_fib(int event, struct dn_fib_node *f, int z, u32 tb_id,
358 struct nlmsghdr *nlh, struct netlink_skb_parms *req) 358 struct nlmsghdr *nlh, struct netlink_skb_parms *req)
359{ 359{
360 struct sk_buff *skb; 360 struct sk_buff *skb;
361 u32 pid = req ? req->pid : 0; 361 u32 pid = req ? req->pid : 0;
362 int err = -ENOBUFS; 362 int err = -ENOBUFS;
363 363
364 skb = nlmsg_new(dn_fib_nlmsg_size(DN_FIB_INFO(f)), GFP_KERNEL); 364 skb = nlmsg_new(dn_fib_nlmsg_size(DN_FIB_INFO(f)), GFP_KERNEL);
365 if (skb == NULL) 365 if (skb == NULL)
366 goto errout; 366 goto errout;
367 367
368 err = dn_fib_dump_info(skb, pid, nlh->nlmsg_seq, event, tb_id, 368 err = dn_fib_dump_info(skb, pid, nlh->nlmsg_seq, event, tb_id,
369 f->fn_type, f->fn_scope, &f->fn_key, z, 369 f->fn_type, f->fn_scope, &f->fn_key, z,
370 DN_FIB_INFO(f), 0); 370 DN_FIB_INFO(f), 0);
371 if (err < 0) { 371 if (err < 0) {
@@ -380,7 +380,7 @@ errout:
380 rtnl_set_sk_err(RTNLGRP_DECnet_ROUTE, err); 380 rtnl_set_sk_err(RTNLGRP_DECnet_ROUTE, err);
381} 381}
382 382
383static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb, 383static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb,
384 struct netlink_callback *cb, 384 struct netlink_callback *cb,
385 struct dn_fib_table *tb, 385 struct dn_fib_table *tb,
386 struct dn_zone *dz, 386 struct dn_zone *dz,
@@ -394,12 +394,12 @@ static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb,
394 continue; 394 continue;
395 if (f->fn_state & DN_S_ZOMBIE) 395 if (f->fn_state & DN_S_ZOMBIE)
396 continue; 396 continue;
397 if (dn_fib_dump_info(skb, NETLINK_CB(cb->skb).pid, 397 if (dn_fib_dump_info(skb, NETLINK_CB(cb->skb).pid,
398 cb->nlh->nlmsg_seq, 398 cb->nlh->nlmsg_seq,
399 RTM_NEWROUTE, 399 RTM_NEWROUTE,
400 tb->n, 400 tb->n,
401 (f->fn_state & DN_S_ZOMBIE) ? 0 : f->fn_type, 401 (f->fn_state & DN_S_ZOMBIE) ? 0 : f->fn_type,
402 f->fn_scope, &f->fn_key, dz->dz_order, 402 f->fn_scope, &f->fn_key, dz->dz_order,
403 f->fn_info, NLM_F_MULTI) < 0) { 403 f->fn_info, NLM_F_MULTI) < 0) {
404 cb->args[4] = i; 404 cb->args[4] = i;
405 return -1; 405 return -1;
@@ -409,7 +409,7 @@ static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb,
409 return skb->len; 409 return skb->len;
410} 410}
411 411
412static __inline__ int dn_hash_dump_zone(struct sk_buff *skb, 412static __inline__ int dn_hash_dump_zone(struct sk_buff *skb,
413 struct netlink_callback *cb, 413 struct netlink_callback *cb,
414 struct dn_fib_table *tb, 414 struct dn_fib_table *tb,
415 struct dn_zone *dz) 415 struct dn_zone *dz)
@@ -433,10 +433,10 @@ static __inline__ int dn_hash_dump_zone(struct sk_buff *skb,
433 return skb->len; 433 return skb->len;
434} 434}
435 435
436static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb, 436static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb,
437 struct netlink_callback *cb) 437 struct netlink_callback *cb)
438{ 438{
439 int m, s_m; 439 int m, s_m;
440 struct dn_zone *dz; 440 struct dn_zone *dz;
441 struct dn_hash *table = (struct dn_hash *)tb->data; 441 struct dn_hash *table = (struct dn_hash *)tb->data;
442 442
@@ -457,7 +457,7 @@ static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb,
457 read_unlock(&dn_fib_tables_lock); 457 read_unlock(&dn_fib_tables_lock);
458 cb->args[2] = m; 458 cb->args[2] = m;
459 459
460 return skb->len; 460 return skb->len;
461} 461}
462 462
463int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb) 463int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
@@ -482,7 +482,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
482 goto next; 482 goto next;
483 if (dumped) 483 if (dumped)
484 memset(&cb->args[2], 0, sizeof(cb->args) - 484 memset(&cb->args[2], 0, sizeof(cb->args) -
485 2 * sizeof(cb->args[0])); 485 2 * sizeof(cb->args[0]));
486 if (tb->dump(tb, skb, cb) < 0) 486 if (tb->dump(tb, skb, cb) < 0)
487 goto out; 487 goto out;
488 dumped = 1; 488 dumped = 1;
@@ -503,13 +503,13 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
503 struct dn_fib_node *new_f, *f, **fp, **del_fp; 503 struct dn_fib_node *new_f, *f, **fp, **del_fp;
504 struct dn_zone *dz; 504 struct dn_zone *dz;
505 struct dn_fib_info *fi; 505 struct dn_fib_info *fi;
506 int z = r->rtm_dst_len; 506 int z = r->rtm_dst_len;
507 int type = r->rtm_type; 507 int type = r->rtm_type;
508 dn_fib_key_t key; 508 dn_fib_key_t key;
509 int err; 509 int err;
510 510
511 if (z > 16) 511 if (z > 16)
512 return -EINVAL; 512 return -EINVAL;
513 513
514 dz = table->dh_zones[z]; 514 dz = table->dh_zones[z];
515 if (!dz && !(dz = dn_new_zone(table, z))) 515 if (!dz && !(dz = dn_new_zone(table, z)))
@@ -524,8 +524,8 @@ static int dn_fib_table_insert(struct dn_fib_table *tb, struct rtmsg *r, struct
524 key = dz_key(dst, dz); 524 key = dz_key(dst, dz);
525 } 525 }
526 526
527 if ((fi = dn_fib_create_info(r, rta, n, &err)) == NULL) 527 if ((fi = dn_fib_create_info(r, rta, n, &err)) == NULL)
528 return err; 528 return err;
529 529
530 if (dz->dz_nent > (dz->dz_divisor << 2) && 530 if (dz->dz_nent > (dz->dz_divisor << 2) &&
531 dz->dz_divisor > DN_MAX_DIVISOR && 531 dz->dz_divisor > DN_MAX_DIVISOR &&
@@ -624,9 +624,9 @@ replace:
624 dn_rt_cache_flush(-1); 624 dn_rt_cache_flush(-1);
625 } 625 }
626 626
627 dn_rtmsg_fib(RTM_NEWROUTE, new_f, z, tb->n, n, req); 627 dn_rtmsg_fib(RTM_NEWROUTE, new_f, z, tb->n, n, req);
628 628
629 return 0; 629 return 0;
630out: 630out:
631 dn_fib_release_info(fi); 631 dn_fib_release_info(fi);
632 return err; 632 return err;
@@ -637,14 +637,14 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
637{ 637{
638 struct dn_hash *table = (struct dn_hash*)tb->data; 638 struct dn_hash *table = (struct dn_hash*)tb->data;
639 struct dn_fib_node **fp, **del_fp, *f; 639 struct dn_fib_node **fp, **del_fp, *f;
640 int z = r->rtm_dst_len; 640 int z = r->rtm_dst_len;
641 struct dn_zone *dz; 641 struct dn_zone *dz;
642 dn_fib_key_t key; 642 dn_fib_key_t key;
643 int matched; 643 int matched;
644 644
645 645
646 if (z > 16) 646 if (z > 16)
647 return -EINVAL; 647 return -EINVAL;
648 648
649 if ((dz = table->dh_zones[z]) == NULL) 649 if ((dz = table->dh_zones[z]) == NULL)
650 return -ESRCH; 650 return -ESRCH;
@@ -680,7 +680,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
680 if (del_fp == NULL && 680 if (del_fp == NULL &&
681 (!r->rtm_type || f->fn_type == r->rtm_type) && 681 (!r->rtm_type || f->fn_type == r->rtm_type) &&
682 (r->rtm_scope == RT_SCOPE_NOWHERE || f->fn_scope == r->rtm_scope) && 682 (r->rtm_scope == RT_SCOPE_NOWHERE || f->fn_scope == r->rtm_scope) &&
683 (!r->rtm_protocol || 683 (!r->rtm_protocol ||
684 fi->fib_protocol == r->rtm_protocol) && 684 fi->fib_protocol == r->rtm_protocol) &&
685 dn_fib_nh_match(r, n, rta, fi) == 0) 685 dn_fib_nh_match(r, n, rta, fi) == 0)
686 del_fp = fp; 686 del_fp = fp;
@@ -688,7 +688,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
688 688
689 if (del_fp) { 689 if (del_fp) {
690 f = *del_fp; 690 f = *del_fp;
691 dn_rtmsg_fib(RTM_DELROUTE, f, z, tb->n, n, req); 691 dn_rtmsg_fib(RTM_DELROUTE, f, z, tb->n, n, req);
692 692
693 if (matched != 1) { 693 if (matched != 1) {
694 write_lock_bh(&dn_fib_tables_lock); 694 write_lock_bh(&dn_fib_tables_lock);
@@ -712,7 +712,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct
712 return 0; 712 return 0;
713 } 713 }
714 714
715 return -ESRCH; 715 return -ESRCH;
716} 716}
717 717
718static inline int dn_flush_list(struct dn_fib_node **fp, int z, struct dn_hash *table) 718static inline int dn_flush_list(struct dn_fib_node **fp, int z, struct dn_hash *table)
@@ -759,7 +759,7 @@ static int dn_fib_table_flush(struct dn_fib_table *tb)
759 759
760static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, struct dn_fib_res *res) 760static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, struct dn_fib_res *res)
761{ 761{
762 int err; 762 int err;
763 struct dn_zone *dz; 763 struct dn_zone *dz;
764 struct dn_hash *t = (struct dn_hash *)tb->data; 764 struct dn_hash *t = (struct dn_hash *)tb->data;
765 765
@@ -788,7 +788,7 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp,
788 788
789 if (err == 0) { 789 if (err == 0) {
790 res->type = f->fn_type; 790 res->type = f->fn_type;
791 res->scope = f->fn_scope; 791 res->scope = f->fn_scope;
792 res->prefixlen = dz->dz_order; 792 res->prefixlen = dz->dz_order;
793 goto out; 793 goto out;
794 } 794 }
@@ -799,21 +799,21 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp,
799 err = 1; 799 err = 1;
800out: 800out:
801 read_unlock(&dn_fib_tables_lock); 801 read_unlock(&dn_fib_tables_lock);
802 return err; 802 return err;
803} 803}
804 804
805 805
806struct dn_fib_table *dn_fib_get_table(u32 n, int create) 806struct dn_fib_table *dn_fib_get_table(u32 n, int create)
807{ 807{
808 struct dn_fib_table *t; 808 struct dn_fib_table *t;
809 struct hlist_node *node; 809 struct hlist_node *node;
810 unsigned int h; 810 unsigned int h;
811 811
812 if (n < RT_TABLE_MIN) 812 if (n < RT_TABLE_MIN)
813 return NULL; 813 return NULL;
814 814
815 if (n > RT_TABLE_MAX) 815 if (n > RT_TABLE_MAX)
816 return NULL; 816 return NULL;
817 817
818 h = n & (DN_FIB_TABLE_HASHSZ - 1); 818 h = n & (DN_FIB_TABLE_HASHSZ - 1);
819 rcu_read_lock(); 819 rcu_read_lock();
@@ -825,54 +825,54 @@ struct dn_fib_table *dn_fib_get_table(u32 n, int create)
825 } 825 }
826 rcu_read_unlock(); 826 rcu_read_unlock();
827 827
828 if (!create) 828 if (!create)
829 return NULL; 829 return NULL;
830 830
831 if (in_interrupt() && net_ratelimit()) { 831 if (in_interrupt() && net_ratelimit()) {
832 printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n"); 832 printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n");
833 return NULL; 833 return NULL;
834 } 834 }
835 835
836 t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash), 836 t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash),
837 GFP_KERNEL); 837 GFP_KERNEL);
838 if (t == NULL) 838 if (t == NULL)
839 return NULL; 839 return NULL;
840 840
841 t->n = n; 841 t->n = n;
842 t->insert = dn_fib_table_insert; 842 t->insert = dn_fib_table_insert;
843 t->delete = dn_fib_table_delete; 843 t->delete = dn_fib_table_delete;
844 t->lookup = dn_fib_table_lookup; 844 t->lookup = dn_fib_table_lookup;
845 t->flush = dn_fib_table_flush; 845 t->flush = dn_fib_table_flush;
846 t->dump = dn_fib_table_dump; 846 t->dump = dn_fib_table_dump;
847 hlist_add_head_rcu(&t->hlist, &dn_fib_table_hash[h]); 847 hlist_add_head_rcu(&t->hlist, &dn_fib_table_hash[h]);
848 848
849 return t; 849 return t;
850} 850}
851 851
852struct dn_fib_table *dn_fib_empty_table(void) 852struct dn_fib_table *dn_fib_empty_table(void)
853{ 853{
854 u32 id; 854 u32 id;
855 855
856 for(id = RT_TABLE_MIN; id <= RT_TABLE_MAX; id++) 856 for(id = RT_TABLE_MIN; id <= RT_TABLE_MAX; id++)
857 if (dn_fib_get_table(id, 0) == NULL) 857 if (dn_fib_get_table(id, 0) == NULL)
858 return dn_fib_get_table(id, 1); 858 return dn_fib_get_table(id, 1);
859 return NULL; 859 return NULL;
860} 860}
861 861
862void dn_fib_flush(void) 862void dn_fib_flush(void)
863{ 863{
864 int flushed = 0; 864 int flushed = 0;
865 struct dn_fib_table *tb; 865 struct dn_fib_table *tb;
866 struct hlist_node *node; 866 struct hlist_node *node;
867 unsigned int h; 867 unsigned int h;
868 868
869 for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) { 869 for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) {
870 hlist_for_each_entry(tb, node, &dn_fib_table_hash[h], hlist) 870 hlist_for_each_entry(tb, node, &dn_fib_table_hash[h], hlist)
871 flushed += tb->flush(tb); 871 flushed += tb->flush(tb);
872 } 872 }
873 873
874 if (flushed) 874 if (flushed)
875 dn_rt_cache_flush(-1); 875 dn_rt_cache_flush(-1);
876} 876}
877 877
878void __init dn_fib_table_init(void) 878void __init dn_fib_table_init(void)
@@ -892,7 +892,7 @@ void __exit dn_fib_table_cleanup(void)
892 write_lock(&dn_fib_tables_lock); 892 write_lock(&dn_fib_tables_lock);
893 for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) { 893 for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) {
894 hlist_for_each_entry_safe(t, node, next, &dn_fib_table_hash[h], 894 hlist_for_each_entry_safe(t, node, next, &dn_fib_table_hash[h],
895 hlist) { 895 hlist) {
896 hlist_del(&t->hlist); 896 hlist_del(&t->hlist);
897 kfree(t); 897 kfree(t);
898 } 898 }