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
------------------------------------------------------------------------------
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