Skip to content

Commit 71fceff

Browse files
committed
ipv4: Use less conflicting local var name in change_nexthops() loop macro.
As noticed by H Hartley Sweeten, since change_nexthops() uses 'nh' as it's iterator variable, it can conflict with other existing local vars. Use "nexthop_nh" to avoid the conflict and make it easier to figure out where this magic variable comes from. Signed-off-by: David S. Miller <[email protected]>
1 parent 4d0392b commit 71fceff

File tree

1 file changed

+40
-36
lines changed

1 file changed

+40
-36
lines changed

net/ipv4/fib_semantics.c

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ static DEFINE_SPINLOCK(fib_multipath_lock);
6262
#define for_nexthops(fi) { int nhsel; const struct fib_nh * nh; \
6363
for (nhsel=0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++)
6464

65-
#define change_nexthops(fi) { int nhsel; struct fib_nh * nh; \
66-
for (nhsel=0, nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++, nhsel++)
65+
#define change_nexthops(fi) { int nhsel; struct fib_nh *nexthop_nh; \
66+
for (nhsel=0, nexthop_nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nexthop_nh++, nhsel++)
6767

6868
#else /* CONFIG_IP_ROUTE_MULTIPATH */
6969

@@ -72,7 +72,7 @@ for (nhsel=0, nh = (struct fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++,
7272
#define for_nexthops(fi) { int nhsel = 0; const struct fib_nh * nh = (fi)->fib_nh; \
7373
for (nhsel=0; nhsel < 1; nhsel++)
7474

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); \
7676
for (nhsel=0; nhsel < 1; nhsel++)
7777

7878
#endif /* CONFIG_IP_ROUTE_MULTIPATH */
@@ -145,9 +145,9 @@ void free_fib_info(struct fib_info *fi)
145145
return;
146146
}
147147
change_nexthops(fi) {
148-
if (nh->nh_dev)
149-
dev_put(nh->nh_dev);
150-
nh->nh_dev = NULL;
148+
if (nexthop_nh->nh_dev)
149+
dev_put(nexthop_nh->nh_dev);
150+
nexthop_nh->nh_dev = NULL;
151151
} endfor_nexthops(fi);
152152
fib_info_cnt--;
153153
release_net(fi->fib_net);
@@ -162,9 +162,9 @@ void fib_release_info(struct fib_info *fi)
162162
if (fi->fib_prefsrc)
163163
hlist_del(&fi->fib_lhash);
164164
change_nexthops(fi) {
165-
if (!nh->nh_dev)
165+
if (!nexthop_nh->nh_dev)
166166
continue;
167-
hlist_del(&nh->nh_hash);
167+
hlist_del(&nexthop_nh->nh_hash);
168168
} endfor_nexthops(fi)
169169
fi->fib_dead = 1;
170170
fib_info_put(fi);
@@ -395,19 +395,20 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
395395
if (!rtnh_ok(rtnh, remaining))
396396
return -EINVAL;
397397

