From 0ef13a45f8ec2da9495de2a750ad239af207149e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ketelaars?= Date: Wed, 15 Feb 2023 13:22:44 +0100 Subject: [PATCH 1/2] Fix calculation of IGMP_GROUP_MEMBERSHIP_INTERVAL `IGMP_GROUP_MEMBERSHIP_INTERVAL` should be calculated using `IGMP_QUERY_INTERVAL` instead of `IGMP_RESPONSE_INTERVAL`. https://github.com/Esdenera/mcast-proxy/blob/master/usr.sbin/mcast-proxy/mcast-proxy.h#L41-L45 --- usr.sbin/mcast-proxy/mrt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/mcast-proxy/mrt.c b/usr.sbin/mcast-proxy/mrt.c index ee4c37f..4376e0d 100644 --- a/usr.sbin/mcast-proxy/mrt.c +++ b/usr.sbin/mcast-proxy/mrt.c @@ -185,7 +185,7 @@ void mrt_timeradd(struct event *ev) { unsigned long total = IGMP_GROUP_MEMBERSHIP_INTERVAL( - IGMP_ROBUSTNESS_DEFVALUE, IGMP_RESPONSE_INTERVAL); + IGMP_ROBUSTNESS_DEFVALUE, IGMP_QUERY_INTERVAL); struct timeval tv; if (evtimer_pending(ev, &tv)) From 7630d56da8f11d268245f531b04d2045b59a123d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ketelaars?= Date: Wed, 15 Feb 2023 13:26:29 +0100 Subject: [PATCH 2/2] Refactor use of IGMP_GROUP_MEMBERSHIP_INTERVAL --- usr.sbin/mcast-proxy/mcast-proxy.h | 4 ++-- usr.sbin/mcast-proxy/mrt.c | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/usr.sbin/mcast-proxy/mcast-proxy.h b/usr.sbin/mcast-proxy/mcast-proxy.h index a0cec24..217336d 100644 --- a/usr.sbin/mcast-proxy/mcast-proxy.h +++ b/usr.sbin/mcast-proxy/mcast-proxy.h @@ -43,8 +43,8 @@ * Group membership interval is composed by the following formula: * (Robustness * Query_Interval) + Query_Response_Interval. */ -#define IGMP_GROUP_MEMBERSHIP_INTERVAL(r, q) \ - (((r) * (q)) + IGMP_RESPONSE_INTERVAL) +#define IGMP_GROUP_MEMBERSHIP_INTERVAL ((IGMP_ROBUSTNESS_DEFVALUE * \ + IGMP_QUERY_INTERVAL) + IGMP_RESPONSE_INTERVAL) /* Signalize invalid virtual/multicast interface index. */ #define INVALID_VINDEX ((uint16_t)-1) diff --git a/usr.sbin/mcast-proxy/mrt.c b/usr.sbin/mcast-proxy/mrt.c index 4376e0d..bba054e 100644 --- a/usr.sbin/mcast-proxy/mrt.c +++ b/usr.sbin/mcast-proxy/mrt.c @@ -184,15 +184,11 @@ mrt_delorigin(struct multicast_route *mr, struct intf_data *id, void mrt_timeradd(struct event *ev) { - unsigned long total = IGMP_GROUP_MEMBERSHIP_INTERVAL( - IGMP_ROBUSTNESS_DEFVALUE, IGMP_QUERY_INTERVAL); - struct timeval tv; + struct timeval tv = { IGMP_GROUP_MEMBERSHIP_INTERVAL, 0 }; if (evtimer_pending(ev, &tv)) evtimer_del(ev); - tv.tv_sec = total; - tv.tv_usec = 0; evtimer_add(ev, &tv); }