diff options
-rw-r--r-- | net/ipv4/fib_semantics.c | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index ed19aa6919c2..96b21011a3e4 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -62,8 +62,8 @@ static DEFINE_SPINLOCK(fib_multipath_lock); | |||
62 | #define for_nexthops(fi) { int nhsel; const struct fib_nh * nh; \ | 62 | #define for_nexthops(fi) { int nhsel; const struct 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 change_nexthops(fi) { int nhsel; struct fib_nh * nh; \ | 65 | #define change_nexthops(fi) { int nhsel; struct fib_nh *nexthop_nh; \ |
66 | for (nhsel=0, nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++, nhsel++) | 66 | for (nhsel=0, nexthop_nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nexthop_nh++, nhsel++) |
67 | 67 | ||
68 | #else /* CONFIG_IP_ROUTE_MULTIPATH */ | 68 | #else /* CONFIG_IP_ROUTE_MULTIPATH */ |
69 | 69 | ||
@@ -72,7 +72,7 @@ for (nhsel=0, nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++, | |||
72 | #define for_nexthops(fi) { int nhsel = 0; const struct fib_nh * nh = (fi)->fib_nh; \ | 72 | #define for_nexthops(fi) { int nhsel = 0; const struct fib_nh * nh = (fi)->fib_nh; \ |
73 | for (nhsel=0; nhsel < 1; nhsel++) | 73 | for (nhsel=0; nhsel < 1; nhsel++) |
74 | 74 | ||
75 | #define change_nexthops(fi) { int nhsel = 0; struct fib_nh * nh = (struct fib_nh *)((fi)->fib_nh); \ | 75 | #define change_nexthops(fi) { int nhsel = 0; struct fib_nh *nexthop_nh = (struct fib_nh *)((fi)->fib_nh); \ |
76 | for (nhsel=0; nhsel < 1; nhsel++) | 76 | for (nhsel=0; nhsel < 1; nhsel++) |
77 | 77 | ||
78 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ | 78 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ |
@@ -145,9 +145,9 @@ void free_fib_info(struct fib_info *fi) | |||
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | change_nexthops(fi) { | 147 | change_nexthops(fi) { |
148 | if (nh->nh_dev) | 148 | if (nexthop_nh->nh_dev) |
149 | dev_put(nh->nh_dev); | 149 | dev_put(nexthop_nh->nh_dev); |
150 | nh->nh_dev = NULL; | 150 | nexthop_nh->nh_dev = NULL; |
151 | } endfor_nexthops(fi); | 151 | } endfor_nexthops(fi); |
152 | fib_info_cnt--; | 152 | fib_info_cnt--; |
153 | release_net(fi->fib_net); | 153 | release_net(fi->fib_net); |
@@ -162,9 +162,9 @@ void fib_release_info(struct fib_info *fi) | |||
162 | if (fi->fib_prefsrc) | 162 | if (fi->fib_prefsrc) |
163 | hlist_del(&fi->fib_lhash); | 163 | hlist_del(&fi->fib_lhash); |
164 | change_nexthops(fi) { | 164 | change_nexthops(fi) { |
165 | if (!nh->nh_dev) | 165 | if (!nexthop_nh->nh_dev) |
166 | continue; | 166 | continue; |
167 | hlist_del(&nh->nh_hash); | 167 | hlist_del(&nexthop_nh->nh_hash); |
168 | } endfor_nexthops(fi) | 168 | } endfor_nexthops(fi) |
169 | fi->fib_dead = 1; | 169 | fi->fib_dead = 1; |
170 | fib_info_put(fi); | 170 | fib_info_put(fi); |
@@ -395,19 +395,20 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, | |||
395 | if (!rtnh_ok(rtnh, remaining)) | 395 | if (!rtnh_ok(rtnh, remaining)) |
396 | return -EINVAL; | 396 | return -EINVAL; |
397 | 397 | ||
398 | nh->nh_flags = (cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags; | 398 | nexthop_nh->nh_flags = |
399 | nh->nh_oif = rtnh->rtnh_ifindex; | 399 | (cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags; |
400 | nh->nh_weight = rtnh->rtnh_hops + 1; | 400 | nexthop_nh->nh_oif = rtnh->rtnh_ifindex; |
401 | nexthop_nh->nh_weight = rtnh->rtnh_hops + 1; | ||
401 | 402 | ||
402 | attrlen = rtnh_attrlen(rtnh); | 403 | attrlen = rtnh_attrlen(rtnh); |
403 | if (attrlen > 0) { | 404 | if (attrlen > 0) { |
404 | struct nlattr *nla, *attrs = rtnh_attrs(rtnh); | 405 | struct nlattr *nla, *attrs = rtnh_attrs(rtnh); |
405 | 406 | ||
406 | nla = nla_find(attrs, attrlen, RTA_GATEWAY); | 407 | nla = nla_find(attrs, attrlen, RTA_GATEWAY); |
407 | nh->nh_gw = nla ? nla_get_be32(nla) : 0; | 408 | nexthop_nh->nh_gw = nla ? nla_get_be32(nla) : 0; |
408 | #ifdef CONFIG_NET_CLS_ROUTE | 409 | #ifdef CONFIG_NET_CLS_ROUTE |
409 | nla = nla_find(attrs, attrlen, RTA_FLOW); | 410 | nla = nla_find(attrs, attrlen, RTA_FLOW); |
410 | nh->nh_tclassid = nla ? nla_get_u32(nla) : 0; | 411 | nexthop_nh->nh_tclassid = nla ? nla_get_u32(nla) : 0; |
411 | #endif | 412 | #endif |
412 | } | 413 | } |
413 | 414 | ||
@@ -738,7 +739,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
738 | 739 | ||
739 | fi->fib_nhs = nhs; | 740 | fi->fib_nhs = nhs; |
740 | change_nexthops(fi) { | 741 | change_nexthops(fi) { |
741 | nh->nh_parent = fi; | 742 | nexthop_nh->nh_parent = fi; |
742 | } endfor_nexthops(fi) | 743 | } endfor_nexthops(fi) |
743 | 744 | ||
744 | if (cfg->fc_mx) { | 745 | if (cfg->fc_mx) { |
@@ -808,7 +809,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
808 | goto failure; | 809 | goto failure; |
809 | } else { | 810 | } else { |
810 | change_nexthops(fi) { | 811 | change_nexthops(fi) { |
811 | if ((err = fib_check_nh(cfg, fi, nh)) != 0) | 812 | if ((err = fib_check_nh(cfg, fi, nexthop_nh)) != 0) |
812 | goto failure; | 813 | goto failure; |
813 | } endfor_nexthops(fi) | 814 | } endfor_nexthops(fi) |
814 | } | 815 | } |
@@ -843,11 +844,11 @@ link_it: | |||
843 | struct hlist_head *head; | 844 | struct hlist_head *head; |
844 | unsigned int hash; | 845 | unsigned int hash; |
845 | 846 | ||
846 | if (!nh->nh_dev) | 847 | if (!nexthop_nh->nh_dev) |
847 | continue; | 848 | continue; |
848 | hash = fib_devindex_hashfn(nh->nh_dev->ifindex); | 849 | hash = fib_devindex_hashfn(nexthop_nh->nh_dev->ifindex); |
849 | head = &fib_info_devhash[hash]; | 850 | head = &fib_info_devhash[hash]; |
850 | hlist_add_head(&nh->nh_hash, head); | 851 | hlist_add_head(&nexthop_nh->nh_hash, head); |
851 | } endfor_nexthops(fi) | 852 | } endfor_nexthops(fi) |
852 | spin_unlock_bh(&fib_info_lock); | 853 | spin_unlock_bh(&fib_info_lock); |
853 | return fi; | 854 | return fi; |
@@ -1080,21 +1081,21 @@ int fib_sync_down_dev(struct net_device *dev, int force) | |||
1080 | prev_fi = fi; | 1081 | prev_fi = fi; |
1081 | dead = 0; | 1082 | dead = 0; |
1082 | change_nexthops(fi) { | 1083 | change_nexthops(fi) { |
1083 | if (nh->nh_flags&RTNH_F_DEAD) | 1084 | if (nexthop_nh->nh_flags&RTNH_F_DEAD) |
1084 | dead++; | 1085 | dead++; |
1085 | else if (nh->nh_dev == dev && | 1086 | else if (nexthop_nh->nh_dev == dev && |
1086 | nh->nh_scope != scope) { | 1087 | nexthop_nh->nh_scope != scope) { |
1087 | nh->nh_flags |= RTNH_F_DEAD; | 1088 | nexthop_nh->nh_flags |= RTNH_F_DEAD; |
1088 | #ifdef CONFIG_IP_ROUTE_MULTIPATH | 1089 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
1089 | spin_lock_bh(&fib_multipath_lock); | 1090 | spin_lock_bh(&fib_multipath_lock); |
1090 | fi->fib_power -= nh->nh_power; | 1091 | fi->fib_power -= nexthop_nh->nh_power; |
1091 | nh->nh_power = 0; | 1092 | nexthop_nh->nh_power = 0; |
1092 | spin_unlock_bh(&fib_multipath_lock); | 1093 | spin_unlock_bh(&fib_multipath_lock); |
1093 | #endif | 1094 | #endif |
1094 | dead++; | 1095 | dead++; |
1095 | } | 1096 | } |
1096 | #ifdef CONFIG_IP_ROUTE_MULTIPATH | 1097 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
1097 | if (force > 1 && nh->nh_dev == dev) { | 1098 | if (force > 1 && nexthop_nh->nh_dev == dev) { |
1098 | dead = fi->fib_nhs; | 1099 | dead = fi->fib_nhs; |
1099 | break; | 1100 | break; |
1100 | } | 1101 | } |
@@ -1144,18 +1145,20 @@ int fib_sync_up(struct net_device *dev) | |||
1144 | prev_fi = fi; | 1145 | prev_fi = fi; |
1145 | alive = 0; | 1146 | alive = 0; |
1146 | change_nexthops(fi) { | 1147 | change_nexthops(fi) { |
1147 | if (!(nh->nh_flags&RTNH_F_DEAD)) { | 1148 | if (!(nexthop_nh->nh_flags&RTNH_F_DEAD)) { |
1148 | alive++; | 1149 | alive++; |
1149 | continue; | 1150 | continue; |
1150 | } | 1151 | } |
1151 | if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP)) | 1152 | if (nexthop_nh->nh_dev == NULL || |
1153 | !(nexthop_nh->nh_dev->flags&IFF_UP)) | ||
1152 | continue; | 1154 | continue; |
1153 | if (nh->nh_dev != dev || !__in_dev_get_rtnl(dev)) | 1155 | if (nexthop_nh->nh_dev != dev || |
1156 | !__in_dev_get_rtnl(dev)) | ||
1154 | continue; | 1157 | continue; |
1155 | alive++; | 1158 | alive++; |
1156 | spin_lock_bh(&fib_multipath_lock); | 1159 | spin_lock_bh(&fib_multipath_lock); |
1157 | nh->nh_power = 0; | 1160 | nexthop_nh->nh_power = 0; |
1158 | nh->nh_flags &= ~RTNH_F_DEAD; | 1161 | nexthop_nh->nh_flags &= ~RTNH_F_DEAD; |
1159 | spin_unlock_bh(&fib_multipath_lock); | 1162 | spin_unlock_bh(&fib_multipath_lock); |
1160 | } endfor_nexthops(fi) | 1163 | } endfor_nexthops(fi) |
1161 | 1164 | ||
@@ -1182,9 +1185,9 @@ void fib_select_multipath(const struct flowi *flp, struct fib_result *res) | |||
1182 | if (fi->fib_power <= 0) { | 1185 | if (fi->fib_power <= 0) { |
1183 | int power = 0; | 1186 | int power = 0; |
1184 | change_nexthops(fi) { | 1187 | change_nexthops(fi) { |
1185 | if (!(nh->nh_flags&RTNH_F_DEAD)) { | 1188 | if (!(nexthop_nh->nh_flags&RTNH_F_DEAD)) { |
1186 | power += nh->nh_weight; | 1189 | power += nexthop_nh->nh_weight; |
1187 | nh->nh_power = nh->nh_weight; | 1190 | nexthop_nh->nh_power = nexthop_nh->nh_weight; |
1188 | } | 1191 | } |
1189 | } endfor_nexthops(fi); | 1192 | } endfor_nexthops(fi); |
1190 | fi->fib_power = power; | 1193 | fi->fib_power = power; |
@@ -1204,9 +1207,10 @@ void fib_select_multipath(const struct flowi *flp, struct fib_result *res) | |||
1204 | w = jiffies % fi->fib_power; | 1207 | w = jiffies % fi->fib_power; |
1205 | 1208 | ||
1206 | change_nexthops(fi) { | 1209 | change_nexthops(fi) { |
1207 | if (!(nh->nh_flags&RTNH_F_DEAD) && nh->nh_power) { | 1210 | if (!(nexthop_nh->nh_flags&RTNH_F_DEAD) && |
1208 | if ((w -= nh->nh_power) <= 0) { | 1211 | nexthop_nh->nh_power) { |
1209 | nh->nh_power--; | 1212 | if ((w -= nexthop_nh->nh_power) <= 0) { |
1213 | nexthop_nh->nh_power--; | ||
1210 | fi->fib_power--; | 1214 | fi->fib_power--; |
1211 | res->nh_sel = nhsel; | 1215 | res->nh_sel = nhsel; |
1212 | spin_unlock_bh(&fib_multipath_lock); | 1216 | spin_unlock_bh(&fib_multipath_lock); |