git: d2c2d6d6b09e - main - igmp: apply net.inet.igmp.default_version to existing interfaces
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 01 May 2025 08:24:05 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=d2c2d6d6b09e8a059dffd6b6c7513d0925a8753d
commit d2c2d6d6b09e8a059dffd6b6c7513d0925a8753d
Author: Olivier BLANC <etihwo@outlook.com>
AuthorDate: 2025-03-14 18:55:55 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-05-01 07:31:21 +0000
igmp: apply net.inet.igmp.default_version to existing interfaces
IGMP requires hosts to use the lowest version they have seen on the network.
When net.inet.igmp.default_version is changed, we do not change IGMP
version used by interface even if the interface use an higher version than
V_igmp_default_version. So we could send IGMPv3 even if the user has requested
IGMPv2 or IGMPv1 via the sysctl.
Change IGMP version for each interface when V_igmp_default_version is smaller
than the version used by the interface.
Pull Request: https://github.com/freebsd/freebsd-src/pull/1615
Differential Revision: https://reviews.freebsd.org/D50071
---
sys/netinet/igmp.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 5082b6294ebb..299f3c2e02bb 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -402,32 +402,43 @@ out:
static int
sysctl_igmp_default_version(SYSCTL_HANDLER_ARGS)
{
+ struct epoch_tracker et;
int error;
int new;
+ struct igmp_ifsoftc *igi;
error = sysctl_wire_old_buffer(req, sizeof(int));
if (error)
return (error);
- IGMP_LOCK();
-
new = V_igmp_default_version;
error = sysctl_handle_int(oidp, &new, 0, req);
if (error || !req->newptr)
- goto out_locked;
+ return (error);
- if (new < IGMP_VERSION_1 || new > IGMP_VERSION_3) {
- error = EINVAL;
- goto out_locked;
- }
+ if (new < IGMP_VERSION_1 || new > IGMP_VERSION_3)
+ return (EINVAL);
+
+ IN_MULTI_LIST_LOCK();
+ IGMP_LOCK();
+ NET_EPOCH_ENTER(et);
- CTR2(KTR_IGMPV3, "change igmp_default_version from %d to %d",
- V_igmp_default_version, new);
+ if (V_igmp_default_version != new) {
+ CTR2(KTR_IGMPV3, "change igmp_default_version from %d to %d",
+ V_igmp_default_version, new);
- V_igmp_default_version = new;
+ V_igmp_default_version = new;
-out_locked:
+ LIST_FOREACH(igi, &V_igi_head, igi_link) {
+ if (igi->igi_version > V_igmp_default_version){
+ igmp_set_version(igi, V_igmp_default_version);
+ }
+ }
+ }
+
+ NET_EPOCH_EXIT(et);
+ IN_MULTI_LIST_UNLOCK();
IGMP_UNLOCK();
return (error);
}