Commit graph

7802 commits

Author SHA1 Message Date
Richard Scheffenegger
1fdbb16f40 tcp: add PRR 6937bis heuristic and retire prr_conservative sysctl
Improve Proportional Rate Reduction (RFC6937) by using a
heuristic, which automatically chooses between
conservative CRB and more aggressive SSRB modes.
Only when snd_una advances (a partial ACK), SSRB may be
used. Also, that ACK must not have any indication of
ongoing loss - using the addition of new holes into the
scoreboard as proxy for such an event.

MFC after: 4 weeks
Reviewed By: #transport, kbowling, rrs
Sponsored By: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D28822

(cherry picked from commit 49a6fbe38728173da74d5b497f700178e2a6c830)
2023-12-15 09:25:07 +01:00
Richard Scheffenegger
544bfa7cea tcp: properly initialize LRD while accepting session in syncache
Inherit the setting from the listener socket in syncache_socket.

MFC after:             2 weeks
Reviewed By:           tuexen, #transport
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D42874

(cherry picked from commit f071abd92e726fc12e9256662e1f286f364252ee)
2023-12-15 09:23:45 +01:00
Kristof Provost
daaaeb3051 vnet: (read) lock the vnet list while iterating it
Ensure that the vnet list cannot be modified while we're running through
it.

Reviewed by:	mjg (previous version), zlei (previous version)
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42927

(cherry picked from commit bd7b2f95019e9715150c34736279805de0818d09)
2023-12-14 12:20:25 +01:00
Richard Scheffenegger
35707083c6 tcp: shift PRR sending cadence slightly left
Don't let PRR pass up on the opportunity of clocking
out packets on arrival of ACKs - by pulling sends
forward by about half a packet. Prevents unexpectedly
long runs of incoming ACKs without eliciting a
packet transmission.

MFC after:             1 week
Reviewed By:           #transport, tuexen
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D42918

(cherry picked from commit 9276ad23b872eddc42e05304acb10bf5421b043c)
2023-12-14 11:13:09 +01:00
Mitchell Horne
bbfd41d430 alq, siftr: add panic/debugger checks to shutdown hooks
Don't try to gracefully terminate the pkt_manager thread if the
scheduler is not running.

We should not attempt to shutdown ald if RB_NOSYNC is set, and must not
if the scheduler is stopped (the function calls wakeup()).

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42340

(cherry picked from commit d79a9edb5ce162c1ba49e12e5c93b894e6a25ad2)
2023-12-08 18:02:44 -04:00
Igor Ostapenko
46a96d68f6 ip_var.h: align comment style
MFC after:	2 weeks
Reviewed by:	kp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/883

(cherry picked from commit b68d2789f0d745d420203ca7dae9408f81cc7206)
2023-11-09 10:56:26 +01:00
Kristof Provost
3903a749c8 pf: use an enum for packet direction in divert tag
The benefit is that in the debugger you will see PF_DIVERT_MTAG_DIR_IN
instead of 1 when looking at a structure. And compilation time failure
if anybody sets it to a wrong value. Using "port" instead of "ndir" when
assigning a port improves readability of code.

Suggested by:	glebius
MFC after:	3 weeks
X-MFC-With:	fabf705f4b

(cherry picked from commit c1146e6ad67fb866c2472a1cbe5609fd939fd5ef)
2023-11-09 10:56:20 +01:00
Igor Ostapenko
2f3f9c9d54 pf: fix pf divert-to loop
Resolved conflict between ipfw and pf if both are used and pf wants to
do divert(4) by having separate mtags for pf and ipfw.

Also fix the incorrect 'rulenum' check, which caused the reported loop.

While here add a few test cases to ensure that divert-to works as
expected, even if ipfw is loaded.

divert(4)
PR:		272770
MFC after:	3 weeks
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D42142

(cherry picked from commit fabf705f4b5aff2fa2dc997c2d0afd62a6927e68)
2023-11-09 10:55:45 +01:00
Olivier Certner
e1153205a7 Fix 'security.bsd.see_jail_proc' by using cr_bsd_visible()
As implemented, this security policy would only prevent seeing processes
in sub-jails, but would not prevent sending signals to, changing
priority of or debugging processes in these, enabling attacks where
unprivileged users could tamper with random processes in sub-jails in
particular circumstances (conflated UIDs) despite the policy being
enforced.

