Skip to content

Commit

Permalink
Support only one kernel at run-time, (multipath-tcp#156)
Browse files Browse the repository at this point in the history
Support only one MPTCP capable kernel at run-time, either the upstream
or multipath-tcp.org kernel but not both. This simplifies the kernel
support in mptcpd, and further prepares mptcpd to support the upcoming
user space MPTCP path management commands in the upstream kernel.

* src: Add user space PM command stubs for upstream.

* configure: Add '--with-kernel' option.

Allow the user to choose build-time support for either the upstream or
multipath-tcp.org kernel, e.g.:

    ./configure --with-kernel=multipath-tcp.org

Valid kernel options are "upstream" or "multipath-tcp.org", with the
former being the default.  Mptcpd will no longer support both kernels
at run-time.

* github: Add multipath-tcp.org kernel build.
  • Loading branch information
Ossama Othman authored Jan 11, 2022
1 parent 31e9646 commit 567afaa
Show file tree
Hide file tree
Showing 13 changed files with 339 additions and 130 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/multipath-tcp.org.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: multipath-tcp.org kernel

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: dependencies
run: sudo apt-get -y install autoconf-archive git
- name: build and install ELL
run: |
git clone git://git.kernel.org/pub/scm/libs/ell/ell.git
cd ell
git checkout 0.30
./bootstrap
./configure --prefix=/usr
sudo make install
- name: bootstrap
run: ./bootstrap
- name: configure
run: ./configure --with-kernel=multipath-tcp.org
- name: make
run: make
113 changes: 69 additions & 44 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ AC_DEFINE_UNQUOTED([MPTCPD_LOGGER],
[Log message destination.])
AC_SUBST([mptcpd_logger],[$enable_logging])

# Allow the user to choose support for either the upstream or
# multipath-tcp.org kernel.
AC_ARG_WITH([kernel],
[AS_HELP_STRING([--with-kernel[=KERNEL]],
[Support a specific MPTCP capable kernel
(upstream, multipath-tcp.org, auto)
@<:@default=auto@:>@])],
[AS_CASE([$withval],
[upstream | multipath-tcp.org | auto],
[with_kernel=$withval],
[AC_MSG_ERROR([invalid MPTCP capable kernel: $withval])])],
[with_kernel=auto])

# Allow the user to set the default path manager plugin at 'configure-time'.
AC_ARG_WITH([path-manager],
[AS_HELP_STRING([--with-path-manager[=PLUGIN]],
Expand Down Expand Up @@ -200,29 +213,41 @@ AH_TEMPLATE([HAVE_LINUX_MPTCP_H_UPSTREAM],
AH_TEMPLATE([HAVE_LINUX_MPTCP_H_MPTCP_ORG],
[Define to 1 if you have the multipath-tcp.org kernel
<linux/mptcp.h> header.])
AH_TEMPLATE([HAVE_LINUX_MPTCP_H_UPSTREAM_EVENTS],
[Define to 1 if <linux/mptcp.h> supports MPTCP genl events.])
AC_CHECK_HEADERS([linux/mptcp.h],
[
AX_CHECK_DEFINE(
[linux/mptcp.h],
[MPTCP_PM_NAME],
[AC_DEFINE([HAVE_LINUX_MPTCP_H_UPSTREAM], [1])
AX_CHECK_DEFINE([linux/mptcp.h],
[MPTCP_PM_EV_GRP_NAME],
[AC_DEFINE([HAVE_LINUX_MPTCP_H_UPSTREAM_EVENTS],
[1])
])
[
MPTCPD_IF_UPSTREAM_KERNEL(
[
AC_DEFINE([HAVE_LINUX_MPTCP_H_UPSTREAM], [1])
AS_IF([test "x$with_kernel" = "xauto"],
[with_kernel=upstream])
],
[
MPTCPD_IF_MPTCP_ORG_KERNEL(
[
AC_DEFINE([HAVE_LINUX_MPTCP_H_MPTCP_ORG], [1])
AS_IF([test "x$with_kernel" = "xauto"],
[with_kernel=multipath-tcp.org])
],
[
AX_CHECK_DEFINE(
[linux/mptcp.h],
[MPTCP_GENL_NAME],
[AC_DEFINE([HAVE_LINUX_MPTCP_H_MPTCP_ORG], [1])],
[AC_MSG_ERROR([Discrepancy in <linux/mptcp.h>.])])
AC_MSG_WARN([Unsupported <linux/mptcp.h> header. Using fallback.])
])
],
[AC_MSG_WARN([<linux/mptcp.h> header not found. Using fallback.])])
])
],
[
AC_MSG_WARN([<linux/mptcp.h> header not found. Using fallback.])
])

AS_IF([test "x$with_kernel" = "xauto"], [with_kernel=upstream])

AM_CONDITIONAL([HAVE_UPSTREAM_KERNEL],
[test "x$with_kernel" = "xupstream"])

AH_TEMPLATE([HAVE_UPSTREAM_KERNEL],
[Define to 1 if mptcpd should support the upstream kernel.])
AS_IF([test "x$with_kernel" = "xupstream"],
[AC_DEFINE([HAVE_UPSTREAM_KERNEL])
AC_MSG_NOTICE([Building support for upstream kernel.])],
[AC_MSG_NOTICE([Building support for multipath-tcp.org kernel.])])

# ---------------------------------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
Expand All @@ -249,14 +274,14 @@ LIBS="$LIBS $ELL_LIBS"
dnl l_genl_msg_get_extended_error() was introduced in ELL v0.31.
AC_CHECK_FUNC([l_genl_msg_get_extended_error],
[AC_DEFINE([HAVE_L_GENL_MSG_GET_EXTENDED_ERROR],
[],
[ELL has l_genl_msg_get_extended_error()])])
[],
[ELL has l_genl_msg_get_extended_error()])])

dnl l_hashmap_replace() was introduced in ELL v0.33.
AC_CHECK_FUNC([l_hashmap_replace],
[AC_DEFINE([HAVE_L_HASHMAP_REPLACE],
[],
[ELL has l_hashmap_replace()])])
[],
[ELL has l_hashmap_replace()])])
LIBS=$mptcpd_save_libs

