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  |  3 +++
 config.c |  1 -
 port.c   | 10 ++++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/clock.c b/clock.c
index da15882..26cbd69 100644
--- a/clock.c
+++ b/clock.c
@@ -38,6 +38,7 @@
 #include "servo.h"
 #include "stats.h"
 #include "print.h"
+#include "rtnl.h"
 #include "tlv.h"
 #include "tsproc.h"
 #include "uds.h"
@@ -932,6 +933,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++;
 
diff --git a/port.c b/port.c
index 834eb45..98c76e7 100644
--- a/port.c
+++ b/port.c
@@ -2231,6 +2231,16 @@ static void port_link_status(void *ctx, int index, int 
linkup, char *ts_iface)
        p->link_status = linkup;
        pr_notice("port %hu: link %s", portnum(p), linkup ? "up" : "down");
 
+       /* ts_iface changed */
+       if (ts_iface[0] != '\0' && strcmp(p->iface->ts_iface, ts_iface)) {
+               strncpy(p->iface->ts_iface, ts_iface, MAX_IFNAME_SIZE);
+               sk_get_ts_info(p->iface->ts_iface, &p->iface->ts_info);
+               if (p->iface->ts_info.valid) {
+                       p->phc_index = p->iface->ts_info.phc_index;
+                       clock_switch_phc(p->clock, p->phc_index);
+               }
+       }
+
        /*
         * A port going down can affect the BMCA result.
         * Force a state decision event.
-- 
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

Reply via email to