From a18461bc7d446f8e130e9276de4397d00059267f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 29 Jan 2018 20:58:24 +0100 Subject: [PATCH] networkd: display wireguard devtype It's not useful to simply show "none", when we have more interesting information to display. Signed-off-by: Jason A. Donenfeld --- src/network/networkctl.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 59ce098cd1..6ce00dff6d 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -62,18 +62,26 @@ static int link_get_type_string(unsigned short iftype, sd_device *d, char **ret) assert(ret); - if (iftype == ARPHRD_ETHER && d) { + if (d) { const char *devtype = NULL, *id = NULL; + + (void) sd_device_get_devtype(d, &devtype); + /* WLANs have iftype ARPHRD_ETHER, but we want * to show a more useful type string for * them */ + if (iftype == ARPHRD_ETHER) { + if (streq_ptr(devtype, "wlan")) + id = "wlan"; + else if (streq_ptr(devtype, "wwan")) + id = "wwan"; + } - (void) sd_device_get_devtype(d, &devtype); - - if (streq_ptr(devtype, "wlan")) - id = "wlan"; - else if (streq_ptr(devtype, "wwan")) - id = "wwan"; + /* Likewise, WireGuard has iftype ARPHRD_NONE, + * since it's layer 3, but we of course want + * something more useful than that. */ + if (iftype == ARPHRD_NONE && streq_ptr(devtype, "wireguard")) + id = "wireguard"; if (id) { p = strdup(id); -- 2.25.1