Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Dec 2024 15:02:32 GMT
From:      Michael Gmelin <grembo@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 9e46f71b468d - main - net/rinetd: Downgrade to 0.62, take maintainership
Message-ID:  <202412091502.4B9F2WTM087571@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by grembo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9e46f71b468dd8d6446d8960b818afbac5416d62

commit 9e46f71b468dd8d6446d8960b818afbac5416d62
Author:     Michael Gmelin <grembo@FreeBSD.org>
AuthorDate: 2024-12-09 13:57:13 +0000
Commit:     Michael Gmelin <grembo@FreeBSD.org>
CommitDate: 2024-12-09 15:01:57 +0000

    net/rinetd: Downgrade to 0.62, take maintainership
    
    This fixes massive performance issues, but also loses IPv6
    support.
    
    Updates will come back, once regressions have been corrected.
    
    PR:             281873
---
 net/rinetd/Makefile                    |  22 ++--
 net/rinetd/distinfo                    |   6 +-
 net/rinetd/files/patch-Makefile        |  22 ++++
 net/rinetd/files/patch-rinetd.c        | 210 +++++++++++++++++++++++++++++++++
 net/rinetd/files/patch-src_Makefile.am |  11 --
 net/rinetd/files/patch-src_rinetd.c    |  11 --
 net/rinetd/pkg-plist                   |   3 -
 7 files changed, 244 insertions(+), 41 deletions(-)

diff --git a/net/rinetd/Makefile b/net/rinetd/Makefile
index 0151bc1221c9..86ea7bda2bf0 100644
--- a/net/rinetd/Makefile
+++ b/net/rinetd/Makefile
@@ -1,24 +1,23 @@
 PORTNAME=	rinetd
-PORTVERSION=	0.73
-PORTREVISION=	2
+PORTVERSION=	0.62
 DISTVERSIONPREFIX=	v
+PORTEPOCH=	1
 CATEGORIES=	net
 
-MAINTAINER=	garga@FreeBSD.org
+MAINTAINER=	grembo@FreeBSD.org
 COMMENT=	Simple TCP port redirector
 WWW=		https://github.com/samhocevar/rinetd
 
 LICENSE=	GPLv2
 
-USES=		cpe dos2unix autoreconf
+USES=		cpe dos2unix
 USE_GITHUB=	yes
 GH_ACCOUNT=	samhocevar
-GH_TAGNAME=	d4e0a60
+GH_TAGNAME=	1c95abb27dbf3
 USE_RC_SUBR=	rinetd
 
-GNU_CONFIGURE=	yes
-GNU_CONFIGURE_MANPREFIX=	${PREFIX}/share
-
+PLIST_FILES=	sbin/rinetd \
+		share/man/man8/rinetd.8.gz
 PORTDOCS=	index.html
 
 OPTIONS_DEFINE=	DOCS
@@ -29,11 +28,8 @@ post-patch:
 			-e "s,/usr(/sbin/rinetd),${PREFIX}\1," \
 		${WRKSRC}/rinetd.8
 	@${REINPLACE_CMD} -E "s,(/etc/rinetd.conf),${PREFIX}\1," \
-		${WRKSRC}/src/rinetd.h
-
-post-install:
-	${MV} ${STAGEDIR}${PREFIX}/etc/rinetd.conf \
-		${STAGEDIR}${PREFIX}/etc/rinetd.conf.sample
+		${WRKSRC}/rinetd.c
+	@${REINPLACE_CMD} -e "s,cc ,${CC} ,g" ${WRKSRC}/Makefile
 
 post-install-DOCS-on:
 	${MKDIR} ${STAGEDIR}${DOCSDIR}
diff --git a/net/rinetd/distinfo b/net/rinetd/distinfo
index 7f43e7e364cf..40603a290e70 100644
--- a/net/rinetd/distinfo
+++ b/net/rinetd/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1696686326
-SHA256 (samhocevar-rinetd-v0.73-d4e0a60_GH0.tar.gz) = 76eef19e0af8459c9434ac8ac0b58edac1bba353f5aaceb1d5f971fb3f6a3016
-SIZE (samhocevar-rinetd-v0.73-d4e0a60_GH0.tar.gz) = 45544
+TIMESTAMP = 1733754055
+SHA256 (samhocevar-rinetd-v0.62-1c95abb27dbf3_GH0.tar.gz) = 6567abbcad830004b32eed8e0e21c9fb28a7843bd2916f60ab5d289d1f3327fd
+SIZE (samhocevar-rinetd-v0.62-1c95abb27dbf3_GH0.tar.gz) = 24036
diff --git a/net/rinetd/files/patch-Makefile b/net/rinetd/files/patch-Makefile
new file mode 100644
index 000000000000..1d9797822e2d
--- /dev/null
+++ b/net/rinetd/files/patch-Makefile
@@ -0,0 +1,22 @@
+--- Makefile.orig	2024-12-09 14:53:18 UTC
++++ Makefile
+@@ -1,9 +1,14 @@
+-CFLAGS=-DLINUX -g
++CFLAGS+=-I. -DLINUX
+ 
+-rinetd: rinetd.o match.o
+-	gcc rinetd.o match.o -o rinetd
++all: rinetd
+ 
++rinetd: rinetd.o match.o getopt.o
++	${CC} ${CFLAGS} rinetd.o match.o getopt.o -o rinetd
++
++getopt.o:
++	${CC} ${CFLAGS} -c getopt.c
++
+ install: rinetd
+-	install -m 700 rinetd /usr/sbin
+-	install -m 644 rinetd.8 /usr/man/man8
++	install -s -m 755 rinetd ${DESTDIR}${PREFIX}/sbin
++	install -m 644 rinetd.8 ${DESTDIR}${PREFIX}/share/man/man8
+ 
diff --git a/net/rinetd/files/patch-rinetd.c b/net/rinetd/files/patch-rinetd.c
new file mode 100644
index 000000000000..11df38569ea4
--- /dev/null
+++ b/net/rinetd/files/patch-rinetd.c
@@ -0,0 +1,210 @@
+--- rinetd.c.orig	2024-12-09 14:53:18 UTC
++++ rinetd.c
+@@ -12,6 +12,7 @@
+ #include <netinet/in.h>
+ #include <getopt.h>
+ #include <errno.h>
++#include <poll.h>
+ #define INVALID_SOCKET (-1)
+ #include <sys/time.h>
+ #endif /* WIN32 */
+@@ -94,6 +95,7 @@ void Sleep(long ms)
+ #include "match.h"
+ 
+ SOCKET *seFds = 0;
++static int first_set = 0;
+ /* In network order, for network purposes */
+ struct in_addr *seLocalAddrs = 0;
+ unsigned short *seLocalPorts = 0;
+@@ -243,6 +245,7 @@ int main(int argc, char *argv[])
+ 			signal(SIGHUP, hup);
+ #endif /* WIN32 */
+ 			signal(SIGTERM, term);
++			setsid();
+ 			initArrays();
+ 			readConfiguration();
+ 			RegisterPID();
+@@ -646,6 +649,7 @@ void readConfiguration(void)
+ 			}
+ 		}
+ 	}
++	fclose(in);
+ 	/* Open the log file */
+ 	if (logFile) {
+ 		fclose(logFile);
+@@ -750,15 +754,82 @@ void handleAccept(int i);
+ void openLocalFd(int se, int i);
+ int getAddress(char *host, struct in_addr *iaddr);
+ 
++inline void poll_init_fds(struct pollfd *pfds, int size) {
++	int i;
++
++	memset(pfds, 0, sizeof(struct pollfd) * size);
++	first_set = 1;
++	for(i = 0; i < size; i++) 
++		pfds[i].fd = -1;
++}
++
++inline int poll_set_fd(struct pollfd *pfds, int size, int count, 
++		 int fd, short int ev) {
++#ifdef _NEW_POLL_SET_FD
++	if(first_set) {
++		pfds[count].fd = fd;
++		pfds[count].events |= ev;
++		first_set = 0;
++		return 0;
++	}
++	if(pfds[count].fd != fd && !first_set) {
++		count++;
++	}
++
++	pfds[count].fd = fd;
++	pfds[count].events |= ev;
++	
++	return count;
++#else
++	int i;
++	
++	for(i = 0; i < size; i++) {
++		if(pfds[i].fd == -1) {
++			pfds[i].fd = fd;
++			pfds[i].events |= ev;
++			count++;
++			break;
++		}
++		if(pfds[i].fd == fd) {
++			pfds[i].events |= ev;
++			break;
++		}
++	}
++
++	return count;
++#endif
++}
++
++int poll_fd_isset(struct pollfd *pfds, int nfds, int fd, short event) {
++	int i;
++
++	for(i = 0; i < nfds; i++) {
++		if(pfds[i].fd == fd)
++			return pfds[i].revents & event;
++	}
++
++	return 0;
++}
++
+ void selectPass(void) {
+ 	int i;
+-	fd_set readfds, writefds;
+-	FD_ZERO(&readfds);
+-	FD_ZERO(&writefds);
++	int nfds = 0;
++	int total = 0;
++	static struct pollfd *pfds = NULL;
++	
+ 	/* Server sockets */
++	total = seTotal + (coTotal * 2);
++	
++	if(!pfds) {
++		pfds = malloc(sizeof(struct pollfd) * total);
++	}
++	
++	poll_init_fds(pfds, total);
++	
+ 	for (i = 0; (i < seTotal); i++) {
+ 		if (seFds[i] != INVALID_SOCKET) {
+-			FD_SET(seFds[i], &readfds);
++			//FD_SET(seFds[i], &readfds)
++			nfds = poll_set_fd(pfds, total, nfds, seFds[i], POLLIN);
+ 		}
+ 	}
+ 	/* Connection sockets */
+@@ -768,35 +839,47 @@ void selectPass(void) {
+ 		}
+ 		if (coClosing[i]) {
+ 			if (!reClosed[i]) {
+-				FD_SET(reFds[i], &writefds);
++				//FD_SET(reFds[i], &writefds);
++				nfds = poll_set_fd(pfds, total, nfds, 
++					    reFds[i], POLLOUT);
+ 			}	
+-			if (!loClosed[i]) {
+-				FD_SET(loFds[i], &writefds);
+-			}	
+ 		}
+ 		/* Get more input if we have room for it */
+ 		if ((!reClosed[i]) && (coInputRPos[i] < bufferSpace)) {
+-			FD_SET(reFds[i], &readfds);
++			//FD_SET(reFds[i], &readfds);
++			nfds = poll_set_fd(pfds, total, nfds, reFds[i], POLLIN);
+ 		}
+ 		/* Send more output if we have any */	
+ 		if ((!reClosed[i]) && (coOutputWPos[i] < coOutputRPos[i])) {
+-			FD_SET(reFds[i], &writefds);
++			//FD_SET(reFds[i], &writefds);
++			nfds = poll_set_fd(pfds, total, nfds, reFds[i], POLLOUT);
+ 		}	
++		if (coClosing[i]) {
++			if (!loClosed[i]) {
++				//FD_SET(loFds[i], &writefds);
++				nfds = poll_set_fd(pfds, total, nfds,
++					    loFds[i], POLLOUT);
++			}
++		}
+ 		/* Accept more output from the local 
+ 			server if there's room */
+ 		if ((!loClosed[i]) && (coOutputRPos[i] < bufferSpace)) {
+-			FD_SET(loFds[i], &readfds);
++			//FD_SET(loFds[i], &readfds);
++			 nfds = poll_set_fd(pfds, total, nfds, loFds[i], POLLIN);
+ 		}
+ 		/* Send more input to the local server 
+ 			if we have any */
+ 		if ((!loClosed[i]) && (coInputWPos[i] < coInputRPos[i])) {
+-			FD_SET(loFds[i], &writefds);
++			//FD_SET(loFds[i], &writefds);
++			nfds = poll_set_fd(pfds, total, nfds, loFds[i], POLLOUT);
+ 		}	
+ 	}
+-	select(maxfd + 1, &readfds, &writefds, 0, 0);
++	//select(maxfd + 1, &readfds, &writefds, 0, 0);
++	poll(pfds, nfds + 1, -1);
+ 	for (i = 0; (i < seTotal); i++) {
+ 		if (seFds[i] != -1) {
+-			if (FD_ISSET(seFds[i], &readfds)) {
++			//if (FD_ISSET(seFds[i], &readfds)) {
++			if (poll_fd_isset(pfds, nfds, seFds[i], POLLIN)) {
+ 				handleAccept(i);
+ 			}
+ 		}
+@@ -806,22 +889,26 @@ void selectPass(void) {
+ 			continue;
+ 		}
+ 		if (!reClosed[i]) {
+-			if (FD_ISSET(reFds[i], &readfds)) {
++			//if (FD_ISSET(reFds[i], &readfds)) {
++			if (poll_fd_isset(pfds, nfds, reFds[i], POLLIN)) {
+ 				handleRemoteRead(i);
+ 			}
+ 		}
+ 		if (!reClosed[i]) {
+-			if (FD_ISSET(reFds[i], &writefds)) {
++			//if (FD_ISSET(reFds[i], &writefds)) {
++			if (poll_fd_isset(pfds, nfds, reFds[i], POLLOUT)) {
+ 				handleRemoteWrite(i);
+ 			}
+ 		}
+ 		if (!loClosed[i]) {
+-			if (FD_ISSET(loFds[i], &readfds)) {
++			//if (FD_ISSET(loFds[i], &readfds)) {
++			if (poll_fd_isset(pfds, nfds, loFds[i], POLLIN)) {
+ 				handleLocalRead(i);
+ 			}
+ 		}
+ 		if (!loClosed[i]) {
+-			if (FD_ISSET(loFds[i], &writefds)) {
++			//if (FD_ISSET(loFds[i], &writefds)) {
++			if (poll_fd_isset(pfds, nfds, loFds[i], POLLOUT)) {
+ 				handleLocalWrite(i);
+ 			}
+ 		}
diff --git a/net/rinetd/files/patch-src_Makefile.am b/net/rinetd/files/patch-src_Makefile.am
deleted file mode 100644
index 1ab42eb1cad7..000000000000
--- a/net/rinetd/files/patch-src_Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
---- src/Makefile.am.orig	2023-10-07 16:13:36 UTC
-+++ src/Makefile.am
-@@ -18,7 +18,7 @@ parse.c: parse.peg
- # _DARWIN_C_SOURCE is for NI_MAXHOST on OS X
- # _XOPEN_SOURCE is for struct sigaction
- # _GNU_SOURCE is for h_errno and gethostbyname-related macros
--___rinetd_CFLAGS = -std=c99 -D_POSIX_C_SOURCE=200809L \
-+___rinetd_CFLAGS = -std=c99 \
-                    -D_XOPEN_SOURCE -D_GNU_SOURCE -D_DARWIN_C_SOURCE \
-                    -Wall -Wextra -Wwrite-strings
- 
diff --git a/net/rinetd/files/patch-src_rinetd.c b/net/rinetd/files/patch-src_rinetd.c
deleted file mode 100644
index 5f0ea6dc73b1..000000000000
--- a/net/rinetd/files/patch-src_rinetd.c
+++ /dev/null
@@ -1,11 +0,0 @@
---- src/rinetd.c.orig	2023-10-07 16:13:36 UTC
-+++ src/rinetd.c
-@@ -927,7 +927,7 @@ RETSIGTYPE quit(int s)
- 
- void registerPID(char const *pid_file_name)
- {
--#if defined(__linux__)
-+#if defined(__linux__) || defined(__FreeBSD__)
- 	FILE *pid_file = fopen(pid_file_name, "w");
- 	if (pid_file == NULL) {
- 		/* non-fatal, non-Linux may lack /var/run... */
diff --git a/net/rinetd/pkg-plist b/net/rinetd/pkg-plist
deleted file mode 100644
index 4942042aa806..000000000000
--- a/net/rinetd/pkg-plist
+++ /dev/null
@@ -1,3 +0,0 @@
-@sample etc/rinetd.conf.sample
-sbin/rinetd
-share/man/man8/rinetd.8.gz



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202412091502.4B9F2WTM087571>