Commit Graph

1487 Commits

Author SHA1 Message Date
Brooks Davis
105a4f7b3c ng_atmllc: remove
This standalone module is the last vestage of ATM support in the tree so
send it on its way.

Reviewed by:	manu, emaste
Relnotes:	yes
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D38880
2023-03-09 18:04:21 +00:00
Brooks Davis
af0cc0b223 NgATM: Remove netgraph ATM support
Most ATM support was removed prior to FreeBSD 12.  The netgraph support
was kept as it was less intrusive, but it is presumed to be unused.

Reviewed by:	manu
Relnotes:	yes
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D38879
2023-03-09 18:04:02 +00:00
Gleb Smirnoff
7fc82fd1f8 ipfw: garbage collect ip_fw_chk_ptr
It is a relict left from the old times when ipfw(4) was hooked
into IP stack directly, without pfil(9).
2023-03-03 10:30:15 -08:00
Brooks Davis
c2285a7b09 ng_atmllc: deprecate
With the deprecation of NgATM, ng_atmllc is the last vestage of ATM
support so deprecate it too.

MFC after:	3 days
Relnotes:	yes

Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D38878
2023-03-03 16:47:36 +00:00
Brooks Davis
211c302f10 NgATM: deprecate
Support for ATM NICs was removed prior to FreeBSD 12.  At the time it
was unclear if this code was still useful without it.  Now the time has
come to finish removing support.

Add DREPRECATION NOTICEs to the manpages and gone_in(14, ...) warnings
in the constructors (or module init for ngatmbase).

MFC after:	3 days
Relnotes:	yes

Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D38877
2023-03-03 16:47:36 +00:00
Konstantin Belousov
2555f175b3 Move kstack_contains() and GET_STACK_USAGE() to MD machine/stack.h
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38320
2023-02-02 00:59:26 +02:00
Justin Hibbits
3d0d5b21c9 IfAPI: Explicitly include <net/if_private.h> in netstack
Summary:
In preparation of making if_t completely opaque outside of the netstack,
explicitly include the header.  <net/if_var.h> will stop including the
header in the future.

Sponsored by:	Juniper Networks, Inc.
Reviewed by:	glebius, melifaro
Differential Revision: https://reviews.freebsd.org/D38200
2023-01-31 15:02:16 -05:00
Ed Maste
05c0c99ea3 ng_hci: handle NG_HCI_M_PULLUP failure in le_advertizing_report
PR:		267396
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	takawata
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37228
2022-11-01 14:33:37 -04:00
Kristof Provost
23559c9d0d netgraph/ng_bridge: add missing array terminator
PR:		267457
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	1 week
2022-10-31 09:47:01 +01:00
Ed Schouten
af3c78886f Alter the prototype of qsort_r(3) to match POSIX, which adopted the
glibc-based interface.

Unfortunately, the glibc maintainers, despite knowing the existence
of the FreeBSD qsort_r(3) interface in 2004 and refused to add the
same interface to glibc based on grounds of the lack of standardization
and portability concerns, has decided it was a good idea to introduce
their own qsort_r(3) interface in 2007 as a GNU extension with a
slightly different and incompatible interface.

With the adoption of their interface as POSIX standard, let's switch
to the same prototype, there is no need to remain incompatible.

C++ and C applications written for the historical FreeBSD interface
get source level compatibility when building in C++ mode, or when
building with a C compiler with C11 generics support, provided that
the caller passes a fifth parameter of qsort_r() that exactly matches
the historical FreeBSD comparator function pointer type and does not
redefine the historical qsort_r(3) prototype in their source code.

Symbol versioning is used to keep old binaries working.

MFC:			never
Relnotes:		yes
Reviewed by:		cem, imp, hps, pauamma
Differential revision:	https://reviews.freebsd.org/D17083
2022-09-30 15:26:30 -07:00
Aleksandr Fedorov
0e6e2c4ef3 netgraph(4): Don't process NGQF_MESG items in NET_EPOCH context.
Netgraph has two main types of message items:

