diff options
Diffstat (limited to 'net/decnet/dn_table.c')
-rw-r--r-- | net/decnet/dn_table.c | 238 |
1 files changed, 119 insertions, 119 deletions
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c index c1f0cc1b1c60..0542015922d6 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 | ||
292 | static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, | 292 | static 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 | ||
350 | nlmsg_failure: | 350 | nlmsg_failure: |
351 | rtattr_failure: | 351 | rtattr_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 | ||
357 | static void dn_rtmsg_fib(int event, struct dn_fib_node *f, int z, u32 tb_id, | 357 | static 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 | ||
383 | static __inline__ int dn_hash_dump_bucket(struct sk_buff *skb, | 383 | static __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 | ||
412 | static __inline__ int dn_hash_dump_zone(struct sk_buff *skb, | 412 | static __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 | ||
436 | static int dn_fib_table_dump(struct dn_fib_table *tb, struct sk_buff *skb, | 436 | static 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 | ||
463 | int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb) | 463 | int 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 && |
@@ -626,9 +626,9 @@ replace: | |||
626 | dn_rt_cache_flush(-1); | 626 | dn_rt_cache_flush(-1); |
627 | } | 627 | } |
628 | 628 | ||
629 | dn_rtmsg_fib(RTM_NEWROUTE, new_f, z, tb->n, n, req); | 629 | dn_rtmsg_fib(RTM_NEWROUTE, new_f, z, tb->n, n, req); |
630 | 630 | ||
631 | return 0; | 631 | return 0; |
632 | out: | 632 | out: |
633 | dn_fib_release_info(fi); | 633 | dn_fib_release_info(fi); |
634 | return err; | 634 | return err; |
@@ -639,14 +639,14 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct | |||
639 | { | 639 | { |
640 | struct dn_hash *table = (struct dn_hash*)tb->data; | 640 | struct dn_hash *table = (struct dn_hash*)tb->data; |
641 | struct dn_fib_node **fp, **del_fp, *f; | 641 | struct dn_fib_node **fp, **del_fp, *f; |
642 | int z = r->rtm_dst_len; | 642 | int z = r->rtm_dst_len; |
643 | struct dn_zone *dz; | 643 | struct dn_zone *dz; |
644 | dn_fib_key_t key; | 644 | dn_fib_key_t key; |
645 | int matched; | 645 | int matched; |
646 | 646 | ||
647 | 647 | ||
648 | if (z > 16) | 648 | if (z > 16) |
649 | return -EINVAL; | 649 | return -EINVAL; |
650 | 650 | ||
651 | if ((dz = table->dh_zones[z]) == NULL) | 651 | if ((dz = table->dh_zones[z]) == NULL) |
652 | return -ESRCH; | 652 | return -ESRCH; |
@@ -682,7 +682,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct | |||
682 | if (del_fp == NULL && | 682 | if (del_fp == NULL && |
683 | (!r->rtm_type || f->fn_type == r->rtm_type) && | 683 | (!r->rtm_type || f->fn_type == r->rtm_type) && |
684 | (r->rtm_scope == RT_SCOPE_NOWHERE || f->fn_scope == r->rtm_scope) && | 684 | (r->rtm_scope == RT_SCOPE_NOWHERE || f->fn_scope == r->rtm_scope) && |
685 | (!r->rtm_protocol || | 685 | (!r->rtm_protocol || |
686 | fi->fib_protocol == r->rtm_protocol) && | 686 | fi->fib_protocol == r->rtm_protocol) && |
687 | dn_fib_nh_match(r, n, rta, fi) == 0) | 687 | dn_fib_nh_match(r, n, rta, fi) == 0) |
688 | del_fp = fp; | 688 | del_fp = fp; |
@@ -690,7 +690,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct | |||
690 | 690 | ||
691 | if (del_fp) { | 691 | if (del_fp) { |
692 | f = *del_fp; | 692 | f = *del_fp; |
693 | dn_rtmsg_fib(RTM_DELROUTE, f, z, tb->n, n, req); | 693 | dn_rtmsg_fib(RTM_DELROUTE, f, z, tb->n, n, req); |
694 | 694 | ||
695 | if (matched != 1) { | 695 | if (matched != 1) { |
696 | write_lock_bh(&dn_fib_tables_lock); | 696 | write_lock_bh(&dn_fib_tables_lock); |
@@ -714,7 +714,7 @@ static int dn_fib_table_delete(struct dn_fib_table *tb, struct rtmsg *r, struct | |||
714 | return 0; | 714 | return 0; |
715 | } | 715 | } |
716 | 716 | ||
717 | return -ESRCH; | 717 | return -ESRCH; |
718 | } | 718 | } |
719 | 719 | ||
720 | static inline int dn_flush_list(struct dn_fib_node **fp, int z, struct dn_hash *table) | 720 | static inline int dn_flush_list(struct dn_fib_node **fp, int z, struct dn_hash *table) |
@@ -761,7 +761,7 @@ static int dn_fib_table_flush(struct dn_fib_table *tb) | |||
761 | 761 | ||
762 | static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, struct dn_fib_res *res) | 762 | static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, struct dn_fib_res *res) |
763 | { | 763 | { |
764 | int err; | 764 | int err; |
765 | struct dn_zone *dz; | 765 | struct dn_zone *dz; |
766 | struct dn_hash *t = (struct dn_hash *)tb->data; | 766 | struct dn_hash *t = (struct dn_hash *)tb->data; |
767 | 767 | ||
@@ -790,7 +790,7 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, | |||
790 | 790 | ||
791 | if (err == 0) { | 791 | if (err == 0) { |
792 | res->type = f->fn_type; | 792 | res->type = f->fn_type; |
793 | res->scope = f->fn_scope; | 793 | res->scope = f->fn_scope; |
794 | res->prefixlen = dz->dz_order; | 794 | res->prefixlen = dz->dz_order; |
795 | goto out; | 795 | goto out; |
796 | } | 796 | } |
@@ -801,21 +801,21 @@ static int dn_fib_table_lookup(struct dn_fib_table *tb, const struct flowi *flp, | |||
801 | err = 1; | 801 | err = 1; |
802 | out: | 802 | out: |
803 | read_unlock(&dn_fib_tables_lock); | 803 | read_unlock(&dn_fib_tables_lock); |
804 | return err; | 804 | return err; |
805 | } | 805 | } |
806 | 806 | ||
807 | 807 | ||
808 | struct dn_fib_table *dn_fib_get_table(u32 n, int create) | 808 | struct dn_fib_table *dn_fib_get_table(u32 n, int create) |
809 | { | 809 | { |
810 | struct dn_fib_table *t; | 810 | struct dn_fib_table *t; |
811 | struct hlist_node *node; | 811 | struct hlist_node *node; |
812 | unsigned int h; | 812 | unsigned int h; |
813 | 813 | ||
814 | if (n < RT_TABLE_MIN) | 814 | if (n < RT_TABLE_MIN) |
815 | return NULL; | 815 | return NULL; |
816 | 816 | ||
817 | if (n > RT_TABLE_MAX) | 817 | if (n > RT_TABLE_MAX) |
818 | return NULL; | 818 | return NULL; |
819 | 819 | ||
820 | h = n & (DN_FIB_TABLE_HASHSZ - 1); | 820 | h = n & (DN_FIB_TABLE_HASHSZ - 1); |
821 | rcu_read_lock(); | 821 | rcu_read_lock(); |
@@ -827,54 +827,54 @@ struct dn_fib_table *dn_fib_get_table(u32 n, int create) | |||
827 | } | 827 | } |
828 | rcu_read_unlock(); | 828 | rcu_read_unlock(); |
829 | 829 | ||
830 | if (!create) | 830 | if (!create) |
831 | return NULL; | 831 | return NULL; |
832 | 832 | ||
833 | if (in_interrupt() && net_ratelimit()) { | 833 | if (in_interrupt() && net_ratelimit()) { |
834 | printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n"); | 834 | printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n"); |
835 | return NULL; | 835 | return NULL; |
836 | } | 836 | } |
837 | 837 | ||
838 | t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash), | 838 | t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash), |
839 | GFP_KERNEL); | 839 | GFP_KERNEL); |
840 | if (t == NULL) | 840 | if (t == NULL) |
841 | return NULL; | 841 | return NULL; |
842 | 842 | ||
843 | t->n = n; | 843 | t->n = n; |
844 | t->insert = dn_fib_table_insert; | 844 | t->insert = dn_fib_table_insert; |
845 | t->delete = dn_fib_table_delete; | 845 | t->delete = dn_fib_table_delete; |
846 | t->lookup = dn_fib_table_lookup; | 846 | t->lookup = dn_fib_table_lookup; |
847 | t->flush = dn_fib_table_flush; | 847 | t->flush = dn_fib_table_flush; |
848 | t->dump = dn_fib_table_dump; | 848 | t->dump = dn_fib_table_dump; |
849 | hlist_add_head_rcu(&t->hlist, &dn_fib_table_hash[h]); | 849 | hlist_add_head_rcu(&t->hlist, &dn_fib_table_hash[h]); |
850 | 850 | ||
851 | return t; | 851 | return t; |
852 | } | 852 | } |
853 | 853 | ||
854 | struct dn_fib_table *dn_fib_empty_table(void) | 854 | struct dn_fib_table *dn_fib_empty_table(void) |
855 | { | 855 | { |
856 | u32 id; | 856 | u32 id; |
857 | 857 | ||
858 | for(id = RT_TABLE_MIN; id <= RT_TABLE_MAX; id++) | 858 | for(id = RT_TABLE_MIN; id <= RT_TABLE_MAX; id++) |
859 | if (dn_fib_get_table(id, 0) == NULL) | 859 | if (dn_fib_get_table(id, 0) == NULL) |
860 | return dn_fib_get_table(id, 1); | 860 | return dn_fib_get_table(id, 1); |
861 | return NULL; | 861 | return NULL; |
862 | } | 862 | } |
863 | 863 | ||
864 | void dn_fib_flush(void) | 864 | void dn_fib_flush(void) |
865 | { | 865 | { |
866 | int flushed = 0; | 866 | int flushed = 0; |
867 | struct dn_fib_table *tb; | 867 | struct dn_fib_table *tb; |
868 | struct hlist_node *node; | 868 | struct hlist_node *node; |
869 | unsigned int h; | 869 | unsigned int h; |
870 | 870 | ||
871 | for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) { | 871 | for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) { |
872 | hlist_for_each_entry(tb, node, &dn_fib_table_hash[h], hlist) | 872 | hlist_for_each_entry(tb, node, &dn_fib_table_hash[h], hlist) |
873 | flushed += tb->flush(tb); | 873 | flushed += tb->flush(tb); |
874 | } | 874 | } |
875 | 875 | ||
876 | if (flushed) | 876 | if (flushed) |
877 | dn_rt_cache_flush(-1); | 877 | dn_rt_cache_flush(-1); |
878 | } | 878 | } |
879 | 879 | ||
880 | void __init dn_fib_table_init(void) | 880 | void __init dn_fib_table_init(void) |
@@ -894,7 +894,7 @@ void __exit dn_fib_table_cleanup(void) | |||
894 | write_lock(&dn_fib_tables_lock); | 894 | write_lock(&dn_fib_tables_lock); |
895 | for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) { | 895 | for (h = 0; h < DN_FIB_TABLE_HASHSZ; h++) { |
896 | hlist_for_each_entry_safe(t, node, next, &dn_fib_table_hash[h], | 896 | hlist_for_each_entry_safe(t, node, next, &dn_fib_table_hash[h], |
897 | hlist) { | 897 | hlist) { |
898 | hlist_del(&t->hlist); | 898 | hlist_del(&t->hlist); |
899 | kfree(t); | 899 | kfree(t); |
900 | } | 900 | } |