Commit graph

1472 commits

Author SHA1 Message Date
Hans Petter Selasky 9d28e15e7b ng_ubt(4): Probe USB Bluetooth per USB interface and not per USB device.
PR:		264416
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-06-03 10:49:17 +02:00
Gleb Smirnoff b46667c63e sockbuf: merge two versions of sbcreatecontrol() into one
No functional change.
2022-05-17 10:10:42 -07:00
John Baldwin d83185d932 ng_ubt: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-09 12:22:03 -07:00
Gleb Smirnoff 7496792841 ng_socket: don't assign NULL in C99 sparse initializer 2022-05-09 10:42:48 -07:00
Gleb Smirnoff 607beb88af bluetooth: don't assign NULL in C99 sparse initializer 2022-05-09 10:42:48 -07:00
Eugene Grosbein 28903f396a ng_pppoe: introduce new sysctl net.graph.pppoe.lcp_pcp
This fixes incomplete commit 2e547442ab

New sysctl allows to mark transmitted PPPoE LCP Control
ethernet frames with needed 3-bit Priority Code Point (PCP) value.
Confirming driver like if_vlan(4) uses the value to fill
IEEE 802.1p class of service field.

This is similar to Cisco IOS "control-packets vlan cos priority"
command.

It helps to avoid premature disconnection of user sessions
due to control frame drops (LCP Echo etc.)
if network infrastructure has a botteleck at a switch
or the xdsl DSLAM.

See also:
https://sourceforge.net/p/mpd/discussion/44692/thread/c7abe70e3a/

Tested by:      Klaus Fokuhl at SourceForge
MFC after:      2 weeks
2022-05-02 21:57:12 +07:00
John Baldwin 2fdf3ed1e3 ng_netflow: Move various variables under INET || INET6. 2022-04-13 16:08:21 -07:00
John Baldwin 6d5f002ed1 netgraph: Remove the rethook parameter from NG_NODE_FOREACH_HOOK.
This parameter was set to the hook that terminated the iteration
early.  However, none of the remaining callers used this argument and
it was always set to an otherwise-unused variable.
2022-04-12 14:58:59 -07:00
John Baldwin fa351643f5 netgraph: Remove unused variable. 2022-04-12 14:58:59 -07:00
Gordon Bergling ecbdfbfd18 netgraph(3): Remove a double word in a source code comment
- s/it it/it/

MFC after:	3 days
2022-04-09 14:41:40 +02:00
Gordon Bergling 77a44875e5 netgraph(4): Fix a typo in a source code comment
- s/peform/perform/

MFC after:	3 days
2022-04-09 11:40:14 +02:00
John Baldwin f44692ce0c ng_tag: Move totlen fully under #ifdef NG_TAG_DEBUG. 2022-04-07 17:01:27 -07:00
John Baldwin 8373c80503 ng_ppp: Remove unused variable. 2022-04-07 17:01:27 -07:00
John Baldwin ad490a5aeb ng_netflow: Remove unused variable. 2022-04-07 17:01:27 -07:00
John Baldwin a11819ca1f ng_lmi: Move all of highest_dlci under #if 0. 2022-04-07 17:01:27 -07:00
John Baldwin 497c2cf4f8 ng_ksocket: Remove unused variable. 2022-04-07 17:01:27 -07:00
John Baldwin 9f566782e0 ng_bt: Remove an unused variable.
Leave a comment describing the field in the packet it represented.
2022-04-07 17:01:26 -07:00
Gordon Bergling f64919bbd9 ng_btsocket(4): Fix a typo in an error message
- s/mulitplexor/multiplexor/

MFC after:	5 days
2022-04-06 18:27:29 +02:00
Gordon Bergling 7fc0ffda35 ng_pppoe(4): Fix a typo in a source code comment
- s/asychronous/asynchronous/

MFC after:	3 days
2022-04-02 13:54:36 +02:00
Gordon Bergling 79438267b3 netgraph(3): Fix a typo in a source code comment
- s/failes/fails/

MFC after:	3 days
2022-03-28 19:31:50 +02:00
Gordon Bergling 1dc2c71ed8 netgraph(4): Fix a typo in a source code comment
- s/shapshot/snapshot/

MFC after:	3 days
2022-03-27 20:08:44 +02:00
Aleksandr Fedorov b27e6e91d0 ng pppoe(4): Add the required NET_EPOCH section to the hook
disconnection function.

Disconnecting hooks are called outside of NET_EPOCH, but
ng_pppoe_disconnect() calls NG_SEND_DATA_ONLY() which should be called
in NET_EPOCH.

