Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0DC2C433EF for ; Thu, 3 Mar 2022 14:55:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234189AbiCCO4R (ORCPT ); Thu, 3 Mar 2022 09:56:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234190AbiCCO4Q (ORCPT ); Thu, 3 Mar 2022 09:56:16 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A7EE18FAE0 for ; Thu, 3 Mar 2022 06:55:30 -0800 (PST) Received: from LAPTOP-CHBRPQ78.localdomain (dynamic-077-011-020-034.77.11.pool.telefonica.de [77.11.20.34]) by linux.microsoft.com (Postfix) with ESMTPSA id B268A20B7178; Thu, 3 Mar 2022 06:55:28 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B268A20B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1646319329; bh=6raFnqFH7gCAGxa8fdvCcfzEBy0HlyjNuBUPg4l7/Ew=; h=From:To:Subject:Date:From; b=kHjWs+gUdyJy3ThbvyMHxwLspy0DStz1S0nG+UGcXmosrmgwpmCtA0q7mtIO0Yo4M JeAK2PbH0f+k6bzI6e/1JXkIJBz0OM9/3AnwEqVSQthWHe4yPsgVCGK80QeKlvqqAE LOlj4Xo0uAZIirB85FJmbEiq7WkrMcesIQ8h/Lkc= From: kailueke@linux.microsoft.com To: netdev@vger.kernel.org, Steffen Klassert , Jakub Kicinski , Paul Chaignon , Eyal Birger Subject: [PATCH] Revert "xfrm: state and policy should fail if XFRMA_IF_ID 0" Date: Thu, 3 Mar 2022 15:55:10 +0100 Message-Id: <20220303145510.324-1-kailueke@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Kai Lueke This reverts commit 68ac0f3810e76a853b5f7b90601a05c3048b8b54 because ID 0 was meant to be used for configuring the policy/state without matching for a specific interface (e.g., Cilium is affected, see https://github.com/cilium/cilium/pull/18789 and https://github.com/cilium/cilium/pull/19019). Signed-off-by: Kai Lueke --- net/xfrm/xfrm_user.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 8cd6c8129004..be89a8ac54a4 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -630,13 +630,8 @@ static struct xfrm_state *xfrm_state_construct(struct net *net, xfrm_smark_init(attrs, &x->props.smark); - if (attrs[XFRMA_IF_ID]) { + if (attrs[XFRMA_IF_ID]) x->if_id = nla_get_u32(attrs[XFRMA_IF_ID]); - if (!x->if_id) { - err = -EINVAL; - goto error; - } - } err = __xfrm_init_state(x, false, attrs[XFRMA_OFFLOAD_DEV]); if (err) @@ -1432,13 +1427,8 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, mark = xfrm_mark_get(attrs, &m); - if (attrs[XFRMA_IF_ID]) { + if (attrs[XFRMA_IF_ID]) if_id = nla_get_u32(attrs[XFRMA_IF_ID]); - if (!if_id) { - err = -EINVAL; - goto out_noput; - } - } if (p->info.seq) { x = xfrm_find_acq_byseq(net, mark, p->info.seq); @@ -1751,13 +1741,8 @@ static struct xfrm_policy *xfrm_policy_construct(struct net *net, struct xfrm_us xfrm_mark_get(attrs, &xp->mark); - if (attrs[XFRMA_IF_ID]) { + if (attrs[XFRMA_IF_ID]) xp->if_id = nla_get_u32(attrs[XFRMA_IF_ID]); - if (!xp->if_id) { - err = -EINVAL; - goto error; - } - } return xp; error: -- 2.25.1