63489c
commit 4e8dbd84925d36f1193a7339a542677d884d3ba1
63489c
Author: Richard Cochran <richardcochran@gmail.com>
63489c
Date:   Tue Dec 6 19:40:36 2016 +0100
63489c
63489c
    ptp4l: Accept any configuration option as a command line argument.
63489c
    
63489c
    This patch provides a way to use the entire table of configuration options
63489c
    as "long" command line switches.
63489c
    
63489c
    Signed-off-by: Richard Cochran <richardcochran@gmail.com>
63489c
63489c
diff --git a/config.c b/config.c
63489c
index 5da5ecc..384b437 100644
63489c
--- a/config.c
63489c
+++ b/config.c
63489c
@@ -329,6 +329,7 @@ static enum parser_result parse_section_line(char *s, enum config_section *secti
63489c
 }
63489c
 
63489c
 static enum parser_result parse_item(struct config *cfg,
63489c
+				     int commandline,
63489c
 				     const char *section,
63489c
 				     const char *option,
63489c
 				     const char *value)
63489c
@@ -387,7 +388,7 @@ static enum parser_result parse_item(struct config *cfg,
63489c
 				return NOT_PARSED;
63489c
 			}
63489c
 		}
63489c
-	} else if (cgi->flags & CFG_ITEM_LOCKED) {
63489c
+	} else if (!commandline && cgi->flags & CFG_ITEM_LOCKED) {
63489c
 		/* This global option was set on the command line. */
63489c
 		return PARSED_OK;
63489c
 	} else {
63489c
@@ -415,6 +416,10 @@ static enum parser_result parse_item(struct config *cfg,
63489c
 		dst->flags |= CFG_ITEM_DYNSTR;
63489c
 		break;
63489c
 	}
63489c
+
63489c
+	if (commandline) {
63489c
+		dst->flags &= CFG_ITEM_LOCKED;
63489c
+	}
63489c
 	return PARSED_OK;
63489c
 }
63489c
 
63489c
@@ -490,6 +495,25 @@ static void check_deprecated_options(const char **option)
63489c
 	}
63489c
 }
63489c
 
63489c
+static struct option *config_alloc_longopts(struct config *cfg)
63489c
+{
63489c
+	struct config_item *ci;
63489c
+	struct option *opts;
63489c
+	int i;
63489c
+
63489c
+	opts = calloc(1, (1 + N_CONFIG_ITEMS) * sizeof(*opts));
63489c
+	if (!opts) {
63489c
+		return NULL;
63489c
+	}
63489c
+	for (i = 0; i < N_CONFIG_ITEMS; i++) {
63489c
+		ci = &config_tab[i];
63489c
+		opts[i].name = ci->label;
63489c
+		opts[i].has_arg = required_argument;
63489c
+	}
63489c
+
63489c
+	return opts;
63489c
+}
63489c
+
63489c
 int config_read(char *name, struct config *cfg)
63489c
 {
63489c
 	enum config_section current_section = UNKNOWN_SECTION;
63489c
@@ -554,7 +578,7 @@ int config_read(char *name, struct config *cfg)
63489c
 
63489c
 		check_deprecated_options(&option);
63489c
 
63489c
-		parser_res = parse_item(cfg, current_section == GLOBAL_SECTION ?
63489c
+		parser_res = parse_item(cfg, 0, current_section == GLOBAL_SECTION ?
63489c
 					NULL : current_port->name, option, value);
63489c
 
63489c
 		switch (parser_res) {
63489c
@@ -627,8 +651,15 @@ struct config *config_create(void)
63489c
 	}
63489c
 	STAILQ_INIT(&cfg->interfaces);
63489c
 
63489c
+	cfg->opts = config_alloc_longopts(cfg);
63489c
+	if (!cfg->opts) {
63489c
+		free(cfg);
63489c
+		return NULL;
63489c
+	}
63489c
+
63489c
 	cfg->htab = hash_create();
63489c
 	if (!cfg->htab) {
63489c
+		free(cfg->opts);
63489c
 		free(cfg);
63489c
 		return NULL;
63489c
 	}
63489c
@@ -657,6 +688,7 @@ struct config *config_create(void)
63489c
 	return cfg;
63489c
 fail:
63489c
 	hash_destroy(cfg->htab, NULL);
63489c
+	free(cfg->opts);
63489c
 	free(cfg);
63489c
 	return NULL;
63489c
 }
63489c
@@ -670,6 +702,7 @@ void config_destroy(struct config *cfg)
63489c
 		free(iface);
63489c
 	}