PR:	257067
Reported by:	niels=freebsd@bakker.net
Reviewed by:	vmaffione (mentor), glebius, donner
Approved by:	vmaffione (mentor), glebius, donner
Sponsored by:	vstack.com
Differential Revision:	https://reviews.freebsd.org/D34185
2022-02-09 22:00:50 +03:00
Gleb Smirnoff 644ca0846d domains: make domain_init() initialize only global state
Now that each module handles its global and VNET initialization
itself, there is no VNET related stuff left to do in domain_init().

Differential revision:	https://reviews.freebsd.org/D33541
2022-01-03 10:15:22 -08:00
Gleb Smirnoff 89128ff3e4 protocols: init with standard SYSINIT(9) or VNET_SYSINIT
The historical BSD network stack loop that rolls over domains and
over protocols has no advantages over more modern SYSINIT(9).
While doing the sweep, split global and per-VNET initializers.

Getting rid of pr_init allows to achieve several things:
o Get rid of ifdef's that protect against double foo_init() when
  both INET and INET6 are compiled in.
o Isolate initializers statically to the module they init.
o Makes code easier to understand and maintain.

Reviewed by:		melifaro
Differential revision:	https://reviews.freebsd.org/D33537
2022-01-03 10:15:21 -08:00
Alexander Motin 2f1a46d12b netgraph: Remove CTLFLAG_NEEDGIANT from sysctl.
MFC after:	2 weeks
2021-12-26 19:42:53 -05:00
Mateusz Guzik fe30e08ac7 ng_pppoe: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-15 12:32:40 +00:00
Hans Petter Selasky 8fa952937b ng_ubt(4): Add missing module dependency for _net_bluetooth sysctl node.
Differential Revision:  https://reviews.freebsd.org/D33282
PR:		238235
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-08 10:18:32 +01:00
Hans Petter Selasky 03f0393477 ng_ubt(4): Make net.bluetooth.usb_isoc_enable writable.
Differential Revision:	https://reviews.freebsd.org/D33282
PR:		238235
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-07 11:50:51 +01:00
Hans Petter Selasky 67cbbf1959 ng_ubt(4): Introduce net.bluetooth.usb_isoc_enable loader tunable to disable
isochronous transfers.

If users want to disable isochronous transfers, which cause high
frequency periodic interrupts from the USB host controller, then
net.bluetooth.usb_isoc_enable can be set to zero, either as a
sysctl(8) or as a loader.conf(5) tunable.

Differential Revision:	https://reviews.freebsd.org/D33282
Submitted by:	naito.yuichiro@gmail.com
PR:		238235
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-07 11:39:49 +01:00
Mark Johnston b25ba58adc ng_ubt: Avoid attaching to several newer Intel controllers
Like other Intel controllers, these require firmware to be loaded, and
generic ng_ubt attach causes them to lock up until a power cycle.
However, their firmware interface for querying version info and loading
operational firmware is different from that implemented by ng_ubt_intel
and iwmbtfw, so they are not usable yet.  Just disable attach for now to
avoid stalls during USB device enumeration.

PR:		260161
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-12-05 10:51:46 -05:00
Gleb Smirnoff ae04d30451 ng_l2tp: use callout_reset() instead of ng_callout()
The previous commit to this node falsely stated that locked callouts
are compatible with netgraph ng_callout KPI.  They are not.  An item
can be queued instead of being applied to the node, which results in
a mutex leak to the callout thread and later unlocked call into function
that expects to be called locked.

Potentially netgraph can be taught to handle locked callouts, but that
would bring a lot of complexity in it.  Instead lets question necessity
of ng_callout() instead of callout_reset().  It protects against node
going away while callout is scheduled.  But a node that drains all
callouts in the shutdown method (ng_l2tp does) is already protected.

Fixes:	89042ff776
2021-12-03 08:57:23 -08:00
Mitchell Horne 0d2224733e Implement GET_STACK_USAGE on remaining archs
This definition enables callers to estimate remaining space on the
kstack, and take action on it. Notably, it enables optimizations in the
GEOM and netgraph subsystems to directly dispatch work items when there
is sufficient stack space, rather than queuing them for a worker thread.

Implement it for riscv, arm, and mips. Remove the #ifdefs, so it will
not go unimplemented elsewhere.

PR:		259157
Reviewed by:	mav, kib, markj (previous version)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32580
2021-11-30 11:15:56 -04:00
Gleb Smirnoff 319e9fc642 ng_bridge: count item allocation failures as memory failures
Submitted by:	Dmitry Luhtionov <dmitryluhtionov gmail.com>
2021-11-23 10:05:36 -08:00
Ian Lepore 44aae623ab Add ETHER_ALIGN support to ng_device(4).
This adds a new ng_device command, NGM_DEVICE_ETHERALIGN, which has no
associated args.  After the command arrives, the device begins adjusting all
packets sent out its hook to have ETHER_ALIGN bytes of padding at the
beginning of the packet.  The ETHER_ALIGN padding is added only when
running on an architecture that requires strict alignment of IP headers
(based on the __NO_STRICT_ALIGNMENT macro, which is only #define'd on
x86 as of this writing).