# ---------------------------------------------------------------
Expand All @@ -272,29 +297,29 @@ AX_APPEND_COMPILE_FLAGS([-Wextra -Werror -pedantic])
# ---------------------------------------------------------------

AC_ARG_ENABLE(stack-protection,
[AS_HELP_STRING([--disable-stack-protection],
[Disable compiler stack protection.
FORTIFY_SOURCE=2 and -fstack-protector-strong]
)],
[],
[enable_stack_protection=yes])
[AS_HELP_STRING([--disable-stack-protection],
[Disable compiler stack protection.
FORTIFY_SOURCE=2 and -fstack-protector-strong]
)],
[],
[enable_stack_protection=yes])

AS_IF([test "x$enable_stack_protection" = "xyes"],
[
# Fortify source
# Enabling optimization implies _FORTIFY_SOURCE on some platforms.
# Explicitly redefine to _FORTIFY_SOURCE=2 to make sure we have the
# desired fortification level.
AX_APPEND_FLAG([-U_FORTIFY_SOURCE], [CPPFLAGS])
AX_APPEND_FLAG([-D_FORTIFY_SOURCE=2], [CPPFLAGS])
# Stack-based buffer overrun detection
MPTCPD_ADD_COMPILE_FLAG([-fstack-protector-strong],
[# GCC < 4.9
MPTCPD_ADD_COMPILE_FLAG([-fstack-protector])
])
],[]
)
[
# Fortify source
# Enabling optimization implies _FORTIFY_SOURCE on some platforms.
# Explicitly redefine to _FORTIFY_SOURCE=2 to make sure we have the
# desired fortification level.
AX_APPEND_FLAG([-U_FORTIFY_SOURCE], [CPPFLAGS])
AX_APPEND_FLAG([-D_FORTIFY_SOURCE=2], [CPPFLAGS])
# Stack-based buffer overrun detection
MPTCPD_ADD_COMPILE_FLAG([-fstack-protector-strong],
[# GCC < 4.9
MPTCPD_ADD_COMPILE_FLAG([-fstack-protector])
])
],[]
)

