Skip to content

Commit

Permalink
ptp4l: init iface->ts_label when interface created
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
liuhangbin authored and richardcochran committed Jul 24, 2022
1 parent e8dc364 commit 55722bc
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 20 deletions.
5 changes: 2 additions & 3 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
8 changes: 1 addition & 7 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions nsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pmc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 55722bc

Please sign in to comment.