Re: [Linuxptp-devel] [PATCHv5 04/12] rtnl: update function rtnl_link_status to get bond slave info
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Richard C. <ric...@gm...> - 2017-10-07 15:30:53
|
On Sat, Sep 30, 2017 at 04:25:12PM +0800, Hangbin Liu wrote: > +static int rtnl_linkinfo_parse(struct rtattr *rta) > +{ > + int index = -1; > + const char *kind; > + struct rtattr *linkinfo[IFLA_INFO_MAX]; > + struct rtattr *bond[IFLA_BOND_MAX]; > + > + if (rtnl_nested_rtattr_parse(linkinfo, IFLA_INFO_MAX, rta) < 0) > + return -1; > + > + if (linkinfo[IFLA_INFO_KIND]) { > + kind = rta_getattr_str(linkinfo[IFLA_INFO_KIND]); > + > + if (kind && !strncmp(kind, "bond", 4) && > + linkinfo[IFLA_INFO_DATA]) { > + if (rtnl_nested_rtattr_parse(bond, IFLA_BOND_MAX, > + linkinfo[IFLA_INFO_DATA]) < 0) > + return -1; > + > + if (bond[IFLA_BOND_ACTIVE_SLAVE]) { > + index = rta_getattr_u32(bond[IFLA_BOND_ACTIVE_SLAVE]); The IFLA_BOND_ macros first appeared in v3.13-rc1, and we need to allow compiling linuxptp with older kernel headers. How about adding something like this? Thanks, Richard --- diff --git a/missing.h b/missing.h index 7bc1776..cf989b5 100644 --- a/missing.h +++ b/missing.h @@ -69,6 +69,42 @@ static inline int clock_adjtime(clockid_t id, struct timex *tx) } #endif +#ifndef IFLA_BOND_MAX +enum { + IFLA_BOND_UNSPEC, + IFLA_BOND_MODE, + IFLA_BOND_ACTIVE_SLAVE, + IFLA_BOND_MIIMON, + IFLA_BOND_UPDELAY, + IFLA_BOND_DOWNDELAY, + IFLA_BOND_USE_CARRIER, + IFLA_BOND_ARP_INTERVAL, + IFLA_BOND_ARP_IP_TARGET, + IFLA_BOND_ARP_VALIDATE, + IFLA_BOND_ARP_ALL_TARGETS, + IFLA_BOND_PRIMARY, + IFLA_BOND_PRIMARY_RESELECT, + IFLA_BOND_FAIL_OVER_MAC, + IFLA_BOND_XMIT_HASH_POLICY, + IFLA_BOND_RESEND_IGMP, + IFLA_BOND_NUM_PEER_NOTIF, + IFLA_BOND_ALL_SLAVES_ACTIVE, + IFLA_BOND_MIN_LINKS, + IFLA_BOND_LP_INTERVAL, + IFLA_BOND_PACKETS_PER_SLAVE, + IFLA_BOND_AD_LACP_RATE, + IFLA_BOND_AD_SELECT, + IFLA_BOND_AD_INFO, + IFLA_BOND_AD_ACTOR_SYS_PRIO, + IFLA_BOND_AD_USER_PORT_KEY, + IFLA_BOND_AD_ACTOR_SYSTEM, + IFLA_BOND_TLB_DYNAMIC_LB, + __IFLA_BOND_MAX, +}; + +#define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1) +#endif /*IFLA_BOND_MAX*/ + #ifdef __UCLIBC__ #if (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) && \ diff --git a/rtnl.c b/rtnl.c index 2ac0b96..0d3bef9 100644 --- a/rtnl.c +++ b/rtnl.c @@ -26,6 +26,7 @@ #include <string.h> #include <unistd.h> +#include "missing.h" #include "print.h" #include "rtnl.h" |