]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkctl: Add support to display bond
authorSusant Sahani <ssahani@vmware.com>
Wed, 18 Mar 2020 07:50:15 +0000 (08:50 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 18 Mar 2020 15:12:07 +0000 (16:12 +0100)
src/network/networkctl.c

index bc67af3c25e92baaa97c6145c005bd1dafbf3eab..7db2142ef24cce8809510f4b62257a580e6b7372 100644 (file)
@@ -161,6 +161,12 @@ typedef struct LinkInfo {
         union in_addr_union local;
         union in_addr_union remote;
 
+        /* bonding info */
+        uint8_t mode;
+        uint32_t miimon;
+        uint32_t updelay;
+        uint32_t downdelay;
+
         /* ethtool info */
         int autonegotiation;
         uint64_t speed;
@@ -229,7 +235,11 @@ static int decode_netdev(sd_netlink_message *m, LinkInfo *info) {
                 (void) sd_netlink_message_read_u32(m, IFLA_BR_STP_STATE, &info->stp_state);
                 (void) sd_netlink_message_read_u16(m, IFLA_BR_PRIORITY, &info->priority);
                 (void) sd_netlink_message_read_u8(m, IFLA_BR_MCAST_IGMP_VERSION, &info->mcast_igmp_version);
-
+        } if (streq(received_kind, "bond")) {
+                (void) sd_netlink_message_read_u8(m, IFLA_BOND_MODE, &info->mode);
+                (void) sd_netlink_message_read_u32(m, IFLA_BOND_MIIMON, &info->miimon);
+                (void) sd_netlink_message_read_u32(m, IFLA_BOND_DOWNDELAY, &info->downdelay);
+                (void) sd_netlink_message_read_u32(m, IFLA_BOND_UPDELAY, &info->updelay);
         } else if (streq(received_kind, "vxlan")) {
                 (void) sd_netlink_message_read_u32(m, IFLA_VXLAN_ID, &info->vxlan_info.vni);
 
@@ -1434,6 +1444,35 @@ static int link_status_one(
                 if (r < 0)
                         return table_log_add_error(r);
 
+        } else if (streq_ptr(info->netdev_kind, "bond")) {
+                static const struct {
+                        const char *mode;
+                } mode_table[] = {
+                        { "balance-rr" },
+                        { "active-backup" },
+                        { "balance-xor" },
+                        { "broadcast" },
+                        { "802.3ad" },
+                        { "balance-tlb" },
+                        { "balance-alb" },
+                };
+
+                r = table_add_many(table,
+                                   TABLE_EMPTY,
+                                   TABLE_STRING, "Mode:",
+                                   TABLE_STRING, mode_table[info->mode],
+                                   TABLE_EMPTY,
+                                   TABLE_STRING, "Miimon:",
+                                   TABLE_TIMESPAN_MSEC, jiffies_to_usec(info->miimon),
+                                   TABLE_EMPTY,
+                                   TABLE_STRING, "Updelay:",
+                                   TABLE_TIMESPAN_MSEC, jiffies_to_usec(info->updelay),
+                                   TABLE_EMPTY,
+                                   TABLE_STRING, "Downdelay:",
+                                   TABLE_TIMESPAN_MSEC, jiffies_to_usec(info->downdelay));
+                if (r < 0)
+                        return table_log_add_error(r);
+
         } else if (streq_ptr(info->netdev_kind, "vxlan")) {
                 if (info->vxlan_info.vni > 0) {
                         r = table_add_many(table,