From ba4727ccaf4a3e5cd590b1d8eb602ca2faf61863 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Wed, 22 Aug 2012 04:43:47 +0200 Subject: [PATCH] Throw an error if SIOCETHTOOL returns a bad PHC index. If the kernel supports the ioctl, but the driver does not (like igb in kernel version 3.5), then ptp4l will incorrectly choose the system clock. Signed-off-by: Richard Cochran --- sk.c | 2 +- sk.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sk.c b/sk.c index 84cf11e..b006c57 100644 --- a/sk.c +++ b/sk.c @@ -119,7 +119,7 @@ int sk_interface_phc(char *name, int *index) close(fd); *index = info.phc_index; - return 0; + return info.phc_index < 0 ? -1 : 0; #else return -1; #endif diff --git a/sk.h b/sk.h index 5f1ee4b..b2787b2 100644 --- a/sk.h +++ b/sk.h @@ -33,7 +33,8 @@ int sk_interface_index(int fd, char *device); /** * Obtain the PHC device index of a network interface. * @param name The name of the interface - * @return index The phc index associated with this iface + * @return index The non-negative phc index associated with this iface. + * On error a negative integer is returned. */ int sk_interface_phc(char *name, int *index);