From 4e964aa05c4c3e305de6e9ebcb7c9a49f557effc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 20 Apr 2018 16:33:00 +0200 Subject: networkd,udev: clean up MTU handling This cleans up handling of MTU values across the codebase. Previously MTU values where stored sometimes in uint32_t, sometimes in uint16_t, sometimes unsigned and sometimes in size_t. This now unifies this to uint32_t across the codebase, as that's what netlink spits out, and what the majority was already using. Also, all MTU parameters are now parsed with config_parse_mtu() and config_parse_ipv6_mtu() is dropped as it is now unneeded. (Note there is one exception for the MTU typing: in the DCHPv4 code we continue to process the MTU as uint16_t value, as it is encoded like that in the protocol, and it's probably better stay close to the protocol there.) --- src/udev/net/link-config-gperf.gperf | 2 +- src/udev/net/link-config.c | 2 +- src/udev/net/link-config.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/udev') diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf index b4c3a45cf3..8bfa998dac 100644 --- a/src/udev/net/link-config-gperf.gperf +++ b/src/udev/net/link-config-gperf.gperf @@ -35,7 +35,7 @@ Link.MACAddress, config_parse_hwaddr, 0, Link.NamePolicy, config_parse_name_policy, 0, offsetof(link_config, name_policy) Link.Name, config_parse_ifname, 0, offsetof(link_config, name) Link.Alias, config_parse_ifalias, 0, offsetof(link_config, alias) -Link.MTUBytes, config_parse_iec_size, 0, offsetof(link_config, mtu) +Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu) Link.BitsPerSecond, config_parse_si_size, 0, offsetof(link_config, speed) Link.Duplex, config_parse_duplex, 0, offsetof(link_config, duplex) Link.AutoNegotiation, config_parse_tristate, 0, offsetof(link_config, autonegotiation) diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 48f6c57758..71d68f60d4 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -169,7 +169,7 @@ static int load_link(link_config_ctx *ctx, const char *filename) { else log_debug("Parsed configuration file %s", filename); - if (link->mtu > UINT_MAX || link->speed > UINT_MAX) + if (link->speed > UINT_MAX) return -ERANGE; link->filename = strdup(filename); diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h index 699e54c837..9f41132810 100644 --- a/src/udev/net/link-config.h +++ b/src/udev/net/link-config.h @@ -55,7 +55,7 @@ struct link_config { NamePolicy *name_policy; char *name; char *alias; - size_t mtu; + uint32_t mtu; size_t speed; Duplex duplex; int autonegotiation; -- cgit v1.2.1