Re: [Linuxptp-devel] [PATCH] rtnl: add team activebackup support
On Thu, 6 Dec 2018 at 15:40, Hangbin Liu wrote: > > This patch add team interface activebackup mode support. As linux team use > genl netlink message, when we get a rtnl link change notify, we have to setup > a new genl socket and request the current active port. > Here are the linuxptp-testsuite and team failover test results ]# linuxptp-testsuite/run 01-defaults (1/29) [...] SUMMARY: TOTAL 29 PASSED 29 FAILED 0() ]# ./ptp4l -2 -i team0 -m -s ptp4l[82039.622]: selected /dev/ptp1 as PTP clock ptp4l[82039.714]: driver rejected most general HWTSTAMP filter ptp4l[82039.715]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[82039.716]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE ptp4l[82039.859]: port 1: new foreign master f8bc12.fffe.13b6e0-1 ptp4l[82043.859]: selected best master clock f8bc12.fffe.13b6e0 ptp4l[82043.859]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE ptp4l[82045.859]: master offset -1189023672 s0 freq +0 path delay 1420 ptp4l[82046.859]: master offset -1189024546 s1 freq-874 path delay 1509 ptp4l[82047.859]: master offset -896 s2 freq -1770 path delay 1509 ptp4l[82047.859]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l[82048.859]: master offset192 s2 freq-951 path delay 1396 ptp4l[82049.859]: master offset345 s2 freq-740 path delay 1396 ptp4l[82050.859]: master offset388 s2 freq-594 path delay 1283 ptp4l[82051.859]: master offset276 s2 freq-589 path delay 1240 [...] ptp4l[82071.860]: master offset-19 s2 freq-795 path delay 1191 ptp4l[82072.860]: master offset 38 s2 freq-744 path delay 1191 ptp4l[82073.860]: master offset-19 s2 freq-790 path delay 1195 ptp4l[82074.273]: recvmsg failed: Network is down ptp4l[82074.273]: port 1: recv message failed ptp4l[82074.273]: port 1: SLAVE to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED) ptp4l[82074.376]: port 1: ts label changed to em2 ptp4l[82090.449]: driver rejected most general HWTSTAMP filter ptp4l[82090.449]: port 1: FAULTY to LISTENING on INIT_COMPLETE ptp4l[82091.860]: port 1: new foreign master f8bc12.fffe.13b6e0-1 ptp4l[82095.860]: selected best master clock f8bc12.fffe.13b6e0 ptp4l[82095.860]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE ptp4l[82095.860]: master offset -1168357452 s0 freq +0 path delay 1195 ptp4l[82096.860]: master offset -1168358204 s1 freq-752 path delay 1195 ptp4l[82097.860]: master offset -1125 s2 freq -1877 path delay 1195 ptp4l[82097.860]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l[82098.860]: master offset-27 s2 freq -1116 path delay 1195 ptp4l[82099.860]: master offset342 s2 freq-756 path delay 1178 ptp4l[82100.860]: master offset345 s2 freq-650 path delay 1178 ptp4l[82101.860]: master offset197 s2 freq-694 path delay 1178 ptp4l[82102.860]: master offset 89 s2 freq-743 path delay 1183 ptp4l[82103.860]: master offset 42 s2 freq-764 path delay 1183 ptp4l[82104.860]: master offset 14 s2 freq-779 path delay 1199 ptp4l[82105.860]: master offset-20 s2 freq-809 path delay 1203 ptp4l[82106.860]: master offset-46 s2 freq-841 path delay 1204 ptp4l[82107.860]: master offset 36 s2 freq-773 path delay 1185 ptp4l[82108.860]: master offset 34 s2 freq-764 path delay 1197 ptp4l[82109.860]: master offset-22 s2 freq-810 path delay 1197 ptp4l[82110.860]: master offset 16 s2 freq-778 path delay 1181 ptp4l[82111.860]: master offset 3 s2 freq-786 path delay 1175 ptp4l[82112.860]: master offset 2 s2 freq-787 path delay 1174 ptp4l[82113.860]: master offset 46 s2 freq-742 path delay 1174 ptp4l[82114.860]: master offset-19 s2 freq-793 path delay 1177 ptp4l[82115.860]: master offset-49 s2 freq-829 path delay 1181 ptp4l[82116.153]: port 1: ts label changed to em1 ptp4l[82116.153]: port 1: SLAVE to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED) ptp4l[82132.325]: driver rejected most general HWTSTAMP filter ptp4l[82132.325]: port 1: FAULTY to LISTENING on INIT_COMPLETE ptp4l[82133.860]: port 1: new foreign master f8bc12.fffe.13b6e0-1 ptp4l[82137.860]: selected best master clock f8bc12.fffe.13b6e0 ptp4l[82137.861]: port 1: LISTENING to UNCALIBRATED on RS_SLAVE ptp4l[82137.861]: master offset338 s0 freq-789 path delay 1181 ptp4l[82138.861]: master offset352 s2 freq-775 path delay 1181 ptp4l[82138.861]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l[82139.861]: master offset335 s2 freq-440 path delay 1177 ptp4l[82140.861]: master offset 13 s2 freq-662 path delay 1177 ptp4l[82141.861]: master offset-62 s2 freq-733 path delay
[Linuxptp-devel] [PATCH] rtnl: add team activebackup support
This patch add team interface activebackup mode support. As linux team use genl netlink message, when we get a rtnl link change notify, we have to setup a new genl socket and request the current active port. Signed-off-by: Hangbin Liu --- missing.h | 16 + phc2sys.8 | 4 +- rtnl.c| 213 +++--- 3 files changed, 221 insertions(+), 12 deletions(-) diff --git a/missing.h b/missing.h index 2f7adb9..8f92079 100644 --- a/missing.h +++ b/missing.h @@ -118,6 +118,22 @@ enum { #define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1) #endif /*IFLA_BOND_MAX*/ +#ifndef NLA_TYPE_MAX +enum { +NLA_UNSPEC, +NLA_U8, +NLA_U16, +NLA_U32, +NLA_U64, +NLA_STRING, +NLA_FLAG, +NLA_MSECS, +NLA_NESTED, +__NLA_TYPE_MAX, +}; +#define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1) +#endif /*NLA_TYPE_MAX*/ + #ifdef __UCLIBC__ #if (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) && \ diff --git a/phc2sys.8 b/phc2sys.8 index 45cb0e3..b3a3de3 100644 --- a/phc2sys.8 +++ b/phc2sys.8 @@ -108,9 +108,9 @@ together with the option, the master clock is used only to correct the offset by whole number of seconds, which cannot be fixed with PPS alone. Not compatible with the .B \-a -option. This option does not support bonded interface (e.g. bond0). If +option. This option does not support bonded interface (e.g. bond0, team0). If .B ptp4l -has a port on an active-backup bond interface, the +has a port on an active-backup bond or team interface, the .B \-a option can be used to track the active interface. .TP diff --git a/rtnl.c b/rtnl.c index f9a572b..e409e41 100644 --- a/rtnl.c +++ b/rtnl.c @@ -20,6 +20,8 @@ #include /* Must come before linux/netlink.h on some systems. */ #include #include +#include +#include #include #include #include @@ -30,8 +32,12 @@ #include "print.h" #include "rtnl.h" +#define BUF_SIZE 4096 +#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN)) + static int rtnl_len; static char *rtnl_buf; +static int get_team_active_iface(int master_index); int rtnl_close(int fd) { @@ -116,14 +122,24 @@ int rtnl_link_query(int fd, char *device) return 0; } -static inline __u32 rta_getattr_u32(const struct rtattr *rta) +static inline __u8 rta_getattr_u8(struct rtattr *rta) +{ + return *(__u8 *)RTA_DATA(rta); +} + +static inline __u16 rta_getattr_u16(struct rtattr *rta) +{ + return *(__u16 *)RTA_DATA(rta); +} + +static inline __u32 rta_getattr_u32(struct rtattr *rta) { return *(__u32 *)RTA_DATA(rta); } -static inline const char *rta_getattr_str(const struct rtattr *rta) +static inline char *rta_getattr_str(struct rtattr *rta) { - return (const char *)RTA_DATA(rta); + return (char *)RTA_DATA(rta); } static int rtnl_rtattr_parse(struct rtattr *tb[], int max, struct rtattr *rta, int len) @@ -150,12 +166,12 @@ static inline int rtnl_nested_rtattr_parse(struct rtattr *tb[], int max, struct return rtnl_rtattr_parse(tb, max, RTA_DATA(rta), RTA_PAYLOAD(rta)); } -static int rtnl_linkinfo_parse(struct rtattr *rta) +static int rtnl_linkinfo_parse(int master_index, struct rtattr *rta) { - int index = -1; - const char *kind; struct rtattr *linkinfo[IFLA_INFO_MAX]; struct rtattr *bond[IFLA_BOND_MAX]; + int index = -1; + char *kind; if (rtnl_nested_rtattr_parse(linkinfo, IFLA_INFO_MAX, rta) < 0) return -1; @@ -172,6 +188,8 @@ static int rtnl_linkinfo_parse(struct rtattr *rta) if (bond[IFLA_BOND_ACTIVE_SLAVE]) { index = rta_getattr_u32(bond[IFLA_BOND_ACTIVE_SLAVE]); } + } else if (kind && !strncmp(kind, "team", 4)) { + index = get_team_active_iface(master_index); } } return index; @@ -190,7 +208,7 @@ int rtnl_link_status(int fd, char *device, rtnl_callback cb, void *ctx) index = if_nametoindex(device); if (!rtnl_buf) { - rtnl_len = 4096; + rtnl_len = BUF_SIZE; rtnl_buf = malloc(rtnl_len); if (!rtnl_buf) { pr_err("rtnl: low memory"); @@ -246,7 +264,7 @@ int rtnl_link_status(int fd, char *device, rtnl_callback cb, void *ctx) IFLA_PAYLOAD(nh)); if (tb[IFLA_LINKINFO]) - slave_index = rtnl_linkinfo_parse(tb[IFLA_LINKINFO]); + slave_index = rtnl_linkinfo_parse(index, tb[IFLA_LINKINFO]); if (cb) cb(ctx, link_up, slave_index); @@ -255,7 +273,7 @@ int rtnl_link_status(int fd, char *device, rtnl_callback cb, void *ctx) return 0; } -int rtnl_open(void) +static int nl_open(int family) { int fd; struct sockaddr_nl sa; @@ -264,7 +282,7 @@ int
Re: [Linuxptp-devel] PHC delay when calling clock_gettime
Am 05.12.18 um 18:16 schrieb Keller, Jacob E: I've never heard of this symptom being reported before. My gut reaction is that this is caused by code in e1000e_read_systim, which reads the SYSTIME multiple times. I am suspicious that multiple readings is somehow impacting the clock time, which would give the results that you see above. You mentioned another board that didn't have this problem using the same driver? Thanks, Jake Yes, my HP Elitebook 830 G5 doesn't show this problem. Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz 00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (4) I219-V (rev 21) Subsystem: Hewlett-Packard Company Ethernet Connection (4) I219-V Flags: bus master, fast devsel, latency 0, IRQ 123 Memory at b640 (32-bit, non-prefetchable) [size=128K] Capabilities: Kernel driver in use: e1000e Kernel modules: e1000e Linux Kernel 4.18.0-12-generic (Ubuntu 18.10) Best Regards, Thomas ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Re: [Linuxptp-devel] PHC delay when calling clock_gettime
> -Original Message- > From: Thomas Behn [mailto:thomas.b...@meinberg.de] > Sent: Tuesday, December 04, 2018 10:04 PM > To: Keller, Jacob E ; > linuxptp-devel@lists.sourceforge.net > Subject: Re: [Linuxptp-devel] PHC delay when calling clock_gettime > > Am 04.12.18 um 19:54 schrieb Keller, Jacob E: > >> -Original Message- > >> From: Thomas Behn [mailto:thomas.b...@meinberg.de] > >> Sent: Tuesday, December 04, 2018 12:46 AM > >> To: Keller, Jacob E ; linuxptp- > de...@lists.sourceforge.net > >> Subject: Re: [Linuxptp-devel] PHC delay when calling clock_gettime > > Ah. Ok. From the sound of the original statement it sounded like you were > developing your own hardware. > > > > I suspect that there is a work around in the 82579V NIC that causes this, > > but I don't > know offhand. I'll have to go dig a bit, the e1000e driver isn't one I worked > on much > myself. > > > > Thanks, > > Jake > > Thanks again for your help! > > In case this really is caused by a work around in the 82579V, are there > other NICs, which have similar impairments? > I am asking, because I want to make my implementation as robust as > possible for all kinds of hardware. > > Thanks, > Thomas > I've never heard of this symptom being reported before. My gut reaction is that this is caused by code in e1000e_read_systim, which reads the SYSTIME multiple times. I am suspicious that multiple readings is somehow impacting the clock time, which would give the results that you see above. You mentioned another board that didn't have this problem using the same driver? Thanks, Jake ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel