]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkctl: Add support to display macvlan/macvtap mode
authorSusant Sahani <ssahani@vmware.com>
Thu, 19 Mar 2020 04:24:49 +0000 (05:24 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 14 May 2020 15:35:56 +0000 (17:35 +0200)
src/network/networkctl.c

index 149bf14a484e43fcccb8755978e06083951bdcdb..175f39910f15b6742bcea56208b9bc26aea15a82 100644 (file)
@@ -36,6 +36,7 @@
 #include "locale-util.h"
 #include "logs-show.h"
 #include "macro.h"
+#include "macvlan-util.h"
 #include "main-func.h"
 #include "netlink-util.h"
 #include "network-internal.h"
@@ -179,6 +180,9 @@ typedef struct LinkInfo {
         uint32_t updelay;
         uint32_t downdelay;
 
+        /* macvlan and macvtap info */
+        uint32_t macvlan_mode;
+
         /* ethtool info */
         int autonegotiation;
         uint64_t speed;
@@ -313,7 +317,8 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
         } else if (streq(received_kind, "vti6")) {
                 (void) sd_netlink_message_read_in6_addr(m, IFLA_VTI_LOCAL, &info->local.in6);
                 (void) sd_netlink_message_read_in6_addr(m, IFLA_VTI_REMOTE, &info->remote.in6);
-        }
+        } else if (STR_IN_SET(received_kind, "macvlan", "macvtap"))
+                (void) sd_netlink_message_read_u32(m, IFLA_MACVLAN_MODE, &info->macvlan_mode);
 
         strncpy(info->netdev_kind, received_kind, IFNAMSIZ);
 
@@ -1731,6 +1736,13 @@ static int link_status_one(
                         if (r < 0)
                                 return table_log_add_error(r);
                 }
+        } else if (STRPTR_IN_SET(info->netdev_kind, "macvlan", "macvtap")) {
+                r = table_add_many(table,
+                                   TABLE_EMPTY,
+                                   TABLE_STRING, "Mode:",
+                                   TABLE_STRING, macvlan_mode_to_string(info->macvlan_mode));
+                if (r < 0)
+                        return table_log_add_error(r);
         }
 
         if (info->has_wlan_link_info) {