Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109822617
D48543.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D48543.diff
View Options
diff --git a/contrib/netcat/nc.1 b/contrib/netcat/nc.1
--- a/contrib/netcat/nc.1
+++ b/contrib/netcat/nc.1
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 17, 2023
+.Dd January 20, 2025
.Dt NC 1
.Os
.Sh NAME
@@ -40,6 +40,7 @@
.Op Fl e Ar IPsec_policy
.Op Fl I Ar length
.Op Fl i Ar interval
+.Op Fl -lb
.Op Fl -no-tcpopt
.Op Fl -sctp
.Op Fl -crlf
@@ -175,6 +176,12 @@
Additionally, any timeouts specified with the
.Fl w
option are ignored.
+.It Fl -lb
+When using
+.Fl l ,
+put the socket in load-balancing mode.
+In this mode, multiple sockets can bind to the same address and port,
+and incoming connections are distributed among them.
.It Fl M
Collect per-connection TCP statistics using the
.Xr stats 3
diff --git a/contrib/netcat/netcat.c b/contrib/netcat/netcat.c
--- a/contrib/netcat/netcat.c
+++ b/contrib/netcat/netcat.c
@@ -89,6 +89,7 @@
unsigned int iflag; /* Interval Flag */
int kflag; /* More than one connect */
int lflag; /* Bind to local port */
+int FreeBSD_lb; /* Use SO_REUSEPORT_LB */
int FreeBSD_Mflag; /* Measure using stats(3) */
int Nflag; /* shutdown() network socket */
int nflag; /* Don't do name look up */
@@ -168,6 +169,7 @@
char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
struct option longopts[] = {
{ "crlf", no_argument, &FreeBSD_crlf, 1 },
+ { "lb", no_argument, &FreeBSD_lb, 1 },
{ "no-tcpopt", no_argument, &FreeBSD_Oflag, 1 },
{ "sctp", no_argument, &FreeBSD_sctp, 1 },
{ "tun", required_argument, NULL, FREEBSD_TUN },
@@ -371,6 +373,8 @@
errx(1, "cannot use -z and -l");
if (!lflag && kflag)
errx(1, "must use -l with -k");
+ if (!lflag && FreeBSD_lb)
+ errx(1, "must use -l with --lb");
if (FreeBSD_sctp) {
if (uflag)
errx(1, "cannot use -u and --sctp");
@@ -800,6 +804,8 @@
res0 = res;
do {
+ int opt;
+
if ((s = socket(res0->ai_family, res0->ai_socktype,
res0->ai_protocol)) < 0)
continue;
@@ -808,7 +814,8 @@
&rtableid, sizeof(rtableid)) == -1))
err(1, "setsockopt SO_SETFIB");
- ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
+ opt = FreeBSD_lb != 0 ? SO_REUSEPORT_LB : SO_REUSEPORT;
+ ret = setsockopt(s, SOL_SOCKET, opt, &x, sizeof(x));
if (ret == -1)
err(1, NULL);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 10, 11:59 PM (8 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16585617
Default Alt Text
D48543.diff (2 KB)
Attached To
Mode
D48543: netcat: Add a flag to enable the use of SO_REUSEPORT_LB
Attached
Detach File
Event Timeline
Log In to Comment