Signed-off-by: Grzegorz Halat <[email protected]>
---
 rtnl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/rtnl.c b/rtnl.c
index f9a572b..d2598ce 100644
--- a/rtnl.c
+++ b/rtnl.c
@@ -150,14 +150,15 @@ static inline int rtnl_nested_rtattr_parse(struct rtattr 
*tb[], int max, struct
        return rtnl_rtattr_parse(tb, max, RTA_DATA(rta), RTA_PAYLOAD(rta));
 }
 
-static int rtnl_linkinfo_parse(struct rtattr *rta)
+static int rtnl_linkinfo_parse(struct rtattr *tb[])
 {
        int index = -1;
        const char *kind;
        struct rtattr *linkinfo[IFLA_INFO_MAX];
        struct rtattr *bond[IFLA_BOND_MAX];
 
-       if (rtnl_nested_rtattr_parse(linkinfo, IFLA_INFO_MAX, rta) < 0)
+       if (!tb[IFLA_LINKINFO] || rtnl_nested_rtattr_parse(linkinfo,
+                                       IFLA_INFO_MAX, tb[IFLA_LINKINFO]) < 0)
                return -1;
 
        if (linkinfo[IFLA_INFO_KIND]) {
@@ -173,6 +174,8 @@ static int rtnl_linkinfo_parse(struct rtattr *rta)
                                index = 
rta_getattr_u32(bond[IFLA_BOND_ACTIVE_SLAVE]);
                        }
                }
+               if (kind && !strncmp(kind, "macvlan", 7) && tb[IFLA_LINK])
+                       index = rta_getattr_u32(tb[IFLA_LINK]);
        }
        return index;
 }
@@ -245,8 +248,7 @@ int rtnl_link_status(int fd, char *device, rtnl_callback 
cb, void *ctx)
                rtnl_rtattr_parse(tb, IFLA_MAX, IFLA_RTA(info),
                                  IFLA_PAYLOAD(nh));
 
-               if (tb[IFLA_LINKINFO])
-                       slave_index = rtnl_linkinfo_parse(tb[IFLA_LINKINFO]);
+               slave_index = rtnl_linkinfo_parse(tb);
 
                if (cb)
                        cb(ctx, link_up, slave_index);
-- 
2.14.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to