From e00181b492d573ecd0621f55d9ad24f134c09d4c Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Wed, 3 Oct 2018 01:13:43 +0200 Subject: ipcpd: Add multithreading to Ethernet IPCP This adds multiple reader and writer threads, configurabe via cmake with IPCP_ETH_RD_THR and IPCP_ETH_WR_THR. Improves ethernet IPCP throughput, which looks to be limited by the raw socket calls. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/eth/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ipcpd/eth/CMakeLists.txt') diff --git a/src/ipcpd/eth/CMakeLists.txt b/src/ipcpd/eth/CMakeLists.txt index 6b8d1a77..7bad6ac0 100644 --- a/src/ipcpd/eth/CMakeLists.txt +++ b/src/ipcpd/eth/CMakeLists.txt @@ -77,6 +77,11 @@ endif () if (HAVE_ETH) message(STATUS "Supported raw packet API found, building eth-llc and eth-dix") + set(IPCP_ETH_RD_THR 3 CACHE STRING + "Number of reader threads in Ethernet IPCP") + set(IPCP_ETH_WR_THR 3 CACHE STRING + "Number of writer threads in Ethernet IPCP") + set(ETH_LLC_SOURCES # Add source files here ${CMAKE_CURRENT_SOURCE_DIR}/llc.c -- cgit v1.2.3 From a789531e1dab39fcddc6d57af2312ead3b1fa4cc Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Wed, 3 Oct 2018 10:59:00 +0200 Subject: ipcpd: Fix build for netmap enabled Ethernet IPCP There were some compilation issues introduced by adding the interface monitor to the Ethernet IPCP. Furthermore it was not possible to select between raw sockets or netmap if both were available. Signed-off-by: Sander Vrijders Signed-off-by: Dimitri Staessens --- src/ipcpd/eth/CMakeLists.txt | 6 ++---- src/ipcpd/eth/eth.c | 10 +++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/ipcpd/eth/CMakeLists.txt') diff --git a/src/ipcpd/eth/CMakeLists.txt b/src/ipcpd/eth/CMakeLists.txt index 7bad6ac0..624b8266 100644 --- a/src/ipcpd/eth/CMakeLists.txt +++ b/src/ipcpd/eth/CMakeLists.txt @@ -19,6 +19,8 @@ find_path(NETMAP_C_INCLUDE_DIR mark_as_advanced(NETMAP_C_INCLUDE_DIR) +unset(HAVE_ETH) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") set(DISABLE_RAW_SOCKETS FALSE CACHE BOOL "Disable raw socket support for Ethernet IPCPs") @@ -29,7 +31,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") else () message(STATUS "Raw socket support for Ethernet IPCPs disabled by user") unset(HAVE_RAW_SOCKETS) - unset(HAVE_ETH) endif () endif () @@ -53,7 +54,6 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") message(STATUS "Berkeley Packet Filter support " "for Ethernet IPCPs disabled by user") unset(HAVE_BPF) - unset(HAVE_ETH) endif () endif () endif () @@ -69,8 +69,6 @@ if (NETMAP_C_INCLUDE_DIR) else () message(STATUS "Netmap support for Ethernet IPCPs disabled by user") unset(HAVE_NETMAP) - unset(HAVE_ETH) - unset(IPCP_ETH_TARGET CACHE) endif () endif () diff --git a/src/ipcpd/eth/eth.c b/src/ipcpd/eth/eth.c index 9456f4cb..8175d803 100644 --- a/src/ipcpd/eth/eth.c +++ b/src/ipcpd/eth/eth.c @@ -194,6 +194,7 @@ struct { struct shim_data * shim_data; #ifdef __linux__ int mtu; + int if_idx; #endif #if defined(HAVE_NETMAP) struct nm_desc * nmd; @@ -884,7 +885,9 @@ static void * eth_ipcp_sdu_reader(void * o) if (deid == MGMT_EID) { #elif defined (BUILD_ETH_LLC) if (length > 0x05FF) {/* DIX */ +#ifndef HAVE_NETMAP ipcp_sdb_release(sdb); +#endif continue; } @@ -1137,7 +1140,7 @@ static void * eth_ipcp_if_monitor(void * o) ifi = NLMSG_DATA(h); /* Not our interface */ - if (ifi->ifi_index != eth_data.device.sll_ifindex) + if (ifi->ifi_index != eth_data.if_idx) continue; if (ifi->ifi_flags & IFF_UP) { @@ -1284,6 +1287,7 @@ static int eth_ipcp_bootstrap(const struct ipcp_config * conf) log_err("Failed to retrieve interface index."); return -1; } + eth_data.if_idx = idx; #endif /* __FreeBSD__ */ #if defined(HAVE_NETMAP) @@ -1370,7 +1374,7 @@ static int eth_ipcp_bootstrap(const struct ipcp_config * conf) #endif /* HAVE_NETMAP */ ipcp_set_state(IPCP_OPERATIONAL); -#ifdef __linux__ +#if defined(__linux__) if (pthread_create(ð_data.if_monitor, NULL, eth_ipcp_if_monitor, @@ -1436,7 +1440,7 @@ static int eth_ipcp_bootstrap(const struct ipcp_config * conf) pthread_cancel(eth_data.if_monitor); pthread_join(eth_data.if_monitor, NULL); #endif -#if !defined(HAVE_NETMAP) +#if defined(__linux__) || !defined(HAVE_NETMAP) fail_device: #endif #if defined(HAVE_NETMAP) -- cgit v1.2.3 From c9a54ee6b45c8566cf2d24f9763907451b50f7c1 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Wed, 3 Oct 2018 14:37:15 +0200 Subject: build: Prioritize raw socket API in build This will change the build to exclusively select one raw socket API in case multiple are present in the sytem, which will simplify the code. Signed-off-by: Sander Vrijders Signed-off-by: Dimitri Staessens --- src/ipcpd/eth/CMakeLists.txt | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/ipcpd/eth/CMakeLists.txt') diff --git a/src/ipcpd/eth/CMakeLists.txt b/src/ipcpd/eth/CMakeLists.txt index 624b8266..6672f93c 100644 --- a/src/ipcpd/eth/CMakeLists.txt +++ b/src/ipcpd/eth/CMakeLists.txt @@ -14,31 +14,31 @@ include_directories(${CMAKE_BINARY_DIR}/include) find_path(NETMAP_C_INCLUDE_DIR net/netmap_user.h - HINTS /usr/include /usr/local/include -) + HINTS /usr/include /usr/local/include) mark_as_advanced(NETMAP_C_INCLUDE_DIR) -unset(HAVE_ETH) - +# Check for raw sockets if (CMAKE_SYSTEM_NAME STREQUAL "Linux") set(DISABLE_RAW_SOCKETS FALSE CACHE BOOL "Disable raw socket support for Ethernet IPCPs") if (NOT DISABLE_RAW_SOCKETS) message(STATUS "Raw socket support for Ethernet IPCPs enabled") set(HAVE_RAW_SOCKETS TRUE PARENT_SCOPE) + set(HAVE_RAW_SOCKETS TRUE) set(HAVE_ETH TRUE) else () message(STATUS "Raw socket support for Ethernet IPCPs disabled by user") + unset(HAVE_RAW_SOCKETS PARENT_SCOPE) unset(HAVE_RAW_SOCKETS) endif () endif () +# Check for BPF if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") find_path(BPF_C_INCLUDE_DIR - net/bpf.h - HINTS /usr/include /usr/local/include - ) + net/bpf.h + HINTS /usr/include /usr/local/include) mark_as_advanced(BPF_C_INCLUDE_DIR) @@ -47,28 +47,31 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") "Disable Berkeley Packet Filter support for Ethernet IPCPs") if (NOT DISABLE_BPF) message(STATUS "Berkeley Packet Filter support " - "for Ethernet IPCPs enabled") + "for Ethernet IPCPs enabled") set(HAVE_BPF TRUE PARENT_SCOPE) + set(HAVE_BPF TRUE) set(HAVE_ETH TRUE) else () message(STATUS "Berkeley Packet Filter support " - "for Ethernet IPCPs disabled by user") + "for Ethernet IPCPs disabled by user") + unset(HAVE_BPF PARENT_SCOPE) unset(HAVE_BPF) endif () endif () endif () -if (NETMAP_C_INCLUDE_DIR) +# Check for netmap exclusively +if (NOT HAVE_RAW_SOCKETS AND NOT HAVE_BPF AND NETMAP_C_INCLUDE_DIR) set(DISABLE_NETMAP FALSE CACHE BOOL - "Disable netmap support for ETH IPCPs") + "Disable netmap support for ETH IPCPs") if (NOT DISABLE_NETMAP) message(STATUS "Netmap support for Ethernet IPCPs enabled") - set(HAVE_NETMAP TRUE PARENT_SCOPE) test_and_set_c_compiler_flag_global(-std=c99) + set(HAVE_NETMAP TRUE PARENT_SCOPE) set(HAVE_ETH TRUE) else () message(STATUS "Netmap support for Ethernet IPCPs disabled by user") - unset(HAVE_NETMAP) + unset(HAVE_NETMAP PARENT_SCOPE) endif () endif () @@ -83,12 +86,12 @@ if (HAVE_ETH) set(ETH_LLC_SOURCES # Add source files here ${CMAKE_CURRENT_SOURCE_DIR}/llc.c - ) + ) set(ETH_DIX_SOURCES # Add source files here ${CMAKE_CURRENT_SOURCE_DIR}/dix.c - ) + ) set(IPCP_ETH_LLC_TARGET ipcpd-eth-llc CACHE INTERNAL "") set(IPCP_ETH_DIX_TARGET ipcpd-eth-dix CACHE INTERNAL "") -- cgit v1.2.3