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 9F9E9344029; Tue, 27 Jan 2026 10:42:56 +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=1769510578; cv=none; b=DP59U3CRWZqWFxA45oiLaMPxMRX+No9YCW9okpLci/xjzTmM3kNpCsOu7z0bZZ7oc6hYfuqWfGIzr4QRicrKgIUPYO/Gdo90ZA4YeJmp43/zQS90lT4qnk4U4auJWGDY0u7dZT9jRYhU97Tr1V0JipAOtdV0XDqdperBart8KsM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769510578; c=relaxed/simple; bh=qaxXbj/lZrGfH45uvz3HpIXzZKwwzlU0afATp2HcdOk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FiLMmUzqHp1joAXtieTWbdVYLRjNBMfxkpsOPtanWeWRUp9gm3UbtRGdAnrtrtKC4gb3KFoq6mBFHIFT3X0V93IVRkaa1xnfce1Sc85S+epOKOfKdenhdn35ql2BlhfifV68lSENZNGfIh1f3HSAtu1YxsBDAGPtehUKO2bmFmg= 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=E0Z/S1HW; 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="E0Z/S1HW" Received: from localhost (localhost [127.0.0.1]) by mx1.secunet.com (Postfix) with ESMTP id F20E0201C7; Tue, 27 Jan 2026 11:42:54 +0100 (CET) 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 WUujZ7IHfjLP; Tue, 27 Jan 2026 11:42:54 +0100 (CET) Received: from EXCH-02.secunet.de (rl2.secunet.de [10.32.0.232]) (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 66132200AC; Tue, 27 Jan 2026 11:42:54 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.secunet.com 66132200AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secunet.com; s=202301; t=1769510574; bh=aF6X62isezJyFOdmRHZ+6fe25lTe0mpz3TLchvYvKBg=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=E0Z/S1HW2Svuckk39gCRnx9Hz5w9exMcDa02Boj1kRWriwBhQ6tniul8MLHDxuuC0 tr5ARjdffpeC8fSRzJdymIpeA8wE6TnPLaH9j3RK5SUcDnrs4d3uC5ZE31mNYR4DkW Od4Hi+TH3AycPnQeDV1hUZEL+lCGPhTj5GCb2oUR7c5kOorNbYfsjuxqfVKkohHxNd vNyDkvuSCisiZlUGVhLUH1qe2+LNnnvjM68GwKzESTL7wTOjnBqFQGvbUWaqta+JMX nXUXm7Upbn2DSeudxRO+2wpXfIpH+OJq8afEnlDBHBW4C2nXgHVKsLQCuX9f0w6ltk QaG2sZf1sE6xQ== Received: from moon.secunet.de (172.18.149.1) by EXCH-02.secunet.de (10.32.0.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 27 Jan 2026 11:42:53 +0100 From: Antony Antony To: Antony Antony , Steffen Klassert , Herbert Xu , CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Chiachang Wang , Yan Yan , , Simon Horman , Subject: [PATCH ipsec-next v5 3/8] xfrm: allow migration from UDP encapsulated to non-encapsulated ESP Date: Tue, 27 Jan 2026 11:42:40 +0100 Message-ID: <7c30e7f8543048a384f693684ccba5f71fe8543b.1769509131.git.antony.antony@secunet.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EXCH-04.secunet.de (10.32.0.184) To EXCH-02.secunet.de (10.32.0.172) 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. Signed-off-by: Antony Antony --- 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 3ee92f93dbd2..9ddd033f5d79 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.39.5