Skip to content

Commit 19e16d2

Browse files
liuhangbindavem330
authored andcommitted
neigh: support smaller retrans_time settting
Currently, we limited the retrans_time to be greater than HZ/2. i.e. setting retrans_time less than 500ms will not work. This makes the user unable to achieve a more accurate control for bonding arp fast failover. Update the sanity check to HZ/100, which is 10ms, to let users have more ability on the retrans_time control. v3: sync the behavior with IPv6 and update all the timer handler v2: use HZ instead of hard code number Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6494842 commit 19e16d2

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

net/core/neighbour.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,11 +1065,12 @@ static void neigh_timer_handler(struct timer_list *t)
10651065
neigh->updated = jiffies;
10661066
atomic_set(&neigh->probes, 0);
10671067
notify = 1;
1068-
next = now + NEIGH_VAR(neigh->parms, RETRANS_TIME);
1068+
next = now + max(NEIGH_VAR(neigh->parms, RETRANS_TIME),
1069+
HZ/100);
10691070
}
10701071
} else {
10711072
/* NUD_PROBE|NUD_INCOMPLETE */
1072-
next = now + NEIGH_VAR(neigh->parms, RETRANS_TIME);
1073+
next = now + max(NEIGH_VAR(neigh->parms, RETRANS_TIME), HZ/100);
10731074
}
10741075

10751076
if ((neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) &&
@@ -1125,7 +1126,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
11251126
neigh->nud_state = NUD_INCOMPLETE;
11261127
neigh->updated = now;
11271128
next = now + max(NEIGH_VAR(neigh->parms, RETRANS_TIME),
1128-
HZ/2);
1129+
HZ/100);
11291130
neigh_add_timer(neigh, next);
11301131
immediate_probe = true;
11311132
} else {
@@ -1427,7 +1428,8 @@ void __neigh_set_probe_once(struct neighbour *neigh)
14271428
neigh->nud_state = NUD_INCOMPLETE;
14281429
atomic_set(&neigh->probes, neigh_max_probes(neigh));
14291430
neigh_add_timer(neigh,
1430-
jiffies + NEIGH_VAR(neigh->parms, RETRANS_TIME));
1431+
jiffies + max(NEIGH_VAR(neigh->parms, RETRANS_TIME),
1432+
HZ/100));
14311433
}
14321434
EXPORT_SYMBOL(__neigh_set_probe_once);
14331435

net/ipv6/addrconf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp,
13571357

13581358
regen_advance = idev->cnf.regen_max_retry *
13591359
idev->cnf.dad_transmits *
1360-
NEIGH_VAR(idev->nd_parms, RETRANS_TIME) / HZ;
1360+
max(NEIGH_VAR(idev->nd_parms, RETRANS_TIME), HZ/100) / HZ;
13611361

13621362
/* recalculate max_desync_factor each time and update
13631363
* idev->desync_factor if it's larger
@@ -4121,7 +4121,8 @@ static void addrconf_dad_work(struct work_struct *w)
41214121

41224122
ifp->dad_probes--;
41234123
addrconf_mod_dad_work(ifp,
4124-
NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME));
4124+
max(NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME),
4125+
HZ/100));
41254126
spin_unlock(&ifp->lock);
41264127
write_unlock_bh(&idev->lock);
41274128

@@ -4527,7 +4528,7 @@ static void addrconf_verify_rtnl(void)
45274528
!(ifp->flags&IFA_F_TENTATIVE)) {
45284529
unsigned long regen_advance = ifp->idev->cnf.regen_max_retry *
45294530
ifp->idev->cnf.dad_transmits *
4530-
NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME) / HZ;
4531+
max(NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME), HZ/100) / HZ;
45314532

45324533
if (age >= ifp->prefered_lft - regen_advance) {
45334534
struct inet6_ifaddr *ifpub = ifp->ifpub;

net/ipv6/ndisc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,8 +1359,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
13591359

13601360
if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
13611361
rtime = (rtime*HZ)/1000;
1362-
if (rtime < HZ/10)
1363-
rtime = HZ/10;
1362+
if (rtime < HZ/100)
1363+
rtime = HZ/100;
13641364
NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime);
13651365
in6_dev->tstamp = jiffies;
13661366
send_ifinfo_notify = true;

0 commit comments

Comments
 (0)