]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nftables_offload: special ethertype handling for VLAN
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 12 Apr 2021 12:20:55 +0000 (14:20 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 18 Apr 2021 20:02:21 +0000 (22:02 +0200)
commit1712046fcfc313c2e3f0cd434f4624b50c7d7b8a
tree51ff62c4a2bd1c2ceebb43681ddbaae669db0b9e
parentc8c5721caa318ce9ddfed198ea5fdd8b77a0f1d4
netfilter: nftables_offload: special ethertype handling for VLAN

The nftables offload parser sets FLOW_DISSECTOR_KEY_BASIC .n_proto to the
ethertype field in the ethertype frame. However:

- FLOW_DISSECTOR_KEY_BASIC .n_proto field always stores either IPv4 or IPv6
  ethertypes.
- FLOW_DISSECTOR_KEY_VLAN .vlan_tpid stores either the 802.1q and 802.1ad
  ethertypes. Same as for FLOW_DISSECTOR_KEY_CVLAN.

This function adjusts the flow dissector to handle two scenarios:

1) FLOW_DISSECTOR_KEY_VLAN .vlan_tpid is set to 802.1q or 802.1ad.
   Then, transfer:
   - the .n_proto field to FLOW_DISSECTOR_KEY_VLAN .tpid.
   - the original FLOW_DISSECTOR_KEY_VLAN .tpid to the
     FLOW_DISSECTOR_KEY_CVLAN .tpid
   - the original FLOW_DISSECTOR_KEY_CVLAN .tpid to the .n_proto field.

2) .n_proto is set to 802.1q or 802.1ad. Then, transfer:
   - the .n_proto field to FLOW_DISSECTOR_KEY_VLAN .tpid.
   - the original FLOW_DISSECTOR_KEY_VLAN .tpid to the .n_proto field.

Fixes: 2850100d7e2c ("netfilter: nft_payload: add VLAN offload support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_offload.c