Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-dialup/rp-pppoe/files/, net-dialup/rp-pppoe/
Date: Wed, 19 Jan 2022 11:35:09
Message-Id: 1642592065.c58d8c6e42efe8282c8e569315d418b41a9e1312.polynomial-c@gentoo
1 commit: c58d8c6e42efe8282c8e569315d418b41a9e1312
2 Author: Jaco Kroon <jaco <AT> uls <DOT> co <DOT> za>
3 AuthorDate: Tue Dec 7 20:08:24 2021 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 19 11:34:25 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c58d8c6e
7
8 net-dialup/rp-pppoe: 3.15-r2 - remove MAX_INTERFACES limit.
9
10 The 64 MAX_INTERFACES is a problem for us. To make matters worse the
11 number of interfaces we need to listen on are climbing at an alarming
12 rate. Need a single pppoe-server instance to share IP pool.
13
14 Package-Manager: Portage-3.0.28, Repoman-3.0.3
15 Signed-off-by: Jaco Kroon <jaco <AT> uls.co.za>
16 Closes: https://github.com/gentoo/gentoo/pull/23213
17 Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
18
19 .../files/rp-pppoe-3.15-no_max_interfaces.patch | 91 +++++++++++++++++++++
20 net-dialup/rp-pppoe/rp-pppoe-3.15-r2.ebuild | 93 ++++++++++++++++++++++
21 2 files changed, 184 insertions(+)
22
23 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
24 new file mode 100644
25 index 000000000000..ecf70f09ddc6
26 --- /dev/null
27 +++ b/net-dialup/rp-pppoe/files/rp-pppoe-3.15-no_max_interfaces.patch
28 @@ -0,0 +1,91 @@
29 +pppoe-server: MAX_INTERFACES 64 is a problem for ULS.
30 +
31 +We currently require 77 interfaces, this code just lifts the limit entirely and
32 +will keep adding interfaces for as much RAM as you have to store an array as
33 +required.
34 +
35 +Signed-off-by: Jaco Kroon <jaco@××××××.za>
36 +
37 +diff -rau rp-pppoe-3.15/src.o/pppoe-server.c rp-pppoe-3.15/src/pppoe-server.c
38 +--- rp-pppoe-3.15.o/src/pppoe-server.c 2021-05-07 15:18:00.000000000 +0200
39 ++++ rp-pppoe-3.15/src/pppoe-server.c 2021-12-07 21:53:46.755693003 +0200
40 +@@ -115,8 +115,9 @@
41 + ClientSession *BusySessions = NULL;
42 +
43 + /* Interfaces we're listening on */
44 +-Interface interfaces[MAX_INTERFACES];
45 ++Interface *interfaces = NULL;
46 + int NumInterfaces = 0;
47 ++int MaxInterfaces = 0;
48 +
49 + /* The number of session slots */
50 + size_t NumSessionSlots;
51 +@@ -1235,11 +1236,16 @@
52 + exit(1);
53 + }
54 +
55 +- memset(interfaces, 0, sizeof(interfaces));
56 +-
57 + /* Initialize syslog */
58 + openlog("pppoe-server", LOG_PID, LOG_DAEMON);
59 +
60 ++ MaxInterfaces = INIT_INTERFACES;
61 ++ interfaces = malloc(sizeof(*interfaces) * INIT_INTERFACES);
62 ++ if (!interfaces) {
63 ++ fprintf(stderr, "Out of memory allocating initial interfaces.\n");
64 ++ exit(1);
65 ++ }
66 ++
67 + /* Default number of session slots */
68 + NumSessionSlots = DEFAULT_MAX_SESSIONS;
69 + MaxSessionsPerMac = 0; /* No limit */
70 +@@ -1406,10 +1412,14 @@
71 + break;
72 +
73 + case 'I':
74 +- if (NumInterfaces >= MAX_INTERFACES) {
75 +- fprintf(stderr, "Too many -I options (max %d)\n",
76 +- MAX_INTERFACES);
77 +- exit(EXIT_FAILURE);
78 ++ if (NumInterfaces >= MaxInterfaces) {
79 ++ MaxInterfaces *= 2;
80 ++ interfaces = realloc(interfaces, sizeof(*interfaces) * MaxInterfaces);
81 ++ if (!interfaces) {
82 ++ fprintf(stderr, "Memory allocation failure trying to increase MaxInterfaces to %d\n",
83 ++ MaxInterfaces);
84 ++ exit(EXIT_FAILURE);
85 ++ }
86 + }
87 + found = 0;
88 + for (i=0; i<NumInterfaces; i++) {
89 +@@ -1419,6 +1429,7 @@
90 + }
91 + }
92 + if (!found) {
93 ++ memset(&interfaces[NumInterfaces], 0, sizeof(*interfaces));
94 + strncpy(interfaces[NumInterfaces].name, optarg, IFNAMSIZ);
95 + NumInterfaces++;
96 + }
97 +diff -rau rp-pppoe-3.15/src.o/pppoe-server.h rp-pppoe-3.15/src/pppoe-server.h
98 +--- rp-pppoe-3.15/src.o/pppoe-server.h 2021-05-07 15:18:00.000000000 +0200
99 ++++ rp-pppoe-3.15/src/pppoe-server.h 2021-12-07 21:44:09.945578094 +0200
100 +@@ -97,8 +97,8 @@
101 + /* Hack for daemonizing */
102 + #define CLOSEFD 64
103 +
104 +-/* Max. number of interfaces to listen on */
105 +-#define MAX_INTERFACES 64
106 ++/* Initial Max. number of interfaces to listen on */
107 ++#define INIT_INTERFACES 8
108 +
109 + /* Max. 64 sessions by default */
110 + #define DEFAULT_MAX_SESSIONS 64
111 +@@ -107,7 +107,7 @@
112 + extern ClientSession *Sessions;
113 +
114 + /* Interfaces we're listening on */
115 +-extern Interface interfaces[MAX_INTERFACES];
116 ++extern Interface *interfaces;
117 + extern int NumInterfaces;
118 +
119 + /* The number of session slots */
120
121 diff --git a/net-dialup/rp-pppoe/rp-pppoe-3.15-r2.ebuild b/net-dialup/rp-pppoe/rp-pppoe-3.15-r2.ebuild
122 new file mode 100644
123 index 000000000000..e7433bcf2749
124 --- /dev/null
125 +++ b/net-dialup/rp-pppoe/rp-pppoe-3.15-r2.ebuild
126 @@ -0,0 +1,93 @@
127 +# Copyright 1999-2021 Gentoo Authors
128 +# Distributed under the terms of the GNU General Public License v2
129 +
130 +EAPI=7
131 +
132 +inherit autotools readme.gentoo-r1 toolchain-funcs
133 +
134 +PATCHSET="${PN}-3.14-patches-01"
135 +PATCHES=(
136 + "${FILESDIR}/rp-pppoe-3.15-no_max_interfaces.patch"
137 +)
138 +
139 +DESCRIPTION="A user-mode PPPoE client and server suite for Linux"
140 +HOMEPAGE="https://dianne.skoll.ca/projects/rp-pppoe/"
141 +SRC_URI="https://dianne.skoll.ca/projects/rp-pppoe/download/${P}.tar.gz
142 + https://dev.gentoo.org/~polynomial-c/dist/${PATCHSET}.tar.xz"
143 +
144 +LICENSE="GPL-2"
145 +SLOT="0"
146 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
147 +IUSE="tk"
148 +
149 +RDEPEND="
150 + net-dialup/ppp:=
151 + sys-apps/iproute2
152 + tk? ( dev-lang/tk:= )
153 +"
154 +DEPEND=">=sys-kernel/linux-headers-2.6.25
155 + ${RDEPEND}"
156 +
157 +DOC_CONTENTS="Use pppoe-setup to configure your dialup connection"
158 +
159 +pkg_setup() {
160 + # This is needed in multiple phases
161 + PPPD_VER="$(best_version net-dialup/ppp)"
162 + PPPD_VER="${PPPD_VER#*/*-}" #reduce it to ${PV}-${PR}
163 + PPPD_VER="${PPPD_VER%%-*}" #reduce it to ${PV}
164 +
165 + PPPD_PLUGIN_DIR="/usr/$(get_libdir)/pppd/${PPPD_VER}"
166 +}
167 +
168 +src_prepare() {
169 + if ! use elibc_musl ; then
170 + rm "${WORKDIR}/patches/${PN}-3.14-musl.patch" || die
171 + fi
172 +
173 + rm "${WORKDIR}/patches/${PN}-3.14-ifconfig-path.patch" || die
174 +
175 + eapply "${WORKDIR}/patches"
176 + eapply "${PATCHES[@]}"
177 + eapply_user
178 +
179 + cd "${S}"/src || die
180 + eautoreconf
181 +}
182 +
183 +src_configure() {
184 + addpredict /dev/ppp
185 +
186 + cd src || die
187 +
188 + econf --enable-plugin=/usr/include/pppd
189 +}
190 +
191 +src_compile() {
192 + cd src || die
193 + emake AR="$(tc-getAR)" PLUGIN_PATH=rp-pppoe.so PLUGIN_DIR="${PPPD_PLUGIN_DIR}"
194 +
195 + if use tk ; then
196 + emake -C "${S}/gui"
197 + fi
198 +}
199 +
200 +src_install() {
201 + cd src || die
202 + emake DESTDIR="${D}" docdir="/usr/share/doc/${PF}" PLUGIN_DIR="${PPPD_PLUGIN_DIR}" install
203 +
204 + # We don't need this README file here.
205 + rm "${ED}${PPPD_PLUGIN_DIR}/README" || die "Error removing ${PPPD_PLUGIN_DIR}/README from installation"
206 +
207 + if use tk ; then
208 + emake -C "${S}/gui" \
209 + DESTDIR="${D}" \
210 + datadir=/usr/share/doc/${PF}/ \
211 + install
212 + dosym doc/${PF}/tkpppoe /usr/share/tkpppoe
213 + fi
214 +
215 + newinitd "${FILESDIR}"/pppoe-server.initd pppoe-server
216 + newconfd "${FILESDIR}"/pppoe-server.confd pppoe-server
217 +
218 + readme.gentoo_create_doc
219 +}