xfrm: bug fixes when processing multiple transforms
Subsystems (3)
cover xfrm: bug fixes when processing multiple transforms
This series contains bug fixes that were encountered when I set up a libreswan tunnel using the config below, which will set up an IPsec policy involving 2 tmpls.
type=transport
compress=yes
esp=aes_gcm_c-128-null # offloaded to Niantic
auto=start
The non-offload test case uses esp=aes_gcm_c-256-null.
Each patch has a technical description of the contents of the fix.
Sowmini Varadhan (2):
xfrm: reset transport header back to network header after all input
transforms ahave been applied
xfrm: reset crypto_done when iterating over multiple input xfrms
net/ipv4/xfrm4_input.c | 1 + net/ipv4/xfrm4_mode_transport.c | 4 +--- net/ipv6/xfrm6_input.c | 1 + net/ipv6/xfrm6_mode_transport.c | 4 +--- net/xfrm/xfrm_input.c | 1 + 5 files changed, 5 insertions(+), 6 deletions(-)
PATCH 1/2 xfrm: reset transport header back to network header after all input transforms ahave been applied
A policy may have been set up with multiple transforms (e.g., ESP and ipcomp). In this situation, the ingress IPsec processing iterates in xfrm_input() and applies each transform in turn, processing the nexthdr to find any additional xfrm that may apply.
This patch resets the transport header back to network header only after the last transformation so that subsequent xfrms can find the correct transport header.
--- net/ipv4/xfrm4_input.c | 1 + net/ipv4/xfrm4_mode_transport.c | 4 +--- net/ipv6/xfrm6_input.c | 1 + net/ipv6/xfrm6_mode_transport.c | 4 +--- 4 files changed, 4 insertions(+), 6 deletions(-)
net/ipv4/xfrm4_input.c +1 -0
@@ -67,6 +67,7 @@ int xfrm4_transport_finish(struct sk_buff *skb, int async)if (xo && (xo->flags &XFRM_GRO )) {skb_mac_header_rebuild (skb); +skb_reset_transport_header (skb);return 0 ; }
net/ipv4/xfrm4_mode_transport.c +1 -3
@@ -46,7 +46,6 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb)static int xfrm4_transport_input (struct xfrm_state *x,struct sk_buff *skb) {int ihl = skb->data -skb_transport_header (skb); -struct xfrm_offload *xo =xfrm_offload (skb);if (skb->transport_header != skb->network_header) { memmove(skb_transport_header(skb),
@@ -54,8 +53,7 @@ static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb) skb->network_header = skb->transport_header; }ip_hdr (skb)->tot_len =htons (skb->len + ihl); -if (!xo || !(xo->flags &XFRM_GRO )) -skb_reset_transport_header (skb); +skb_reset_transport_header (skb);return 0 ; }
net/ipv6/xfrm6_input.c +1 -0
@@ -59,6 +59,7 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async)if (xo && (xo->flags &XFRM_GRO )) {skb_mac_header_rebuild (skb); +skb_reset_transport_header (skb);return -1 ; }
net/ipv6/xfrm6_mode_transport.c +1 -3
@@ -51,7 +51,6 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)static int xfrm6_transport_input (struct xfrm_state *x,struct sk_buff *skb) {int ihl = skb->data -skb_transport_header (skb); -struct xfrm_offload *xo =xfrm_offload (skb);if (skb->transport_header != skb->network_header) { memmove(skb_transport_header(skb),
@@ -60,8 +59,7 @@ static int xfrm6_transport_input(struct xfrm_state *x, struct sk_buff *skb) }ipv6_hdr (skb)->payload_len =htons (skb->len + ihl -sizeof (struct ipv6hdr )); -if (!xo || !(xo->flags &XFRM_GRO )) -skb_reset_transport_header (skb); +skb_reset_transport_header (skb);return 0 ; }
Signature · 1 line
1.7.1
PATCH 2/2 xfrm: reset crypto_done when iterating over multiple input xfrms
In reply to Sowmini VaradhanWe only support one offloaded xfrm (we do not have devices that can handle more than one offload), so reset crypto_done in xfrm_input() when iterating over multiple transforms in xfrm_input, so that we can invoke the appropriate x->type->input for the non-offloaded transforms
--- net/xfrm/xfrm_input.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
net/xfrm/xfrm_input.c +1 -0
@@ -458,6 +458,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)XFRM_INC_STATS (net,LINUX_MIB_XFRMINHDRERROR ); goto drop; } + crypto_done = false; }while (!err); err =xfrm_rcv_cb (skb, family, x->type->proto,0 );
Signature · 1 line
1.7.1
Steffen Klassert
maintainerRe: [PATCH ipsec-next 1/2] xfrm: reset transport header back to network header after all input transforms ahave been applied
In reply to Sowmini VaradhanQuoted 11 lines · Sowmini Varadhan
A policy may have been set up with multiple transforms (e.g., ESP and ipcomp). In this situation, the ingress IPsec processing iterates in
xfrm_input()and applies each transform in turn, processing the nexthdr to find any additional xfrm that may apply.This patch resets the transport header back to network header only after the last transformation so that subsequent xfrms can find the correct transport header.
Suggested-by Steffen Klassert <[email protected]>Signed-off-by Sowmini Varadhan <[email protected]>
This patch is a fix, so please add a proper fixes tag so that it can be backported to the stable trees. Same applied to the other patch in this series.