> -----Original Message-----
> From: Miroslav Lichvar [mailto:mlich...@redhat.com]
> Sent: Friday, April 13, 2018 8:12 AM
> To: linuxptp-devel@lists.sourceforge.net
> Subject: [Linuxptp-devel] [PATCH 2/4] 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.
> 

Neat.

Thanks,
Jake

> Signed-off-by: Miroslav Lichvar <mlich...@redhat.com>
> ---
>  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 <libgen.h>
>  #include <limits.h>
>  #include <linux/net_tstamp.h>
> +#include <net/if.h>
>  #include <signal.h>
>  #include <spawn.h>
>  #include <stdarg.h>
> @@ -35,6 +36,7 @@
>  #include <unistd.h>
> 
>  #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 */
> --
> 2.14.3
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linuxptp-devel mailing list
> Linuxptp-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to