mirror of
https://github.com/systemd/systemd.git
synced 2025-02-24 17:57:34 +03:00
network: introduce TripleSampling= option in CAN section
When enabled, three samples are used to determine the value of a received bit by majority rule. This patch adds support for the TripleSampling= option in the [CAN] section of .network files.
This commit is contained in:
parent
7f45d738a6
commit
c423be28a0
@ -1903,6 +1903,13 @@
|
||||
automatic restart off. By default automatic restart is disabled.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>TripleSampling=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes a boolean. When <literal>yes</literal>, 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.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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");
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -132,6 +132,7 @@ PVID=
|
||||
SamplePoint=
|
||||
BitRate=
|
||||
RestartSec=
|
||||
TripleSampling=
|
||||
[Address]
|
||||
DuplicateAddressDetection=
|
||||
AutoJoin=
|
||||
|
Loading…
x
Reference in New Issue
Block a user