Skip to content

Commit cb8e59c

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next
Pull networking updates from David Miller: 1) Allow setting bluetooth L2CAP modes via socket option, from Luiz Augusto von Dentz. 2) Add GSO partial support to igc, from Sasha Neftin. 3) Several cleanups and improvements to r8169 from Heiner Kallweit. 4) Add IF_OPER_TESTING link state and use it when ethtool triggers a device self-test. From Andrew Lunn. 5) Start moving away from custom driver versions, use the globally defined kernel version instead, from Leon Romanovsky. 6) Support GRO vis gro_cells in DSA layer, from Alexander Lobakin. 7) Allow hard IRQ deferral during NAPI, from Eric Dumazet. 8) Add sriov and vf support to hinic, from Luo bin. 9) Support Media Redundancy Protocol (MRP) in the bridging code, from Horatiu Vultur. 10) Support netmap in the nft_nat code, from Pablo Neira Ayuso. 11) Allow UDPv6 encapsulation of ESP in the ipsec code, from Sabrina Dubroca. Also add ipv6 support for espintcp. 12) Lots of ReST conversions of the networking documentation, from Mauro Carvalho Chehab. 13) Support configuration of ethtool rxnfc flows in bcmgenet driver, from Doug Berger. 14) Allow to dump cgroup id and filter by it in inet_diag code, from Dmitry Yakunin. 15) Add infrastructure to export netlink attribute policies to userspace, from Johannes Berg. 16) Several optimizations to sch_fq scheduler, from Eric Dumazet. 17) Fallback to the default qdisc if qdisc init fails because otherwise a packet scheduler init failure will make a device inoperative. From Jesper Dangaard Brouer. 18) Several RISCV bpf jit optimizations, from Luke Nelson. 19) Correct the return type of the ->ndo_start_xmit() method in several drivers, it's netdev_tx_t but many drivers were using 'int'. From Yunjian Wang. 20) Add an ethtool interface for PHY master/slave config, from Oleksij Rempel. 21) Add BPF iterators, from Yonghang Song. 22) Add cable test infrastructure, including ethool interfaces, from Andrew Lunn. Marvell PHY driver is the first to support this facility. 23) Remove zero-length arrays all over, from Gustavo A. R. Silva. 24) Calculate and maintain an explicit frame size in XDP, from Jesper Dangaard Brouer. 25) Add CAP_BPF, from Alexei Starovoitov. 26) Support terse dumps in the packet scheduler, from Vlad Buslov. 27) Support XDP_TX bulking in dpaa2 driver, from Ioana Ciornei. 28) Add devm_register_netdev(), from Bartosz Golaszewski. 29) Minimize qdisc resets, from Cong Wang. 30) Get rid of kernel_getsockopt and kernel_setsockopt in order to eliminate set_fs/get_fs calls. From Christoph Hellwig. * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2517 commits) selftests: net: ip_defrag: ignore EPERM net_failover: fixed rollback in net_failover_open() Revert "tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv" Revert "tipc: Fix potential tipc_node refcnt leak in tipc_rcv" vmxnet3: allow rx flow hash ops only when rss is enabled hinic: add set_channels ethtool_ops support selftests/bpf: Add a default $(CXX) value tools/bpf: Don't use $(COMPILE.c) bpf, selftests: Use bpf_probe_read_kernel s390/bpf: Use bcr 0,%0 as tail call nop filler s390/bpf: Maintain 8-byte stack alignment selftests/bpf: Fix verifier test selftests/bpf: Fix sample_cnt shared between two threads bpf, selftests: Adapt cls_redirect to call csum_level helper bpf: Add csum_level helper for fixing up csum levels bpf: Fix up bpf_skb_adjust_room helper's skb csum setting sfc: add missing annotation for efx_ef10_try_update_nic_stats_vf() crypto/chtls: IPv6 support for inline TLS Crypto/chcr: Fixes a coccinile check error Crypto/chcr: Fixes compilations warnings ...
2 parents 2e63f6c + 065fcfd commit cb8e59c

File tree

2,097 files changed

+151766
-46213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,097 files changed

+151766
-46213
lines changed

Documentation/ABI/testing/sysfs-class-net

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ Description:
124124
authentication is performed (e.g: 802.1x). 'link_mode' attribute
125125
will also reflect the dormant state.
126126

