I'm investigating why a port immediately enters a faulty state on
startup (and then self-recovers).

It looks like there might be some buggy rtnl logic.

In rtnl_link_status(), the following code is used to pass info to callers:

------
int slave_index = -1;
...
if (tb[IFLA_LINKINFO])
  slave_index = rtnl_linkinfo_parse(index, tb[IFLA_LINKINFO]);
...
cb(ctx, link_up, slave_index);
-----------

Note that if slave_index is not set, then it will default to -1.

The problem is that in the callback port_link_status(), the passed
index is used in to check if the ethernet label has changed:

----
void port_link_status(void *ctx, int linkup, int ts_index) {
if (if_indextoname(ts_index, ts_label) && strcmp(old_ts_label, ts_label))
  p->link_status |= TS_LABEL_CHANGED;
-----

The "weird" thing is that if_indextoname() succeeds even and returns
an empty string when -1 is passed, whereas it seems like it should
return NULLPTR. Still, we should be passing the regular if index.

The effect of this is that TS_LABEL_CHANGED is set immediately and
that causes the port to go into a FAULTY state.

I think the fix here is to set slave_index to index if IFLA_LINKINFO
is not set. That said, I'm not really familiar with RTNL logic so I'm
not sure what this all means or why that is not set in this case. The
kernel version is Debian 6.5.6-1.

-cliff


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to