This also adds ascii <-> binary command translation to ng_device, both for
the existing NGM_DEVICE_GET_DEVNAME and the new ETHERALIGN command.

This also gives a name to every ng_device node when it is constructed, using
the cdev device name (ngd0, ngd1, etc).  This makes it easier to address
command msgs to the device using ngctl(8).

Reviewed by:	donner, ray, adrian
Differential Revision:	https://reviews.freebsd.org/D32905
MFC after:   1 week
2021-11-14 13:37:41 +01:00
Gordon Bergling 40a57b00f9 ng_pptpgre(4): Fix a typo in a source code comment
- s/mimimum/minimum/

MFC after:	3 days
2021-11-03 17:15:59 +01:00
Gleb Smirnoff 6aae3517ed Retire synchronous PPP kernel driver sppp(4).
The last two drivers that required sppp are cp(4) and ce(4).

These devices are still produced and can be purchased
at Cronyx <http://cronyx.ru/hardware/wan.html>.

Since Roman Kurakin <rik@FreeBSD.org> has quit them, they no
longer support FreeBSD officially.  Later they have dropped
support for Linux drivers to.  As of mid-2020 they don't even
have a developer to maintain their Windows driver.  However,
their support verbally told me that they could provide aid to
a FreeBSD developer with documentaion in case if there appears
a new customer for their devices.

These drivers have a feature to not use sppp(4) and create an
interface, but instead expose the device as netgraph(4) node.
Then, you can attach ng_ppp(4) with help of ports/net/mpd5 on
top of the node and get your synchronous PPP.  Alternatively
you can attach ng_frame_relay(4) or ng_cisco(4) for HDLC.
Actually, last time I used cp(4) back in 2004, using netgraph(4)
instead of sppp(4) was already the right way to do.

Thus, remove the sppp(4) related part of the drivers and enable
by default the negraph(4) part.  Further maintenance of these
drivers in the tree shouldn't be a big deal.

While doing that, remove some cruft and enable cp(4) compilation
on amd64.  The ce(4) for some unknown reason marks its internal
DDK functions with __attribute__ fastcall, which most likely is
safe to remove, but without hardware I'm not going to do that, so
ce(4) remains i386-only.

Reviewed by:		emaste, imp, donner
Differential Revision:	https://reviews.freebsd.org/D32590
See also:		https://reviews.freebsd.org/D23928
2021-10-22 11:41:36 -07:00
Gordon Bergling 0a8159d8ca ng_ppp(4): Fix a typo in a comment
- s/delcared/declared/

MFC after:	3 days
2021-10-14 15:30:32 +02:00
Warner Losh 79a100e28e bluetooth: complete removal of ng_h4
The ng_h4 module was disconnected 13 years ago when the tty later was
locked by Ed. It completely fails to compile, and has a number of false
positives for Giant use. Remove it for lack of interest. Bluetooth has
largely (completely?) moved on from bluetooth over UART transport.

OK'd by:		emax
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D31846
2021-09-29 20:00:02 -06:00
Yoshihiro Takahashi d653b188e8 ng_ether: Create netgraph nodes for bridge interfaces.
Create netgraph nodes for bridge interfaces when the ng_ether module
is loaded.  If a bridge interface is created after loading the ng_ether
module, a netgraph node is created via ether_ifattach().

MFC after:	1 week
2021-09-26 01:24:33 +09:00
Gleb Smirnoff 89042ff776 ng_l2tp: improve callout locking.
Apparently e62e4b8594 wasn't enough to close the race between
a queue being flushed by a packet and callout executing, because
the callouts used without a lock aren't 100% bulletproof. To close
the race use callout_init_mtx() for L2TP timers, and make sure that
all calls to ng_callout()/ng_uncallout() are done under the seq lock.

If used properly, a locked callout can be used transparently with
old netgraph KPI of ng_callout/ng_uncallout which predates locked
callouts.

While here, utilize ng_uncallout_drain() instead of ng_uncallout()
on the node shutdown.

PR:			241133
Reviewed by:		mjg, markj
Differential Revision:	https://reviews.freebsd.org/D31476
2021-09-10 11:27:19 -07:00
Gleb Smirnoff 0a76c63dd4 ng_l2tp: improve seq structure locking.
Cover few cases of access to seq without lock missed in 702f98951d.
There are no known bugs fixed with this change, however. With INVARIANTS
embed ng_l2tp_seq_check() into lock/unlock macros. Slightly reduce number
of locks/unlocks per packet keeping the lock between functions.

