net: ipv6: igmp6_event_query: use msecs_to_jiffies
Use proper API functions to calculate jiffies from milliseconds and not the crude method of dividing HZ by a value. This ensures more accurate values even in the case of strange HZ values. While at it, also simplify code in the mlh2 case by using max(). Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
d8a64420eb
commit
846989635b
@@ -1150,9 +1150,7 @@ int igmp6_event_query(struct sk_buff *skb)
|
|||||||
int switchback;
|
int switchback;
|
||||||
/* MLDv1 router present */
|
/* MLDv1 router present */
|
||||||
|
|
||||||
/* Translate milliseconds to jiffies */
|
max_delay = msecs_to_jiffies(ntohs(mld->mld_maxdelay));
|
||||||
max_delay = (ntohs(mld->mld_maxdelay)*HZ)/1000;
|
|
||||||
|
|
||||||
switchback = (idev->mc_qrv + 1) * max_delay;
|
switchback = (idev->mc_qrv + 1) * max_delay;
|
||||||
idev->mc_v1_seen = jiffies + switchback;
|
idev->mc_v1_seen = jiffies + switchback;
|
||||||
|
|
||||||
@@ -1169,10 +1167,11 @@ int igmp6_event_query(struct sk_buff *skb)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mlh2 = (struct mld2_query *)skb_transport_header(skb);
|
mlh2 = (struct mld2_query *)skb_transport_header(skb);
|
||||||
max_delay = (MLDV2_MRC(ntohs(mlh2->mld2q_mrc))*HZ)/1000;
|
|
||||||
if (!max_delay)
|
max_delay = max(msecs_to_jiffies(MLDV2_MRC(ntohs(mlh2->mld2q_mrc))), 1UL);
|
||||||
max_delay = 1;
|
|
||||||
idev->mc_maxdelay = max_delay;
|
idev->mc_maxdelay = max_delay;
|
||||||
|
|
||||||
if (mlh2->mld2q_qrv)
|
if (mlh2->mld2q_qrv)
|
||||||
idev->mc_qrv = mlh2->mld2q_qrv;
|
idev->mc_qrv = mlh2->mld2q_qrv;
|
||||||
if (group_type == IPV6_ADDR_ANY) { /* general query */
|
if (group_type == IPV6_ADDR_ANY) { /* general query */
|
||||||
|
Reference in New Issue
Block a user