From e5ba2dae5f102a66e152b96f9cc7b06aff4b90b5 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Fri, 13 Apr 2018 17:11:57 +0200 Subject: [PATCH] timemaster: add support for bonded interfaces. Use the rtnl_get_ts_device() function to get the name of the slave interface which will be timestamping PTP packets and use it instead of the master interface to check the timestamping capabilities and PHC. Signed-off-by: Miroslav Lichvar --- makefile | 2 +- timemaster.c | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/makefile b/makefile index 6f5321c..17189e6 100644 --- a/makefile +++ b/makefile @@ -60,7 +60,7 @@ hwstamp_ctl: hwstamp_ctl.o version.o phc_ctl: phc_ctl.o phc.o sk.o util.o clockadj.o sysoff.o print.o version.o -timemaster: print.o sk.o timemaster.o util.o version.o +timemaster: print.o rtnl.o sk.o timemaster.o util.o version.o version.o: .version version.sh $(filter-out version.d,$(DEPEND)) diff --git a/timemaster.c b/timemaster.c index cda2d90..fc3ba31 100644 --- a/timemaster.c +++ b/timemaster.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include #include "print.h" +#include "rtnl.h" #include "sk.h" #include "util.h" #include "version.h" @@ -674,6 +676,7 @@ static int add_ptp_source(struct ptp_domain *source, { struct config_file *config_file; char **command, *uds_path, **interfaces, *message_tag; + char ts_interface[IF_NAMESIZE]; int i, j, num_interfaces, *phc, *phcs, hw_ts, sw_ts; struct sk_ts_info ts_info; @@ -696,26 +699,38 @@ static int add_ptp_source(struct ptp_domain *source, for (i = 0; i < num_interfaces; i++) { phcs[i] = -1; + /* + * if it is a bonded interface, use the name of the active + * slave interface (which will be timestamping packets) + */ + if (!rtnl_get_ts_device(source->interfaces[i], ts_interface)) { + pr_debug("slave interface of %s: %s", + source->interfaces[i], ts_interface); + } else { + snprintf(ts_interface, sizeof(ts_interface), "%s", + source->interfaces[i]); + } + /* check if the interface has a usable PHC */ - if (sk_get_ts_info(source->interfaces[i], &ts_info)) { + if (sk_get_ts_info(ts_interface, &ts_info)) { pr_err("failed to get time stamping info for %s", - source->interfaces[i]); + ts_interface); free(phcs); return 1; } if (((ts_info.so_timestamping & hw_ts) != hw_ts)) { - pr_debug("interface %s: no PHC", source->interfaces[i]); + pr_debug("interface %s: no PHC", ts_interface); if ((ts_info.so_timestamping & sw_ts) != sw_ts) { pr_err("time stamping not supported on %s", - source->interfaces[i]); + ts_interface); free(phcs); return 1; } continue; } - pr_debug("interface %s: PHC %d", source->interfaces[i], + pr_debug("interface %s: PHC %d", ts_interface, ts_info.phc_index); /* and the PHC isn't already used in another source */