summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMichele Dionisio <michele.dionisio@powersoft.com>2024-11-05 11:53:30 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2024-11-06 16:50:27 +0100
commitd865abf9eb50bc484c1671c323e9e59e204b0a5b (patch)
tree88c817e02b9a4f8f649446b403303d77f0303421 /src/network
parentGrammar and formatting for DeviceTree docs (#35050) (diff)
downloadsystemd-d865abf9eb50bc484c1671c323e9e59e204b0a5b.tar.xz
systemd-d865abf9eb50bc484c1671c323e9e59e204b0a5b.zip
networkd: add possibility to specify MulticastIGMPVersion
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-network-gperf.gperf1
-rw-r--r--src/network/networkd-network.c1
-rw-r--r--src/network/networkd-network.h1
-rw-r--r--src/network/networkd-sysctl.c26
-rw-r--r--src/network/networkd-sysctl.h15
5 files changed, 44 insertions, 0 deletions
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 50be74e55f..ab7f2553ec 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -150,6 +150,7 @@ Network.IPv4ProxyARPPrivateVLAN, config_parse_tristate,
Network.ProxyARP, config_parse_tristate, 0, offsetof(Network, proxy_arp)
Network.IPv6ProxyNDPAddress, config_parse_ipv6_proxy_ndp_address, 0, 0
Network.IPv4ReversePathFilter, config_parse_ip_reverse_path_filter, 0, offsetof(Network, ipv4_rp_filter)
+Network.MulticastIGMPVersion, config_parse_ipv4_force_igmp_version, 0, offsetof(Network, ipv4_force_igmp_version)
Network.BindCarrier, config_parse_strv, 0, offsetof(Network, bind_carrier)
Network.ConfigureWithoutCarrier, config_parse_bool, 0, offsetof(Network, configure_without_carrier)
Network.IgnoreCarrierLoss, config_parse_ignore_carrier_loss, 0, 0
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 97bfe65394..2488530829 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -481,6 +481,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.proxy_arp = -1,
.proxy_arp_pvlan = -1,
.ipv4_rp_filter = _IP_REVERSE_PATH_FILTER_INVALID,
+ .ipv4_force_igmp_version = _IPV4_FORCE_IGMP_VERSION_INVALID,
.ndisc = -1,
.ndisc_use_redirect = true,
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index 30ea9ac352..3ea94e0e49 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -340,6 +340,7 @@ struct Network {
uint32_t ipv6_mtu;
IPv6PrivacyExtensions ipv6_privacy_extensions;
IPReversePathFilter ipv4_rp_filter;
+ IPv4ForceIgmpVersion ipv4_force_igmp_version;
int ipv6_proxy_ndp;
Set *ipv6_proxy_ndp_addresses;
diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c
index 17a2c6da38..10a35bc44b 100644
--- a/src/network/networkd-sysctl.c
+++ b/src/network/networkd-sysctl.c
@@ -408,6 +408,18 @@ static int link_set_ipv4_rp_filter(Link *link) {
return sysctl_write_ip_property_int(AF_INET, link->ifname, "rp_filter", link->network->ipv4_rp_filter, manager_get_sysctl_shadow(link->manager));
}
+static int link_set_ipv4_force_igmp_version(Link *link) {
+ assert(link);
+
+ if (!link_is_configured_for_family(link, AF_INET))
+ return 0;
+
+ if (link->network->ipv4_force_igmp_version < 0)
+ return 0;
+
+ return sysctl_write_ip_property_int(AF_INET, link->ifname, "force_igmp_version", link->network->ipv4_force_igmp_version, manager_get_sysctl_shadow(link->manager));
+}
+
static int link_set_ipv6_privacy_extensions(Link *link) {
IPv6PrivacyExtensions val;
@@ -723,6 +735,10 @@ int link_set_sysctl(Link *link) {
if (r < 0)
log_link_warning_errno(link, r, "Cannot set IPv4 reverse path filtering for interface, ignoring: %m");
+ r = link_set_ipv4_force_igmp_version(link);
+ if (r < 0)
+ log_link_warning_errno(link, r, "Cannot set IPv4 force igmp version, ignoring: %m");
+
r = link_set_ipv4_promote_secondaries(link);
if (r < 0)
log_link_warning_errno(link, r, "Cannot enable promote_secondaries for interface, ignoring: %m");
@@ -770,3 +786,13 @@ int config_parse_ip_forward_deprecated(
"and the same settings in .network files for per-interface setting.");
return 0;
}
+
+static const char* const ipv4_force_igmp_version_table[_IPV4_FORCE_IGMP_VERSION_MAX] = {
+ [IPV4_FORCE_IGMP_VERSION_NO] = "no",
+ [IPV4_FORCE_IGMP_VERSION_1] = "v1",
+ [IPV4_FORCE_IGMP_VERSION_2] = "v2",
+ [IPV4_FORCE_IGMP_VERSION_3] = "v3",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(ipv4_force_igmp_version, IPv4ForceIgmpVersion);
+DEFINE_CONFIG_PARSE_ENUM(config_parse_ipv4_force_igmp_version, ipv4_force_igmp_version, IPv4ForceIgmpVersion);
diff --git a/src/network/networkd-sysctl.h b/src/network/networkd-sysctl.h
index 1c19fbd2d6..ea1d2bc897 100644
--- a/src/network/networkd-sysctl.h
+++ b/src/network/networkd-sysctl.h
@@ -53,3 +53,18 @@ IPReversePathFilter ip_reverse_path_filter_from_string(const char *s) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_privacy_extensions);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_reverse_path_filter);
CONFIG_PARSER_PROTOTYPE(config_parse_ip_forward_deprecated);
+
+typedef enum IPv4ForceIgmpVersion {
+ /* These values map to the kernel's /proc/sys/net/ipv4/conf/INTERFACE/force_igmp_version values. Do not reorder! */
+ IPV4_FORCE_IGMP_VERSION_NO = 0,
+ IPV4_FORCE_IGMP_VERSION_1 = 1,
+ IPV4_FORCE_IGMP_VERSION_2 = 2,
+ IPV4_FORCE_IGMP_VERSION_3 = 3,
+ _IPV4_FORCE_IGMP_VERSION_MAX,
+ _IPV4_FORCE_IGMP_VERSION_INVALID = -EINVAL,
+} IPv4ForceIgmpVersion;
+
+const char* ipv4_force_igmp_version_to_string(IPv4ForceIgmpVersion i) _const_;
+IPv4ForceIgmpVersion ipv4_force_igmp_version_from_string(const char *s) _pure_;
+
+CONFIG_PARSER_PROTOTYPE(config_parse_ipv4_force_igmp_version);