This allows running phc2sys and pmc in multiple PTP domains at the same time. It also makes it easier to configure ptp4l, the uds_address option doesn't need to be set if domainNumber is different from other instances. --- clock.c | 1 + pmc.8 | 3 ++- pmc_common.c | 3 +++ ptp4l.8 | 4 +++- uds.c | 12 ++++++++---- uds.h | 3 ++- 6 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/clock.c b/clock.c index ddea72f..c9a46ed 100644 --- a/clock.c +++ b/clock.c @@ -765,6 +765,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, snprintf(udsif->name, sizeof(udsif->name), "%s", uds_path); udsif->transport = TRANS_UDS; udsif->delay_filter_length = 1; + uds_domain_number = dds->dds.domainNumber; c->free_running = dds->free_running; c->freq_est_interval = dds->freq_est_interval; diff --git a/pmc.8 b/pmc.8 index 0d36354..87232cb 100644 --- a/pmc.8 +++ b/pmc.8 @@ -77,7 +77,8 @@ Specify the network interface. The default is /var/run/pmc for the Unix Domain Socket transport and eth0 for the other transports. .TP .BI \-s " uds-address" -Specifies the address of the server's UNIX domain socket. +Specifies the address of the server's UNIX domain socket. The domain +number will be appended automatically to the specified address. The default is /var/run/ptp4l. .TP .BI \-t " transport-specific-field" diff --git a/pmc_common.c b/pmc_common.c index 41385da..8f52d8f 100644 --- a/pmc_common.c +++ b/pmc_common.c @@ -24,6 +24,7 @@ #include "print.h" #include "tlv.h" #include "transport.h" +#include "uds.h" #include "util.h" #include "pmc_common.h" @@ -76,6 +77,8 @@ struct pmc *pmc_create(enum transport_type transport_type, const char *iface_nam iface_name)) { pr_err("failed to generate a clock identity"); goto failed; + } else { + uds_domain_number = domain_number; } pmc->port_identity.portNumber = 1; pmc_target_all(pmc); diff --git a/ptp4l.8 b/ptp4l.8 index 1bae78c..82cbfe7 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -392,7 +392,9 @@ is only relevant with IPv6 transport. See RFC 4291. The default is .TP .B uds_address Specifies the address of the UNIX domain socket for receiving local -management messages. The default is /var/run/ptp4l. +management messages. The domain number will be appended automatically to the +specified address. +The default is /var/run/ptp4l. .TP .B logging_level The maximum logging level of messages which should be printed. diff --git a/uds.c b/uds.c index e98e32c..e071f83 100644 --- a/uds.c +++ b/uds.c @@ -32,6 +32,7 @@ #include "uds.h" char uds_path[MAX_IFNAME_SIZE + 1] = "/var/run/ptp4l"; +int uds_domain_number = 0; #define UDS_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) /*0660*/ @@ -60,9 +61,10 @@ static int uds_open(struct transport *t, const char *name, struct fdarray *fda, } memset(&sa, 0, sizeof(sa)); sa.sun_family = AF_LOCAL; - strncpy(sa.sun_path, name, sizeof(sa.sun_path) - 1); + snprintf(sa.sun_path, sizeof(sa.sun_path), "%s.%d", + name, uds_domain_number); - unlink(name); + unlink(sa.sun_path); err = bind(fd, (struct sockaddr *) &sa, sizeof(sa)); if (err < 0) { @@ -71,14 +73,16 @@ static int uds_open(struct transport *t, const char *name, struct fdarray *fda, return -1; } + chmod(sa.sun_path, UDS_FILEMODE); + /* For client use, pre load the server path. */ memset(&sa, 0, sizeof(sa)); sa.sun_family = AF_LOCAL; - strncpy(sa.sun_path, uds_path, sizeof(sa.sun_path) - 1); + snprintf(sa.sun_path, sizeof(sa.sun_path), "%s.%d", + uds_path, uds_domain_number); uds->address.sun = sa; uds->address.len = sizeof(sa); - chmod(name, UDS_FILEMODE); fda->fd[FD_EVENT] = -1; fda->fd[FD_GENERAL] = fd; return 0; diff --git a/uds.h b/uds.h index d7f6626..2cab481 100644 --- a/uds.h +++ b/uds.h @@ -25,9 +25,10 @@ #include "transport.h" /** - * Address of the server. + * Address of the server specified as uds_path + '.' + uds_domain_number */ extern char uds_path[MAX_IFNAME_SIZE + 1]; +extern int uds_domain_number; /** * Allocate an instance of a UDS transport. -- 1.9.3 ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel