From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx1.secunet.com (mx1.secunet.com [62.96.220.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10A533E122E for ; Fri, 12 Jun 2026 07:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.96.220.36 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781250493; cv=none; b=G9CjGfzcU189Cd3I2u6578O2yzAYb3jatTjvmGzAqK/B8/9J6Ro0kyUIrysOBYeIVKwALeafLNFLmiSx8dDXUtlejf5NDbWyYd/0WJCcc030MG8GfYWRTbq2V14eAeoO46p2ubh/3KF3slMwfD3TEZu7vsMLjD3xpTnpvwdTot0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781250493; c=relaxed/simple; bh=+nSj1HgHSzWJYGa01lG+LlT24/TtrejZWBI6Yrxr4f4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mPCbjZLbTirW2mo/MyHgEGtuK+VlvIODOZdsIcdSjD2RNKX1tgHJ57FhAqSD/sjfuWm6gwGKSxwZ88knnpvWmVhci+GZl9xnLm85NqFaKeIToO7oD+rlSI23OsDI0JNKbdnv3BcLTTHowDkFwFTg6MJulkIELtfpViXhPJfCXos= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com; spf=pass smtp.mailfrom=secunet.com; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.b=A+PndSCJ; arc=none smtp.client-ip=62.96.220.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=secunet.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=secunet.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=secunet.com header.i=@secunet.com header.b="A+PndSCJ" Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id 6B92F207B3; Fri, 12 Jun 2026 09:48:07 +0200 (CEST) X-Virus-Scanned: by secunet Received: from mx1.secunet.com ([127.0.0.1]) by localhost (mx1.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zc2n73dgpfyf; Fri, 12 Jun 2026 09:48:06 +0200 (CEST) Received: from EXCH-01.secunet.de (rl1.secunet.de [10.32.0.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.secunet.com (Postfix) with ESMTPS id D3E7C206E9; Fri, 12 Jun 2026 09:48:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com D3E7C206E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1781250486; bh=1FpR4HWlvEXrTFfynEE1ituGt5XMffHgjWlDvB+9kro=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=A+PndSCJt0zploBoC1+x62qVe9VfaAJzoqhz51CBnUgKBEQXsZutxhr5Dm2Tu+vCw gvF3nKI/tc0K57EffDZJZwnVk4ne6rW4ZSiyYKBEKvmfUyIopvTvb8NSMN4UCSnSip xPNVn/2qwWQjRHlGHA7iROGGOy4FhhZnDhdlkgcYQEvRj40/h4e6dwWcXvzD0/dji2 dU+9gm8xmWNAvj6Tj1SBR/nlyiK3qKqaOqJNqjiKbbbzCT3y3MM0kza9cq3WYNCbYN Fa6FNbAITO4/5waFh7oiavN5MMvTGUtoAqS5MANHJyxj0DnpndKKkzR1hx/kspo+39 OstMIyGdaUuDg== Received: from secunet.com (10.182.7.193) by EXCH-01.secunet.de (10.32.0.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Fri, 12 Jun 2026 09:48:06 +0200 Received: (nullmailer pid 1768278 invoked by uid 1000); Fri, 12 Jun 2026 07:47:57 -0000 From: Steffen Klassert To: David Miller , Jakub Kicinski CC: Herbert Xu , Steffen Klassert , Subject: [PATCH 05/18] xfrm: allow migration from UDP encapsulated to non-encapsulated ESP Date: Fri, 12 Jun 2026 09:46:21 +0200 Message-ID: <20260612074725.1760473-6-steffen.klassert@secunet.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260612074725.1760473-1-steffen.klassert@secunet.com> References: <20260612074725.1760473-1-steffen.klassert@secunet.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EXCH-01.secunet.de (10.32.0.171) To EXCH-01.secunet.de (10.32.0.171) From: Antony Antony The current code prevents migrating an SA from UDP encapsulation to plain ESP. This is needed when moving from a NATed path to a non-NATed one, for example when switching from IPv4+NAT to IPv6. Only copy the existing encapsulation during migration if the encap attribute is explicitly provided. Note: PF_KEY's SADB_X_MIGRATE always passes encap=NULL and never supported encapsulation in migration. PF_KEY is deprecated and was in feature freeze when UDP encapsulation was added to xfrm. Tested-by: Yan Yan Reviewed-by: Sabrina Dubroca Signed-off-by: Antony Antony Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_state.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 53d88b87bdbd..933541bc9093 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2008,14 +2008,8 @@ static struct xfrm_state *xfrm_state_clone_and_setup(struct xfrm_state *orig, } x->props.calgo = orig->props.calgo; - if (encap || orig->encap) { - if (encap) - x->encap = kmemdup(encap, sizeof(*x->encap), - GFP_KERNEL); - else - x->encap = kmemdup(orig->encap, sizeof(*x->encap), - GFP_KERNEL); - + if (encap) { + x->encap = kmemdup(encap, sizeof(*x->encap), GFP_KERNEL); if (!x->encap) goto error; } -- 2.43.0