127+
What: /sys/class/net/<iface>/testing
128+
Date: April 2002
129+
KernelVersion: 5.8
130+
131+
Description:
132+
Indicates whether the interface is under test. Possible
133+
values are:
134+
0: interface is not being tested
135+
1: interface is being tested
136+
137+
When an interface is under test, it cannot be expected
138+
to pass packets as normal.
139+
127140
What: /sys/clas/net/<iface>/duplex
128141
Date: October 2009
129142
KernelVersion: 2.6.33

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@
356356
shot down by NMI
357357

358358
autoconf= [IPV6]
359-
See Documentation/networking/ipv6.txt.
359+
See Documentation/networking/ipv6.rst.
360360

361361
show_lapic= [APIC,X86] Advanced Programmable Interrupt Controller
362362
Limit apic dumping. The parameter defines the maximal
@@ -638,7 +638,7 @@
638638

639639
See Documentation/admin-guide/serial-console.rst for more
640640
information. See
641-
Documentation/networking/netconsole.txt for an
641+
Documentation/networking/netconsole.rst for an
642642
alternative.
643643

644644
uart[8250],io,<addr>[,options]
@@ -831,7 +831,7 @@
831831

832832
decnet.addr= [HW,NET]
833833
Format: <area>[,<node>]
834-
See also Documentation/networking/decnet.txt.
834+
See also Documentation/networking/decnet.rst.
835835

836836
default_hugepagesz=
837837
[same as hugepagesz=] The size of the default
@@ -872,7 +872,7 @@
872872
miss to occur.
873873

874874
disable= [IPV6]
875-
See Documentation/networking/ipv6.txt.
875+
See Documentation/networking/ipv6.rst.
876876

877877
hardened_usercopy=
878878
[KNL] Under CONFIG_HARDENED_USERCOPY, whether
@@ -912,7 +912,7 @@
912912
to workaround buggy firmware.
913913

914914
disable_ipv6= [IPV6]
915-
See Documentation/networking/ipv6.txt.
915+
See Documentation/networking/ipv6.rst.
916916

917917
disable_mtrr_cleanup [X86]
918918
The kernel tries to adjust MTRR layout from continuous
@@ -4956,7 +4956,7 @@
49564956
Set the number of tcp_metrics_hash slots.
49574957
Default value is 8192 or 16384 depending on total
49584958
ram pages. This is used to specify the TCP metrics
4959-
cache size. See Documentation/networking/ip-sysctl.txt
4959+
cache size. See Documentation/networking/ip-sysctl.rst
49604960
"tcp_no_metrics_save" section for more details.
49614961

49624962
tdfx= [HW,DRM]

Documentation/admin-guide/serial-console.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ You will need to create a new device to use ``/dev/console``. The official
5454
``/dev/console`` is now character device 5,1.
5555

5656
(You can also use a network device as a console. See
57-
``Documentation/networking/netconsole.txt`` for information on that.)
57+
``Documentation/networking/netconsole.rst`` for information on that.)
5858

5959
Here's an example that will use ``/dev/ttyS1`` (COM2) as the console.
6060
Replace the sample values as needed.

Documentation/admin-guide/sysctl/net.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ settings from init_net and for IPv6 we reset all settings to default.
339339

340340
If set to 1, both IPv4 and IPv6 settings are forced to inherit from
341341
current ones in init_net. If set to 2, both IPv4 and IPv6 settings are
342-
forced to reset to their default values.
342+
forced to reset to their default values. If set to 3, both IPv4 and IPv6
343+
settings are forced to inherit from current ones in the netns where this
344+
new netns has been created.
343345

344346
Default : 0 (for compatibility reasons)
345347

@@ -353,8 +355,8 @@ socket's buffer. It will not take effect unless PF_UNIX flag is specified.
353355

354356
3. /proc/sys/net/ipv4 - IPV4 settings
355357
-------------------------------------
356-
Please see: Documentation/networking/ip-sysctl.txt and ipvs-sysctl.txt for
357-
descriptions of these entries.
358+
Please see: Documentation/networking/ip-sysctl.rst and
359+
Documentation/admin-guide/sysctl/net.rst for descriptions of these entries.
358360

359361

360362
4. Appletalk

Documentation/bpf/bpf_devel_QA.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,21 @@ needed::
437437
See the kernels selftest `Documentation/dev-tools/kselftest.rst`_
438438
document for further documentation.
439439