PR:                     272092
Reviewed by:            mhorne
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40628

(cherry picked from commit 5817169bc4a06a35aa5ef7f5ed18f6cb35037e18)
2023-10-17 16:42:58 -03:00
Zhenlei Huang
fd9de12a71 sctp: Various fixes for loader tunables
The following sysctl variables are actually loader tunables. Add sysctl
flag CTLFLAG_TUN to them so that `sysctl -T` will report them correctly.

 1. net.inet.sctp.tcbhashsize
 2. net.inet.sctp.pcbhashsize
 3. net.inet.sctp.chunkscale

The loader tunable 'net.inet.sctp.tcbhashsize' and 'net.inet.sctp.chunkscale'
are only used during vnet initializing, thus it make no senses to make them
writable tunable.

Validate the values of loader tunables on vnet initialize, reset them to
theirs defaults if invalid to prevent potential kernel panics.

Reviewed by:	tuexen, #transport, #network
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42007

(cherry picked from commit dac91eb7660324677d8a2f71bd6f192422355ba1)
2023-10-16 23:15:37 +08:00
Zhenlei Huang
3a97686fc1 tcp: Simplify the initialization of loader tunable 'net.inet.tcp.tcbhashsize'
No functional change intended.

Reviewed by:	cc, rscheff, #transport
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41998

(cherry picked from commit 38ecc80b2a4e5e11ece83ca4df63632f0b6fa394)
2023-10-16 23:15:37 +08:00
Kristof Provost
ff15498894 netlink: move NETLINK define to opt_global.h
Move the NETLINK define into opt_global.h so we can rely on it being
set correctly, without having to remember to include opt_netlink.h.
This ensures that the NETLINK define is correctly set. If not we
may end up with unloadable modules, due to missing symbols (such as
nlmsg_get_group_writer).

PR:		274306
Reviewed by:	imp, markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42179

(cherry picked from commit ab393e9548f8cc0ee28499c411963b798ebb38a5)
2023-10-16 09:42:33 +02:00
Michael Tuexen
8209af15a6 udp: fix sending of IPv4-mapped addresses
The inp_vflags field must be adjusted during the call of
in_pcbbind_setup(). This is consistent with the other places in the
code, but not elegant at all.

PR:			274009
Reported by:		syzbot+81ccc423a2737ed031ac@syzkaller.appspotmail.com
Reported by:		syzbot+c8e3dac881bba85bc029@syzkaller.appspotmail.com
Reviewed by:		markj, rrs, rscheff
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D42031

(cherry picked from commit abca3ae7734f664ee9c5edc7a9d3a17e29180bdb)
2023-10-13 22:13:44 +02:00
Mark Johnston
d08ef6f7da netdump: Check the return value of ifunit_ref()
We may fail to match if the specific interface doesn't exist or was
renamed.

PR:		273715
Reported by:	grembo
MFC after:	1 week

(cherry picked from commit d94d07d58141dcff48f01c6b3e5a31de9d7a7938)
2023-10-08 20:41:42 -04:00
Zhenlei Huang
b0f026435a ip_mroute: Fix sysctl knobs
The loader tunable `net.inet.ip.mfchashsize` does not have corresponding
sysctl MIB entry. Just add it.

While here, the sysctl variable `net.inet.pim.squelch_wholepkt` is actually
a loader tunable. Add sysctl flag CTLFLAG_TUN to it so that `sysctl -T`
will report it correctly.

Reviewed by:	kp
Fixes:		443fc3176d Introduce a number of changes to the MROUTING code
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41997

(cherry picked from commit f549e22901b3a391c76659bee55802b1214112fd)
2023-10-02 08:49:38 +08:00
Alan Somers
2209676efe Fix padding in struct tcp_info
This structure should have the same size across different FreeBSD
versions to ensure backwards-compatibility.  It has since stable/6.  But
two recent changes added fields without compensating by reducing
padding:
945f9a7cc9 and
22c81cc516 .  Reduce padding to
compensate.

Direct commit to stable/14 because we decided to break compatibility in
FreeBSD 15 in order to add more fields.  Of course, that decision could
be reversed before 15.0-RELEASE.  See the review for details.

