diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 4fa2d1dc48f..1a3d24aa763 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1903,6 +1903,13 @@ automatic restart off. By default automatic restart is disabled. + + TripleSampling= + + Takes a boolean. When yes, three samples (instead of one) are used to determine + the value of a received bit by majority rule. When unset, the kernel's default will be used. + + diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index 5ef2ba37809..803de54712a 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -308,6 +308,7 @@ static const NLType rtnl_link_info_data_geneve_types[] = { static const NLType rtnl_link_info_data_can_types[] = { [IFLA_CAN_BITTIMING] = { .size = sizeof(struct can_bittiming) }, [IFLA_CAN_RESTART_MS] = { .type = NETLINK_TYPE_U32 }, + [IFLA_CAN_CTRLMODE] = { .size = sizeof(struct can_ctrlmode) }, }; /* these strings must match the .kind entries in the kernel */ diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 9e3cd71a095..de112a2ef80 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -2163,6 +2163,19 @@ static int link_set_can(Link *link) { return log_link_error_errno(link, r, "Could not append IFLA_CAN_RESTART_MS attribute: %m"); } + if (link->network->can_triple_sampling >= 0) { + struct can_ctrlmode cm = { + .mask = CAN_CTRLMODE_3_SAMPLES, + .flags = link->network->can_triple_sampling ? CAN_CTRLMODE_3_SAMPLES : 0, + }; + + log_link_debug(link, "%sabling triple-sampling", link->network->can_triple_sampling ? "En" : "Dis"); + + r = sd_netlink_message_append_data(m, IFLA_CAN_CTRLMODE, &cm, sizeof(cm)); + if (r < 0) + return log_link_error_errno(link, r, "Could not append IFLA_CAN_CTRLMODE attribute: %m"); + } + r = sd_netlink_message_close_container(m); if (r < 0) return log_link_error_errno(link, r, "Failed to close netlink container: %m"); diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 7888bdf07af..51123d12ef0 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -195,6 +195,7 @@ IPv6Prefix.PreferredLifetimeSec, config_parse_prefix_lifetime, CAN.BitRate, config_parse_si_size, 0, offsetof(Network, can_bitrate) CAN.SamplePoint, config_parse_permille, 0, offsetof(Network, can_sample_point) CAN.RestartSec, config_parse_sec, 0, offsetof(Network, can_restart_us) +CAN.TripleSampling, config_parse_tristate, 0, offsetof(Network, can_triple_sampling) /* backwards compatibility: do not add new entries to this section */ Network.IPv4LL, config_parse_ipv4ll, 0, offsetof(Network, link_local) DHCPv4.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index ab4e90543c3..5f12df907af 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -428,6 +428,8 @@ int network_load_one(Manager *manager, const char *filename) { .ipv6_accept_ra_use_onlink_prefix = true, .ipv6_accept_ra_route_table = RT_TABLE_MAIN, .ipv6_accept_ra_route_table_set = false, + + .can_triple_sampling = -1, }; r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname, diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 63d0328750f..2f7b6133fd5 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -202,6 +202,7 @@ struct Network { size_t can_bitrate; unsigned can_sample_point; usec_t can_restart_us; + int can_triple_sampling; AddressFamilyBoolean ip_forward; bool ip_masquerade; diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index d77c6989cdd..9a60eb712df 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -132,6 +132,7 @@ PVID= SamplePoint= BitRate= RestartSec= +TripleSampling= [Address] DuplicateAddressDetection= AutoJoin=