63489c
 	hash_destroy(cfg->htab, config_item_free);
63489c
+	free(cfg->opts);
63489c
 	free(cfg);
63489c
 }
63489c
 
63489c
@@ -720,6 +753,33 @@ char *config_get_string(struct config *cfg, const char *section,
63489c
 	return ci->val.s;
63489c
 }
63489c
 
63489c
+int config_parse_option(struct config *cfg, const char *opt, const char *val)
63489c
+{
63489c
+	enum parser_result result;
63489c
+
63489c
+	result = parse_item(cfg, 1, NULL, opt, val);
63489c
+
63489c
+	switch (result) {
63489c
+	case PARSED_OK:
63489c
+		return 0;
63489c
+	case NOT_PARSED:
63489c
+		fprintf(stderr, "unknown option %s\n", opt);
63489c
+		break;
63489c
+	case BAD_VALUE:
63489c
+		fprintf(stderr, "%s is a bad value for option %s\n", val, opt);
63489c
+		break;
63489c
+	case MALFORMED:
63489c
+		fprintf(stderr, "%s is a malformed value for option %s\n",
63489c
+			val, opt);
63489c
+		break;
63489c
+	case OUT_OF_RANGE:
63489c
+		fprintf(stderr, "%s is an out of range value for option %s\n",
63489c
+			val, opt);
63489c
+		break;
63489c
+	}
63489c
+	return -1;
63489c
+}
63489c
+
63489c
 int config_set_double(struct config *cfg, const char *option, double val)
63489c
 {
63489c
 	struct config_item *ci = config_find_item(cfg, NULL, option);
63489c
diff --git a/config.h b/config.h
63489c
index b02bde6..1cc7051 100644
63489c
--- a/config.h
63489c
+++ b/config.h
63489c
@@ -20,6 +20,7 @@
63489c
 #ifndef HAVE_CONFIG_H
63489c
 #define HAVE_CONFIG_H
63489c
 
63489c
+#include <getopt.h>
63489c
 #include <sys/queue.h>
63489c
 
63489c
 #include "ds.h"
63489c
@@ -43,6 +44,9 @@ struct config {
63489c
 	STAILQ_HEAD(interfaces_head, interface) interfaces;
63489c
 	int n_interfaces;
63489c
 
63489c
+	/* for parsing command line options */
63489c
+	struct option *opts;
63489c
+
63489c
 	/* hash of all non-legacy items */
63489c
 	struct hash *htab;
63489c
 };
63489c
@@ -64,6 +68,13 @@ int config_get_int(struct config *cfg, const char *section,
63489c
 char *config_get_string(struct config *cfg, const char *section,
63489c
 			const char *option);
63489c
 
63489c
+static inline struct option *config_long_options(struct config *cfg)
63489c
+{
63489c
+	return cfg->opts;
63489c
+}
63489c
+
63489c
+int config_parse_option(struct config *cfg, const char *opt, const char *val);
63489c
+
63489c
 int config_set_double(struct config *cfg, const char *option, double val);
63489c
 
63489c
 int config_set_section_int(struct config *cfg, const char *section,
63489c
diff --git a/ptp4l.c b/ptp4l.c
63489c
index a87e7e6..e90fcb2 100644
63489c
--- a/ptp4l.c
63489c
+++ b/ptp4l.c
63489c
@@ -73,8 +73,9 @@ static void usage(char *progname)
63489c
 int main(int argc, char *argv[])
63489c
 {
63489c
 	char *config = NULL, *req_phc = NULL, *progname;
63489c
-	int c, err = -1, print_level;
63489c
+	int c, err = -1, index, print_level;
63489c
 	struct clock *clock = NULL;
63489c
+	struct option *opts;
63489c
 	struct config *cfg;
63489c
 
63489c
 	if (handle_term_signals())
63489c
@@ -84,12 +85,18 @@ int main(int argc, char *argv[])
63489c
 	if (!cfg) {
63489c
 		return -1;
63489c
 	}
63489c
+	opts = config_long_options(cfg);
63489c
 
63489c
 	/* Process the command line arguments. */
63489c
 	progname = strrchr(argv[0], '/');
63489c
 	progname = progname ? 1+progname : argv[0];
63489c
-	while (EOF != (c = getopt(argc, argv, "AEP246HSLf:i:p:sl:mqvh"))) {
63489c
+	while (EOF != (c = getopt_long(argc, argv, "AEP246HSLf:i:p:sl:mqvh",
63489c
+				       opts, &index))) {
63489c
 		switch (c) {
63489c
+		case 0:
63489c
+			if (config_parse_option(cfg, opts[index].name, optarg))
63489c
+				goto out;
63489c
+			break;
63489c
 		case 'A':
63489c
 			if (config_set_int(cfg, "delay_mechanism", DM_AUTO))
63489c
 				goto out;
63489c
63489c
commit e658982624bfd5cd998066fdf35b93cdcf8797ca
63489c
Author: Richard Cochran <rcochran@linutronix.de>
63489c
Date:   Tue Dec 13 19:55:39 2016 +0100
63489c
63489c
    config: Fix bitwise copy-and-pasto for command line items.
63489c
    
63489c
    The recent change allowing every configuration option to appear on the
63489c
    command line wrongly used bitwise AND to set a flag.  This patch fixes
63489c
    the bug by using the proper bitwise OR idiom.
63489c
    
63489c
    Signed-off-by: Richard Cochran <rcochran@linutronix.de>
63489c
    Reported-by: Miroslav Lichvar <mlichvar@redhat.com>
63489c
    Fixes: 4e8dbd8 ("ptp4l: Accept any configuration option as a command line argument.")
63489c
63489c
diff --git a/config.c b/config.c
63489c
index 384b437..b19f3ad 100644
63489c
--- a/config.c
63489c
+++ b/config.c
63489c
@@ -418,7 +418,7 @@ static enum parser_result parse_item(struct config *cfg,
63489c
 	}
63489c
 
63489c
 	if (commandline) {
63489c
-		dst->flags &= CFG_ITEM_LOCKED;
63489c
+		dst->flags |= CFG_ITEM_LOCKED;
63489c
 	}
63489c
 	return PARSED_OK;
63489c
 }
63489c
63489c
commit 4e966536c6253d73e1a3202e8b562ab0f518e33b
63489c
Author: Richard Cochran <rcochran@linutronix.de>
63489c
Date:   Tue Dec 13 20:49:22 2016 +0100
63489c
63489c
    ptp4l: Document the "long" command line options in the man page.
63489c
    
63489c
    Signed-off-by: Richard Cochran <rcochran@linutronix.de>
63489c
63489c
diff --git a/ptp4l.8 b/ptp4l.8
63489c
index 63e9abd..f53fc6e 100644
63489c
--- a/ptp4l.8
63489c
+++ b/ptp4l.8
63489c
@@ -1,4 +1,4 @@
63489c
-.TH PTP4l 8 "July 2016" "linuxptp"
63489c
+.TH PTP4l 8 "December 2016" "linuxptp"
63489c
 .SH NAME
63489c
 ptp4l - PTP Boundary/Ordinary Clock
63489c
 
63489c
@@ -15,6 +15,8 @@ ptp4l - PTP Boundary/Ordinary Clock
63489c
 ]
63489c
 [
63489c
 .BI \-i " interface"
63489c
+] [
63489c
+.I long-options
63489c
 ]
63489c
 .I .\|.\|.
63489c
 
63489c
@@ -94,6 +96,19 @@ Prints the software version and exits.
63489c
 .BI \-h
63489c
 Display a help message.
63489c
 
63489c
+.SH LONG OPTIONS
63489c
+
63489c
+Each and every configuration file option (see below) may also appear
63489c
+as a "long" style command line argument.  For example, the slaveOnly
63489c
+option may be set using either of these two forms.
63489c
+
63489c
+.RS
63489c
+\f(CW\-\-slaveOnly 1   \-\-slaveOnly=1\fP
63489c
+.RE
63489c
+
63489c
+Option values given on the command line override values in the global
63489c
+section of the configuration file.
63489c
+
63489c
 .SH CONFIGURATION FILE
63489c
 
63489c
 The configuration file is divided into sections. Each section starts with a
63489c
63489c
commit 0f6c6972c791813e0b9618e9158da3951a099737
63489c
Author: Miroslav Lichvar <mlichvar@redhat.com>
63489c
Date:   Tue Jan 17 14:17:39 2017 +0100
63489c
63489c
    Add options to tag ptp4l and phc2sys log messages.
63489c
    
63489c
    When running multiple instances of ptp4l or phc2sys, it's difficult to
63489c
    tell which log message belongs to which instance. Add new options to
63489c
    ptp4l and phc2sys which can specify a tag for all messages printed to
63489c
    the standard output or system log, so messages from different instances
63489c
    can have different tags.
63489c
    
63489c
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
63489c
63489c
diff --git a/config.c b/config.c
63489c
index 7bb949d..e6fe676 100644
63489c
--- a/config.c
63489c
+++ b/config.c
63489c
@@ -199,6 +199,7 @@ struct config_item config_tab[] = {
63489c
 	PORT_ITEM_INT("logMinPdelayReqInterval", 0, INT8_MIN, INT8_MAX),
63489c
 	PORT_ITEM_INT("logSyncInterval", 0, INT8_MIN, INT8_MAX),
63489c
 	GLOB_ITEM_INT("logging_level", LOG_INFO, PRINT_LEVEL_MIN, PRINT_LEVEL_MAX),
63489c
+	GLOB_ITEM_STR("message_tag", NULL),
63489c
 	GLOB_ITEM_STR("manufacturerIdentity", "00:00:00"),
63489c
 	GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX),
63489c
 	PORT_ITEM_INT("min_neighbor_prop_delay", -20000000, INT_MIN, -1),
63489c
diff --git a/phc2sys.8 b/phc2sys.8
63489c
index 22d02c2..2559c74 100644
63489c
--- a/phc2sys.8
63489c
+++ b/phc2sys.8
63489c
@@ -206,6 +206,10 @@ The default is /var/run/ptp4l.
63489c
 Set the maximum syslog level of messages which should be printed or sent to
63489c
 the system logger. The default is 6 (LOG_INFO).
63489c
 .TP
63489c
+.BI \-t " message-tag"
63489c
+Specify the tag which is added to all messages printed to the standard output
63489c
+or system log. The default is an empty string.
63489c
+.TP
63489c
 .B \-m
63489c
 Print messages to the standard output.
63489c
 .TP
63489c
diff --git a/phc2sys.c b/phc2sys.c
63489c
index 35cf6fa..aa4186b 100644
63489c
--- a/phc2sys.c
63489c
+++ b/phc2sys.c
63489c
@@ -1209,6 +1209,7 @@ static void usage(char *progname)
63489c
 		" -x             apply leap seconds by servo instead of kernel\n"
63489c
 		" -z [path]      server address for UDS (/var/run/ptp4l)\n"
63489c
 		" -l [num]       set the logging level to 'num' (6)\n"
63489c
+		" -t [tag]       add tag to log messages\n"
63489c
 		" -m             print messages to stdout\n"
63489c
 		" -q             do not print messages to the syslog\n"
63489c
 		" -v             prints the software version and exits\n"
63489c
@@ -1219,7 +1220,7 @@ static void usage(char *progname)
63489c
 
63489c
 int main(int argc, char *argv[])
63489c
 {
63489c
-	char *progname;
63489c
+	char *progname, *message_tag = NULL;
63489c
 	char *src_name = NULL, *dst_name = NULL;
63489c
 	struct clock *src, *dst;
63489c
 	struct config *cfg;
63489c
@@ -1251,7 +1252,7 @@ int main(int argc, char *argv[])
63489c
 	progname = strrchr(argv[0], '/');
63489c
 	progname = progname ? 1+progname : argv[0];
63489c
 	while (EOF != (c = getopt(argc, argv,
63489c
-				  "arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:mqvh"))) {
63489c
+				  "arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
63489c
 		switch (c) {
63489c
 		case 'a':
63489c
 			autocfg = 1;
63489c
@@ -1363,6 +1364,9 @@ int main(int argc, char *argv[])
63489c
 					  PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))
63489c
 				goto end;
63489c
 			break;
63489c
+		case 't':
63489c
+			message_tag = optarg;
63489c
+			break;
63489c
 		case 'm':
63489c
 			verbose = 1;
63489c
 			break;
63489c
@@ -1405,6 +1409,7 @@ int main(int argc, char *argv[])
63489c
 	}
63489c
 
63489c
 	print_set_progname(progname);
63489c
+	print_set_tag(message_tag);
63489c
 	print_set_verbose(verbose);
63489c
 	print_set_syslog(use_syslog);
63489c
 	print_set_level(print_level);
63489c
diff --git a/print.c b/print.c
63489c
index a82d0e7..6c48e1e 100644
63489c
--- a/print.c
63489c
+++ b/print.c
63489c
@@ -28,12 +28,18 @@ static int verbose = 0;
63489c
 static int print_level = LOG_INFO;
63489c
 static int use_syslog = 1;
63489c
 static const char *progname;
63489c
+static const char *message_tag;
63489c
 
63489c
 void print_set_progname(const char *name)
63489c
 {
63489c
 	progname = name;
63489c
 }
63489c
 
63489c
+void print_set_tag(const char *tag)
63489c
+{
63489c
+	message_tag = tag;
63489c
+}
63489c
+
63489c
 void print_set_syslog(int value)
63489c
 {
63489c
 	use_syslog = value ? 1 : 0;
63489c
@@ -67,13 +73,17 @@ void print(int level, char const *format, ...)
63489c
 
63489c
 	if (verbose) {
63489c
 		f = level >= LOG_NOTICE ? stdout : stderr;
63489c
-		fprintf(f, "%s[%ld.%03ld]: %s\n",
63489c
+		fprintf(f, "%s[%ld.%03ld]: %s%s%s\n",
63489c
 			progname ? progname : "",
63489c
-			ts.tv_sec, ts.tv_nsec / 1000000, buf);
63489c
+			ts.tv_sec, ts.tv_nsec / 1000000,
63489c
+			message_tag ? message_tag : "", message_tag ? " " : "",
63489c
+			buf);
63489c
 		fflush(f);
63489c
 	}
63489c
 	if (use_syslog) {
63489c
-		syslog(level, "[%ld.%03ld] %s",
63489c
-		       ts.tv_sec, ts.tv_nsec / 1000000, buf);
63489c
+		syslog(level, "[%ld.%03ld] %s%s%s",
63489c
+		       ts.tv_sec, ts.tv_nsec / 1000000,
63489c
+		       message_tag ? message_tag : "", message_tag ? " " : "",
63489c
+		       buf);
63489c
 	}
63489c
 }
63489c
diff --git a/print.h b/print.h
63489c
index e8f2c8e..1723d8a 100644
63489c
--- a/print.h
63489c
+++ b/print.h
63489c
@@ -33,6 +33,7 @@ __attribute__ ((format (printf, 2, 3)))
63489c
 void print(int level, char const *format, ...);
63489c
 
63489c
 void print_set_progname(const char *name);
63489c
+void print_set_tag(const char *tag);
63489c
 void print_set_syslog(int value);
63489c
 void print_set_level(int level);
63489c
 void print_set_verbose(int value);
63489c
diff --git a/ptp4l.8 b/ptp4l.8
63489c
index 53d5f28..a724151 100644
63489c
--- a/ptp4l.8
63489c
+++ b/ptp4l.8
63489c
@@ -485,6 +485,12 @@ is 0.
63489c
 The maximum logging level of messages which should be printed.
63489c
 The default is 6 (LOG_INFO).
63489c
 .TP
63489c
+.B message_tag
63489c
+The tag which is added to all messages printed to the standard output or system
63489c
+log.
63489c
+The default is an empty string (which cannot be set in the configuration file
63489c
+as the option requires an argument).
63489c
+.TP
63489c
 .B verbose
63489c
 Print messages to the standard output if enabled.
63489c
 The default is 0 (disabled).
63489c
diff --git a/ptp4l.c b/ptp4l.c
63489c
index e90fcb2..f01ff6f 100644
63489c
--- a/ptp4l.c
63489c
+++ b/ptp4l.c
63489c
@@ -183,6 +183,7 @@ int main(int argc, char *argv[])
63489c
 	}
63489c
 
63489c
 	print_set_progname(progname);
63489c
+	print_set_tag(config_get_string(cfg, NULL, "message_tag"));
63489c
 	print_set_verbose(config_get_int(cfg, NULL, "verbose"));
63489c
 	print_set_syslog(config_get_int(cfg, NULL, "use_syslog"));
63489c
 	print_set_level(config_get_int(cfg, NULL, "logging_level"));
63489c
63489c
commit e54158195b1eadfdb6275646bc3dfb7611dba5b6
63489c
Author: Miroslav Lichvar <mlichvar@redhat.com>
63489c
Date:   Tue Jan 17 14:17:40 2017 +0100
63489c
63489c
    timemaster: tag ptp4l and phc2sys messages.
63489c
    
63489c
    Use the new options of ptp4l and phc2sys to tag their log messages with
63489c
    the PTP domain number and name(s) of interface(s) in the domain.
63489c
    
63489c
    Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
63489c
63489c
diff --git a/timemaster.c b/timemaster.c
63489c
index 66ac521..880b2ab 100644
63489c
--- a/timemaster.c
63489c
+++ b/timemaster.c
63489c
@@ -599,7 +599,8 @@ static char **get_ptp4l_command(struct program_config *config,
63489c
 }
63489c
 
63489c
 static char **get_phc2sys_command(struct program_config *config, int domain,
63489c
-				  int poll, int shm_segment, char *uds_path)
63489c
+				  int poll, int shm_segment, char *uds_path,
63489c
+				  char *message_tag)
63489c
 {
63489c
 	char **command = (char **)parray_new();
63489c
 
63489c
@@ -610,6 +611,7 @@ static char **get_phc2sys_command(struct program_config *config, int domain,
63489c
 		      xstrdup("-R"), string_newf("%.2f", poll > 0 ?
63489c
 						1.0 / (1 << poll) : 1 << -poll),
63489c
 		      xstrdup("-z"), xstrdup(uds_path),
63489c
+		      xstrdup("-t"), xstrdup(message_tag),
63489c
 		      xstrdup("-n"), string_newf("%d", domain),
63489c
 		      xstrdup("-E"), xstrdup("ntpshm"),
63489c
 		      xstrdup("-M"), string_newf("%d", shm_segment), NULL);
63489c
@@ -671,7 +673,7 @@ static int add_ptp_source(struct ptp_domain *source,
63489c
 			  struct script *script)
63489c
 {
63489c
 	struct config_file *config_file;
63489c
-	char **command, *uds_path, **interfaces;
63489c
+	char **command, *uds_path, **interfaces, *message_tag;
63489c
 	int i, j, num_interfaces, *phc, *phcs, hw_ts;
63489c
 	struct sk_ts_info ts_info;
63489c
 
63489c
@@ -749,6 +751,12 @@ static int add_ptp_source(struct ptp_domain *source,
63489c
 		uds_path = string_newf("%s/ptp4l.%d.socket",
63489c
 				       config->rundir, *shm_segment);
63489c
 
63489c
+		message_tag = string_newf("[%d", source->domain);
63489c
+		for (j = 0; interfaces[j]; j++)
63489c
+			string_appendf(&message_tag, "%s%s", j ? "+" : ":",
63489c
+				       interfaces[j]);
63489c
+		string_appendf(&message_tag, "]");
63489c
+
63489c
 		config_file = xmalloc(sizeof(*config_file));
63489c
 		config_file->path = string_newf("%s/ptp4l.%d.conf",
63489c
 						config->rundir, *shm_segment);
63489c
@@ -760,8 +768,9 @@ static int add_ptp_source(struct ptp_domain *source,
63489c
 		string_appendf(&config_file->content,
63489c
 			       "slaveOnly 1\n"
63489c
 			       "domainNumber %d\n"
63489c
-			       "uds_address %s\n",
63489c
-			       source->domain, uds_path);
63489c
+			       "uds_address %s\n"
63489c
+			       "message_tag %s\n",
63489c
+			       source->domain, uds_path, message_tag);
63489c
 
63489c
 		if (phcs[i] >= 0) {
63489c
 			/* HW time stamping */
63489c
@@ -772,7 +781,8 @@ static int add_ptp_source(struct ptp_domain *source,
63489c
 			command = get_phc2sys_command(&config->phc2sys,
63489c
 						      source->domain,
63489c
 						      source->phc2sys_poll,
63489c
-						      *shm_segment, uds_path);
63489c
+						      *shm_segment, uds_path,
63489c
+						      message_tag);
63489c
 			parray_append((void ***)&script->commands, command);
63489c
 		} else {
63489c
 			/* SW time stamping */
63489c
@@ -793,6 +803,7 @@ static int add_ptp_source(struct ptp_domain *source,
63489c
 
63489c
 		(*shm_segment)++;
63489c
 
63489c
+		free(message_tag);
63489c
 		free(uds_path);
63489c
 		free(interfaces);
63489c
 	}