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