PR:		273902
MFC after:	1 week
Reviewed by:	tuexen, glebius
Differential Revision: https://reviews.freebsd.org/D41894
2023-09-22 10:57:03 -06:00
Michael Tuexen
7b21cccf9c sctp: further improve shutting down the read side of a socket
Deal with the case that the association is already gone.

Reported by:	syzbot+e256d42e9b390564530a@syzkaller.appspotmail.com
2023-09-15 19:48:02 +02:00
Michael Tuexen
c4e047ab6e sctp: improve shutting down the read side of a socket
When shutdown(..., SHUT_RD) or shutdown(..., SHUT_RDWR) is called,
really clean up the read queue and issue an ungraceful shutdown if
user messages are affected.

Reported by:	syzbot+d4e1d30d578891245f59@syzkaller.appspotmail.com
2023-09-15 19:45:42 +02:00
Michael Tuexen
78e5017cbe sctp: don't call sctp_ulp_notify() recursively
This does not work with the new locking scheme.
2023-09-15 19:43:30 +02:00
Michael Tuexen
2139107d2d sctp: cleanup locking for notifications
All notifications are now queued via sctp_ulp_notify(). Do
the locking of the inp read lock there and validate this in all
functions being used.
This is one step in avoiding race conditions when closing the
read end of an SCTP socket.
2023-09-15 19:41:16 +02:00
Michael Tuexen
8d7d28e8c8 sctp: make sure all SCTP RESET notifications use sctp_ulp_notify()
While there, improve consistency of the notification related code.
No functional change intended.
2023-09-15 19:38:29 +02:00
Michael Tuexen
0730555039 sctp: cleanup SCTP AUTH related notification
This makes consistent use of the parameters and ensures that
all SCTP AUTH related notifications are using sctp_ulp_notify().

No functional change intended.
2023-09-15 19:35:57 +02:00
Michael Tuexen
6cf1d4a323 sctp: cleanup
In particular, don't use a socket level flag, use the inp level one.
After adding appropriate locking, this will close a race condition.
2023-09-15 19:33:35 +02:00
Michael Tuexen
351792d4cf sctp: cleanup
No functional change intended. Just asserting the conditions when
being called.
2023-09-15 19:30:51 +02:00
Kristof Provost
70fbe797c0 mcast: fix memory leak in imf_purge()
The IGMP code buffers packets in the imf_inm->inm_scq mbufq, but does
not clear this queue when struct in_mfilter is freed by imf_purge().
This can cause memory leaks if IGMPv3 is used.

Purge the mbufq on imf_purge().

MFC after:	1 week
Approved by:	re (gjb)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41629

(cherry picked from commit fa03d37432caf17d56a931a9e6f5d9b06f102c5b)
2023-09-07 21:26:07 +02:00
Zhenlei Huang
144851777e tcp: Initialize the maximum number of entries in a client cookie cache bucket
This vnet loader tunable is defined with SYSCTL_PROC, thus will not be
initialized by kernel on vnet creating and will always have the default
value TCP_FASTOPEN_CCACHE_BUCKET_LIMIT_DEFAULT.

Fix by fetching the value from the corresponding kernel environment during
vnet constructing.

PR:		273509
Reviewed by:	#transport, tuexen
Approved by:	re (gjb)
Fixes:	c560df6f12 This is an implementation of the client side of TCP Fast Open (TFO) [RFC7413]
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41691

(cherry picked from commit 224aec05e732bb97a0d3c91142973b98a91238d1)
2023-09-06 12:07:49 +08:00
Michael Tuexen
847fa61fad sctp: improve handling of socket shutdown for reading
If a socket is marked as cannot read anymore, drop chunks which
should be added to a control element in the receive queue.
This is consistent with dropping control elements instead of
adding them in the same situation.

Reported by:	syzbot+291f6581cecb77097b16@syzkaller.appspotmail.com
MFC after:	1 week
2023-08-24 15:52:55 +02:00
Michael Tuexen
d18c845f99 sctp: improve handling of SHUTDOWN and SHUTDOWN ACK chunks
When handling a SHUTDOWN or SHUTDOWN ACK chunk detect if the peer
is violating the protocol by not having made sure all user messages
are reveived by the peer. If this situation is detected, abort the
association.

