Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SO_REUSEPORT in FreeBSD #13

Open
marcos-ng opened this issue Apr 24, 2023 · 0 comments
Open

Support SO_REUSEPORT in FreeBSD #13

marcos-ng opened this issue Apr 24, 2023 · 0 comments

Comments

@marcos-ng
Copy link

marcos-ng commented Apr 24, 2023

SO_REUSEPORT enables duplicate address and port bindings

https://man.freebsd.org/cgi/man.cgi?query=setsockopt&manpath=FreeBSD+14.0-CURRENT

With this added to the package, both this app and miniupnpd (as of 2.2.2) can both listen to e.g. UDP/1900 at the same time.

From 29e5b998f922c1e04052e5ffc4e0d642ed8b78cb Mon Sep 17 00:00:00 2001
From: Kristof Provost <[email protected]>
Date: Fri, 10 May 2024 13:36:13 -0600
Subject: [PATCH] set SO_REUSEPORT

Allows udpbroadcastrelay to share the port binding with other processes.

diff --git a/main.c b/main.c
index db28944..0712bde 100644
--- a/main.c
+++ b/main.c
@@ -1975,6 +1975,11 @@ srandom(time(NULL) ^ getpid());
           exit(1);
       };
 
+    int yes = 1;
+    if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)) != 0) {
+        perror("setsockopt");
+        exit(1);
+    }
 
     /* For each interface on the command line */
     for (int i = 0; i < interfaceNamesNum; i++) {

I'm making this available here instead of an MR given that it's only been tested with a previous version (currently available in FreeBSD 15).

@marcos-ng marcos-ng changed the title Support SO_REUSEPORT_LB in FreeBSD Support SO_REUSEPORT in FreeBSD May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant