Skip to content

Commit

Permalink
Merge branch 'v3_8'
Browse files Browse the repository at this point in the history
  • Loading branch information
abower-amd committed Feb 9, 2025
2 parents 4df2fee + faa8630 commit 41657da
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 37 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- This option requires a calibration step that may take a few seconds.
- Add hardware clock control and diagnostic utility `tstool`.

## [3.8.1.x] - Unreleased
## [3.8.1.1003] - 2025-02-14

### Added

Expand All @@ -44,8 +44,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- chrony: use smoothed offset from chrony not last NTP sample
- Issue SWPTP-1531
- freerun: fix resolution of bond when VLAN specified
- Issue SWPTP-1559
- Avoid double UTC compensation for looped-back Tx software timestamps
- Issue SWPTP-1560
- Fix potential buffer overflow reading long PPS device 'names' from sysfs
- Issue SWPTP-1561
- Avoid bailing out if diagnostic copy of log file cannot be written out
- Xilinx-CNS/sfptpd#17
- avoid crash if a clock step occurs when a NIC has gone away
- Avoid crash if a clock step occurs when a NIC has gone away

## [3.8.0.1005] - 2024-10-10 [Feature Release]

Expand Down
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AMD Solarflare Enhanced PTP Daemon
==================================

Version: v3.8.1.1002
Version: v3.8.1.1003

These release notes relate to official supported binary releases of sfptpd.
Please see [the changelog](CHANGELOG.md) for a list of changes since earlier
Expand Down
40 changes: 20 additions & 20 deletions src/ptp/ptpd2/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,26 @@ processPortMessage(RunTimeOpts *rtOpts, PtpClock *ptpClock,
because there are now guards on the unpacking functions. */
}

/*Spec 9.5.2.2*/
isFromSelf = (ptpClock->portIdentity.portNumber == ptpInterface->msgTmpHeader.sourcePortIdentity.portNumber
&& !memcmp(ptpInterface->msgTmpHeader.sourcePortIdentity.clockIdentity, ptpClock->portIdentity.clockIdentity, CLOCK_IDENTITY_LENGTH));

if (isFromSelf && timestampValid &&
ptpInterface->tsMethod == TS_METHOD_SYSTEM) {
struct sfptpd_ts_ticket ticket;
struct sfptpd_ts_user user;

ticket = netMatchPacketToTsCache(&ptpInterface->ts_cache,
&user,
ptpInterface->msgIbuf, length);
processTxTimestamp(ptpInterface, user, ticket, *timestamp);
}

if (isFromSelf) {
/* Looped-back packets need no further processing */
return;
}

/*
* Make sure we use the TAI to UTC offset specified if the master is
* sending the UTC_VALID bit.
Expand All @@ -1140,26 +1160,6 @@ processPortMessage(RunTimeOpts *rtOpts, PtpClock *ptpClock,
if (timestampValid)
applyUtcOffset(timestamp, rtOpts, ptpClock);

/*Spec 9.5.2.2*/
isFromSelf = (ptpClock->portIdentity.portNumber == ptpInterface->msgTmpHeader.sourcePortIdentity.portNumber
&& !memcmp(ptpInterface->msgTmpHeader.sourcePortIdentity.clockIdentity, ptpClock->portIdentity.clockIdentity, CLOCK_IDENTITY_LENGTH));

if (isFromSelf && timestampValid &&
ptpInterface->tsMethod == TS_METHOD_SYSTEM) {
struct sfptpd_ts_ticket ticket;
struct sfptpd_ts_user user;

ticket = netMatchPacketToTsCache(&ptpInterface->ts_cache,
&user,
ptpInterface->msgIbuf, length);
processTxTimestamp(ptpInterface, user, ticket, *timestamp);
}

if (isFromSelf) {
/* Looped-back packets need no further processing */
return;
}

/* subtract the inbound latency adjustment */
if (timestampValid && timestamp->sec > 0)
sfptpd_time_subtract(timestamp, timestamp, &rtOpts->inboundLatency);
Expand Down
20 changes: 14 additions & 6 deletions src/sfptpd_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static char state_file_format[PATH_MAX];
static char state_next_file_format[PATH_MAX];
static char sfptpd_config_log_tmpfile[] = "/tmp/sfptpd.conf.lexed.XXXXXX";
static FILE *config_log_tmp = NULL;
static bool config_log_attempted = false;

/* JSON stats is block-buffered and we ensure lines get written whole. */
static FILE *json_stats_fp = NULL;
Expand Down Expand Up @@ -1129,21 +1130,28 @@ void sfptpd_log_format_time(struct sfptpd_log_time *time,

void sfptpd_log_lexed_config(const char *format, ...)
{
const char *error="could not record config copy, %s\n";
va_list ap;

assert(format != NULL);

va_start(ap, format);

if (!config_log_tmp) {
if (!config_log_tmp && !config_log_attempted) {
int log_fd = mkstemp(sfptpd_config_log_tmpfile);
assert(log_fd != -1);

config_log_tmp = fdopen(log_fd, "w");
assert(config_log_tmp);
if (log_fd == -1) {
WARNING(error, strerror(errno));
} else {
config_log_tmp = fdopen(log_fd, "w");
if (config_log_tmp == NULL) {
ERROR(error, strerror(errno));
}
}
config_log_attempted = true;
}

vfprintf(config_log_tmp, format, ap);
if (config_log_tmp)
vfprintf(config_log_tmp, format, ap);

va_end(ap);
}
Expand Down
29 changes: 21 additions & 8 deletions src/sfptpd_phc.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,12 @@ static int phc_configure_pps(struct sfptpd_phc *phc)

assert(phc != NULL);

snprintf(phc_name, sizeof(phc_name), SFPTPD_PHC_NAME_FORMAT,
phc->phc_idx);
rc = snprintf(phc_name, sizeof(phc_name), SFPTPD_PHC_NAME_FORMAT,
phc->phc_idx);
if (rc >= sizeof phc_name)
return ENAMETOOLONG;
else if (rc < 0)
return errno;

/* Search through the PPS devices looking for the one associated with
* this PHC device. */
Expand Down Expand Up @@ -325,7 +329,7 @@ static int phc_configure_pps(struct sfptpd_phc *phc)
if (file == NULL) {
TRACE_L3("phc: couldn't open %s\n", path);
} else {
tokens = fscanf(file, "%16s", candidate_name);
tokens = fscanf(file, "%15s", candidate_name);
(void)fclose(file);

if ((tokens == 1) && (strcmp(candidate_name, phc_name) == 0)) {
Expand Down Expand Up @@ -409,10 +413,19 @@ static int phc_discover_devpps(struct sfptpd_phc *phc,

assert(phc != NULL);

snprintf(phc_name, sizeof(phc_name), SFPTPD_PHC_NAME_FORMAT,
phc->phc_idx);
snprintf(phc_extname, sizeof(phc_extname), SFPTPD_PHC_EXT_NAME_FORMAT,
phc->phc_idx);
rc = snprintf(phc_name, sizeof(phc_name), SFPTPD_PHC_NAME_FORMAT,
phc->phc_idx);
if (rc >= sizeof phc_name)
return ENAMETOOLONG;
else if (rc < 0)
return errno;

rc = snprintf(phc_extname, sizeof(phc_extname), SFPTPD_PHC_EXT_NAME_FORMAT,
phc->phc_idx);
if (rc >= sizeof phc_extname)
return ENAMETOOLONG;
else if (rc < 0)
return errno;

/* Search through the PPS devices looking for the one associated with
* this PHC device. */
Expand Down Expand Up @@ -451,7 +464,7 @@ static int phc_discover_devpps(struct sfptpd_phc *phc,
if (state == STATE_FOUND_INTPPS)
state = STATE_NOTFOUND;
} else {
tokens = fscanf(file, "%16s", candidate_name);
tokens = fscanf(file, "%15s", candidate_name);
(void)fclose(file);

if ((tokens == 1)) {
Expand Down

0 comments on commit 41657da

Please sign in to comment.