Reviewed by:		mjg, markj
Differential Revision:	https://reviews.freebsd.org/D31476
2021-09-10 11:27:13 -07:00
Gleb Smirnoff b2954f0a8f netgraph: add ng_uncallout_drain().
Move shared code into ng_uncallout_internal(). While here add a comment
mentioning a problem with scheduled+executing callout.

Reviewed by:		mjg, markj
Differential Revision:	https://reviews.freebsd.org/D31476
2021-09-10 11:27:04 -07:00
Gleb Smirnoff 26cf4b53d9 netgraph: pass return value from callout_stop() unmodified to callers of
ng_uncallout. Most of them do not check it anyway, so very little node
changes are required.

Reviewed by:		mjg, markj
Differential Revision:	https://reviews.freebsd.org/D31476
2021-09-10 11:26:59 -07:00
Mark Johnston bd4a39cc93 socket: Properly interlock when transitioning to a listening socket
Currently, most protocols implement pru_listen with something like the
following:

	SOCK_LOCK(so);
	error = solisten_proto_check(so);
	if (error) {
		SOCK_UNLOCK(so);
		return (error);
	}
	solisten_proto(so);
	SOCK_UNLOCK(so);

solisten_proto_check() fails if the socket is connected or connecting.
However, the socket lock is not used during I/O, so this pattern is
racy.

The change modifies solisten_proto_check() to additionally acquire
socket buffer locks, and the calling thread holds them until
solisten_proto() or solisten_proto_abort() is called.  Now that the
socket buffer locks are preserved across a listen(2), this change allows
socket I/O paths to properly interlock with listen(2).

This fixes a large number of syzbot reports, only one is listed below
and the rest will be dup'ed to it.

Reported by:	syzbot+9fece8a63c0e27273821@syzkaller.appspotmail.com
Reviewed by:	tuexen, gallatin
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31659
2021-09-07 17:11:43 -04:00
Zhenlei Huang 62e1a437f3 routing: Allow using IPv6 next-hops for IPv4 routes (RFC 5549).
Implement kernel support for RFC 5549/8950.

* Relax control plane restrictions and allow specifying IPv6 gateways
 for IPv4 routes. This behavior is controlled by the
 net.route.rib_route_ipv6_nexthop sysctl (on by default).

* Always pass final destination in ro->ro_dst in ip_forward().

* Use ro->ro_dst to exract packet family inside if_output() routines.
 Consistently use RO_GET_FAMILY() macro to handle ro=NULL case.

* Pass extracted family to nd6_resolve() to get the LLE with proper encap.
 It leverages recent lltable changes committed in c541bd368f.

Presence of the functionality can be checked using ipv4_rfc5549_support feature(3).
Example usage:
  route add -net 192.0.0.0/24 -inet6 fe80::5054:ff:fe14:e319%vtnet0

Differential Revision: https://reviews.freebsd.org/D30398
MFC after:	2 weeks
2021-08-22 22:56:08 +00:00
Gordon Bergling 34f620f1d0 Fix a few typos in source code comments
- s/posbile/possible/

MFC after:	5 days
2021-08-14 09:39:17 +02:00
Mark Johnston e0e3ded78a ng_bridge: Use M_NOWAIT when allocating memory in the newhook routine
newhook can be invoked by ngthread, which runs in a network epoch
section and is thus not permitted to perform M_WAITOK allocations.

Reported by:	Jenkins
Reviewed by:	donner, afedorov
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31486
2021-08-13 09:49:43 -04:00
Roy Marples 7045b1603b socket: Implement SO_RERROR
SO_RERROR indicates that receive buffer overflows should be handled as
errors. Historically receive buffer overflows have been ignored and
programs could not tell if they missed messages or messages had been
truncated because of overflows. Since programs historically do not
expect to get receive overflow errors, this behavior is not the
default.

This is really really important for programs that use route(4) to keep
in sync with the system. If we loose a message then we need to reload
the full system state, otherwise the behaviour from that point is
undefined and can lead to chasing bogus bug reports.

Reviewed by:	philip (network), kbowling (transport), gbe (manpages)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26652
2021-07-28 09:35:09 -07:00
Mark Johnston f4bb1869dd Consistently use the SOLISTENING() macro
Some code was using it already, but in many places we were testing
SO_ACCEPTCONN directly.  As a small step towards fixing some bugs
involving synchronization with listen(2), make the kernel consistently
use SOLISTENING().  No functional change intended.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-06-14 17:32:27 -04:00
Lutz Donnerhacke 4c3280e587 netgraph/bridge: malloc without flags
During tests an assert was triggered and pointed to missing flags in
the newlink function of ng_bridge(4).

Reported by:	markj
Reviewed by:	markj
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D30759
2021-06-14 15:41:46 +02:00