# Format string vulnerabilities
# -Wformat=2 implies:
Expand Down
4 changes: 4 additions & 0 deletions include/linux/mptcp_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ enum {
MPTCP_PM_ATTR_ADDR, /* nested address */
MPTCP_PM_ATTR_RCV_ADD_ADDRS, /* u32 */
MPTCP_PM_ATTR_SUBFLOWS, /* u32 */
MPTCP_PM_ATTR_TOKEN, /* u32 */
MPTCP_PM_ATTR_LOC_ID, /* u8 */

__MPTCP_PM_ATTR_MAX
};
Expand Down Expand Up @@ -84,6 +86,8 @@ enum {
MPTCP_PM_CMD_SET_LIMITS,
MPTCP_PM_CMD_GET_LIMITS,
MPTCP_PM_CMD_SET_FLAGS,
MPTCP_PM_CMD_ANNOUNCE,
MPTCP_PM_CMD_REMOVE,

__MPTCP_PM_CMD_AFTER_LAST
};
Expand Down
3 changes: 1 addition & 2 deletions include/mptcpd/private/mptcp_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
# include "mptcpd/private/config.h"
#endif

#if defined(HAVE_LINUX_MPTCP_H_UPSTREAM) \
&& defined(HAVE_LINUX_MPTCP_H_UPSTREAM_EVENTS)
#ifdef HAVE_LINUX_MPTCP_H_UPSTREAM
# include <linux/mptcp.h>
#else
/*
Expand Down
3 changes: 3 additions & 0 deletions include/mptcpd/private/netlink_pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
extern "C" {
#endif

struct mptcpd_pm_cmd_ops;
struct mptcpd_kpm_cmd_ops;

/**
* @struct mptcpd_netlink_pm
*
Expand Down
46 changes: 32 additions & 14 deletions include/mptcpd/private/path_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ struct mptcpd_pm_cmd_ops
* ignored if it is zero.
* @param[in] id MPTCP local address ID.
* @param[in] token MPTCP connection token.
*
* @return @c 0 if operation was successful. -1 or @c errno
* otherwise.
*/
int (*add_addr)(struct mptcpd_pm *pm,
struct sockaddr const *addr,
Expand All @@ -142,6 +145,12 @@ struct mptcpd_pm_cmd_ops

/**
* @brief Stop advertising network address to peers.
* @param[in] pm The mptcpd path manager object.
* @param[in] address_id MPTCP local address ID.
* @param[in] token MPTCP connection token.
*
* @return @c 0 if operation was successful. -1 or @c errno
* otherwise.
*/
int (*remove_addr)(struct mptcpd_pm *pm,
mptcpd_aid_t address_id,
Expand Down Expand Up @@ -177,12 +186,12 @@ struct mptcpd_pm_cmd_ops
/**
* @brief Remove a subflow.
*
* @param[in] pm The mptcpd path manager object.
* @param[in] token MPTCP connection token.
* @param[in] local_addr MPTCP subflow local address
* information, including the port.
* @param[in] remote_addr MPTCP subflow remote address
* information, including the port.
* @param[in] pm The mptcpd path manager object.
* @param[in] token MPTCP connection token.
* @param[in] local_addr MPTCP subflow local address
* information, including the port.
* @param[in] remote_addr MPTCP subflow remote address
* information, including the port.
*
* @return @c 0 if operation was successful. @c errno
* otherwise.
Expand All @@ -195,14 +204,14 @@ struct mptcpd_pm_cmd_ops
/**
* @brief Set priority of a subflow.
*
* @param[in] pm The mptcpd path manager object.
* @param[in] token MPTCP connection token.
* @param[in] local_addr MPTCP subflow local address
* information, including the port.
* @param[in] remote_addr MPTCP subflow remote address
* information, including the port.
* @param[in] backup Whether or not to set the MPTCP
* subflow backup priority flag.
* @param[in] pm The mptcpd path manager object.
* @param[in] token MPTCP connection token.
* @param[in] local_addr MPTCP subflow local address
* information, including the port.
* @param[in] remote_addr MPTCP subflow remote address
* information, including the port.
* @param[in] backup Whether or not to set the MPTCP
* subflow backup priority flag.
*
* @return @c 0 if operation was successful. @c errno
* otherwise.
Expand Down Expand Up @@ -238,6 +247,9 @@ struct mptcpd_kpm_cmd_ops
* @param[in] id MPTCP local address ID.
* @param[in] flags
* @param[in] index Network interface index (optional).
*
* @return @c 0 if operation was successful. -1 or @c errno
* otherwise.
*/
int (*add_addr)(struct mptcpd_pm *pm,
struct sockaddr const *addr,
Expand All @@ -247,6 +259,12 @@ struct mptcpd_kpm_cmd_ops

/**
* @brief Stop advertising network address to peers.
*
* @param[in] pm The mptcpd path manager object.
* @param[in] address_id MPTCP local address ID.
*
* @return @c 0 if operation was successful. -1 or @c errno
* otherwise.
*/
int (*remove_addr)(struct mptcpd_pm *pm,
mptcpd_aid_t address_id);
Expand Down
37 changes: 37 additions & 0 deletions m4/mptcpd_kernel.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright (c) 2021, Intel Corporation

#serial 1

# MPTCPD_IF_UPSTREAM_KERNEL([ACTION-IF-TRUE], [ACTION-IF-FALSE])
#
# Check if the <linux/mptcp.h> header for the upstream kernel is
# available in the system include path.
AC_DEFUN([MPTCPD_IF_UPSTREAM_KERNEL],
[
AC_CACHE_CHECK([for MPTCP_PM_CMD_ANNOUNCE in linux/mptcp.h],
[mptcpd_cv_header_upstream],
[
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([
#include <linux/mptcp.h>
int announce_cmd(void) { return MPTCP_PM_CMD_ANNOUNCE; }
])
],
[mptcpd_cv_header_upstream=yes],
[mptcpd_cv_header_upstream=no])
])
AS_IF([test "x$mptcpd_cv_header_upstream" = xyes], [$1], [$2])
])

# MPTCPD_IF_MPTCP_ORG_KERNEL([ACTION-IF-TRUE], [ACTION-IF-FALSE])
#
# Check if the <linux/mptcp.h> header for the multipath-tcp.org kernel
# is available in the system include path.
AC_DEFUN([MPTCPD_IF_MPTCP_ORG_KERNEL],
[
AX_CHECK_DEFINE([linux/mptcp.h], [MPTCP_GENL_NAME], [$1], [$2])
])
8 changes: 6 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ libpath_manager_la_SOURCES = \
configuration.c \
netlink_pm.c \
netlink_pm.h \
netlink_pm_mptcp_org.c \
netlink_pm_upstream.c \
path_manager.c \
path_manager.h

if HAVE_UPSTREAM_KERNEL
libpath_manager_la_SOURCES += netlink_pm_upstream.c
else
libpath_manager_la_SOURCES += netlink_pm_mptcp_org.c
endif

libpath_manager_la_LIBADD = \
$(top_builddir)/lib/libmptcpd.la \
$(ELL_LIBS) $(CODE_COVERAGE_LIBS)
Expand Down
Loading

0 comments on commit 567afaa

Please sign in to comment.