summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Eshenko <dmitriy.eshenko@accel-ppp.org>2024-04-14 18:24:50 +0300
committerGitHub <noreply@github.com>2024-04-14 18:24:50 +0300
commitfc78e082352168a2051928d25eaf0c0b09d20873 (patch)
treeadfc7b0b13e78e516d92b584c67991f3c7ee358c
parent74a58e70f03db19263d377dbad0ca289ea07a7ad (diff)
parentce3ee7595c1239a20de589c95dd8ccce38ae49e7 (diff)
downloadaccel-ppp-fc78e082352168a2051928d25eaf0c0b09d20873.tar.gz
accel-ppp-fc78e082352168a2051928d25eaf0c0b09d20873.zip
Merge pull request #130 from nuclearcat/add-musl-compatibility
musl: Add musl compatibility
-rw-r--r--.github/workflows/build-and-run.yml38
-rw-r--r--accel-pppd/CMakeLists.txt45
-rw-r--r--accel-pppd/accel-ppp.conf4
-rw-r--r--accel-pppd/ctrl/ipoe/arp.c2
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c2
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c4
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c2
7 files changed, 94 insertions, 3 deletions
diff --git a/.github/workflows/build-and-run.yml b/.github/workflows/build-and-run.yml
index 8ddbafae..2fbc9388 100644
--- a/.github/workflows/build-and-run.yml
+++ b/.github/workflows/build-and-run.yml
@@ -77,7 +77,8 @@ jobs:
path: build/accel-ppp_*.deb
if-no-files-found: error
- Build-in-Container:
+ # Debian based distros
+ Build-in-Container-Debian:
#if: ${{ false }} # disable for now
strategy:
fail-fast: false
@@ -215,3 +216,38 @@ jobs:
run: sleep 1
- name: Check accel-ppp stat
run: accel-cmd show stat
+
+ Build-in-Container-Alpine:
+ runs-on: ubuntu-latest
+ container:
+ image: alpine:latest
+ steps:
+ - name: Install build tools
+ run: >
+ apk update && apk add --no-cache git cmake make g++ pcre-dev libressl-dev linux-headers libucontext-dev lua5.1-dev
+ - name: Check out repository code
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - name: mkdir build
+ run: mkdir build
+ - name: Disable git security warnings
+ run: git config --global --add safe.directory '*'
+ - name: cmake
+ working-directory: ./build
+ run: >
+ cmake -DBUILD_IPOE_DRIVER=FALSE -DBUILD_VLAN_MON_DRIVER=FALSE -DCMAKE_INSTALL_PREFIX=/usr
+ -DKDIR=/usr/src/linux-headers-`uname -r`
+ -DLUA=TRUE -DSHAPER=FALSE -DRADIUS=TRUE ..
+ - name: make and install
+ working-directory: ./build
+ run: make && make install
+ - name: Copy default config
+ run: cp accel-pppd/accel-ppp.conf /etc/accel-ppp.conf
+ - name: Start accel-ppp with default config
+ run: accel-pppd -d -c /etc/accel-ppp.conf
+ - name: Sleep for 1 sec
+ run: sleep 1
+ - name: Check accel-ppp stat
+ run: accel-cmd show stat
+ \ No newline at end of file
diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt
index ab8a3508..d194eaa7 100644
--- a/accel-pppd/CMakeLists.txt
+++ b/accel-pppd/CMakeLists.txt
@@ -44,6 +44,33 @@ IF (RADIUS)
ADD_SUBDIRECTORY(radius)
ENDIF (RADIUS)
+# define __free_fn_t in musl
+INCLUDE (CheckCSourceCompiles)
+CHECK_C_SOURCE_COMPILES("
+#include <stdlib.h>
+int main(void)
+{
+ __free_fn_t *f;
+ return 0;
+}" HAVE_FREE_FN_T)
+IF (HAVE_FREE_FN_T)
+ ADD_DEFINITIONS(-DHAVE_FREE_FN_T)
+ENDIF (HAVE_FREE_FN_T)
+
+INCLUDE (CheckCSourceCompiles)
+CHECK_C_SOURCE_COMPILES("
+#include <linux/if_arp.h>
+#include <net/ethernet.h>
+int main(void)
+{
+ return 0;
+}" HAVE_GOOD_IFARP)
+
+IF (HAVE_GOOD_IFARP)
+ ADD_DEFINITIONS(-DHAVE_GOOD_IFARP)
+ENDIF (HAVE_GOOD_IFARP)
+
+
ADD_SUBDIRECTORY(triton)
ADD_SUBDIRECTORY(vlan-mon)
ADD_SUBDIRECTORY(ctrl)
@@ -62,6 +89,12 @@ ENDIF (SHAPER)
INCLUDE(CheckIncludeFile)
CHECK_INCLUDE_FILE("linux/netfilter/ipset/ip_set.h" HAVE_IPSET)
+# MUSL does not have printf.h
+CHECK_INCLUDE_FILE("printf.h" HAVE_PRINTF_H)
+IF (HAVE_PRINTF_H)
+ ADD_DEFINITIONS(-DHAVE_PRINTF_H)
+ENDIF (HAVE_PRINTF_H)
+
INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(setns HAVE_SETNS)
@@ -123,7 +156,17 @@ ADD_EXECUTABLE(accel-pppd
main.c
)
-TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre)
+# check if we have getcontext/setcontext
+INCLUDE(CheckFunctionExists)
+CHECK_FUNCTION_EXISTS(getcontext HAVE_GETCONTEXT)
+CHECK_FUNCTION_EXISTS(setcontext HAVE_SETCONTEXT)
+
+IF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)
+ TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre)
+ELSE (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)
+ TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre ucontext)
+ENDIF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT)
+
set_property(TARGET accel-pppd PROPERTY CMAKE_SKIP_BUILD_RPATH FALSE)
set_property(TARGET accel-pppd PROPERTY CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set_property(TARGET accel-pppd PROPERTY INSTALL_RPATH_USE_LINK_PATH FALSE)
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index e80ffd00..abfd1ac9 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -4,6 +4,8 @@ log_file
#log_tcp
#log_pgsql
+connlimit
+
pptp
l2tp
#sstp
@@ -25,7 +27,7 @@ pppd_compat
#shaper
#net-snmp
#logwtmp
-#connlimit
+
#ipv6_nd
#ipv6_dhcp
diff --git a/accel-pppd/ctrl/ipoe/arp.c b/accel-pppd/ctrl/ipoe/arp.c
index e9b55ff4..ef9d3859 100644
--- a/accel-pppd/ctrl/ipoe/arp.c
+++ b/accel-pppd/ctrl/ipoe/arp.c
@@ -13,7 +13,9 @@
#include <netinet/ip.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
+#ifdef HAVE_GOOD_IFARP
#include <linux/if_arp.h>
+#endif
#include <linux/if_packet.h>
#include "list.h"
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 61b7c238..95ff8568 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -15,7 +15,9 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/if.h>
+#ifdef HAVE_GOOD_IFARP
#include <linux/if_arp.h>
+#endif
#include <linux/route.h>
#include <pcre.h>
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 027d7100..9fc2283c 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -853,7 +853,11 @@ static void l2tp_tunnel_free_sessions(struct l2tp_conn_t *conn)
void *sessions = conn->sessions;
conn->sessions = NULL;
+#ifdef HAVE_FREE_FN_T
tdestroy(sessions, (__free_fn_t)l2tp_session_free);
+#else
+ tdestroy(sessions, free);
+#endif
/* Let l2tp_session_free() handle the session counter and
* the reference held by the tunnel.
*/
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 76684285..dd623acc 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -11,7 +11,9 @@
#include <net/ethernet.h>
#include <netpacket/packet.h>
#include <arpa/inet.h>
+#ifdef HAVE_PRINTF_H
#include <printf.h>
+#endif
#include "crypto.h"