From patchwork Tue Oct 15 09:11:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13835968 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 BA6DD1D9A45 for ; Tue, 15 Oct 2024 09:11:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983494; cv=none; b=aptBS9BTv4Jm9I4xNlhXWncFjvUK3E4as9M4+f4woxrogD83wCzF3iY7N8kXTgClrZZtHmhbR88KMaiKX7npcfFMISL2IHOUU8OMwtdVfGNIeK36+oI2jCK32bImHBjsG+TJi99ML0s6S+JwdhKWHkYT0K62RCX3F8q9UOH7S60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983494; c=relaxed/simple; bh=+ZJbHEUCt8uIFKCFjVE0DwAumbjRnoTg0o6D3a8oao4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FaV705hjAemm/NuXY8FkSc/M99WP674xTtZU7zyj31YvWKhjZmDJbnmqhm3UjHbDqEfZbVm9S97AvIwufmRYKjrirTO7Isj78vtptwpVZqcp1u89Qo6ces2zuoTZdpgUJeZ8Z+qpTCBYS3HsqTSiAuOKh5DOSHDZwHtGUE82GAA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=X6iE1FbT; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="X6iE1FbT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728983490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NXl0UsW78ZnOX79ISir//K4p/RwcrOXNWC8dgMLoFgY=; b=X6iE1FbTO/2QoYXwTsmcKUeVl1z5+2y5cJGthFPRDRVGuKOYE1VXAjrFyUmKuozaZNmbuz 7WxP4sm8r4LTDxBDMCDHsTfIa3K+G17xisVWRDLYGVf1sIhM94LZDxy52LCappXBwH2XsP gzkKaZPN3AtbYYdlV7q/+YwzWr6GBKI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-A-SqtMNxPKm3LgL0d9szjQ-1; Tue, 15 Oct 2024 05:11:29 -0400 X-MC-Unique: A-SqtMNxPKm3LgL0d9szjQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4311cf79381so26264465e9.0 for ; Tue, 15 Oct 2024 02:11:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728983488; x=1729588288; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NXl0UsW78ZnOX79ISir//K4p/RwcrOXNWC8dgMLoFgY=; b=H6Rsg0TSZxHrWUc77c+e6aJG0lEnCweFRrlzJYkb+fjsVbHimL2wYQl8Y0cN9jD+K5 SOzRvNDJ9fMKSiKuO1AMTfJlGuweUokSb+IqvyITC5zmV4GTjP5Ab4uBa/exrRG6G5KI rhYRs4mJeKDPvKdr3dgSzX4KXWSGW/D5SgVuHeputXtZgVXZiMBLNYzjFeSg3Y9Hv6jq n3X71arhzMZ37O3CgoChAA7tyQNJmHQ4YKt4CSfMYb2pXWPRbYDMRPjpW+Hanb/dY4nP 5Ye47N1p43dDdbdsFrMkBuaTq9Jr72Jrf62dbSbq8yRGjivLoO5fsw249v4C+T6/o2YY LnXw== X-Gm-Message-State: AOJu0YxY/Ra8TxGGCVFzeWWj95Iq9s6MX41wwENjn4GIBkUCtb1L8N+p 9AI15sasUMY354U14lIw/0xAUshnNYDm1SkFqmywOi4rdixuEszhef7Xm32dQv5gVfHnrSUstSW lo+//jykC+Sw8DX9EeAK+EkU5IB4JHDzjR0odLNlhNisVYRO4WkqVLQ== X-Received: by 2002:a05:600c:3511:b0:42c:b9a5:ebbc with SMTP id 5b1f17b1804b1-4311deeb82dmr136667205e9.16.1728983488014; Tue, 15 Oct 2024 02:11:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMWLhpjdNkRWzbAkJsg+ZTFRJJp6S7hDKu63nfTN9MP8cv01JiU9AIGOVEDntUivXgODbWGA== X-Received: by 2002:a05:600c:3511:b0:42c:b9a5:ebbc with SMTP id 5b1f17b1804b1-4311deeb82dmr136667005e9.16.1728983487654; Tue, 15 Oct 2024 02:11:27 -0700 (PDT) Received: from debian (2a01cb058d23d60030b5722051bf3d85.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:30b5:7220:51bf:3d85]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43145a98ed0sm2535425e9.0.2024.10.15.02.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 02:11:27 -0700 (PDT) Date: Tue, 15 Oct 2024 11:11:25 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Steffen Klassert , Herbert Xu , David Ahern , Ido Schimmel Subject: [PATCH net-next 1/6] xfrm: Convert xfrm_get_tos() to dscp_t. Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Return a dscp_t variable to prepare for the future conversion of xfrm_bundle_create() to dscp_t. While there, rename the function "xfrm_get_dscp", to align its name with the new return type. Signed-off-by: Guillaume Nault --- net/xfrm/xfrm_policy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 914bac03b52a..dd472e9df059 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -2550,10 +2550,10 @@ xfrm_tmpl_resolve(struct xfrm_policy **pols, int npols, const struct flowi *fl, } -static int xfrm_get_tos(const struct flowi *fl, int family) +static dscp_t xfrm_get_dscp(const struct flowi *fl, int family) { if (family == AF_INET) - return fl->u.ip4.flowi4_tos & INET_DSCP_MASK; + return inet_dsfield_to_dscp(fl->u.ip4.flowi4_tos); return 0; } @@ -2647,7 +2647,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, xfrm_flowi_addr_get(fl, &saddr, &daddr, family); - tos = xfrm_get_tos(fl, family); + tos = inet_dscp_to_dsfield(xfrm_get_dscp(fl, family)); dst_hold(dst); From patchwork Tue Oct 15 09:11:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13835969 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 525531E2825 for ; Tue, 15 Oct 2024 09:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983496; cv=none; b=FgIkvN/iwLPOXIUUct8rb6dC8x+dnQtGJe/1lmK/PcsnW2OTVmO40w35kvIHgHSfn7vW+T31f5TL5eWfdvPsdN+vdo0Pe7m2wTPBOLhtV7xTni96UcfZ2av1MzKMGkVbRkoHAYsEYaAqvNZGmLP7QUmjfIkUGmnvqEJztS8wAtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983496; c=relaxed/simple; bh=ci6SYSv24/2m6zH5eR0zepGnoDfgz892dKFFJC7LoQE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WVvTgyVAM505EOHgSuFLCzaT9P0U7Y+YTg6xE4QGlVs1Fp7PxDVDE+wft3WVBgh9wy6LqVcjCs8Qw7QDGyDlzjSOoZCaE2far6qipOBBWfFM3LBduWaT5KIDU6vjynZXbbhj7AD3j9uZcMPUFoPCZ1DXnG+k4IWpepzA+ipBxVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CINK5LLN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CINK5LLN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728983494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aJoTE8zVpQ7BdycHoKDA0BPiIQr42d4xFhr1RoFPvsM=; b=CINK5LLNgkVJo+Z7L2g5Dd87Xp9wFr6VPakcQJ+RCuUSlYHt8RRv+t8EOt8mwvNF0W2lcn Y+FooUhPGAMmxI84CVKi2DSyrxqWJRnql2eX/+8vjP85SsaX9+B0wpWVbMPVzR1naPt4s7 AWMeShsYBw+fKaM5NmS/2uCTcBt7Ep4= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-3I4b0FWiPPWVb9nzRs7Nlg-1; Tue, 15 Oct 2024 05:11:33 -0400 X-MC-Unique: 3I4b0FWiPPWVb9nzRs7Nlg-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-539f067414fso1623626e87.2 for ; Tue, 15 Oct 2024 02:11:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728983491; x=1729588291; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aJoTE8zVpQ7BdycHoKDA0BPiIQr42d4xFhr1RoFPvsM=; b=RqnKyH52welV5iaI9goI8f5Gz396bZd/5DBba4h2YfyssjHLadydaVfbhiETgY/kLZ ABOpgR+Cj0twhrn6e1n+JKcJXBFAYfMInA+5iW0qo9bMrVLBlneK2o14SRYbEZEnt5M3 PkSm91FyzJNu/ts5u/0KaM3ApXorcXLk1UxtT8kxamn9oP5Z1SOz8/zWO6fHfoiEProW g5m2ZpQSsK7KVj+R27l91QgEsx5TQidVBVrjhtaU7Utyf48JSzMyNEfG/8ajtVWv0fvh KT4PdbcjmpiHLdmOfccSS8WT0tlrM4/S/yC+ivAsk3dcNhrp5m2yM9rfsZoLUJwpztS7 t4pA== X-Gm-Message-State: AOJu0YzStESwr7MTuE12ZuPN/QMHXRcBk29tt1tpkMjE+etU2xZbrbdj WN538IlqmE2nPxWU6brRSXa06sFJvyk+px6YeDg7M425WEHb/v715SnMtSV+hTUWq8YOkSTboqh 1YtzS4D8A4cggT6GMGqL7jXFfyBHlZEOuFbFgcLVwi2W+bpmtbhDu5Q== X-Received: by 2002:a05:6512:110e:b0:539:fc75:99ae with SMTP id 2adb3069b0e04-539fc759ab3mr2650481e87.31.1728983491471; Tue, 15 Oct 2024 02:11:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELc49DSy1nmoHloMfBd3oO+f8GzPHILsMYgroEHw5gpdoXv19MwT+DwubKifjOA6ul0KfB0Q== X-Received: by 2002:a05:6512:110e:b0:539:fc75:99ae with SMTP id 2adb3069b0e04-539fc759ab3mr2650467e87.31.1728983491048; Tue, 15 Oct 2024 02:11:31 -0700 (PDT) Received: from debian (2a01cb058d23d60030b5722051bf3d85.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:30b5:7220:51bf:3d85]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431487c194asm695955e9.21.2024.10.15.02.11.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 02:11:30 -0700 (PDT) Date: Tue, 15 Oct 2024 11:11:28 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Steffen Klassert , Herbert Xu , David Ahern , Ido Schimmel Subject: [PATCH net-next 2/6] xfrm: Convert xfrm_bundle_create() to dscp_t. Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Use a dscp_t variable to store the result of xfrm_get_dscp(). This prepares for the future conversion of xfrm_dst_lookup(). Signed-off-by: Guillaume Nault --- net/xfrm/xfrm_policy.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index dd472e9df059..c6ea3ca69e95 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -2641,13 +2641,13 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, int header_len = 0; int nfheader_len = 0; int trailer_len = 0; - int tos; + dscp_t dscp; int family = policy->selector.family; xfrm_address_t saddr, daddr; xfrm_flowi_addr_get(fl, &saddr, &daddr, family); - tos = inet_dscp_to_dsfield(xfrm_get_dscp(fl, family)); + dscp = xfrm_get_dscp(fl, family); dst_hold(dst); @@ -2695,7 +2695,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, family = xfrm[i]->props.family; oif = fl->flowi_oif ? : fl->flowi_l3mdev; - dst = xfrm_dst_lookup(xfrm[i], tos, oif, + dst = xfrm_dst_lookup(xfrm[i], + inet_dscp_to_dsfield(dscp), oif, &saddr, &daddr, family, mark); err = PTR_ERR(dst); if (IS_ERR(dst)) From patchwork Tue Oct 15 09:11:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13835970 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 016C41E3789 for ; Tue, 15 Oct 2024 09:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983500; cv=none; b=WnmGDI+P0SHPKQUiFtQx99Oq1qlRyubnVto8VrfySyf6sMQar4mVydDNiJwCZyQZTXv6mDYcmurI2bI6LlE5HBToqED6pXsPwiFmVrwuO+hqMLWa1p4Gr1QwM/zMul2RsfXaAxtAseiK+5BqSqKzt8E6Wnhx715hXW4z0mX1LRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983500; c=relaxed/simple; bh=D45yL0Nju2kzfdQUmpMYjnkDKhPHxNDRiWQdBByaQVc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=g2yKvdkNQFS7X8Wv6mKTwUXaQ20rxPf/9mI1elTAwb+XWhQJ4cfbO+ot3thxkWY9YfqpRhZ6C1xxLnAKuAkT5A9s1QeWSGf9jd1uuo+6I7FMY8mJ8ynFtpUHNr31g4c7Wfe4fzlkbjqSjV2+3v8AUdpLe8jolHn1PcVdl132e00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BKYVyrEa; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BKYVyrEa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728983498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wWSRCepcrvlsxye2pWByyEa1SGiFttt8FSXGegJlNpA=; b=BKYVyrEa6Cz0S8VW6d3MCAyaLgs++6O/uEBD1yRmEqXSi03/KXHBRqI0KRqjGLce2doup9 Xb49+oy5FJzZ85SRJFh5gA8p2GfSPx4OPpCNRGfSAohgMnc+nO6JpdcmiglCo25X9aYv0Q Wp8NxtYahaT3D8DPoLS2UM6APjzZFPk= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-Cr1g_R2pPH6vBk-tq963pA-1; Tue, 15 Oct 2024 05:11:36 -0400 X-MC-Unique: Cr1g_R2pPH6vBk-tq963pA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4311c5e8c02so25243205e9.2 for ; Tue, 15 Oct 2024 02:11:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728983495; x=1729588295; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wWSRCepcrvlsxye2pWByyEa1SGiFttt8FSXGegJlNpA=; b=HwHfX1DA0Zsh9rmZvxDbRW3LzQcViXViJwU/T2TyDCN1GGJaVV1zLodQ6DsMp/JJwv 6oDO/lx2EujLmLSe1g6zlXgKMro0fVTlWUnEO+eQv2+Wr5wOkxnBBJ1vjz7QZ+cAfNn3 69cX0x/a2rMoV/sQF/TV70hj8TEe1fkEOul/ZkQVj4RMCS0iQWr73YBsVJW4YFlbieb5 KHZt40PHTugvGGaIT5YbF/BrtY3UY6PiVblFeTCRHy1l/dX7RqJ6OoYjCehrlEZB1liE 5JdRjOk7hz8Z65M9Ux6sHQQ39YlEW1GiJuhZYKtSaZ7d1oTzIXRrEXADWfPkhLW1/9Nm g2Jw== X-Gm-Message-State: AOJu0YypjBwyzNVMHvjumbNkfXSFkIEhkadstfJPYqg6mEWs4NP3RmZT ZDtyD1FAwfe56Wu9N9GkYK4vwLU1DnQMvUGU+hPQy8YiScWiOce5Lz8OFC+AGDucxytydJq/v9Q vxACqI0ZXhm6xlL+jtOxCVXCiCNJVpis24rnZZHME7ogEtwOeeDEBzw== X-Received: by 2002:a05:600c:1ca3:b0:426:5269:1a50 with SMTP id 5b1f17b1804b1-4311deca951mr121116995e9.11.1728983495325; Tue, 15 Oct 2024 02:11:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/Gojakidof+JbRocyzjez9WGX2iWcFsxWM7LieLAfsxobmd6zuSq0jnECBlYGNu0Rd2+ZVA== X-Received: by 2002:a05:600c:1ca3:b0:426:5269:1a50 with SMTP id 5b1f17b1804b1-4311deca951mr121116825e9.11.1728983494963; Tue, 15 Oct 2024 02:11:34 -0700 (PDT) Received: from debian (2a01cb058d23d60030b5722051bf3d85.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:30b5:7220:51bf:3d85]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f56eab2sm11562235e9.26.2024.10.15.02.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 02:11:34 -0700 (PDT) Date: Tue, 15 Oct 2024 11:11:31 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Steffen Klassert , Herbert Xu , David Ahern , Ido Schimmel Subject: [PATCH net-next 3/6] xfrm: Convert xfrm_dst_lookup() to dscp_t. Message-ID: <4c397061eb9f054cdcc3f5e60716b77c6b7912ad.1728982714.git.gnault@redhat.com> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Pass a dscp_t variable to xfrm_dst_lookup(), instead of an int, to prevent accidental setting of ECN bits in ->flowi4_tos. Only xfrm_bundle_create() actually calls xfrm_dst_lookup(). Since it already has a dscp_t variable to pass as parameter, we only need to remove the inet_dscp_to_dsfield() conversion. Signed-off-by: Guillaume Nault --- net/xfrm/xfrm_policy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index c6ea3ca69e95..6e30b110accf 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -291,7 +291,7 @@ struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, int oif, EXPORT_SYMBOL(__xfrm_dst_lookup); static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x, - int tos, int oif, + dscp_t dscp, int oif, xfrm_address_t *prev_saddr, xfrm_address_t *prev_daddr, int family, u32 mark) @@ -310,7 +310,8 @@ static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x, daddr = x->coaddr; } - dst = __xfrm_dst_lookup(net, tos, oif, saddr, daddr, family, mark); + dst = __xfrm_dst_lookup(net, inet_dscp_to_dsfield(dscp), oif, saddr, + daddr, family, mark); if (!IS_ERR(dst)) { if (prev_saddr != saddr) @@ -2695,9 +2696,8 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, family = xfrm[i]->props.family; oif = fl->flowi_oif ? : fl->flowi_l3mdev; - dst = xfrm_dst_lookup(xfrm[i], - inet_dscp_to_dsfield(dscp), oif, - &saddr, &daddr, family, mark); + dst = xfrm_dst_lookup(xfrm[i], dscp, oif, &saddr, + &daddr, family, mark); err = PTR_ERR(dst); if (IS_ERR(dst)) goto put_states; From patchwork Tue Oct 15 09:11:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13835971 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 132A81E32CF for ; Tue, 15 Oct 2024 09:11:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983506; cv=none; b=c390tOIgaZa2V0qAuoIaLgmc2iiJwav6E6oD4HrLklSiRFpbFNiiF9+7TJjvlOiaVyOGEzSPItEv6oHKrgdhAAkiAfWX6a1XiPJdYryxpoArGo1I/eawnY/6sfQcJj+X7NP/KCc5uqjePTShLHj+/tYGvagabMLrLuDHFh3hfkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983506; c=relaxed/simple; bh=hzebdBjXmg/LyQIPzZ1kj2lccxTuBm/v0jaCRSELemY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=d6/6T90bHkl+jIwN6lE1TFh8rLfjou3w07F0xu6SgU79rOp2Z9+D1oOzhUiNdGiR/Vdrm/ABJBBf9+mHH4ZJIAEPntFlwX1t/gdzlSKj90KkfA4fuKWgwqUhk6AKNPp7x8BE8K4vWTwwdFn8aadN8AihTje7MgOmcqiNk3XRjEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LMfgJGaM; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LMfgJGaM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728983502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lyxldozdxkCmKgDHt1NxVMWVKztWFVpOxa3mceHgoVc=; b=LMfgJGaMEX7t81Kcz5MvAuNPmxvQIeYvbMKhLWDHG8/XWr83QpDIY1QA9dcBhF47eBiRp9 7dwtalKzgpjCqrfjcJwFpOjk3todb/8IMzygnixvlLO+YYt1IFk3YrqPZJDvdIJbKdRUNd 96Mp6hRT70a2lAT4NKCZs7foBLQ+Gnw= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-321-tfqqdzrcNSSvEliIsREV4Q-1; Tue, 15 Oct 2024 05:11:40 -0400 X-MC-Unique: tfqqdzrcNSSvEliIsREV4Q-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539ed93e08aso1822741e87.3 for ; Tue, 15 Oct 2024 02:11:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728983499; x=1729588299; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lyxldozdxkCmKgDHt1NxVMWVKztWFVpOxa3mceHgoVc=; b=D+JfwIkgd8EXCIYm8AJa0C0vWUzIK0EQKVRVV8gpxyyPk//mEjaV8eCGk2Nqb5UgUW 1nKSfP+VkXEEeBPEafc/is4TUtKADjXs52sOURbIvewWX3FZqtnZdyvxyxPWWy7dqbtz Q90WWvWYWfUnpxBO9d2vx/odo0Z1KowbhgEKI1nOwwfOdTG+MS/GOBlesXqE6VQziU/8 IV+VFS244AFQmj7tRJEYYaoftc1zWmBqU6zRTPPM2Y3xVdG4rApZtDqFRbrXoypjIAjS 05cGrQsRE4rVat74CuXSlhpK8Gx0bot6AKVId0JIkF7bfecN+2qjpI7LxNkODTM6kVB0 EfRQ== X-Gm-Message-State: AOJu0YwcFU/eGGYakShpc4o3k+ZxZ6AxPZvX/tXRF20ifzJXbj7WHxsa +P0ouphNr4KVmq5Qhg9gexIpoRlpZjLr8zjungJ1RLafCJGUPihKHV+rsnxMafrBiYRYYk8DLHa GxsWvFMoR7A7FRQTRpB9YBI2rmhINX6Fj2Q1X7hpON4+8GGf08oymHA== X-Received: by 2002:a05:6512:3a8d:b0:539:d539:db3 with SMTP id 2adb3069b0e04-539da3b41f9mr7669819e87.5.1728983499304; Tue, 15 Oct 2024 02:11:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrF4T2xgP9X/y2YCqijhuoJgh3p+++EhzS4qxuHtHufEGPegZZQWpg+4YEw/ykx26wa3i8IA== X-Received: by 2002:a05:6512:3a8d:b0:539:d539:db3 with SMTP id 2adb3069b0e04-539da3b41f9mr7669784e87.5.1728983498863; Tue, 15 Oct 2024 02:11:38 -0700 (PDT) Received: from debian (2a01cb058d23d60030b5722051bf3d85.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:30b5:7220:51bf:3d85]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f6b31b9sm11561085e9.29.2024.10.15.02.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 02:11:38 -0700 (PDT) Date: Tue, 15 Oct 2024 11:11:36 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Steffen Klassert , Herbert Xu , David Ahern , Ido Schimmel Subject: [PATCH net-next 4/6] xfrm: Convert __xfrm_dst_lookup() to dscp_t. Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Pass a dscp_t variable to __xfrm_dst_lookup(), instead of an int, to prevent accidental setting of ECN bits in ->flowi4_tos. Callers of ip_mc_validate_source() to consider are: * xfrm_dst_lookup() which already has a dscp_t variable to pass as parameter. We just need to remove the inet_dscp_to_dsfield() conversion. * xfrm_dev_state_add() in net/xfrm/xfrm_device.c. This function sets the tos parameter to 0, which is already a valid dscp_t value, so it doesn't need to be adjusted for the new prototype. Signed-off-by: Guillaume Nault --- include/net/xfrm.h | 3 ++- net/xfrm/xfrm_policy.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index b6bfdc6416c7..18c0a6077ae9 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -1764,7 +1765,7 @@ static inline int xfrm_user_policy(struct sock *sk, int optname, } #endif -struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, int oif, +struct dst_entry *__xfrm_dst_lookup(struct net *net, dscp_t dscp, int oif, const xfrm_address_t *saddr, const xfrm_address_t *daddr, int family, u32 mark); diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 6e30b110accf..a1b499cc840c 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -270,7 +270,7 @@ static const struct xfrm_if_cb *xfrm_if_get_cb(void) return rcu_dereference(xfrm_if_cb); } -struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, int oif, +struct dst_entry *__xfrm_dst_lookup(struct net *net, dscp_t dscp, int oif, const xfrm_address_t *saddr, const xfrm_address_t *daddr, int family, u32 mark) @@ -282,7 +282,8 @@ struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, int oif, if (unlikely(afinfo == NULL)) return ERR_PTR(-EAFNOSUPPORT); - dst = afinfo->dst_lookup(net, tos, oif, saddr, daddr, mark); + dst = afinfo->dst_lookup(net, inet_dscp_to_dsfield(dscp), oif, saddr, + daddr, mark); rcu_read_unlock(); @@ -310,8 +311,7 @@ static inline struct dst_entry *xfrm_dst_lookup(struct xfrm_state *x, daddr = x->coaddr; } - dst = __xfrm_dst_lookup(net, inet_dscp_to_dsfield(dscp), oif, saddr, - daddr, family, mark); + dst = __xfrm_dst_lookup(net, dscp, oif, saddr, daddr, family, mark); if (!IS_ERR(dst)) { if (prev_saddr != saddr) From patchwork Tue Oct 15 09:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13835972 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 C7F911E379C for ; Tue, 15 Oct 2024 09:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983510; cv=none; b=Sj9YpSYXaLPc7K4pVDKSsYrKvJMvpX8I9QxXrcnOjs3EBl/mzw4QNzsbJBI+SvwPwtQUWQWCtx7bRkDs9AF+VJIH/YBmO8z0RlfJaCRZ3lKyJIVUX8p/8r6WQHyW4B5duZzunbgCHMuSHjiScdhaAVUdv/0uQrc76+ebzhGEOUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983510; c=relaxed/simple; bh=p7fVzJblWm/aWEA3jxVRzNVUzYm11vtV23L0TNvG4Lk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hd952ybdJKsRwSrPjYtBQyvlOJBqnGRrfm21HHJhJlcXwOYgZG4RUxIXCmsGkkDyHfDW5jD4Dn7DgK3P8Ckb1LBCqwgFlJLvIZ24y0zCuD/goZju/b8UY0Ij+SwV9xyv8Dd8E4m8sIA+8y5l5fWijhr1/CWVS9KDnduX8KVf33U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iStoMHLN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iStoMHLN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728983507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xhLuySMAmdo78JA+3a46bjlHZTPCrbjc8I3LY3cAXtI=; b=iStoMHLNqFf4lBWOI1TbqAwtnDuxTlyghTVyxjo43R3I+hQPk9h1kXiTpWFgW1Lq8d0ibd fZo78L+QItqINWDV3y+j+OqDKU8lvEB4VRejZ0E3R8tJ7/SnqSsLfXBvs0Tp1TE87YvlZT cWAaDi9YT+4R7Qy+ppB2sPvqoNKWJQ4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-278-xqMyje9MOkG1sm5yG2yvvQ-1; Tue, 15 Oct 2024 05:11:46 -0400 X-MC-Unique: xqMyje9MOkG1sm5yG2yvvQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-430581bd920so33147975e9.3 for ; Tue, 15 Oct 2024 02:11:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728983505; x=1729588305; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xhLuySMAmdo78JA+3a46bjlHZTPCrbjc8I3LY3cAXtI=; b=UXcKr3u2qjuSWhCIkP1be9X8Z5DIwxhNxi9KPuLyhHyAkUfQguGDID/LpPeUaYpzG3 OwYPMquiT89OEeA/rUcIONEV2e2PpHDIOiHiFK47eSPf7GWNdyaAaUvnovVcOh79YkNt RqouuK9UTfYUDOvLbT5GD36cWjV4MKhQOpCEIJKaQ1mnN0rOF4NZts9ieMTTAK2NGk1Q wf3tgMF5qGwfILDMXw5de6kDDVE2jxkxp4oPYUBMfc2oBnFe8WCc8VZhKd1rXCgy5odn E4rRzuJMNyuq+MGKoPO1wGhSzzCXSXjsnEvSy/wwd0bKN6lFtrJ47y5u8c6rj0sWkUxS FeLw== X-Gm-Message-State: AOJu0YxmYNr6H4SKNsOux9n1zFEYC/DAdmOk9Cx8aTGOSQd8ZiNiE8TQ TcJbuwRaS+AeTrjWjRUXesy0NRICk2BCyuzJLPJpWUibZKoZRcg1If1o/vL7pU1Xl4a3MNVmq2R 0cSmCOY3o6GYFImRV+C3IYlgLVYHPuJsT8mJOS8iJIRG4LVpjDGh2oGavu9QEyg== X-Received: by 2002:a05:600c:4f0c:b0:42c:af06:703 with SMTP id 5b1f17b1804b1-4311df55ca0mr113008855e9.31.1728983504775; Tue, 15 Oct 2024 02:11:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRI606w1bKl8VjZU95EsSmuQ/ISRv+3BLrmHvQJi33JGRkPnLVK0oVk6gabEq/GU8Fplp3yg== X-Received: by 2002:a05:600c:4f0c:b0:42c:af06:703 with SMTP id 5b1f17b1804b1-4311df55ca0mr113008555e9.31.1728983504283; Tue, 15 Oct 2024 02:11:44 -0700 (PDT) Received: from debian (2a01cb058d23d60030b5722051bf3d85.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:30b5:7220:51bf:3d85]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f55dfa8sm11803325e9.6.2024.10.15.02.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 02:11:43 -0700 (PDT) Date: Tue, 15 Oct 2024 11:11:42 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Steffen Klassert , Herbert Xu , David Ahern , Ido Schimmel Subject: [PATCH net-next 5/6] xfrm: Convert the ->dst_lookup() callback to dscp_t. Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Pass a dscp_t variable to ->dst_lookup() callbacks (struct xfrm_policy_afinfo), instead of an int, to prevent accidental setting of ECN bits in ->flowi4_tos. This callback is only called by __xfrm_dst_lookup(), which already has a dscp_t variable to pass as parameter. We just need to remove the inet_dscp_to_dsfield() conversion. There are two implementations of this callback: xfrm6_dst_lookup(), which doesn't use the modified parameter, and xfrm4_dst_lookup() which needs to convert it again before calling __xfrm4_dst_lookup(). Signed-off-by: Guillaume Nault --- include/net/xfrm.h | 4 ++-- net/ipv4/xfrm4_policy.c | 8 +++++--- net/ipv6/xfrm6_policy.c | 5 +++-- net/xfrm/xfrm_policy.c | 3 +-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 18c0a6077ae9..46c82d75679a 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -355,8 +355,8 @@ struct xfrm_type; struct xfrm_dst; struct xfrm_policy_afinfo { struct dst_ops *dst_ops; - struct dst_entry *(*dst_lookup)(struct net *net, - int tos, int oif, + struct dst_entry *(*dst_lookup)(struct net *net, dscp_t dscp, + int oif, const xfrm_address_t *saddr, const xfrm_address_t *daddr, u32 mark); diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 0294fef577fa..342a0158da91 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -40,14 +41,15 @@ static struct dst_entry *__xfrm4_dst_lookup(struct net *net, struct flowi4 *fl4, return ERR_CAST(rt); } -static struct dst_entry *xfrm4_dst_lookup(struct net *net, int tos, int oif, - const xfrm_address_t *saddr, +static struct dst_entry *xfrm4_dst_lookup(struct net *net, dscp_t dscp, + int oif, const xfrm_address_t *saddr, const xfrm_address_t *daddr, u32 mark) { struct flowi4 fl4; - return __xfrm4_dst_lookup(net, &fl4, tos, oif, saddr, daddr, mark); + return __xfrm4_dst_lookup(net, &fl4, inet_dscp_to_dsfield(dscp), oif, + saddr, daddr, mark); } static int xfrm4_get_saddr(struct net *net, int oif, diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index b1d81c4270ab..0c28b22ae3c1 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c @@ -18,13 +18,14 @@ #include #include #include +#include #include #include #include #include -static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, int oif, - const xfrm_address_t *saddr, +static struct dst_entry *xfrm6_dst_lookup(struct net *net, dscp_t dscp, + int oif, const xfrm_address_t *saddr, const xfrm_address_t *daddr, u32 mark) { diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index a1b499cc840c..db2e602971fd 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -282,8 +282,7 @@ struct dst_entry *__xfrm_dst_lookup(struct net *net, dscp_t dscp, int oif, if (unlikely(afinfo == NULL)) return ERR_PTR(-EAFNOSUPPORT); - dst = afinfo->dst_lookup(net, inet_dscp_to_dsfield(dscp), oif, saddr, - daddr, mark); + dst = afinfo->dst_lookup(net, dscp, oif, saddr, daddr, mark); rcu_read_unlock(); From patchwork Tue Oct 15 09:11:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13835973 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 906F61D9A4E for ; Tue, 15 Oct 2024 09:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983514; cv=none; b=cEc2hTAY/1T5GFnQsim/zGfEgOkRuYmLn2vFgSYmDS6WGblakEhTNuO/b8ssryMALk+UNvLJKI8K5Wiexbi5Qcv6IXVsmHE4ZF0zPEpgtbnx1ngbOwASonqGJR1pfX8ud/lrFgSPRq2QRqKwyyNegpKdu3nzp4/7t5dvgiUszRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983514; c=relaxed/simple; bh=6NV9yB75n52RBtc0P7s1FtMJM7j+shpju7c7gvxERKw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LvqhFlWqtz7GT/tVZG8eMwTxFIYcmTbAaO28fts8oMFKHD/wDUPM9mci+Z0cc/2m613cXKS1UdQY98mLCkUCYX8V7iKLe2uH0nQK2K8yFAzSRh4ltRMPFsa8PaKNhukDznkqF/BGx9rZK2hFUJiEj85sSjPWutyRSXPQFpnCsdQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LRDjIy2y; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LRDjIy2y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728983511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jwY5lZ54UTFvIQn7Uakl8QJT3XuWTsJfS5e17G7IBQg=; b=LRDjIy2y0JJB0j9hQgLzunwcMGg5F3H9eKNT0C3aSzvGjMtRcUT+ykzQVkh7ZmleQgQwar 7Y47DZQlkKVrYQo1gpx+nTiKJXj2dtJgOrARC2kM9nYJXLiVwbKSyAm0Ei3m6D9Rzh1Juq 6IVNBv5r/p83ypAWAP/yrxJsJwdSlWE= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-507-gZaWjv0xOWWNNPqkLLUCOg-1; Tue, 15 Oct 2024 05:11:50 -0400 X-MC-Unique: gZaWjv0xOWWNNPqkLLUCOg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d47127e69so1993214f8f.1 for ; Tue, 15 Oct 2024 02:11:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728983509; x=1729588309; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jwY5lZ54UTFvIQn7Uakl8QJT3XuWTsJfS5e17G7IBQg=; b=G/wj+CvD4nT9mm84AzL6PvmHS1/AHDKsI3Nt6QK1LCH+6q0BaZ6j1S0FgGbWCtvmG0 JyEzIFfB3aap8os4gYSC0UILEi6JGM1SIC7RTkpNpPiSMXhfOfV8W1v4sVvCMX0blEk/ 2ltrIhN5qSrgEkbG1qQ3mAElGiTGQQ8tn32IkTjfCz6PMY+3arcrDLahaqm19YFCJzsR ZGUey+q1XEwSffaCccJ2Si1Ff26kCB7b/0ToSxobyeTpOmlfvThY9qL9FoE3kZKZRzHG axlbgnL6mToLVSQkYyA1E8Cb4b03G1OIwX8vjs6agfyDbFCVyI9KDy4GWCgc74mbHsCl fbzg== X-Gm-Message-State: AOJu0YwLz7EJh6+2qGPc+AGYoGJuBgHLlwctUUgk5SZ6qunJ/lrIVDo8 LpHafzmkbIA7QiUPhZR9yLg2LRa6SDyvfLTQbdOh8130Oa+POivP7+SheJizdgqEu4mMm2Q5ToJ RskgNDC6spVHNKBvhaaAoe0/EJ28AKuWp8mUswhLiiQFWDic0ZouaxQ== X-Received: by 2002:adf:ea85:0:b0:374:c640:8596 with SMTP id ffacd0b85a97d-37d551fb5demr8532852f8f.32.1728983509414; Tue, 15 Oct 2024 02:11:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGUf42D4DTW2UkP4WlaqdUzdJkIJrsJHbObiPi26jODF5Mz42s7Ly+1vckzSpoN3T7BPFQ7g== X-Received: by 2002:adf:ea85:0:b0:374:c640:8596 with SMTP id ffacd0b85a97d-37d551fb5demr8532836f8f.32.1728983508989; Tue, 15 Oct 2024 02:11:48 -0700 (PDT) Received: from debian (2a01cb058d23d60030b5722051bf3d85.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:30b5:7220:51bf:3d85]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fa87c70sm1042223f8f.30.2024.10.15.02.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 02:11:48 -0700 (PDT) Date: Tue, 15 Oct 2024 11:11:46 +0200 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Steffen Klassert , Herbert Xu , David Ahern , Ido Schimmel Subject: [PATCH net-next 6/6] xfrm: Convert __xfrm4_dst_lookup() to dscp_t. Message-ID: <6069820d4452ed34b153c03da3a6ea52c279bda7.1728982714.git.gnault@redhat.com> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Pass a dscp_t variable to __xfrm4_dst_lookup(), instead of an int, to prevent accidental setting of ECN bits in ->flowi4_tos. Callers of __xfrm4_dst_lookup() to consider are: * xfrm4_dst_lookup(), which already has a dscp_t variable to pass as parameter. We just need to remove the inet_dscp_to_dsfield() conversion. * xfrm4_get_saddr(). This function sets the tos parameter to 0, which is already a valid dscp_t value, so it doesn't need to be adjusted for the new prototype. Signed-off-by: Guillaume Nault --- net/ipv4/xfrm4_policy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 342a0158da91..b1968ae756c9 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c @@ -18,8 +18,9 @@ #include #include -static struct dst_entry *__xfrm4_dst_lookup(struct net *net, struct flowi4 *fl4, - int tos, int oif, +static struct dst_entry *__xfrm4_dst_lookup(struct net *net, + struct flowi4 *fl4, dscp_t dscp, + int oif, const xfrm_address_t *saddr, const xfrm_address_t *daddr, u32 mark) @@ -28,7 +29,7 @@ static struct dst_entry *__xfrm4_dst_lookup(struct net *net, struct flowi4 *fl4, memset(fl4, 0, sizeof(*fl4)); fl4->daddr = daddr->a4; - fl4->flowi4_tos = tos; + fl4->flowi4_tos = inet_dscp_to_dsfield(dscp); fl4->flowi4_l3mdev = l3mdev_master_ifindex_by_index(net, oif); fl4->flowi4_mark = mark; if (saddr) @@ -48,8 +49,7 @@ static struct dst_entry *xfrm4_dst_lookup(struct net *net, dscp_t dscp, { struct flowi4 fl4; - return __xfrm4_dst_lookup(net, &fl4, inet_dscp_to_dsfield(dscp), oif, - saddr, daddr, mark); + return __xfrm4_dst_lookup(net, &fl4, dscp, oif, saddr, daddr, mark); } static int xfrm4_get_saddr(struct net *net, int oif,