Add a new attribute to display the name of the master interface for
each slave.

Signed-off-by: Hangbin Liu <[email protected]>
---
 ip/iplink_bond_slave.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ip/iplink_bond_slave.c b/ip/iplink_bond_slave.c
index c88100e248dd..55deaadf5fe2 100644
--- a/ip/iplink_bond_slave.c
+++ b/ip/iplink_bond_slave.c
@@ -92,6 +92,17 @@ static void bond_slave_print_opt(struct link_util *lu, FILE 
*f, struct rtattr *t
        if (!tb)
                return;
 
+       if (tb[IFLA_BOND_SLAVE_MASTER]) {
+               unsigned int ifindex = 
rta_getattr_u32(tb[IFLA_BOND_SLAVE_MASTER]);
+
+               if (ifindex) {
+                       print_string(PRINT_ANY,
+                                    "master",
+                                    "master %s ",
+                                    ll_index_to_name(ifindex));
+               }
+       }
+
        if (tb[IFLA_BOND_SLAVE_STATE])
                print_slave_state(f, tb[IFLA_BOND_SLAVE_STATE]);
 
-- 
2.50.1


Reply via email to