440+
To maximize the number of tests passing, the .config of the kernel
441+
under test should match the config file fragment in
442+
tools/testing/selftests/bpf as closely as possible.
443+
444+
Finally to ensure support for latest BPF Type Format features -
445+
discussed in `Documentation/bpf/btf.rst`_ - pahole version 1.16
446+
is required for kernels built with CONFIG_DEBUG_INFO_BTF=y.
447+
pahole is delivered in the dwarves package or can be built
448+
from source at
449+
450+
https://github.com/acmel/dwarves
451+
452+
Some distros have pahole version 1.16 packaged already, e.g.
453+
Fedora, Gentoo.
454+
440455
Q: Which BPF kernel selftests version should I run my kernel against?
441456
---------------------------------------------------------------------
442457
A: If you run a kernel ``xyz``, then always run the BPF kernel selftests

Documentation/bpf/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Filter) facility, with a focus on the extended BPF version (eBPF).
77

88
This kernel side documentation is still work in progress. The main
99
textual documentation is (for historical reasons) described in
10-
`Documentation/networking/filter.txt`_, which describe both classical
10+
`Documentation/networking/filter.rst`_, which describe both classical
1111
and extended BPF instruction-set.
1212
The Cilium project also maintains a `BPF and XDP Reference Guide`_
1313
that goes into great technical depth about the BPF Architecture.
@@ -59,7 +59,7 @@ Testing and debugging BPF
5959

6060

6161
.. Links:
62-
.. _Documentation/networking/filter.txt: ../networking/filter.txt
62+
.. _Documentation/networking/filter.rst: ../networking/filter.txt
6363
.. _man-pages: https://www.kernel.org/doc/man-pages/
6464
.. _bpf(2): http://man7.org/linux/man-pages/man2/bpf.2.html
6565
.. _BPF and XDP Reference Guide: http://cilium.readthedocs.io/en/latest/bpf/

