]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkctl: Add support to display ipvlan 15166/head
authorSusant Sahani <ssahani@vmware.com>
Thu, 19 Mar 2020 10:29:10 +0000 (11:29 +0100)
committerSusant Sahani <ssahani@vmware.com>
Mon, 18 May 2020 17:07:04 +0000 (19:07 +0200)
```
build/networkctl status myipvlan1                                                                                                                                                        ─╯
● 26: myipvlan1
             Link File: /usr/lib/systemd/network/99-default.link
          Network File: n/a
                  Type: ether
                 State: off (unmanaged)
                Driver: ipvlan
            HW Address: 4e:c5:88:28:c1:c0
                   MTU: 1500 (min: 68, max: 65535)
                 QDisc: noop
                  Mode: L2 (bridge)
  Queue Length (Tx/Rx): 1/1

```

src/network/networkctl.c

index 175f39910f15b6742bcea56208b9bc26aea15a82..d4555d6fce407f60a4e7d8e1a1062df1b5f9c97f 100644 (file)
@@ -32,6 +32,7 @@
 #include "geneve-util.h"
 #include "glob-util.h"
 #include "hwdb-util.h"
+#include "ipvlan-util.h"
 #include "local-addresses.h"
 #include "locale-util.h"
 #include "logs-show.h"
@@ -183,6 +184,10 @@ typedef struct LinkInfo {
         /* macvlan and macvtap info */
         uint32_t macvlan_mode;
 
+        /* ipvlan info */
+        uint16_t ipvlan_mode;
+        uint16_t ipvlan_flags;
+
         /* ethtool info */
         int autonegotiation;
         uint64_t speed;
@@ -319,6 +324,10 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
                 (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);
+        else if (streq(received_kind, "ipvlan")) {
+                (void) sd_netlink_message_read_u16(m, IFLA_IPVLAN_MODE, &info->ipvlan_mode);
+                (void) sd_netlink_message_read_u16(m, IFLA_IPVLAN_FLAGS, &info->ipvlan_flags);
+        }
 
         strncpy(info->netdev_kind, received_kind, IFNAMSIZ);
 
@@ -1743,6 +1752,28 @@ static int link_status_one(
                                    TABLE_STRING, macvlan_mode_to_string(info->macvlan_mode));
                 if (r < 0)
                         return table_log_add_error(r);
+        } else if (streq_ptr(info->netdev_kind, "ipvlan")) {
+                _cleanup_free_ char *p = NULL, *s = NULL;
+
+                if (info->ipvlan_flags & IPVLAN_F_PRIVATE)
+                        p = strdup("private");
+                else if (info->ipvlan_flags & IPVLAN_F_VEPA)
+                        p = strdup("vepa");
+                else
+                        p = strdup("bridge");
+                if (!p)
+                        log_oom();
+
+                s = strjoin(ipvlan_mode_to_string(info->ipvlan_mode), " (", p, ")");
+                if (!s)
+                        return log_oom();
+
+                r = table_add_many(table,
+                                   TABLE_EMPTY,
+                                   TABLE_STRING, "Mode:",
+                                   TABLE_STRING, s);
+                if (r < 0)
+                        return table_log_add_error(r);
         }
 
         if (info->has_wlan_link_info) {