Subject: Re: [PATCH RFC ipsec-next] esp: Consolidate esp4 and esp6.

From: Simon Horman <[email-masked]>
Date: Mon, 27 Oct 2025 15:48:25 +0000

On Wed, Oct 22, 2025 at 08:03:07AM +0200, Steffen Klassert wrote:
> This patch merges common code of esp4.c and esp6.c into
> xfrm_esp.c. This almost halves the size of the ESP
> implementation for the prize of three indirect calls

nit: prize -> price

> on UDP/TCP encapsulation. No functional changes.
> 
> Signed-off-by: Steffen Klassert <[email-masked]>
> Tested-by: Tobias Brunner <[email-masked]>
> ---
>  include/net/esp.h       |    6 +
>  include/net/xfrm.h      |    4 +
>  net/ipv4/esp4.c         | 1067 ++------------------------------------
>  net/ipv6/esp6.c         | 1093 +++------------------------------------
>  net/ipv6/esp6_offload.c |    6 +-
>  net/xfrm/Makefile       |    1 +
>  net/xfrm/xfrm_esp.c     | 1025 ++++++++++++++++++++++++++++++++++++
>  7 files changed, 1156 insertions(+), 2046 deletions(-)

Less is more :)

...

> diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c

...

> +static int esp6_input_encap(struct sk_buff *skb, struct xfrm_state *x)
>  {
> +	const struct ipv6hdr *ip6h = ipv6_hdr(skb);
> +	int offset = skb_network_offset(skb) + sizeof(*ip6h);
> +	int hdr_len = skb_network_header_len(skb);

nit: hrd_len is set here and incremented below,
     but otherwise unused in this function.

...