Skip to content

Commit

Permalink
rtnl: check if the kernel provides if_team
Browse files Browse the repository at this point in the history
"net: introduce ethernet teaming device" was introduced in Linux v3.3 [1],
this patch adds support for older kernels

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3d249d4ca7d0ed6629a135ea1ea21c72286c0d80

Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com>
  • Loading branch information
ThomasDevoogdt authored and richardcochran committed Sep 1, 2024
1 parent 365c994 commit 8157559
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions incdefs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ kernel_flags()
prefix=""
tstamp=/usr/include/linux/net_tstamp.h
ptp_clock=/usr/include/linux/ptp_clock.h
if_team=/usr/include/linux/if_team.h

if [ "x$KBUILD_OUTPUT" != "x" ]; then
# With KBUILD_OUTPUT set, we are building against
Expand Down Expand Up @@ -185,6 +186,10 @@ kernel_flags()
if grep -q adjust_phase ${prefix}${ptp_clock}; then
printf " -DHAVE_PTP_CAPS_ADJUST_PHASE"
fi

if grep -q -s TEAM_GENL_NAME ${prefix}${if_team}; then
printf " -DHAVE_IF_TEAM"
fi
}

flags="$(user_flags)$(kernel_flags)"
Expand Down
39 changes: 39 additions & 0 deletions missing.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,45 @@ struct so_timestamping {
};
#endif

#ifndef HAVE_IF_TEAM
#define TEAM_GENL_NAME "team"
#define TEAM_GENL_VERSION 1

enum {
TEAM_ATTR_UNSPEC,
TEAM_ATTR_TEAM_IFINDEX,
TEAM_ATTR_LIST_OPTION,
TEAM_ATTR_LIST_PORT,

__TEAM_ATTR_MAX,
TEAM_ATTR_MAX = (__TEAM_ATTR_MAX - 1)
};

enum {
TEAM_ATTR_OPTION_UNSPEC,
TEAM_ATTR_OPTION_NAME,
TEAM_ATTR_OPTION_CHANGED,
TEAM_ATTR_OPTION_TYPE,
TEAM_ATTR_OPTION_DATA,
TEAM_ATTR_OPTION_REMOVED,
TEAM_ATTR_OPTION_PORT_IFINDEX,
TEAM_ATTR_OPTION_ARRAY_INDEX,

__TEAM_ATTR_OPTION_MAX,
TEAM_ATTR_OPTION_MAX = (__TEAM_ATTR_OPTION_MAX - 1)
};

enum {
TEAM_CMD_NOOP,
TEAM_CMD_OPTIONS_SET,
TEAM_CMD_OPTIONS_GET,
TEAM_CMD_PORT_LIST_GET,

__TEAM_CMD_MAX,
TEAM_CMD_MAX = (__TEAM_CMD_MAX - 1)
};
#endif

#ifndef HWTSTAMP_FLAG_BONDED_PHC_INDEX
enum {
HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),
Expand Down
2 changes: 2 additions & 0 deletions rtnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#endif
#include <linux/rtnetlink.h>
#include <linux/genetlink.h>
#ifdef HAVE_IF_TEAM
#include <linux/if_team.h>
#endif
#include <net/if.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down

0 comments on commit 8157559

Please sign in to comment.