MFC after:	1 week
2023-08-23 08:36:15 +02:00
Marius Strobl
dc485b968d tcp_info: Add and export more FreeBSD-specific fields
This change adds struct tcp_info fields corresponding to the following
struct tcpcb ones:
- snd_una
- snd_max
- rcv_numsacks
- rcv_adv
- dupacks

Note that while both tcp_fill_info() and fill_tcp_info_from_tcb() are
extended accordingly, no counterpart of rcv_numsacks is available in
the cxgbe(4) TOE PCB, though.

Sponsored by:	NetApp, Inc. (originally)
2023-08-22 20:34:01 +02:00
Marius Strobl
8c6104c48e tcp_fill_info(): Change lock assertion on INPCB to locked only
This function actually only ever reads from the TCP PCB. Consequently,
also make the pointer to its TCP PCB parameter const.

Sponsored by:	NetApp, Inc. (originally)
2023-08-22 20:33:49 +02:00
Michael Tuexen
1095da7503 sctp: fix a warning
Fix an unused-but-set-variable warning for builds without INVARIANTS.

Reported by:	O. Hartmann
MFC after:	1 week
2023-08-19 13:24:02 +02:00
Michael Tuexen
4f14d4b6b7 sctp: cleanup handling of graceful shutdown of the peer
Don't handle a graceful shutdown of the peer as an implicit signal
that all partial messages are complete. First, this is not implemented
correctly and second this should not be done by the peer. It is more
appropriate to handle this as a protocol violation.
Remove the incorrect code and leave detecting the protocol violation
and its handling in a followup commit.

MFC after:	1 week
2023-08-19 12:35:49 +02:00
Michael Tuexen
c3179e6660 sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
Michael Tuexen
e416c81923 sctp: whitespace change to improve consistency
MFC after:	1 week
2023-08-18 15:06:23 +02:00
Michael Tuexen
fb259f62bb sctp: unbreak congestion control dtrace support
Fix a typo and improve consistency of handling variables only used
when compiling with dtrace support.

MFC after:	1 week
2023-08-18 15:01:35 +02:00
Warner Losh
78d146160d sys: Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:17 -06:00
Warner Losh
9e78921256 sys: Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:06 -06:00
Warner Losh
685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh
dfc016587a sys: Remove $FreeBSD$: two-line .c pattern
Remove /^#include\s+<sys/cdefs.h>.*$\n\s+__FBSDID\("\$FreeBSD\$"\);\n/
2023-08-16 11:54:30 -06:00
Warner Losh
71625ec9ad sys: Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:24 -06:00
Warner Losh
2ff63af9b8 sys: Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:18 -06:00
Warner Losh
95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Michael Tuexen
749a7fb588 sctp: cleanup
Do not put a variable in the stcb for passing it to a function.
Just use a parameter of the function. No functional change intended.

MFC after:	1 week
2023-08-14 12:27:39 +02:00
Michael Tuexen
e8eb0b7134 sctp: add an assert
This enforces a condition mentioned in a comment.

MFC after:	1 week
2023-08-13 22:47:43 +02:00
Michael Tuexen
6cb8b3b5cd sctp: use consistent names for locking macros
While there, add also a macro for an assert. Will be used shortly.
No functional change intended.

MFC after:	1 week
2023-08-13 22:35:53 +02:00
Michael Tuexen
85e5480df9 sctp: another cleanup
No functional change intended.

MFC after:	1 week
2023-08-09 04:17:52 +02:00
Michael Tuexen
9ade2745db sctp: remove duplicate code
No functional change intended.

MFC after:	1 week
2023-08-08 13:05:39 +02:00
Andrey V. Elsukov
600bf006d3 carp: delete interface routes on link loss.
Obtained from:	Yandex LLC
MFC after:	10 days
Sponsored by:	Yandex LLC
Differential Revision: https://reviews.freebsd.org/D41290
2023-08-08 13:22:10 +03:00
Michael Tuexen
10b2b30670 sctp: improve consistency
MFC after:	1 week
2023-08-05 11:29:23 +02:00
Michael Tuexen
e3771cc034 sctp: remove redundant check
This is already checked by the caller.

MFC after:	1 week
2023-08-05 11:26:45 +02:00