Re: [Linuxptp-devel] [PATCHv2 4/9] rtnl: add function rtnl_link_info
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Richard C. <ric...@gm...> - 2017-08-09 06:49:45
|
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 |