398-
nh->nh_flags = (cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags;
399-
nh->nh_oif = rtnh->rtnh_ifindex;
400-
nh->nh_weight = rtnh->rtnh_hops + 1;
398+
nexthop_nh->nh_flags =
399+
(cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags;
400+
nexthop_nh->nh_oif = rtnh->rtnh_ifindex;
401+
nexthop_nh->nh_weight = rtnh->rtnh_hops + 1;
401402

402403
attrlen = rtnh_attrlen(rtnh);
403404
if (attrlen > 0) {
404405
struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
405406

406407
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;
408409
#ifdef CONFIG_NET_CLS_ROUTE
409410
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;
411412
#endif
412413
}
413414

@@ -738,7 +739,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
738739

739740
fi->fib_nhs = nhs;
740741
change_nexthops(fi) {
741-
nh->nh_parent = fi;
742+
nexthop_nh->nh_parent = fi;
742743
} endfor_nexthops(fi)
743744

744745
if (cfg->fc_mx) {
@@ -808,7 +809,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
808809
goto failure;
809810
} else {
810811
change_nexthops(fi) {
811-
if ((err = fib_check_nh(cfg, fi, nh)) != 0)
812+
if ((err = fib_check_nh(cfg, fi, nexthop_nh)) != 0)
812813
goto failure;
813814
} endfor_nexthops(fi)
814815
}
@@ -843,11 +844,11 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
843844
struct hlist_head *head;
844845
unsigned int hash;
845846

846-
if (!nh->nh_dev)
847+
if (!nexthop_nh->nh_dev)
847848
continue;
848-
hash = fib_devindex_hashfn(nh->nh_dev->ifindex);
849+
hash = fib_devindex_hashfn(nexthop_nh->nh_dev->ifindex);
849850
head = &fib_info_devhash[hash];
850-
hlist_add_head(&nh->nh_hash, head);
851+
hlist_add_head(&nexthop_nh->nh_hash, head);
851852
} endfor_nexthops(fi)
852853
spin_unlock_bh(&fib_info_lock);
853854
return fi;
@@ -1080,21 +1081,21 @@ int fib_sync_down_dev(struct net_device *dev, int force)
10801081
prev_fi = fi;
10811082
dead = 0;
10821083
change_nexthops(fi) {
1083-
if (nh->nh_flags&RTNH_F_DEAD)
1084+
if (nexthop_nh->nh_flags&RTNH_F_DEAD)
10841085
dead++;
1085-
else if (nh->nh_dev == dev &&
1086-
nh->nh_scope != scope) {
1087-
nh->nh_flags |= RTNH_F_DEAD;
1086+
else if (nexthop_nh->nh_dev == dev &&
1087+
nexthop_nh->nh_scope != scope) {
1088+
nexthop_nh->nh_flags |= RTNH_F_DEAD;
10881089
#ifdef CONFIG_IP_ROUTE_MULTIPATH
10891090
spin_lock_bh(&fib_multipath_lock);
1090-
fi->fib_power -= nh->nh_power;
1091-
nh->nh_power = 0;
1091+
fi->fib_power -= nexthop_nh->nh_power;
1092+
nexthop_nh->nh_power = 0;
10921093
spin_unlock_bh(&fib_multipath_lock);
10931094
#endif
10941095
dead++;
10951096
}
10961097
#ifdef CONFIG_IP_ROUTE_MULTIPATH
1097-
if (force > 1 && nh->nh_dev == dev) {
1098+
if (force > 1 && nexthop_nh->nh_dev == dev) {
10981099
dead = fi->fib_nhs;
10991100
break;
11001101
}
@@ -1144,18 +1145,20 @@ int fib_sync_up(struct net_device *dev)
11441145
prev_fi = fi;
11451146
alive = 0;
11461147
change_nexthops(fi) {
1147-
if (!(nh->nh_flags&RTNH_F_DEAD)) {
1148+
if (!(nexthop_nh->nh_flags&RTNH_F_DEAD)) {
11481149
alive++;
11491150
continue;
11501151
}
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))
11521154
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))
11541157
continue;
11551158
alive++;
11561159
spin_lock_bh(&fib_multipath_lock);
1157-
nh->nh_power = 0;
1158-
nh->nh_flags &= ~RTNH_F_DEAD;
1160+
nexthop_nh->nh_power = 0;
1161+
nexthop_nh->nh_flags &= ~RTNH_F_DEAD;
11591162
spin_unlock_bh(&fib_multipath_lock);
11601163
} endfor_nexthops(fi)
11611164

@@ -1182,9 +1185,9 @@ void fib_select_multipath(const struct flowi *flp, struct fib_result *res)
11821185
if (fi->fib_power <= 0) {
11831186
int power = 0;
11841187
change_nexthops(fi) {
1185-
if (!(nh->nh_flags&RTNH_F_DEAD)) {
1186-
power += nh->nh_weight;
1187-
nh->nh_power = nh->nh_weight;
1188+
if (!(nexthop_nh->nh_flags&RTNH_F_DEAD)) {
1189+
power += nexthop_nh->nh_weight;
1190+
nexthop_nh->nh_power = nexthop_nh->nh_weight;
11881191
}
11891192
} endfor_nexthops(fi);
11901193
fi->fib_power = power;
@@ -1204,9 +1207,10 @@ void fib_select_multipath(const struct flowi *flp, struct fib_result *res)
12041207
w = jiffies % fi->fib_power;
12051208

12061209
change_nexthops(fi) {
1207-
if (!(nh->nh_flags&RTNH_F_DEAD) && nh->nh_power) {
1208-
if ((w -= nh->nh_power) <= 0) {
1209-
nh->nh_power--;
1210+
if (!(nexthop_nh->nh_flags&RTNH_F_DEAD) &&
1211+
nexthop_nh->nh_power) {
1212+
if ((w -= nexthop_nh->nh_power) <= 0) {
1213+
nexthop_nh->nh_power--;
12101214
fi->fib_power--;
12111215
res->nh_sel = nhsel;
12121216
spin_unlock_bh(&fib_multipath_lock);

0 commit comments

Comments
 (0)