diff --git a/clock.c b/clock.c index f808b351..7be021f9 100644 --- a/clock.c +++ b/clock.c @@ -1002,9 +1002,8 @@ struct clock *clock_create(enum clock_type type, struct config *config, required_modes = clock_required_modes(c); STAILQ_FOREACH(iface, &config->interfaces, list) { memset(ts_label, 0, sizeof(ts_label)); - rtnl_get_ts_device(interface_name(iface), ts_label); - interface_set_label(iface, ts_label); - interface_ensure_tslabel(iface); + if (!rtnl_get_ts_device(interface_name(iface), ts_label)) + interface_set_label(iface, ts_label); interface_get_tsinfo(iface); if (interface_tsinfo_valid(iface) && !interface_tsmodes_supported(iface, required_modes)) { diff --git a/interface.c b/interface.c index 445a2708..6c2630c5 100644 --- a/interface.c +++ b/interface.c @@ -24,6 +24,7 @@ struct interface *interface_create(const char *name) return NULL; } strncpy(iface->name, name, MAX_IFNAME_SIZE); + strncpy(iface->ts_label, name, MAX_IFNAME_SIZE); iface->vclock = -1; return iface; @@ -34,13 +35,6 @@ void interface_destroy(struct interface *iface) free(iface); } -void interface_ensure_tslabel(struct interface *iface) -{ - if (!iface->ts_label[0]) { - memcpy(iface->ts_label, iface->name, MAX_IFNAME_SIZE); - } -} - int interface_get_tsinfo(struct interface *iface) { return sk_get_ts_info(iface->ts_label, &iface->ts_info); diff --git a/interface.h b/interface.h index 752f4f14..5fc78362 100644 --- a/interface.h +++ b/interface.h @@ -33,12 +33,6 @@ struct interface *interface_create(const char *name); */ void interface_destroy(struct interface *iface); -/** - * Ensures that an interface has a proper time stamping label. - * @param iface The interface of interest. - */ -void interface_ensure_tslabel(struct interface *iface); - /** * Populate the time stamping information of a given interface. * @param iface The interface of interest. diff --git a/nsm.c b/nsm.c index 5aa925bf..8d4a362b 100644 --- a/nsm.c +++ b/nsm.c @@ -274,9 +274,8 @@ static int nsm_open(struct nsm *nsm, struct config *cfg) STAILQ_FOREACH(iface, &cfg->interfaces, list) { ifname = interface_name(iface); memset(ts_label, 0, sizeof(ts_label)); - rtnl_get_ts_device(ifname, ts_label); - interface_set_label(iface, ts_label); - interface_ensure_tslabel(iface); + if (!rtnl_get_ts_device(ifname, ts_label)) + interface_set_label(iface, ts_label); count++; } if (count != 1) { diff --git a/pmc_common.c b/pmc_common.c index 43ad22c2..1dd89f6a 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -435,7 +435,6 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type, pr_err("failed to create interface"); goto failed; } - interface_ensure_tslabel(pmc->iface); if (transport_open(pmc->transport, pmc->iface, &pmc->fdarray, TS_SOFTWARE)) {