summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-11 03:48:41 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-11 15:22:29 +0200
commitf5bab0d9c0632890e69f907c168174a4904ca764 (patch)
tree75e9dce1df1bab227428a1e39a5fb16257a26f53 /src
parentnetwork: fdb: do not allocate separated memory for lladdr (diff)
downloadsystemd-f5bab0d9c0632890e69f907c168174a4904ca764.tar.xz
systemd-f5bab0d9c0632890e69f907c168174a4904ca764.zip
network: fdb: use ether_addr_from_string()
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-fdb.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c
index f53f661675..5b7468c103 100644
--- a/src/network/networkd-fdb.c
+++ b/src/network/networkd-fdb.c
@@ -215,17 +215,9 @@ int config_parse_fdb_hwaddr(
if (r < 0)
return log_oom();
- /* read in the MAC address for the FDB table. */
- r = sscanf(rvalue, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
- &fdb_entry->mac_addr.ether_addr_octet[0],
- &fdb_entry->mac_addr.ether_addr_octet[1],
- &fdb_entry->mac_addr.ether_addr_octet[2],
- &fdb_entry->mac_addr.ether_addr_octet[3],
- &fdb_entry->mac_addr.ether_addr_octet[4],
- &fdb_entry->mac_addr.ether_addr_octet[5]);
-
- if (r != ETHER_ADDR_LEN) {
- log_syntax(unit, LOG_ERR, filename, line, 0, "Not a valid MAC address, ignoring assignment: %s", rvalue);
+ r = ether_addr_from_string(rvalue, &fdb_entry->mac_addr);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Not a valid MAC address, ignoring assignment: %s", rvalue);
return 0;
}