aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/mcast.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-08-20 06:22:00 -0400
committerDavid S. Miller <davem@davemloft.net>2013-08-21 02:52:02 -0400
commit846989635b368c41efd9079ec6fe0e8d2845ec11 (patch)
tree282a9eacb2f268ef50d4c769078157b10a5c3877 /net/ipv6/mcast.c
parentd8a64420eb267bec9f4c99627deee4fa3bf4133e (diff)
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>
Diffstat (limited to 'net/ipv6/mcast.c')
-rw-r--r--net/ipv6/mcast.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 6c76df9909bf..57863e206d56 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1150,9 +1150,7 @@ int igmp6_event_query(struct sk_buff *skb)
1150 int switchback; 1150 int switchback;
1151 /* MLDv1 router present */ 1151 /* MLDv1 router present */
1152 1152
1153 /* Translate milliseconds to jiffies */ 1153 max_delay = msecs_to_jiffies(ntohs(mld->mld_maxdelay));
1154 max_delay = (ntohs(mld->mld_maxdelay)*HZ)/1000;
1155
1156 switchback = (idev->mc_qrv + 1) * max_delay; 1154 switchback = (idev->mc_qrv + 1) * max_delay;
1157 idev->mc_v1_seen = jiffies + switchback; 1155 idev->mc_v1_seen = jiffies + switchback;
1158 1156
@@ -1169,10 +1167,11 @@ int igmp6_event_query(struct sk_buff *skb)
1169 return -EINVAL; 1167 return -EINVAL;
1170 1168
1171 mlh2 = (struct mld2_query *)skb_transport_header(skb); 1169 mlh2 = (struct mld2_query *)skb_transport_header(skb);
1172 max_delay = (MLDV2_MRC(ntohs(mlh2->mld2q_mrc))*HZ)/1000; 1170
1173 if (!max_delay) 1171 max_delay = max(msecs_to_jiffies(MLDV2_MRC(ntohs(mlh2->mld2q_mrc))), 1UL);
1174 max_delay = 1; 1172
1175 idev->mc_maxdelay = max_delay; 1173 idev->mc_maxdelay = max_delay;
1174
1176 if (mlh2->mld2q_qrv) 1175 if (mlh2->mld2q_qrv)
1177 idev->mc_qrv = mlh2->mld2q_qrv; 1176 idev->mc_qrv = mlh2->mld2q_qrv;
1178 if (group_type == IPV6_ADDR_ANY) { /* general query */ 1177 if (group_type == IPV6_ADDR_ANY) { /* general query */