diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-05-13 09:17:44 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-05-13 09:17:44 +0100 |
commit | ce6655a372b67dbf744e1301300bef7c81ab2cb8 (patch) | |
tree | 40205742efceb2af63cdba4faf164309f84f59b6 /net-dialup/rp-pppoe/files/rp-pppoe-3.15-no_max_interfaces.patch | |
parent | 0e968c4f90483490ac9579b6b2da60032ad311d9 (diff) |
net-dialup/rp-pppoe : import from gentoo, fix build
Diffstat (limited to 'net-dialup/rp-pppoe/files/rp-pppoe-3.15-no_max_interfaces.patch')
-rw-r--r-- | net-dialup/rp-pppoe/files/rp-pppoe-3.15-no_max_interfaces.patch | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/net-dialup/rp-pppoe/files/rp-pppoe-3.15-no_max_interfaces.patch b/net-dialup/rp-pppoe/files/rp-pppoe-3.15-no_max_interfaces.patch new file mode 100644 index 00000000..ecf70f09 --- /dev/null +++ b/net-dialup/rp-pppoe/files/rp-pppoe-3.15-no_max_interfaces.patch @@ -0,0 +1,91 @@ +pppoe-server: MAX_INTERFACES 64 is a problem for ULS. + +We currently require 77 interfaces, this code just lifts the limit entirely and +will keep adding interfaces for as much RAM as you have to store an array as +required. + +Signed-off-by: Jaco Kroon <jaco@uls.co.za> + +diff -rau rp-pppoe-3.15/src.o/pppoe-server.c rp-pppoe-3.15/src/pppoe-server.c +--- rp-pppoe-3.15.o/src/pppoe-server.c 2021-05-07 15:18:00.000000000 +0200 ++++ rp-pppoe-3.15/src/pppoe-server.c 2021-12-07 21:53:46.755693003 +0200 +@@ -115,8 +115,9 @@ + ClientSession *BusySessions = NULL; + + /* Interfaces we're listening on */ +-Interface interfaces[MAX_INTERFACES]; ++Interface *interfaces = NULL; + int NumInterfaces = 0; ++int MaxInterfaces = 0; + + /* The number of session slots */ + size_t NumSessionSlots; +@@ -1235,11 +1236,16 @@ + exit(1); + } + +- memset(interfaces, 0, sizeof(interfaces)); +- + /* Initialize syslog */ + openlog("pppoe-server", LOG_PID, LOG_DAEMON); + ++ MaxInterfaces = INIT_INTERFACES; ++ interfaces = malloc(sizeof(*interfaces) * INIT_INTERFACES); ++ if (!interfaces) { ++ fprintf(stderr, "Out of memory allocating initial interfaces.\n"); ++ exit(1); ++ } ++ + /* Default number of session slots */ + NumSessionSlots = DEFAULT_MAX_SESSIONS; + MaxSessionsPerMac = 0; /* No limit */ +@@ -1406,10 +1412,14 @@ + break; + + case 'I': +- if (NumInterfaces >= MAX_INTERFACES) { +- fprintf(stderr, "Too many -I options (max %d)\n", +- MAX_INTERFACES); +- exit(EXIT_FAILURE); ++ if (NumInterfaces >= MaxInterfaces) { ++ MaxInterfaces *= 2; ++ interfaces = realloc(interfaces, sizeof(*interfaces) * MaxInterfaces); ++ if (!interfaces) { ++ fprintf(stderr, "Memory allocation failure trying to increase MaxInterfaces to %d\n", ++ MaxInterfaces); ++ exit(EXIT_FAILURE); ++ } + } + found = 0; + for (i=0; i<NumInterfaces; i++) { +@@ -1419,6 +1429,7 @@ + } + } + if (!found) { ++ memset(&interfaces[NumInterfaces], 0, sizeof(*interfaces)); + strncpy(interfaces[NumInterfaces].name, optarg, IFNAMSIZ); + NumInterfaces++; + } +diff -rau rp-pppoe-3.15/src.o/pppoe-server.h rp-pppoe-3.15/src/pppoe-server.h +--- rp-pppoe-3.15/src.o/pppoe-server.h 2021-05-07 15:18:00.000000000 +0200 ++++ rp-pppoe-3.15/src/pppoe-server.h 2021-12-07 21:44:09.945578094 +0200 +@@ -97,8 +97,8 @@ + /* Hack for daemonizing */ + #define CLOSEFD 64 + +-/* Max. number of interfaces to listen on */ +-#define MAX_INTERFACES 64 ++/* Initial Max. number of interfaces to listen on */ ++#define INIT_INTERFACES 8 + + /* Max. 64 sessions by default */ + #define DEFAULT_MAX_SESSIONS 64 +@@ -107,7 +107,7 @@ + extern ClientSession *Sessions; + + /* Interfaces we're listening on */ +-extern Interface interfaces[MAX_INTERFACES]; ++extern Interface *interfaces; + extern int NumInterfaces; + + /* The number of session slots */ |