- NGQF_DATA items are used for data processing. This is a hot path that
should be called from a NET_EPOCH context.

- NGQF_MESG items are used for node configuration. There are many places
in netgraph(4) where processing the NGQF_MESG item can call sections of code
that are forbidden in the NET_EPOCH context.

All item types can be queued and then processed using ngthread().
But ngthread() is unconditionally enter in the NET_EPOCH section for all types.
This causes panic/deadlocks when processing NGQF_MESG elements.

Reported by:	mjg
Reviewed by:	glebius, vmaffione (mentor)
Tested by:	mjg, afedorov
Approved by:	glebius, vmaffione (mentor)
Sponsored by:	vstack.com
Differential Revision:	https://reviews.freebsd.org/D36496
2022-09-13 17:20:41 +03:00
Gleb Smirnoff
8624f4347e divert: declare PF_DIVERT domain and stop abusing PF_INET
The divert(4) is not a protocol of IPv4.  It is a socket to
intercept packets from ipfw(4) to userland and re-inject them
back.  It can divert and re-inject IPv4 and IPv6 packets today,
but potentially it is not limited to these two protocols.  The
IPPROTO_DIVERT does not belong to known IP protocols, it
doesn't even fit into u_char.  I guess, the implementation of
divert(4) was done the way it is done basically because it was
easier to do it this way, back when protocols for sockets were
intertwined with IP protocols and domains were statically
compiled in.

Moving divert(4) out of inetsw accomplished two important things:

1) IPDIVERT is getting much closer to be not dependent on INET.
   This will be finalized in following changes.
2) Now divert socket no longer aliases with raw IPv4 socket.
   Domain/proto selection code won't need a hack for SOCK_RAW and
   multiple entries in inetsw implementing different flavors of
   raw socket can merge into one without requirement of raw IPv4
   being the last member of dom_protosw.

Differential revision:	https://reviews.freebsd.org/D36379
2022-08-30 15:09:21 -07:00
Gleb Smirnoff
e7d02be19d protosw: refactor protosw and domain static declaration and load
o Assert that every protosw has pr_attach.  Now this structure is
  only for socket protocols declarations and nothing else.
o Merge struct pr_usrreqs into struct protosw.  This was suggested
  in 1996 by wollman@ (see 7b187005d1), and later reiterated
  in 2006 by rwatson@ (see 6fbb9cf860).
o Make struct domain hold a variable sized array of protosw pointers.
  For most protocols these pointers are initialized statically.
  Those domains that may have loadable protocols have spacers. IPv4
  and IPv6 have 8 spacers each (andre@ dff3237ee5).
o For inetsw and inet6sw leave a comment noting that many protosw
  entries very likely are dead code.
o Refactor pf_proto_[un]register() into protosw_[un]register().
o Isolate pr_*_notsupp() methods into uipc_domain.c

Reviewed by:		melifaro
Differential revision:	https://reviews.freebsd.org/D36232
2022-08-17 11:50:32 -07:00
Gleb Smirnoff
f277746e13 protosw: change prototype for pr_control
For some reason protosw.h is used during world complation and userland
is not aware of caddr_t, a relic from the first version of C.  Broken
buildworld is good reason to get rid of yet another caddr_t in kernel.

Fixes:	886fc1e804
2022-08-12 12:08:18 -07:00
Dimitry Andric
dba7f4aa09 Adjust ng_{name,ID}_rehash() definitions to avoid clang 15 warnings
With clang 15, the following -Werror warnings are produced:

    sys/netgraph/ng_base.c:981:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ng_name_rehash()
                  ^
                   void
    sys/netgraph/ng_base.c:1012:13: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ng_ID_rehash()
                ^
                 void

This is because ng_name_rehash() and ng_ID_rehash() are declared with
(void) argument lists, but defined with empty argument lists. Make the
definitions match the declarations.

MFC after:	3 days
2022-07-25 20:02:31 +02:00
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