Documentation/bpf/ringbuf.rst

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
===============
2+
BPF ring buffer
3+
===============
4+
5+
This document describes BPF ring buffer design, API, and implementation details.
6+
7+
.. contents::
8+
:local:
9+
:depth: 2
10+
11+
Motivation
12+
----------
13+
14+
There are two distinctive motivators for this work, which are not satisfied by
15+
existing perf buffer, which prompted creation of a new ring buffer
16+
implementation.
17+
18+
- more efficient memory utilization by sharing ring buffer across CPUs;
19+
- preserving ordering of events that happen sequentially in time, even across
20+
multiple CPUs (e.g., fork/exec/exit events for a task).
21+
22+
These two problems are independent, but perf buffer fails to satisfy both.
23+
Both are a result of a choice to have per-CPU perf ring buffer. Both can be
24+
also solved by having an MPSC implementation of ring buffer. The ordering
25+
problem could technically be solved for perf buffer with some in-kernel
26+
counting, but given the first one requires an MPSC buffer, the same solution
27+
would solve the second problem automatically.
28+
29+
Semantics and APIs
30+
------------------
31+
32+
Single ring buffer is presented to BPF programs as an instance of BPF map of
33+
type ``BPF_MAP_TYPE_RINGBUF``. Two other alternatives considered, but
34+
ultimately rejected.
35+
36+
One way would be to, similar to ``BPF_MAP_TYPE_PERF_EVENT_ARRAY``, make
37+
``BPF_MAP_TYPE_RINGBUF`` could represent an array of ring buffers, but not
38+
enforce "same CPU only" rule. This would be more familiar interface compatible
39+
with existing perf buffer use in BPF, but would fail if application needed more
40+
advanced logic to lookup ring buffer by arbitrary key.
41+
``BPF_MAP_TYPE_HASH_OF_MAPS`` addresses this with current approach.
42+
Additionally, given the performance of BPF ringbuf, many use cases would just
43+
opt into a simple single ring buffer shared among all CPUs, for which current
44+
approach would be an overkill.
45+
46+
Another approach could introduce a new concept, alongside BPF map, to represent
47+
generic "container" object, which doesn't necessarily have key/value interface
48+
with lookup/update/delete operations. This approach would add a lot of extra
49+
infrastructure that has to be built for observability and verifier support. It
50+
would also add another concept that BPF developers would have to familiarize
51+
themselves with, new syntax in libbpf, etc. But then would really provide no
52+
additional benefits over the approach of using a map. ``BPF_MAP_TYPE_RINGBUF``
53+
doesn't support lookup/update/delete operations, but so doesn't few other map
54+
types (e.g., queue and stack; array doesn't support delete, etc).
55+
56+
The approach chosen has an advantage of re-using existing BPF map
57+
infrastructure (introspection APIs in kernel, libbpf support, etc), being
58+
familiar concept (no need to teach users a new type of object in BPF program),
59+
and utilizing existing tooling (bpftool). For common scenario of using a single
60+
ring buffer for all CPUs, it's as simple and straightforward, as would be with
61+
a dedicated "container" object. On the other hand, by being a map, it can be
62+
combined with ``ARRAY_OF_MAPS`` and ``HASH_OF_MAPS`` map-in-maps to implement
63+
a wide variety of topologies, from one ring buffer for each CPU (e.g., as
64+
a replacement for perf buffer use cases), to a complicated application
65+
hashing/sharding of ring buffers (e.g., having a small pool of ring buffers
66+
with hashed task's tgid being a look up key to preserve order, but reduce
67+
contention).
68+
69+
Key and value sizes are enforced to be zero. ``max_entries`` is used to specify
70+
the size of ring buffer and has to be a power of 2 value.
71+
72+
There are a bunch of similarities between perf buffer
73+
(``BPF_MAP_TYPE_PERF_EVENT_ARRAY``) and new BPF ring buffer semantics:
74+
75+
- variable-length records;
76+
- if there is no more space left in ring buffer, reservation fails, no
77+
blocking;
78+
- memory-mappable data area for user-space applications for ease of
79+
consumption and high performance;
80+
- epoll notifications for new incoming data;
81+
- but still the ability to do busy polling for new data to achieve the
82+
lowest latency, if necessary.
83+
84+
BPF ringbuf provides two sets of APIs to BPF programs:
85+
86+
- ``bpf_ringbuf_output()`` allows to *copy* data from one place to a ring
87+
buffer, similarly to ``bpf_perf_event_output()``;
88+
- ``bpf_ringbuf_reserve()``/``bpf_ringbuf_commit()``/``bpf_ringbuf_discard()``
89+
APIs split the whole process into two steps. First, a fixed amount of space
90+
is reserved. If successful, a pointer to a data inside ring buffer data
91+
area is returned, which BPF programs can use similarly to a data inside
92+
array/hash maps. Once ready, this piece of memory is either committed or
93+
discarded. Discard is similar to commit, but makes consumer ignore the
94+
record.
95+
96+
``bpf_ringbuf_output()`` has disadvantage of incurring extra memory copy,
97+
because record has to be prepared in some other place first. But it allows to
98+
submit records of the length that's not known to verifier beforehand. It also
99+
closely matches ``bpf_perf_event_output()``, so will simplify migration
100+
significantly.
101+
102+
``bpf_ringbuf_reserve()`` avoids the extra copy of memory by providing a memory
103+
pointer directly to ring buffer memory. In a lot of cases records are larger
104+
than BPF stack space allows, so many programs have use extra per-CPU array as
105+
a temporary heap for preparing sample. bpf_ringbuf_reserve() avoid this needs
106+
completely. But in exchange, it only allows a known constant size of memory to
107+
be reserved, such that verifier can verify that BPF program can't access memory
108+
outside its reserved record space. bpf_ringbuf_output(), while slightly slower
109+
due to extra memory copy, covers some use cases that are not suitable for
110+
``bpf_ringbuf_reserve()``.
111+
112+
The difference between commit and discard is very small. Discard just marks
113+
a record as discarded, and such records are supposed to be ignored by consumer
114+
code. Discard is useful for some advanced use-cases, such as ensuring
115+
all-or-nothing multi-record submission, or emulating temporary
116+
``malloc()``/``free()`` within single BPF program invocation.
117+
118+
Each reserved record is tracked by verifier through existing
119+
reference-tracking logic, similar to socket ref-tracking. It is thus
120+
impossible to reserve a record, but forget to submit (or discard) it.
121+
122+
``bpf_ringbuf_query()`` helper allows to query various properties of ring
123+
buffer. Currently 4 are supported:
124+
125+
- ``BPF_RB_AVAIL_DATA`` returns amount of unconsumed data in ring buffer;
126+
- ``BPF_RB_RING_SIZE`` returns the size of ring buffer;
127+
- ``BPF_RB_CONS_POS``/``BPF_RB_PROD_POS`` returns current logical possition
128+
of consumer/producer, respectively.
129+
130+
Returned values are momentarily snapshots of ring buffer state and could be
131+
off by the time helper returns, so this should be used only for
132+
debugging/reporting reasons or for implementing various heuristics, that take
133+
into account highly-changeable nature of some of those characteristics.
134+
135+
One such heuristic might involve more fine-grained control over poll/epoll
136+
notifications about new data availability in ring buffer. Together with
137+
``BPF_RB_NO_WAKEUP``/``BPF_RB_FORCE_WAKEUP`` flags for output/commit/discard
138+
helpers, it allows BPF program a high degree of control and, e.g., more
139+
efficient batched notifications. Default self-balancing strategy, though,
140+
should be adequate for most applications and will work reliable and efficiently
141+
already.
142+
143+
Design and Implementation
144+
-------------------------
145+
146+
This reserve/commit schema allows a natural way for multiple producers, either
147+
on different CPUs or even on the same CPU/in the same BPF program, to reserve
148+
independent records and work with them without blocking other producers. This
149+
means that if BPF program was interruped by another BPF program sharing the
150+
same ring buffer, they will both get a record reserved (provided there is
151+
enough space left) and can work with it and submit it independently. This
152+
applies to NMI context as well, except that due to using a spinlock during
153+
reservation, in NMI context, ``bpf_ringbuf_reserve()`` might fail to get
154+
a lock, in which case reservation will fail even if ring buffer is not full.
155+
156+
The ring buffer itself internally is implemented as a power-of-2 sized
157+
circular buffer, with two logical and ever-increasing counters (which might
158+
wrap around on 32-bit architectures, that's not a problem):
159+
160+
- consumer counter shows up to which logical position consumer consumed the
161+
data;
162+
- producer counter denotes amount of data reserved by all producers.
163+
164+
Each time a record is reserved, producer that "owns" the record will
165+
successfully advance producer counter. At that point, data is still not yet
166+
ready to be consumed, though. Each record has 8 byte header, which contains the
167+
length of reserved record, as well as two extra bits: busy bit to denote that
168+
record is still being worked on, and discard bit, which might be set at commit
169+
time if record is discarded. In the latter case, consumer is supposed to skip
170+
the record and move on to the next one. Record header also encodes record's
171+
relative offset from the beginning of ring buffer data area (in pages). This
172+
allows ``bpf_ringbuf_commit()``/``bpf_ringbuf_discard()`` to accept only the
173+
pointer to the record itself, without requiring also the pointer to ring buffer
174+
itself. Ring buffer memory location will be restored from record metadata
175+
header. This significantly simplifies verifier, as well as improving API
176+
usability.
177+
178+
Producer counter increments are serialized under spinlock, so there is
179+
a strict ordering between reservations. Commits, on the other hand, are
180+
completely lockless and independent. All records become available to consumer
181+
in the order of reservations, but only after all previous records where
182+
already committed. It is thus possible for slow producers to temporarily hold
183+
off submitted records, that were reserved later.
184+
185+
Reservation/commit/consumer protocol is verified by litmus tests in
186+
Documentation/litmus_tests/bpf-rb/_.
187+
188+
One interesting implementation bit, that significantly simplifies (and thus
189+
speeds up as well) implementation of both producers and consumers is how data
190+
area is mapped twice contiguously back-to-back in the virtual memory. This
191+
allows to not take any special measures for samples that have to wrap around
192+
at the end of the circular buffer data area, because the next page after the
193+
last data page would be first data page again, and thus the sample will still
194+
appear completely contiguous in virtual memory. See comment and a simple ASCII
195+
diagram showing this visually in ``bpf_ringbuf_area_alloc()``.
196+
197+
Another feature that distinguishes BPF ringbuf from perf ring buffer is
198+
a self-pacing notifications of new data being availability.
199+
``bpf_ringbuf_commit()`` implementation will send a notification of new record
200+
being available after commit only if consumer has already caught up right up to
201+
the record being committed. If not, consumer still has to catch up and thus
202+
will see new data anyways without needing an extra poll notification.
203+
Benchmarks (see tools/testing/selftests/bpf/benchs/bench_ringbuf.c_) show that
204+
this allows to achieve a very high throughput without having to resort to
205+
tricks like "notify only every Nth sample", which are necessary with perf
206+
buffer. For extreme cases, when BPF program wants more manual control of
207+
notifications, commit/discard/output helpers accept ``BPF_RB_NO_WAKEUP`` and
208+
``BPF_RB_FORCE_WAKEUP`` flags, which give full control over notifications of
209+
data availability, but require extra caution and diligence in using this API.

Documentation/dev-tools/kselftest.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ Helpers
301301

302302
.. kernel-doc:: tools/testing/selftests/kselftest_harness.h
303303
:functions: TH_LOG TEST TEST_SIGNAL FIXTURE FIXTURE_DATA FIXTURE_SETUP
304-
FIXTURE_TEARDOWN TEST_F TEST_HARNESS_MAIN
304+
FIXTURE_TEARDOWN TEST_F TEST_HARNESS_MAIN FIXTURE_VARIANT
305+
FIXTURE_VARIANT_ADD
305306

306307
Operators
307308
---------

0 commit comments

Comments
 (0)