It's redundant to ensure tslabel if we could get ts_info directly from
the interface. By init iface->ts_label when interface created, there is
no need to take care of ts_label on other places.

It will also make the later vlan over bonding support patch more clear
after removing function interface_ensure_tslabel().

Signed-off-by: Hangbin Liu <liuhang...@gmail.com>
---
v6-v7: no update
v5: update commit description
v2-v4: no update
---
 clock.c      | 5 ++---
 interface.c  | 8 +-------
 interface.h  | 6 ------
 nsm.c        | 5 ++---
 pmc_common.c | 1 -
 5 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/clock.c b/clock.c
index f808b35..7be021f 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 445a270..6c2630c 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 752f4f1..5fc7836 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 5aa925b..8d4a362 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 43ad22c..1dd89f6 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)) {
-- 
2.35.1



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

Reply via email to