Skip to content

netfilter: add netfilter hooks to track SRv6-encapsulated flows

Ryoga Saito netfilter-devel 6 versions – Applied

Status from this message: Applied to nf-next with a few edits. I'll post it to net-next in the

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest2 patches 1 replyApplied
  2. v62 patches 1 replySuperseded
  3. v52 patches 1 replySuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v42 patches2 repliesSuperseded
v32 patches0 repliesSuperseded
v22 patches0 repliesSuperseded

Patches in v7 Applied

#Subject and filesSizeRepliesApplied
1/2netfilter: add new sysctl toggle for lightweight tunnel netfilter hooksDocumentation/networking/nf_conntrack-sysctl.rst include/net/lwtunnel.h include/net/netfilter/nf_hooks_lwtunnel.h +4 more+112 -00 replies
2/2netfilter: add netfilter hooks to SRv6 data planenet/ipv6/seg6_iptunnel.c net/ipv6/seg6_local.c+148 -360 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v7 yet.

Read the v7 thread

Cover letter [PATCH v7 0/2] netfilter: add netfilter hooks to track SRv6-encapsulated flows

Tunneling protocols such as VXLAN or IPIP are implemented using virtual network devices (vxlan0 or ipip0). Therefore, conntrack can record both inner flows and outer flows correctly. In contrast, SRv6 is implemented using lightweight tunnel infrastructure. Therefore, SRv6 packets are encapsulated and decapsulated without passing through virtual network device. Due to the following problems caused by this, conntrack can't record both inner flows and outer flows correctly.

First problem is caused when SRv6 packets are encapsulated. In VXLAN, at first, packets received are passed to nf_conntrack_in called from ip_rcv/ipv6_rcv. These packets are sent to virtual network device and these flows are confirmed in ip_output/ip6_output. However, in SRv6, at first, packets are passed to nf_conntrack_in, encapsulated and flows are confirmed in ipv6_output even if inner packets are IPv4. Therefore, IPv6 conntrack needs to be enabled to track IPv4 inner flow.

Second problem is caused when SRv6 packets are decapsulated. If IPv6 conntrack is enabled, SRv6 packets are passed to nf_conntrack_in called from ipv6_rcv. Even if inner packets are passed to nf_conntrack_in after packets are decapsulated, flow aren't tracked because skb->_nfct is already set. Therefore, IPv6 conntrack needs to be disabled to track IPv4 flow when packets are decapsulated.

This patch series solves these problems and allows conntrack to record inner flows correctly. It introduces netfilter hooks to srv6 lwtunnel and srv6local lwtunnel. It also introduces new sysctl toggle to turn on lightweight tunnel netfilter hooks. You can enable lwtunnel netfilter as following:

sysctl net.netfilter.nf_hooks_lwtunnel=1

v7: fix some comments
v6: apply some code chunks suggested
v5: rename nf_conntrack_lwtunnel to nf_hooks_lwtunnel, fix link error
when CONFIG_SYSCTL, add example code
v4: fix compile error when CONFIG_LWTUNNEL isn't enabled
v3: fix warning in nf_conntrack_lwtunnel.c
v2: introduce nf_ct_lwtunnel_enabled static_key and sysctl toggle to turn
on lightweight tunnel netfilter hook

Ryoga Saito (2):
netfilter: add new sysctl toggle for lightweight tunnel netfilter
hooks
netfilter: add netfilter hooks to SRv6 data plane

 .../networking/nf_conntrack-sysctl.rst        |   7 ++
 include/net/lwtunnel.h                        |   3 +
 include/net/netfilter/nf_hooks_lwtunnel.h     |  15 +++
 net/core/lwtunnel.c                           |   3 +
 net/ipv6/seg6_iptunnel.c                      |  74 +++++++++++-
 net/ipv6/seg6_local.c                         | 110 ++++++++++++------
 net/netfilter/Makefile                        |   3 +
 net/netfilter/nf_conntrack_standalone.c       |  15 +++
 net/netfilter/nf_hooks_lwtunnel.c             |  66 +++++++++++
 9 files changed, 260 insertions(+), 36 deletions(-)
 create mode 100644 include/net/netfilter/nf_hooks_lwtunnel.h
 create mode 100644 net/netfilter/nf_hooks_lwtunnel.c
Signature · 1 line
2.25.1