Re: [PATCH ipsec] xfrm: allow route optimization mode only for DSTOPTS and ROUTING states
From: Steffen Klassert
Date: Tue Nov 24 2026 - 05:19:04 EST
On Tue, Nov 24, 2026 at 11:13:22AM +0100, Sabrina Dubroca wrote:
> 2026-11-24, 16:08:56 +0900, Kyuwon Cho wrote:
> > verify_newsa_info() accepts XFRM_MODE_ROUTEOPTIMIZATION with any
> > protocol. esp6_init_state() treats a mode it does not know as
> > transport, so an ESP state in that mode is created, and the first
>
> nit: I'd say it doesn't really "treat" it as transport, it accepts
> everything and doesn't adjust header_len.
>
> > packet through it hits the WARN_ON_ONCE()s in xfrm_state_mtu() and
> > xfrm_inner_mode_input(), which assume that route optimization never
> > comes with ESP:
>
> Looking at the list of available modes (include/uapi/linux/xfrm.h),
> what about XFRM_MODE_IN_TRIGGER?
>
> > WARNING: net/xfrm/xfrm_state.c:3264 at xfrm_state_mtu+0x239/0x3d0
> > RIP: 0010:xfrm_state_mtu (net/xfrm/xfrm_state.c:3264)
> > Call Trace:
> > <TASK>
> > xfrm_bundle_create (net/xfrm/xfrm_policy.c:3992 net/xfrm/xfrm_policy.c:2785)
> > xfrm_resolve_and_create_bundle (net/xfrm/xfrm_policy.c:2885)
> > xfrm_lookup_with_ifid (net/xfrm/xfrm_policy.c:3114 net/xfrm/xfrm_policy.c:3245)
> > xfrm_lookup_route (net/xfrm/xfrm_policy.c:3344 net/xfrm/xfrm_policy.c:3355)
> > ip6_dst_lookup_flow (net/ipv6/ip6_output.c:1299)
> > udpv6_sendmsg (net/ipv6/udp.c:1699)
> >
> > WARNING: net/xfrm/xfrm_input.c:449 at xfrm_input+0x2176/0x5f50
> > RIP: 0010:xfrm_input (net/xfrm/xfrm_input.c:449 net/xfrm/xfrm_input.c:705)
> > Call Trace:
> > <IRQ>
> > xfrm6_esp_rcv (net/ipv6/xfrm6_protocol.c:119)
> > ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:479)
> >
> > Accept the mode only for the Mobile IPv6 protocols, as IP-TFS mode is
> > already limited to ESP.
>
> This is reasonable, but I think we should instead (or maybe "also")
> add mode filtering to each ->init_state.
I suggested to do it this way, but we also can do it on both sides.