Add interface element in struct port. And update ts iface info after device fail over.
Signed-off-by: Hangbin Liu <liuhang...@gmail.com> --- clock.c | 7 +++++++ port.c | 7 +++++++ port.h | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/clock.c b/clock.c index 5e9f2cd..67bdecb 100644 --- a/clock.c +++ b/clock.c @@ -331,6 +331,7 @@ static void clock_link_status(void *ctx, int index, int linkup, char *ts_iface) struct clock *c = ctx; struct port *p; char key[16]; + struct interface *iface; snprintf(key, sizeof(key), "%d", index); p = hash_lookup(c->index2port, key); @@ -338,6 +339,12 @@ static void clock_link_status(void *ctx, int index, int linkup, char *ts_iface) return; } port_link_status_set(p, linkup); + + iface = port_interface_get(p); + if (ts_iface[0] != '\0' && strcmp(iface->ts_iface, ts_iface)) { + strncpy(iface->ts_iface, ts_iface, MAX_IFNAME_SIZE); + } + if (linkup) { port_dispatch(p, EV_FAULT_CLEARED, 0); } else { diff --git a/port.c b/port.c index ec02825..b28849f 100644 --- a/port.c +++ b/port.c @@ -66,6 +66,7 @@ struct nrate_estimator { struct port { LIST_ENTRY(port) list; char *name; + struct interface *iface; struct clock *clock; struct transport *trp; enum timestamp_type timestamping; @@ -2378,6 +2379,11 @@ void port_link_status_set(struct port *p, int up) pr_notice("port %hu: link %s", portnum(p), up ? "up" : "down"); } +struct interface *port_interface_get(struct port *p) +{ + return p->iface; +} + int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg) { struct management_tlv *mgt; @@ -2586,6 +2592,7 @@ struct port *port_open(int phc_index, } p->name = interface->name; + p->iface = interface; p->asymmetry = config_get_int(cfg, p->name, "delayAsymmetry"); p->asymmetry <<= 16; p->announce_span = transport == TRANS_UDS ? 0 : ANNOUNCE_SPAN; diff --git a/port.h b/port.h index b00bc64..7f9be42 100644 --- a/port.h +++ b/port.h @@ -139,6 +139,13 @@ int port_link_status_get(struct port *p); void port_link_status_set(struct port *p, int up); /** + * Obtain the interface pointer of a port. + * @param p A port instance. + * @return Interface pointer of the port. + */ +struct interface *port_interface_get(struct port *p); + +/** * Manage a port according to a given message. * @param p A pointer previously obtained via port_open(). * @param ingress The port on which 'msg' was received. -- 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