Re: [Linuxptp-devel] [PATCHv5 08/12] ptp4l: use ts label to get ts info
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Richard C. <ric...@gm...> - 2017-10-09 11:40:06
|
On Sat, Sep 30, 2017 at 04:25:16PM +0800, Hangbin Liu wrote: > @@ -2231,6 +2232,8 @@ static void port_link_status(void *ctx, int linkup, int ts_index) > { > struct port *p = ctx; > int link_state; > + char ts_label[MAX_IFNAME_SIZE + 1]; We need char ts_label[MAX_IFNAME_SIZE + 1] = {0}; here because... > + int required_modes; > > link_state = linkup ? LINK_UP : LINK_DOWN; > if (p->link_status & link_state) { > @@ -2240,6 +2243,39 @@ static void port_link_status(void *ctx, int linkup, int ts_index) > pr_notice("port %hu: link %s", portnum(p), linkup ? "up" : "down"); > } > > + /* ts_label changed */ > + if (if_indextoname(ts_index, ts_label) && strcmp(p->iface->ts_label, ts_label)) { The man page for if_indextoname does not promise to terminate the string. (It may in fact terminate the string, but lets be defensive.) > + strncpy(p->iface->ts_label, ts_label, MAX_IFNAME_SIZE); > + p->link_status |= TS_LABEL_CHANGED; > + pr_notice("port %hu: ts label changed to %s", portnum(p), ts_label); > + } Thanks, Richard |