On Tue, Aug 08, 2017 at 06:16:37PM +0800, Hangbin Liu wrote:
> The goal of this call path is to call port_link_status() whenever link status
> changed. And the call path should like
> 
> 1. port_event() -> rtnl_link_status() -> port_link_status()
> 
> > 2. clock_create() -> rtnl_link_info() -> rtnl_link_status()
> 
> This one only want to get the bond slave info when add iface at the begining.

Right.

> What do you think? any other good ideas?

Yes, I have an idea.  Pass an interface index (instead of a string) to
port_link_status(), and then you can remove the ugly code.

        if (cb)
                device = calloc(1, sizeof(MAX_IFNAME_SIZE + 1));
        else
                device = (char *)ctx;

Then you can also simplify this block

                        if (bond[IFLA_BOND_ACTIVE_SLAVE]) {
                                index = 
rta_getattr_u32(bond[IFLA_BOND_ACTIVE_SLAVE]);

                                if (!if_indextoname(index, device)) {
                                        pr_err("failed to get device name: %m");
                                        return -1;
                                }
                        }

by removing the if_indextoname() call.

Thanks,
Richard

------------------------------------------------------------------------------
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
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to