diff options
author | David S. Miller <davem@davemloft.net> | 2011-12-03 17:50:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-03 17:50:45 -0500 |
commit | 507c9b1e0702db4fb6c25135019158d1201f4de7 (patch) | |
tree | b9843152e7bd4d89acc7c8b65fe92b9c7eaa7619 /net/ipv6/ip6_fib.c | |
parent | 340e8dc1fb4032b6c8334c9bff20b2aec42ecfd8 (diff) |
ipv6: Various cleanups in ip6_route.c
1) x == NULL --> !x
2) x != NULL --> x
3) if() --> if ()
4) while() --> while ()
5) (x & BIT) == 0 --> !(x & BIT)
6) (x&BIT) --> (x & BIT)
7) x=y --> x = y
8) (BIT1|BIT2) --> (BIT1 | BIT2)
9) if ((x & BIT)) --> if (x & BIT)
10) proper argument and struct member alignment
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ip6_fib.c')
-rw-r--r-- | net/ipv6/ip6_fib.c | 115 |
1 files changed, 56 insertions, 59 deletions
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 424f063fb229..7b4730315d09 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -190,7 +190,7 @@ static struct fib6_table *fib6_alloc_table(struct net *net, u32 id) | |||
190 | struct fib6_table *table; | 190 | struct fib6_table *table; |
191 | 191 | ||
192 | table = kzalloc(sizeof(*table), GFP_ATOMIC); | 192 | table = kzalloc(sizeof(*table), GFP_ATOMIC); |
193 | if (table != NULL) { | 193 | if (table) { |
194 | table->tb6_id = id; | 194 | table->tb6_id = id; |
195 | table->tb6_root.leaf = net->ipv6.ip6_null_entry; | 195 | table->tb6_root.leaf = net->ipv6.ip6_null_entry; |
196 | table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; | 196 | table->tb6_root.fn_flags = RTN_ROOT | RTN_TL_ROOT | RTN_RTINFO; |
@@ -210,7 +210,7 @@ struct fib6_table *fib6_new_table(struct net *net, u32 id) | |||
210 | return tb; | 210 | return tb; |
211 | 211 | ||
212 | tb = fib6_alloc_table(net, id); | 212 | tb = fib6_alloc_table(net, id); |
213 | if (tb != NULL) | 213 | if (tb) |
214 | fib6_link_table(net, tb); | 214 | fib6_link_table(net, tb); |
215 | 215 | ||
216 | return tb; | 216 | return tb; |
@@ -367,7 +367,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) | |||
367 | s_e = cb->args[1]; | 367 | s_e = cb->args[1]; |
368 | 368 | ||
369 | w = (void *)cb->args[2]; | 369 | w = (void *)cb->args[2]; |
370 | if (w == NULL) { | 370 | if (!w) { |
371 | /* New dump: | 371 | /* New dump: |
372 | * | 372 | * |
373 | * 1. hook callback destructor. | 373 | * 1. hook callback destructor. |
@@ -379,7 +379,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) | |||
379 | * 2. allocate and initialize walker. | 379 | * 2. allocate and initialize walker. |
380 | */ | 380 | */ |
381 | w = kzalloc(sizeof(*w), GFP_ATOMIC); | 381 | w = kzalloc(sizeof(*w), GFP_ATOMIC); |
382 | if (w == NULL) | 382 | if (!w) |
383 | return -ENOMEM; | 383 | return -ENOMEM; |
384 | w->func = fib6_dump_node; | 384 | w->func = fib6_dump_node; |
385 | cb->args[2] = (long)w; | 385 | cb->args[2] = (long)w; |
@@ -467,7 +467,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr, | |||
467 | 467 | ||
468 | if (plen == fn->fn_bit) { | 468 | if (plen == fn->fn_bit) { |
469 | /* clean up an intermediate node */ | 469 | /* clean up an intermediate node */ |
470 | if ((fn->fn_flags & RTN_RTINFO) == 0) { | 470 | if (!(fn->fn_flags & RTN_RTINFO)) { |
471 | rt6_release(fn->leaf); | 471 | rt6_release(fn->leaf); |
472 | fn->leaf = NULL; | 472 | fn->leaf = NULL; |
473 | } | 473 | } |
@@ -512,7 +512,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr, | |||
512 | 512 | ||
513 | ln = node_alloc(); | 513 | ln = node_alloc(); |
514 | 514 | ||
515 | if (ln == NULL) | 515 | if (!ln) |
516 | return NULL; | 516 | return NULL; |
517 | ln->fn_bit = plen; | 517 | ln->fn_bit = plen; |
518 | 518 | ||
@@ -555,7 +555,7 @@ insert_above: | |||
555 | in = node_alloc(); | 555 | in = node_alloc(); |
556 | ln = node_alloc(); | 556 | ln = node_alloc(); |
557 | 557 | ||
558 | if (in == NULL || ln == NULL) { | 558 | if (!in || !ln) { |
559 | if (in) | 559 | if (in) |
560 | node_free(in); | 560 | node_free(in); |
561 | if (ln) | 561 | if (ln) |
@@ -609,7 +609,7 @@ insert_above: | |||
609 | 609 | ||
610 | ln = node_alloc(); | 610 | ln = node_alloc(); |
611 | 611 | ||
612 | if (ln == NULL) | 612 | if (!ln) |
613 | return NULL; | 613 | return NULL; |
614 | 614 | ||
615 | ln->fn_bit = plen; | 615 | ln->fn_bit = plen; |
@@ -642,15 +642,15 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, | |||
642 | { | 642 | { |
643 | struct rt6_info *iter = NULL; | 643 | struct rt6_info *iter = NULL; |
644 | struct rt6_info **ins; | 644 | struct rt6_info **ins; |
645 | int replace = (NULL != info->nlh && | 645 | int replace = (info->nlh && |
646 | (info->nlh->nlmsg_flags&NLM_F_REPLACE)); | 646 | (info->nlh->nlmsg_flags & NLM_F_REPLACE)); |
647 | int add = (NULL == info->nlh || | 647 | int add = (!info->nlh || |
648 | (info->nlh->nlmsg_flags&NLM_F_CREATE)); | 648 | (info->nlh->nlmsg_flags & NLM_F_CREATE)); |
649 | int found = 0; | 649 | int found = 0; |
650 | 650 | ||
651 | ins = &fn->leaf; | 651 | ins = &fn->leaf; |
652 | 652 | ||
653 | for (iter = fn->leaf; iter; iter=iter->dst.rt6_next) { | 653 | for (iter = fn->leaf; iter; iter = iter->dst.rt6_next) { |
654 | /* | 654 | /* |
655 | * Search for duplicates | 655 | * Search for duplicates |
656 | */ | 656 | */ |
@@ -659,8 +659,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, | |||
659 | /* | 659 | /* |
660 | * Same priority level | 660 | * Same priority level |
661 | */ | 661 | */ |
662 | if (NULL != info->nlh && | 662 | if (info->nlh && |
663 | (info->nlh->nlmsg_flags&NLM_F_EXCL)) | 663 | (info->nlh->nlmsg_flags & NLM_F_EXCL)) |
664 | return -EEXIST; | 664 | return -EEXIST; |
665 | if (replace) { | 665 | if (replace) { |
666 | found++; | 666 | found++; |
@@ -671,10 +671,10 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, | |||
671 | iter->rt6i_idev == rt->rt6i_idev && | 671 | iter->rt6i_idev == rt->rt6i_idev && |
672 | ipv6_addr_equal(&iter->rt6i_gateway, | 672 | ipv6_addr_equal(&iter->rt6i_gateway, |
673 | &rt->rt6i_gateway)) { | 673 | &rt->rt6i_gateway)) { |
674 | if (!(iter->rt6i_flags&RTF_EXPIRES)) | 674 | if (!(iter->rt6i_flags & RTF_EXPIRES)) |
675 | return -EEXIST; | 675 | return -EEXIST; |
676 | iter->rt6i_expires = rt->rt6i_expires; | 676 | iter->rt6i_expires = rt->rt6i_expires; |
677 | if (!(rt->rt6i_flags&RTF_EXPIRES)) { | 677 | if (!(rt->rt6i_flags & RTF_EXPIRES)) { |
678 | iter->rt6i_flags &= ~RTF_EXPIRES; | 678 | iter->rt6i_flags &= ~RTF_EXPIRES; |
679 | iter->rt6i_expires = 0; | 679 | iter->rt6i_expires = 0; |
680 | } | 680 | } |
@@ -707,7 +707,7 @@ add: | |||
707 | inet6_rt_notify(RTM_NEWROUTE, rt, info); | 707 | inet6_rt_notify(RTM_NEWROUTE, rt, info); |
708 | info->nl_net->ipv6.rt6_stats->fib_rt_entries++; | 708 | info->nl_net->ipv6.rt6_stats->fib_rt_entries++; |
709 | 709 | ||
710 | if ((fn->fn_flags & RTN_RTINFO) == 0) { | 710 | if (!(fn->fn_flags & RTN_RTINFO)) { |
711 | info->nl_net->ipv6.rt6_stats->fib_route_nodes++; | 711 | info->nl_net->ipv6.rt6_stats->fib_route_nodes++; |
712 | fn->fn_flags |= RTN_RTINFO; | 712 | fn->fn_flags |= RTN_RTINFO; |
713 | } | 713 | } |
@@ -725,7 +725,7 @@ add: | |||
725 | atomic_inc(&rt->rt6i_ref); | 725 | atomic_inc(&rt->rt6i_ref); |
726 | inet6_rt_notify(RTM_NEWROUTE, rt, info); | 726 | inet6_rt_notify(RTM_NEWROUTE, rt, info); |
727 | rt6_release(iter); | 727 | rt6_release(iter); |
728 | if ((fn->fn_flags & RTN_RTINFO) == 0) { | 728 | if (!(fn->fn_flags & RTN_RTINFO)) { |
729 | info->nl_net->ipv6.rt6_stats->fib_route_nodes++; | 729 | info->nl_net->ipv6.rt6_stats->fib_route_nodes++; |
730 | fn->fn_flags |= RTN_RTINFO; | 730 | fn->fn_flags |= RTN_RTINFO; |
731 | } | 731 | } |
@@ -737,7 +737,7 @@ add: | |||
737 | static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt) | 737 | static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt) |
738 | { | 738 | { |
739 | if (!timer_pending(&net->ipv6.ip6_fib_timer) && | 739 | if (!timer_pending(&net->ipv6.ip6_fib_timer) && |
740 | (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) | 740 | (rt->rt6i_flags & (RTF_EXPIRES | RTF_CACHE))) |
741 | mod_timer(&net->ipv6.ip6_fib_timer, | 741 | mod_timer(&net->ipv6.ip6_fib_timer, |
742 | jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); | 742 | jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); |
743 | } | 743 | } |
@@ -761,25 +761,26 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) | |||
761 | int err = -ENOMEM; | 761 | int err = -ENOMEM; |
762 | int allow_create = 1; | 762 | int allow_create = 1; |
763 | int replace_required = 0; | 763 | int replace_required = 0; |
764 | if (NULL != info->nlh) { | 764 | |
765 | if (!(info->nlh->nlmsg_flags&NLM_F_CREATE)) | 765 | if (info->nlh) { |
766 | if (!(info->nlh->nlmsg_flags & NLM_F_CREATE)) | ||
766 | allow_create = 0; | 767 | allow_create = 0; |
767 | if ((info->nlh->nlmsg_flags&NLM_F_REPLACE)) | 768 | if (info->nlh->nlmsg_flags & NLM_F_REPLACE) |
768 | replace_required = 1; | 769 | replace_required = 1; |
769 | } | 770 | } |
770 | if (!allow_create && !replace_required) | 771 | if (!allow_create && !replace_required) |
771 | pr_warn("IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE\n"); | 772 | pr_warn("IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE\n"); |
772 | 773 | ||
773 | fn = fib6_add_1(root, &rt->rt6i_dst.addr, sizeof(struct in6_addr), | 774 | fn = fib6_add_1(root, &rt->rt6i_dst.addr, sizeof(struct in6_addr), |
774 | rt->rt6i_dst.plen, offsetof(struct rt6_info, rt6i_dst), | 775 | rt->rt6i_dst.plen, offsetof(struct rt6_info, rt6i_dst), |
775 | allow_create, replace_required); | 776 | allow_create, replace_required); |
776 | 777 | ||
777 | if (IS_ERR(fn)) { | 778 | if (IS_ERR(fn)) { |
778 | err = PTR_ERR(fn); | 779 | err = PTR_ERR(fn); |
779 | fn = NULL; | 780 | fn = NULL; |
780 | } | 781 | } |
781 | 782 | ||
782 | if (fn == NULL) | 783 | if (!fn) |
783 | goto out; | 784 | goto out; |
784 | 785 | ||
785 | pn = fn; | 786 | pn = fn; |
@@ -788,7 +789,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) | |||
788 | if (rt->rt6i_src.plen) { | 789 | if (rt->rt6i_src.plen) { |
789 | struct fib6_node *sn; | 790 | struct fib6_node *sn; |
790 | 791 | ||
791 | if (fn->subtree == NULL) { | 792 | if (!fn->subtree) { |
792 | struct fib6_node *sfn; | 793 | struct fib6_node *sfn; |
793 | 794 | ||
794 | /* | 795 | /* |
@@ -803,7 +804,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) | |||
803 | 804 | ||
804 | /* Create subtree root node */ | 805 | /* Create subtree root node */ |
805 | sfn = node_alloc(); | 806 | sfn = node_alloc(); |
806 | if (sfn == NULL) | 807 | if (!sfn) |
807 | goto st_failure; | 808 | goto st_failure; |
808 | 809 | ||
809 | sfn->leaf = info->nl_net->ipv6.ip6_null_entry; | 810 | sfn->leaf = info->nl_net->ipv6.ip6_null_entry; |
@@ -818,7 +819,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) | |||
818 | offsetof(struct rt6_info, rt6i_src), | 819 | offsetof(struct rt6_info, rt6i_src), |
819 | allow_create, replace_required); | 820 | allow_create, replace_required); |
820 | 821 | ||
821 | if (sn == NULL) { | 822 | if (!sn) { |
822 | /* If it is failed, discard just allocated | 823 | /* If it is failed, discard just allocated |
823 | root, and then (in st_failure) stale node | 824 | root, and then (in st_failure) stale node |
824 | in main tree. | 825 | in main tree. |
@@ -840,11 +841,11 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) | |||
840 | err = PTR_ERR(sn); | 841 | err = PTR_ERR(sn); |
841 | sn = NULL; | 842 | sn = NULL; |
842 | } | 843 | } |
843 | if (sn == NULL) | 844 | if (!sn) |
844 | goto st_failure; | 845 | goto st_failure; |
845 | } | 846 | } |
846 | 847 | ||
847 | if (fn->leaf == NULL) { | 848 | if (!fn->leaf) { |
848 | fn->leaf = rt; | 849 | fn->leaf = rt; |
849 | atomic_inc(&rt->rt6i_ref); | 850 | atomic_inc(&rt->rt6i_ref); |
850 | } | 851 | } |
@@ -853,10 +854,9 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nl_info *info) | |||
853 | #endif | 854 | #endif |
854 | 855 | ||
855 | err = fib6_add_rt2node(fn, rt, info); | 856 | err = fib6_add_rt2node(fn, rt, info); |
856 | 857 | if (!err) { | |
857 | if (err == 0) { | ||
858 | fib6_start_gc(info->nl_net, rt); | 858 | fib6_start_gc(info->nl_net, rt); |
859 | if (!(rt->rt6i_flags&RTF_CACHE)) | 859 | if (!(rt->rt6i_flags & RTF_CACHE)) |
860 | fib6_prune_clones(info->nl_net, pn, rt); | 860 | fib6_prune_clones(info->nl_net, pn, rt); |
861 | } | 861 | } |
862 | 862 | ||
@@ -904,7 +904,7 @@ st_failure: | |||
904 | */ | 904 | */ |
905 | 905 | ||
906 | struct lookup_args { | 906 | struct lookup_args { |
907 | int offset; /* key offset on rt6_info */ | 907 | int offset; /* key offset on rt6_info */ |
908 | const struct in6_addr *addr; /* search key */ | 908 | const struct in6_addr *addr; /* search key */ |
909 | }; | 909 | }; |
910 | 910 | ||
@@ -934,11 +934,10 @@ static struct fib6_node * fib6_lookup_1(struct fib6_node *root, | |||
934 | fn = next; | 934 | fn = next; |
935 | continue; | 935 | continue; |
936 | } | 936 | } |
937 | |||
938 | break; | 937 | break; |
939 | } | 938 | } |
940 | 939 | ||
941 | while(fn) { | 940 | while (fn) { |
942 | if (FIB6_SUBTREE(fn) || fn->fn_flags & RTN_RTINFO) { | 941 | if (FIB6_SUBTREE(fn) || fn->fn_flags & RTN_RTINFO) { |
943 | struct rt6key *key; | 942 | struct rt6key *key; |
944 | 943 | ||
@@ -985,8 +984,7 @@ struct fib6_node * fib6_lookup(struct fib6_node *root, const struct in6_addr *da | |||
985 | }; | 984 | }; |
986 | 985 | ||
987 | fn = fib6_lookup_1(root, daddr ? args : args + 1); | 986 | fn = fib6_lookup_1(root, daddr ? args : args + 1); |
988 | 987 | if (!fn || fn->fn_flags & RTN_TL_ROOT) | |
989 | if (fn == NULL || fn->fn_flags & RTN_TL_ROOT) | ||
990 | fn = root; | 988 | fn = root; |
991 | 989 | ||
992 | return fn; | 990 | return fn; |
@@ -1046,7 +1044,7 @@ struct fib6_node * fib6_locate(struct fib6_node *root, | |||
1046 | } | 1044 | } |
1047 | #endif | 1045 | #endif |
1048 | 1046 | ||
1049 | if (fn && fn->fn_flags&RTN_RTINFO) | 1047 | if (fn && fn->fn_flags & RTN_RTINFO) |
1050 | return fn; | 1048 | return fn; |
1051 | 1049 | ||
1052 | return NULL; | 1050 | return NULL; |
@@ -1060,14 +1058,13 @@ struct fib6_node * fib6_locate(struct fib6_node *root, | |||
1060 | 1058 | ||
1061 | static struct rt6_info *fib6_find_prefix(struct net *net, struct fib6_node *fn) | 1059 | static struct rt6_info *fib6_find_prefix(struct net *net, struct fib6_node *fn) |
1062 | { | 1060 | { |
1063 | if (fn->fn_flags&RTN_ROOT) | 1061 | if (fn->fn_flags & RTN_ROOT) |
1064 | return net->ipv6.ip6_null_entry; | 1062 | return net->ipv6.ip6_null_entry; |
1065 | 1063 | ||
1066 | while(fn) { | 1064 | while (fn) { |
1067 | if(fn->left) | 1065 | if (fn->left) |
1068 | return fn->left->leaf; | 1066 | return fn->left->leaf; |
1069 | 1067 | if (fn->right) | |
1070 | if(fn->right) | ||
1071 | return fn->right->leaf; | 1068 | return fn->right->leaf; |
1072 | 1069 | ||
1073 | fn = FIB6_SUBTREE(fn); | 1070 | fn = FIB6_SUBTREE(fn); |
@@ -1105,12 +1102,12 @@ static struct fib6_node *fib6_repair_tree(struct net *net, | |||
1105 | if (children == 3 || FIB6_SUBTREE(fn) | 1102 | if (children == 3 || FIB6_SUBTREE(fn) |
1106 | #ifdef CONFIG_IPV6_SUBTREES | 1103 | #ifdef CONFIG_IPV6_SUBTREES |
1107 | /* Subtree root (i.e. fn) may have one child */ | 1104 | /* Subtree root (i.e. fn) may have one child */ |
1108 | || (children && fn->fn_flags&RTN_ROOT) | 1105 | || (children && fn->fn_flags & RTN_ROOT) |
1109 | #endif | 1106 | #endif |
1110 | ) { | 1107 | ) { |
1111 | fn->leaf = fib6_find_prefix(net, fn); | 1108 | fn->leaf = fib6_find_prefix(net, fn); |
1112 | #if RT6_DEBUG >= 2 | 1109 | #if RT6_DEBUG >= 2 |
1113 | if (fn->leaf==NULL) { | 1110 | if (!fn->leaf) { |
1114 | WARN_ON(!fn->leaf); | 1111 | WARN_ON(!fn->leaf); |
1115 | fn->leaf = net->ipv6.ip6_null_entry; | 1112 | fn->leaf = net->ipv6.ip6_null_entry; |
1116 | } | 1113 | } |
@@ -1143,7 +1140,7 @@ static struct fib6_node *fib6_repair_tree(struct net *net, | |||
1143 | 1140 | ||
1144 | read_lock(&fib6_walker_lock); | 1141 | read_lock(&fib6_walker_lock); |
1145 | FOR_WALKERS(w) { | 1142 | FOR_WALKERS(w) { |
1146 | if (child == NULL) { | 1143 | if (!child) { |
1147 | if (w->root == fn) { | 1144 | if (w->root == fn) { |
1148 | w->root = w->node = NULL; | 1145 | w->root = w->node = NULL; |
1149 | RT6_TRACE("W %p adjusted by delroot 1\n", w); | 1146 | RT6_TRACE("W %p adjusted by delroot 1\n", w); |
@@ -1172,7 +1169,7 @@ static struct fib6_node *fib6_repair_tree(struct net *net, | |||
1172 | read_unlock(&fib6_walker_lock); | 1169 | read_unlock(&fib6_walker_lock); |
1173 | 1170 | ||
1174 | node_free(fn); | 1171 | node_free(fn); |
1175 | if (pn->fn_flags&RTN_RTINFO || FIB6_SUBTREE(pn)) | 1172 | if (pn->fn_flags & RTN_RTINFO || FIB6_SUBTREE(pn)) |
1176 | return pn; | 1173 | return pn; |
1177 | 1174 | ||
1178 | rt6_release(pn->leaf); | 1175 | rt6_release(pn->leaf); |
@@ -1206,7 +1203,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, | |||
1206 | if (w->state == FWS_C && w->leaf == rt) { | 1203 | if (w->state == FWS_C && w->leaf == rt) { |
1207 | RT6_TRACE("walker %p adjusted by delroute\n", w); | 1204 | RT6_TRACE("walker %p adjusted by delroute\n", w); |
1208 | w->leaf = rt->dst.rt6_next; | 1205 | w->leaf = rt->dst.rt6_next; |
1209 | if (w->leaf == NULL) | 1206 | if (!w->leaf) |
1210 | w->state = FWS_U; | 1207 | w->state = FWS_U; |
1211 | } | 1208 | } |
1212 | } | 1209 | } |
@@ -1215,7 +1212,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, | |||
1215 | rt->dst.rt6_next = NULL; | 1212 | rt->dst.rt6_next = NULL; |
1216 | 1213 | ||
1217 | /* If it was last route, expunge its radix tree node */ | 1214 | /* If it was last route, expunge its radix tree node */ |
1218 | if (fn->leaf == NULL) { | 1215 | if (!fn->leaf) { |
1219 | fn->fn_flags &= ~RTN_RTINFO; | 1216 | fn->fn_flags &= ~RTN_RTINFO; |
1220 | net->ipv6.rt6_stats->fib_route_nodes--; | 1217 | net->ipv6.rt6_stats->fib_route_nodes--; |
1221 | fn = fib6_repair_tree(net, fn); | 1218 | fn = fib6_repair_tree(net, fn); |
@@ -1229,7 +1226,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, | |||
1229 | * to still alive ones. | 1226 | * to still alive ones. |
1230 | */ | 1227 | */ |
1231 | while (fn) { | 1228 | while (fn) { |
1232 | if (!(fn->fn_flags&RTN_RTINFO) && fn->leaf == rt) { | 1229 | if (!(fn->fn_flags & RTN_RTINFO) && fn->leaf == rt) { |
1233 | fn->leaf = fib6_find_prefix(net, fn); | 1230 | fn->leaf = fib6_find_prefix(net, fn); |
1234 | atomic_inc(&fn->leaf->rt6i_ref); | 1231 | atomic_inc(&fn->leaf->rt6i_ref); |
1235 | rt6_release(rt); | 1232 | rt6_release(rt); |
@@ -1256,17 +1253,17 @@ int fib6_del(struct rt6_info *rt, struct nl_info *info) | |||
1256 | return -ENOENT; | 1253 | return -ENOENT; |
1257 | } | 1254 | } |
1258 | #endif | 1255 | #endif |
1259 | if (fn == NULL || rt == net->ipv6.ip6_null_entry) | 1256 | if (!fn || rt == net->ipv6.ip6_null_entry) |
1260 | return -ENOENT; | 1257 | return -ENOENT; |
1261 | 1258 | ||
1262 | WARN_ON(!(fn->fn_flags & RTN_RTINFO)); | 1259 | WARN_ON(!(fn->fn_flags & RTN_RTINFO)); |
1263 | 1260 | ||
1264 | if (!(rt->rt6i_flags&RTF_CACHE)) { | 1261 | if (!(rt->rt6i_flags & RTF_CACHE)) { |
1265 | struct fib6_node *pn = fn; | 1262 | struct fib6_node *pn = fn; |
1266 | #ifdef CONFIG_IPV6_SUBTREES | 1263 | #ifdef CONFIG_IPV6_SUBTREES |
1267 | /* clones of this route might be in another subtree */ | 1264 | /* clones of this route might be in another subtree */ |
1268 | if (rt->rt6i_src.plen) { | 1265 | if (rt->rt6i_src.plen) { |
1269 | while (!(pn->fn_flags&RTN_ROOT)) | 1266 | while (!(pn->fn_flags & RTN_ROOT)) |
1270 | pn = pn->parent; | 1267 | pn = pn->parent; |
1271 | pn = pn->parent; | 1268 | pn = pn->parent; |
1272 | } | 1269 | } |
@@ -1317,11 +1314,11 @@ static int fib6_walk_continue(struct fib6_walker_t *w) | |||
1317 | 1314 | ||
1318 | for (;;) { | 1315 | for (;;) { |
1319 | fn = w->node; | 1316 | fn = w->node; |
1320 | if (fn == NULL) | 1317 | if (!fn) |
1321 | return 0; | 1318 | return 0; |
1322 | 1319 | ||
1323 | if (w->prune && fn != w->root && | 1320 | if (w->prune && fn != w->root && |
1324 | fn->fn_flags&RTN_RTINFO && w->state < FWS_C) { | 1321 | fn->fn_flags & RTN_RTINFO && w->state < FWS_C) { |
1325 | w->state = FWS_C; | 1322 | w->state = FWS_C; |
1326 | w->leaf = fn->leaf; | 1323 | w->leaf = fn->leaf; |
1327 | } | 1324 | } |
@@ -1350,7 +1347,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w) | |||
1350 | w->state = FWS_C; | 1347 | w->state = FWS_C; |
1351 | w->leaf = fn->leaf; | 1348 | w->leaf = fn->leaf; |
1352 | case FWS_C: | 1349 | case FWS_C: |
1353 | if (w->leaf && fn->fn_flags&RTN_RTINFO) { | 1350 | if (w->leaf && fn->fn_flags & RTN_RTINFO) { |
1354 | int err; | 1351 | int err; |
1355 | 1352 | ||
1356 | if (w->count < w->skip) { | 1353 | if (w->count < w->skip) { |
@@ -1524,7 +1521,7 @@ static int fib6_age(struct rt6_info *rt, void *arg) | |||
1524 | * only if they are not in use now. | 1521 | * only if they are not in use now. |
1525 | */ | 1522 | */ |
1526 | 1523 | ||
1527 | if (rt->rt6i_flags&RTF_EXPIRES && rt->rt6i_expires) { | 1524 | if (rt->rt6i_flags & RTF_EXPIRES && rt->rt6i_expires) { |
1528 | if (time_after(now, rt->rt6i_expires)) { | 1525 | if (time_after(now, rt->rt6i_expires)) { |
1529 | RT6_TRACE("expiring %p\n", rt); | 1526 | RT6_TRACE("expiring %p\n", rt); |
1530 | return -1; | 1527 | return -1; |