From patchwork Fri Nov 8 16:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13868505 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 3A3361E0E15 for ; Fri, 8 Nov 2024 16:47:18 +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=1731084440; cv=none; b=AVAJgJWzBS+U+UI8WlWbjSR7fEMuXXlmlw8Yju52QnO1WA4AhkWL9kwspU/8znv6jIhoyqi6Ge3Ju5y2wKthtQYee321hKWPCls7YcdmZzD4AGvON6CMqSj94dG/NAtvmfVlflj7rzzX5nMu1GaxfWluCM5rsk+a/qdTZJbOOnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731084440; c=relaxed/simple; bh=LjJVosaVV8VZZYl0msQv5bgAMnoA8ds8SVqI6M2WSSQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MqD4RJTTrxvzzfoRp9ZIsoMnw0PEEnUbhSpjwyAlio0fC4G0Z/vqXMEJ/U74bK2wCszxUdeNNS7Xd5X5CVioOHB9515RtDfRWyQob/BdgQZCpbAMYe+VKoJLUx9bvTQqyZk1jE6eUTrAXqLXeLtFh1Y0kahNK3kcpMWo+qCZui8= 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=EeCZCwBT; 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="EeCZCwBT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731084438; 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=RrfC5q+p1hRQazHgbLjKpHsQFhKuqen69LFywqbKp+0=; b=EeCZCwBTywXWeqnMlkGBI595BwdBsu5W8gdIQAfmMYOYjWEn2fQiZFoBpDf8u+dpztZNMU 4aGhoijgZ+R8LGcQs60oliEEYsqsgcgG2A8RnjcMhYaksUjQZYVEC1M8uRtjEzWaDtack4 H1gxPDNbkO83VA/qZ6cjxnRxjy2+ZyQ= 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-489-dCUPBOfAMOCev7qrqG5Wzw-1; Fri, 08 Nov 2024 11:47:16 -0500 X-MC-Unique: dCUPBOfAMOCev7qrqG5Wzw-1 X-Mimecast-MFC-AGG-ID: dCUPBOfAMOCev7qrqG5Wzw Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d603515cfso1157338f8f.1 for ; Fri, 08 Nov 2024 08:47:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731084435; x=1731689235; 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=RrfC5q+p1hRQazHgbLjKpHsQFhKuqen69LFywqbKp+0=; b=c5YWDwSglv8tshlNL+xuwRRU4UzbwoPAN8R0Yla61GSLYuDAbbKvVSVn3TnZD9F/1g JxFRs3/Gd5LCCesmmg1+wslRHSY7DJb9nKayNWsLd8nXX1eViAGXqWMq2YJDsFRYc1z5 6ImuXF3sGTlLkMs8YqwMtWI/7yApodEwDbrB04lxIdvAmEMH+eP/KSKo/cK/la7YdFak 8wI+vchTjYYJCjLKxQN+DFfYQYmNiP7iwVhk5KhH98GkVtPqWJg16184yL7onyWonJ4m t2siDT6jRmFMCuS0yKhxPHj/Dw87p5JuwkqQoL1cks1iIoX0/G7GAu/Fq71dGwet1Byg /aSA== X-Forwarded-Encrypted: i=1; AJvYcCXrmgpehiVLcSChiV9le8KksF0E3PIY4X0B5QfiDold4T8+SieF33z2XMSQcNf7ZP8fPjQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyborobKiUqq4y4nPrtwOzkMzciC1KjsUvcCbMgoWhcBxxXgFxC ESMimnuIZKcenuBFtSGa6CjgZpaqKJc+KzKB5RonKwRPtO0NJ1RQwNVVhHqFHryNBoHavLvoBcE mzhB9tLYvDzGIzEmLEOQnDvTJ54JraMdSVT7/swoorSyDZaoHbQ== X-Received: by 2002:a05:6000:1863:b0:37d:4846:3d29 with SMTP id ffacd0b85a97d-381f186bd0fmr2959652f8f.28.1731084435532; Fri, 08 Nov 2024 08:47:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWcA41LXOh161RiZjWnOUtvZ9VjaYlW0EStSNknKhrAL/eqwHFCZUrVVXjDZ0PTGHOOgAS9A== X-Received: by 2002:a05:6000:1863:b0:37d:4846:3d29 with SMTP id ffacd0b85a97d-381f186bd0fmr2959622f8f.28.1731084435183; Fri, 08 Nov 2024 08:47:15 -0800 (PST) Received: from debian (2a01cb058d23d60039a5c1e29a817dbe.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:39a5:c1e2:9a81:7dbe]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed9719easm5508835f8f.9.2024.11.08.08.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 08:47:14 -0800 (PST) Date: Fri, 8 Nov 2024 17:47:12 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Simon Horman , Martin KaFai Lau , Daniel Borkmann , John Fastabend , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Ido Schimmel , bpf@vger.kernel.org Subject: [PATCH net-next 1/2] bpf: ipv4: Prepare __bpf_redirect_neigh_v4() to future .flowi4_tos conversion. Message-ID: <35eacc8955003e434afb1365d404193cc98a9579.1731064982.git.gnault@redhat.com> References: Precedence: bulk X-Mailing-List: bpf@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 ip4h_dscp() to get the DSCP from the IPv4 header, then convert the dscp_t value to __u8 with inet_dscp_to_dsfield(). Then, when we'll convert .flowi4_tos to dscp_t, we'll just have to drop the inet_dscp_to_dsfield() call. Signed-off-by: Guillaume Nault --- net/core/filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/filter.c b/net/core/filter.c index 82f92ed0dc72..c3a722134ca1 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2355,7 +2355,7 @@ static int __bpf_redirect_neigh_v4(struct sk_buff *skb, struct net_device *dev, struct flowi4 fl4 = { .flowi4_flags = FLOWI_FLAG_ANYSRC, .flowi4_mark = skb->mark, - .flowi4_tos = ip4h->tos & INET_DSCP_MASK, + .flowi4_tos = inet_dscp_to_dsfield(ip4h_dscp(ip4h)), .flowi4_oif = dev->ifindex, .flowi4_proto = ip4h->protocol, .daddr = ip4h->daddr, From patchwork Fri Nov 8 16:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 13868506 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 144101C3F28 for ; Fri, 8 Nov 2024 16:47:22 +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=1731084444; cv=none; b=LENXytq15yV3PcdNmhIIFYsgYxgOvjSbgtNlJOWf89tXEgb3zPzUMQeWOQuP8jb66Ty183OlJpeEuQ7v6eP7xB4B1CfeUhIKhwuADHnBuKNavC9rQCYI/H20oI9oqn7iIc6Nye7ixOU7+X6V9/05yO9QfSVvrqzVDiaoxCaLBxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731084444; c=relaxed/simple; bh=HgpX6tjgGPAMEkbHtYCsKAtXDMaBY39C4BAyLKPf9qY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uyMkE2sPmSI47pOjWkDzUr56X2q7SDkd/dwOLdwCGVmFuUu00tcz3v58+0aBmW1i4fQvLPdtoj/lBoyoBQe4lTty+BtPzV5nuAng9RToaZZLHYQhGrlZ5W2Jenb0CTqg66Od1wNxVnmMPm1l45hB4mlswL1q9F3KOGOAJNE9VYw= 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=WQnRK3DG; 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="WQnRK3DG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731084441; 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=e0cIt/+XAIZgDENxrBqdIIl26BAp6/hywyRIqUkYYwM=; b=WQnRK3DG6xAgrjJ92tNKP0bM30G7lqxGedCr7kFwMWBm+Mbs69TztgQ/d3YIymHUKSrXTJ 7XW+w/XMfMpGemd6kDPsKzc7xLjEEc5JMqSULBeWFFhREZSBddjDzCDdq2IebhEgMwNpxk ghVTxItlWbv+eX2qgQYrqgmS6Po+WrU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-m-iiAFWKOTepw2AHTUvLkA-1; Fri, 08 Nov 2024 11:47:20 -0500 X-MC-Unique: m-iiAFWKOTepw2AHTUvLkA-1 X-Mimecast-MFC-AGG-ID: m-iiAFWKOTepw2AHTUvLkA Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4315d98a873so15100885e9.1 for ; Fri, 08 Nov 2024 08:47:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731084439; x=1731689239; 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=e0cIt/+XAIZgDENxrBqdIIl26BAp6/hywyRIqUkYYwM=; b=miqaoH75pb2f1HfynuPfQZBe3zhadqS3WWB0BplCv9JaYviNvqIMuGRk4oaV++/De+ y0cv7P2jWlfZNEhU8KrIVHKHhB3+E58NtJDt4sl75y/VjwYff68Jw+0e46W57j8Ozscr xBXYI6gCncMGJKU3qpd4c69sNy8MLnJApd5FI+xSn4YJ9XikZm7XFujpxFMIxUpPQq2z gGraeChsGHf67TrqJBFeA13UXCB+TJhOhdrsSqr7ECfNNs9sEpZxZusv9ohff8sAaSYk 1zt4OAMxixTkA6l9jFmj3RSRV3hHBKsKoodUdmy8U8B2jXjaUqJMskICGaiDVZnnlX3X JOEw== X-Forwarded-Encrypted: i=1; AJvYcCWp3Y+Yj7YlWm+SeLYZeKkBgZifh1sHELunPCy1fxMJ/xUh09Y+/0vqHmAL+1nD7RiAzeE=@vger.kernel.org X-Gm-Message-State: AOJu0YyCnNpXc0eoiwQfOTP1HDlcRt8x71YEczVJL65P0oVAhk1vwNfW tfgC7nSe6mhSqB/LsnFDQOiuv+djEV5fJBcsUqG9v5Ac92fhvJl8pexnFWK2zR+MaMKRMdLlBR5 gUTrEJavZlBi9Avc6fBu3wdWXGj+cP1rCA4swm1OnMcWX6wzB7g== X-Received: by 2002:a05:6000:1f87:b0:37d:39f8:a77a with SMTP id ffacd0b85a97d-381f18270c4mr2439968f8f.8.1731084438811; Fri, 08 Nov 2024 08:47:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFi//4NoWzVklrn7s3bkXBgd2ArudhPQnTT0EjnZgbd0c6RqQ0eaSZZYBxd4RY2wzrJ5vaOTg== X-Received: by 2002:a05:6000:1f87:b0:37d:39f8:a77a with SMTP id ffacd0b85a97d-381f18270c4mr2439945f8f.8.1731084438400; Fri, 08 Nov 2024 08:47:18 -0800 (PST) Received: from debian (2a01cb058d23d60039a5c1e29a817dbe.ipv6.abo.wanadoo.fr. [2a01:cb05:8d23:d600:39a5:c1e2:9a81:7dbe]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432b0562ccdsm73851045e9.23.2024.11.08.08.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 08:47:17 -0800 (PST) Date: Fri, 8 Nov 2024 17:47:15 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Simon Horman , Martin KaFai Lau , Daniel Borkmann , John Fastabend , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Ido Schimmel , bpf@vger.kernel.org Subject: [PATCH net-next 2/2] bpf: lwtunnel: Prepare bpf_lwt_xmit_reroute() to future .flowi4_tos conversion. Message-ID: <8338a12377c44f698a651d1ce357dd92bdf18120.1731064982.git.gnault@redhat.com> References: Precedence: bulk X-Mailing-List: bpf@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 ip4h_dscp() to get the DSCP from the IPv4 header, then convert the dscp_t value to __u8 with inet_dscp_to_dsfield(). Then, when we'll convert .flowi4_tos to dscp_t, we'll just have to drop the inet_dscp_to_dsfield() call. Signed-off-by: Guillaume Nault --- net/core/lwt_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c index e0ca24a58810..6655af5c267d 100644 --- a/net/core/lwt_bpf.c +++ b/net/core/lwt_bpf.c @@ -207,7 +207,7 @@ static int bpf_lwt_xmit_reroute(struct sk_buff *skb) fl4.flowi4_oif = oif; fl4.flowi4_mark = skb->mark; fl4.flowi4_uid = sock_net_uid(net, sk); - fl4.flowi4_tos = iph->tos & INET_DSCP_MASK; + fl4.flowi4_tos = inet_dscp_to_dsfield(ip4h_dscp(iph)); fl4.flowi4_flags = FLOWI_FLAG_ANYSRC; fl4.flowi4_proto = iph->protocol; fl4.daddr = iph->daddr;