Now the ts interface will be either the active slave or the interface name, which is the exactly interface we need to get ts info.
If there is a fail over and ts_iface changed. We need to switch phc index and reset the port status. Signed-off-by: Hangbin Liu <liuhang...@gmail.com> --- clock.c | 14 ++++++++++---- config.c | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/clock.c b/clock.c index 67bdecb..582438c 100644 --- a/clock.c +++ b/clock.c @@ -341,11 +341,15 @@ static void clock_link_status(void *ctx, int index, int linkup, char *ts_iface) port_link_status_set(p, linkup); iface = port_interface_get(p); - if (ts_iface[0] != '\0' && strcmp(iface->ts_iface, ts_iface)) { + if (linkup && ts_iface[0] != '\0' && strcmp(iface->ts_iface, ts_iface)) { strncpy(iface->ts_iface, ts_iface, MAX_IFNAME_SIZE); - } - - if (linkup) { + sk_get_ts_info(iface->ts_iface, &iface->ts_info); + if (iface->ts_info.valid) { + port_set_phc(p, iface->ts_info.phc_index); + clock_switch_phc(c, iface->ts_info.phc_index); + port_dispatch(p, EV_INITIALIZE, 0); + } + } else if (linkup) { port_dispatch(p, EV_FAULT_CLEARED, 0); } else { port_dispatch(p, EV_FAULT_DETECTED, 0); @@ -991,6 +995,8 @@ struct clock *clock_create(enum clock_type type, struct config *config, break; } STAILQ_FOREACH(iface, &config->interfaces, list) { + rtnl_link_info(iface); + sk_get_ts_info(iface->ts_iface, &iface->ts_info); if (iface->ts_info.valid && ((iface->ts_info.so_timestamping & required_modes) != required_modes)) { pr_err("interface '%s' does not support " diff --git a/config.c b/config.c index e6fe676..bbaf36e 100644 --- a/config.c +++ b/config.c @@ -633,7 +633,6 @@ struct interface *config_create_interface(char *name, struct config *cfg) } strncpy(iface->name, name, MAX_IFNAME_SIZE); - sk_get_ts_info(iface->name, &iface->ts_info); STAILQ_INSERT_TAIL(&cfg->interfaces, iface, list); cfg->n_interfaces++; -- 2.5.5 ------------------------------------------------------------------------------ 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