XFRM Interface Development Notes: Difference between revisions

From Libreswan
Jump to navigation Jump to search
No edit summary
No edit summary
Line 106: Line 106:


==== Which mark? ====
==== Which mark? ====
Two marks related to xfrm code in Linux kernel.  [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6f26b61e177e57a41795355f6222cf817f1212dc XFRMA_MARK] and  [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9b42c1f179a614e11893ae4619f0304a38f481ae XFRMA_SET_MARK](XFRMA_OUTPUT_MARK). Now on I use XFRM_OUTPUT_MARK mark which as 4.20 mean XFRM_SET_MARK/[XFRM_SET_MARK_MASK]
Two marks related to xfrm code in Linux kernel.  [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6f26b61e177e57a41795355f6222cf817f1212dc XFRMA_MARK] and  [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9b42c1f179a614e11893ae4619f0304a38f481ae XFRMA_SET_MARK]([https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=077fbac405bfc6d41419ad6c1725804ad4e9887c  aka XFRMA_OUTPUT_MARK]). Now on I use XFRM_OUTPUT_MARK mark which as of 4.20 mean XFRM_SET_MARK/[https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9b42c1f179a614e11893ae4619f0304a38f481ae XFRM_SET_MARK_MASK]


One line difference. XFRM_OUTPUT_MARK mark is for routing a packet after XFRM (ESP out or Clear text in), while [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6f26b61e177e57a41795355f6222cf817f1212dc XFRMA_MARK] could be sees as routing a clear text packet into xfrm code,  XFRMA_MARK is a lookup key of SPDB and SADB.  
One line difference. XFRM_OUTPUT_MARK mark is for routing a packet after XFRM (ESP out or Clear text in), while [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6f26b61e177e57a41795355f6222cf817f1212dc XFRMA_MARK] could be sees as routing a clear text packet into xfrm code,  XFRMA_MARK is a lookup key of SPDB and SADB.  

Revision as of 11:39, 19 February 2019

Development notes for XFRMi

libreswan/pluto design choices

  • allow names ipsec0, ipsec1 ... ipsecx.
  • Should we allow names other than ipsecXX ?
  • initial thought is keep "xfrm interface id" and "xfrm output mark" consistent.
  • interface creation is inside pluto.
  • create bugzilla entry for Fedora/CentOS kernels? Fedora 28 do not enable

Kernel XFRM - related

XFRM INTERFACE

Commit cover letter from Steffen 20180612, Merged in 4.19:

https://patchwork.ozlabs.org/cover/928175/

Steffen Klassert June 12, 2018, 7:56 a.m.

This patchset introduces new virtual xfrm interfaces.
The design of virtual xfrm interfaces interfaces was
discussed at the Linux IPsec workshop 2018. This patchset
implements these interfaces as the IPsec userspace and
kernel developers agreed. The purpose of these interfaces
is to overcome the design limitations that the existing
VTI devices have.

The main limitations that we see with the current VTI are the
following:

- VTI interfaces are L3 tunnels with configurable endpoints.
  For xfrm, the tunnel endpoint are already determined by the SA.
  So the VTI tunnel endpoints must be either the same as on the
  SA or wildcards. In case VTI tunnel endpoints are same as on
  the SA, we get a one to one correlation between the SA and
  the tunnel. So each SA needs its own tunnel interface.

  On the other hand, we can have only one VTI tunnel with
  wildcard src/dst tunnel endpoints in the system because the
  lookup is based on the tunnel endpoints. The existing tunnel
  lookup won't work with multiple tunnels with wildcard
  tunnel endpoints. Some usecases require more than on
  VTI tunnel of this type, for example if somebody has multiple
  namespaces and every namespace requires such a VTI.

- VTI needs separate interfaces for IPv4 and IPv6 tunnels.
  So when routing to a VTI, we have to know to which address
  family this traffic class is going to be encapsulated.
  This is a lmitation because it makes routing more complex
  and it is not always possible to know what happens behind the
  VTI, e.g. when the VTI is move to some namespace.

- VTI works just with tunnel mode SAs. We need generic interfaces
  that ensures transfomation, regardless of the xfrm mode and
  the encapsulated address family.

- VTI is configured with a combination GRE keys and xfrm marks.
  With this we have to deal with some extra cases in the generic
  tunnel lookup because the GRE keys on the VTI are actually
  not GRE keys, the GRE keys were just reused for something else.
  All extensions to the VTI interfaces would require to add
  even more complexity to the generic tunnel lookup.

To overcome this, we started with the following design goal:

- It should be possible to tunnel IPv4 and IPv6 through the same
  interface.

- No limitation on xfrm mode (tunnel, transport and beet).

- Should be a generic virtual interface that ensures IPsec
  transformation, no need to know what happens behind the
  interface.

- Interfaces should be configured with a new key that must match a
  new policy/SA lookup key.

- The lookup logic should stay in the xfrm codebase, no need to
  change or extend generic routing and tunnel lookups.

- Should be possible to use IPsec hardware offloads of the underlying
  interface.

Initial xfrmi kernel commits

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f203b76d78092faf248db3f851840fbecf80b40e

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7e6526404adedf079279aa7aa11722deaca8fe2e

XFRM OUTPUT_MARK (required commits to be pulled to RHEL)

Add mask and rename to XFRMA_SET_MARK, Steffen

Initial Commit, Lorenzo

Which mark?

Two marks related to xfrm code in Linux kernel. XFRMA_MARK and XFRMA_SET_MARK(aka XFRMA_OUTPUT_MARK). Now on I use XFRM_OUTPUT_MARK mark which as of 4.20 mean XFRM_SET_MARK/XFRM_SET_MARK_MASK

One line difference. XFRM_OUTPUT_MARK mark is for routing a packet after XFRM (ESP out or Clear text in), while XFRMA_MARK could be sees as routing a clear text packet into xfrm code, XFRMA_MARK is a lookup key of SPDB and SADB.

XFRMA_MARK is used inside xfrm code (clear text packet out only) code. One could say both marks are used for routing a packet. However XFRM_SET_MARK it is used from routing say outgoing clear text packet. While XFRM_SET_MARK is used for rougint ESP packet on the output side and clear text packet on the input side.

[https://lwn.net/Articles/375829/ Jamal's explination https://lwn.net/Articles/375829/ XFRMA_MARK syntax is mark(u32)/mark(u32). XFRM_OUTPUT_MARK

Track bugs and related

Fedora support

  • F29 commit enabled it. However not in F28
  • RHEL bugzilla request??