forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Several hash table refcount fixes in batman-adv, from Sven Eckelmann. 2) Use after free in bpf_evict_inode(), from Daniel Borkmann. 3) Fix mdio bus registration in ixgbe, from Ivan Vecera. 4) Unbounded loop in __skb_try_recv_datagram(), from Paolo Abeni. 5) ila rhashtable corruption fix from Herbert Xu. 6) Don't allow upper-devices to be added to vrf devices, from Sabrina Dubroca. 7) Add qmi_wwan device ID for Olicard 600, from Bjørn Mork. 8) Don't leave skb->next poisoned in __netif_receive_skb_list_ptype, from Alexander Lobakin. 9) Missing IDR checks in mlx5 driver, from Aditya Pakki. 10) Fix false connection termination in ktls, from Jakub Kicinski. 11) Work around some ASPM issues with r8169 by disabling rx interrupt coalescing on certain chips. From Heiner Kallweit. 12) Properly use per-cpu qstat values on NOLOCK qdiscs, from Paolo Abeni. 13) Fully initialize sockaddr_in structures in SCTP, from Xin Long. 14) Various BPF flow dissector fixes from Stanislav Fomichev. 15) Divide by zero in act_sample, from Davide Caratti. 16) Fix bridging multicast regression introduced by rhashtable conversion, from Nikolay Aleksandrov. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (106 commits) ibmvnic: Fix completion structure initialization ipv6: sit: reset ip header pointer in ipip6_rcv net: bridge: always clear mcast matching struct on reports and leaves libcxgb: fix incorrect ppmax calculation vlan: conditional inclusion of FCoE hooks to match netdevice.h and bnx2x sch_cake: Make sure we can write the IP header before changing DSCP bits sch_cake: Use tc_skb_protocol() helper for getting packet protocol tcp: Ensure DCTCP reacts to losses net/sched: act_sample: fix divide by zero in the traffic path net: thunderx: fix NULL pointer dereference in nicvf_open/nicvf_stop net: hns: Fix sparse: some warnings in HNS drivers net: hns: Fix WARNING when remove HNS driver with SMMU enabled net: hns: fix ICMP6 neighbor solicitation messages discard problem net: hns: Fix probabilistic memory overwrite when HNS driver initialized net: hns: Use NAPI_POLL_WEIGHT for hns driver net: hns: fix KASAN: use-after-free in hns_nic_net_xmit_hw() flow_dissector: rst'ify documentation ipv6: Fix dangling pointer when ipv6 fragment net-gro: Fix GRO flush when receiving a GSO packet. flow_dissector: document BPF flow dissector environment ...
- Loading branch information
Showing
122 changed files
with
1,096 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
.. SPDX-License-Identifier: GPL-2.0 | ||
================== | ||
BPF Flow Dissector | ||
================== | ||
|
||
Overview | ||
======== | ||
|
||
Flow dissector is a routine that parses metadata out of the packets. It's | ||
used in the various places in the networking subsystem (RFS, flow hash, etc). | ||
|
||
BPF flow dissector is an attempt to reimplement C-based flow dissector logic | ||
in BPF to gain all the benefits of BPF verifier (namely, limits on the | ||
number of instructions and tail calls). | ||
|
||
API | ||
=== | ||
|
||
BPF flow dissector programs operate on an ``__sk_buff``. However, only the | ||
limited set of fields is allowed: ``data``, ``data_end`` and ``flow_keys``. | ||
``flow_keys`` is ``struct bpf_flow_keys`` and contains flow dissector input | ||
and output arguments. | ||
|
||
The inputs are: | ||
* ``nhoff`` - initial offset of the networking header | ||
* ``thoff`` - initial offset of the transport header, initialized to nhoff | ||
* ``n_proto`` - L3 protocol type, parsed out of L2 header | ||
|
||
Flow dissector BPF program should fill out the rest of the ``struct | ||
bpf_flow_keys`` fields. Input arguments ``nhoff/thoff/n_proto`` should be | ||
also adjusted accordingly. | ||
|
||
The return code of the BPF program is either BPF_OK to indicate successful | ||
dissection, or BPF_DROP to indicate parsing error. | ||
|
||
__sk_buff->data | ||
=============== | ||
|
||
In the VLAN-less case, this is what the initial state of the BPF flow | ||
dissector looks like:: | ||
|
||
+------+------+------------+-----------+ | ||
| DMAC | SMAC | ETHER_TYPE | L3_HEADER | | ||
+------+------+------------+-----------+ | ||
^ | ||
| | ||
+-- flow dissector starts here | ||
|
||
|
||
.. code:: c | ||
skb->data + flow_keys->nhoff point to the first byte of L3_HEADER | ||
flow_keys->thoff = nhoff | ||
flow_keys->n_proto = ETHER_TYPE | ||
In case of VLAN, flow dissector can be called with the two different states. | ||
|
||
Pre-VLAN parsing:: | ||
|
||
+------+------+------+-----+-----------+-----------+ | ||
| DMAC | SMAC | TPID | TCI |ETHER_TYPE | L3_HEADER | | ||
+------+------+------+-----+-----------+-----------+ | ||
^ | ||
| | ||
+-- flow dissector starts here | ||
|
||
.. code:: c | ||
skb->data + flow_keys->nhoff point the to first byte of TCI | ||
flow_keys->thoff = nhoff | ||
flow_keys->n_proto = TPID | ||
Please note that TPID can be 802.1AD and, hence, BPF program would | ||
have to parse VLAN information twice for double tagged packets. | ||
|
||
|
||
Post-VLAN parsing:: | ||
|
||
+------+------+------+-----+-----------+-----------+ | ||
| DMAC | SMAC | TPID | TCI |ETHER_TYPE | L3_HEADER | | ||
+------+------+------+-----+-----------+-----------+ | ||
^ | ||
| | ||
+-- flow dissector starts here | ||
|
||
.. code:: c | ||
skb->data + flow_keys->nhoff point the to first byte of L3_HEADER | ||
flow_keys->thoff = nhoff | ||
flow_keys->n_proto = ETHER_TYPE | ||
In this case VLAN information has been processed before the flow dissector | ||
and BPF flow dissector is not required to handle it. | ||
|
||
|
||
The takeaway here is as follows: BPF flow dissector program can be called with | ||
the optional VLAN header and should gracefully handle both cases: when single | ||
or double VLAN is present and when it is not present. The same program | ||
can be called for both cases and would have to be written carefully to | ||
handle both cases. | ||
|
||
|
||
Reference Implementation | ||
======================== | ||
|
||
See ``tools/testing/selftests/bpf/progs/bpf_flow.c`` for the reference | ||
implementation and ``tools/testing/selftests/bpf/flow_dissector_load.[hc]`` | ||
for the loader. bpftool can be used to load BPF flow dissector program as well. | ||
|
||
The reference implementation is organized as follows: | ||
* ``jmp_table`` map that contains sub-programs for each supported L3 protocol | ||
* ``_dissect`` routine - entry point; it does input ``n_proto`` parsing and | ||
does ``bpf_tail_call`` to the appropriate L3 handler | ||
|
||
Since BPF at this point doesn't support looping (or any jumping back), | ||
jmp_table is used instead to handle multiple levels of encapsulation (and | ||
IPv6 options). | ||
|
||
|
||
Current Limitations | ||
=================== | ||
BPF flow dissector doesn't support exporting all the metadata that in-kernel | ||
C-based implementation can export. Notable example is single VLAN (802.1Q) | ||
and double VLAN (802.1AD) tags. Please refer to the ``struct bpf_flow_keys`` | ||
for a set of information that's currently can be exported from the BPF context. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5833,7 +5833,7 @@ L: [email protected] | |
S: Maintained | ||
F: Documentation/ABI/testing/sysfs-bus-mdio | ||
F: Documentation/devicetree/bindings/net/mdio* | ||
F: Documentation/networking/phy.txt | ||
F: Documentation/networking/phy.rst | ||
F: drivers/net/phy/ | ||
F: drivers/of/of_mdio.c | ||
F: drivers/of/of_net.c | ||
|
@@ -13981,7 +13981,7 @@ F: drivers/media/rc/serial_ir.c | |
SFC NETWORK DRIVER | ||
M: Solarflare linux maintainers <[email protected]> | ||
M: Edward Cree <[email protected]> | ||
M: Bert Kenward <bkenward@solarflare.com> | ||
M: Martin Habets <mhabets@solarflare.com> | ||
L: [email protected] | ||
S: Supported | ||
F: drivers/net/ethernet/sfc/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.