From patchwork Mon Nov 9 23:13:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 11892773 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8436C5517A for ; Mon, 9 Nov 2020 23:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49C782074F for ; Mon, 9 Nov 2020 23:13:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="r1xQr5Ha" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730695AbgKIXN5 (ORCPT ); Mon, 9 Nov 2020 18:13:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729452AbgKIXN4 (ORCPT ); Mon, 9 Nov 2020 18:13:56 -0500 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9510C0613CF for ; Mon, 9 Nov 2020 15:13:56 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id w11so5489692pll.8 for ; Mon, 09 Nov 2020 15:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Oduogtnbw5/TKsSx9Xyi3jGYRSYurv0+Gmjk3ygWYFU=; b=r1xQr5Hadf5RzWS4UZmVozXBtgfRjYPEX32af6H+6W+cMbDpl6ceRegQaJg8FepAph 08fYpfOqHXrxsBkHot2fVmg+h+gRA+j3/MNH6CKaJcOaG10jXYw/QUmK9NZNvI/eAHo5 lAmkDPWPghTo02WXcXQ3P5DWn7XZ9FtEu6HCJClv3YU3Ik02Ngyd4sDy2IUXmUnu29JN CVXV4p6CHosFpPplJkU192tAlD9iJ+VNG9yk7gz8hOgXn5oEkvE7uRpxw4O8DzX58eLv RgoaCFZm5V2aelvloJjAgacV0wDGEG/NGDrpaa24e/+zA47V9ui87NaSh+ieaURHnLSm O7ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Oduogtnbw5/TKsSx9Xyi3jGYRSYurv0+Gmjk3ygWYFU=; b=AF/dLW/uajhrnndJCJdqEZWnS74i1E62ClVck9HF3i+CLRBzv3YiZTJgTy0e90vbz2 M7voiSo99JQ2LQ+m/bYJFge9RjkyxUcS6ZalJxEhHHKjkZCEAB3VqzCRP+n3cTNGyqif L/M7g0uIL9n2s1IwuC2Vginj2rPR3wUfaGSVPs4jjWhmlqQWSpQ8U7LyApr3jGSaEA5Z deRC5Br1FD4Vzh/IazrZB+cJVfpu11uJLzSo93Y8aLcsVJT1xb6uPBOx30fmg1Tm4xHU BcvjrJJcQybzDxCdKMFbni4MRU0NA93aG3HprPRz/uAGB5kZa//DC8y/FL4lHDbgj0jl El3w== X-Gm-Message-State: AOAM531au4AWbeYhnj6OwF0wZJXHdPDkdNUnMkZOB880A2JVIqpt1jE2 4qhb+yBzlPqN46ZLKOCDqDU= X-Google-Smtp-Source: ABdhPJzzVLq8QaGAeoxW0XKn8ddUsciCYB9t0C1Gn3l0lLJeJxtFYw+OEkyVpSiwpIPniw5PjziDUA== X-Received: by 2002:a17:902:6b08:b029:d6:c471:8b5b with SMTP id o8-20020a1709026b08b02900d6c4718b5bmr14668910plk.78.1604963636348; Mon, 09 Nov 2020 15:13:56 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:7220:84ff:fe09:1424]) by smtp.gmail.com with ESMTPSA id w16sm12375365pfn.45.2020.11.09.15.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 15:13:55 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Alexander Lobakin Subject: [PATCH net-next 1/2] inet: constify inet_sdif() argument Date: Mon, 9 Nov 2020 15:13:48 -0800 Message-Id: <20201109231349.20946-2-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog In-Reply-To: <20201109231349.20946-1-eric.dumazet@gmail.com> References: <20201109231349.20946-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet inet_sdif() does not modify the skb. This will permit propagating the const qualifier in udp{4|6}_lib_lookup_skb() functions. Signed-off-by: Eric Dumazet Cc: Alexander Lobakin --- include/net/ip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/ip.h b/include/net/ip.h index 2d6b985d11ccaa75827b3a15ac3f898d7a193242..e20874059f826eb0f9e899aed556bfbc9c9d71e8 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -99,7 +99,7 @@ static inline void ipcm_init_sk(struct ipcm_cookie *ipcm, #define PKTINFO_SKB_CB(skb) ((struct in_pktinfo *)((skb)->cb)) /* return enslaved device index if relevant */ -static inline int inet_sdif(struct sk_buff *skb) +static inline int inet_sdif(const struct sk_buff *skb) { #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) if (skb && ipv4_l3mdev_skb(IPCB(skb)->flags)) From patchwork Mon Nov 9 23:13:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 11892771 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6B52C4741F for ; Mon, 9 Nov 2020 23:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77BEA2074F for ; Mon, 9 Nov 2020 23:14:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FWhlYmLg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730395AbgKIXOA (ORCPT ); Mon, 9 Nov 2020 18:14:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729452AbgKIXN6 (ORCPT ); Mon, 9 Nov 2020 18:13:58 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85616C0613CF for ; Mon, 9 Nov 2020 15:13:58 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id e21so8442507pgr.11 for ; Mon, 09 Nov 2020 15:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8ZuOt1YUk8YzgrckG18G++ujRPzQJWo5wbeuOl9xQc4=; b=FWhlYmLgg2mkf28KMRxsyTBJQIniLPGRQHaW7ye+7fKD6b0t8pWDtuN6OwMHdFi7EG 9vsDR1HkiDoHgUT9hgjllAFbvF2yoaJ1SiB2Mg0iIRLpaxO3kqFHwwp6++MdR35KlL6y bruz5rPOLyReg84N4sN5TyiR31TDr2q7WgTlHtNWwMHUYH+LbHbL5bHP2j4vIJMHWq3j AkD2rWcJu8VZb8T7PmSOGoIRmRIodsOh5O0Lvfyv7GHUN3GKJlQ/qfPBVrwasROf6Lf9 jSpA5jzaPacv0Hvf3wNAzV6yWn2/7qL4yVGb3DgaNTVK87+fst3KorjURiL6zeV8w/tI paDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8ZuOt1YUk8YzgrckG18G++ujRPzQJWo5wbeuOl9xQc4=; b=V1Mrwq3rjmSE5rUvboIek2TOU9f20V/EfcSNL4pomzdSzdq5IVVcc4q+R8+Yd1ePtb tyvFyXB4GPUDMFc5zabZBqWOHwL4dvoucvvkzAkpr1JeiCrm/cfmnR5Cy9vzvfGRfNU0 KGOyTdckWggBAsU63p7+YcTAO6GpAfIpWyMUeyWBgjDESsIT+WOcPPH5JfRuiUUF7VpR YAhKzEqWxf5N2A5YsYthXNiDdIn2KYaEgwj9RqXfCGeF2CPLSQ4NppfacynI5Nis9xee CvayOdpzqrZw9eRjIG+M/+MP0OhpVXfnAEExjZBDtUnFCosuwumUgeCBM0ATgWhIeR24 5L1Q== X-Gm-Message-State: AOAM531Id0MeGn/LFtL/gG8DQlZd/itfmRcE9imWVe9XrjsspGPWB4C1 pwG1/ETT+GmAS+6BFMVMBCs= X-Google-Smtp-Source: ABdhPJxFn2XSIGeHwvOfpyfSqB01my4s4fQBlpHPHSTEqfq81vYQ+mEODq/evIpI8ebku5GeoMG1bg== X-Received: by 2002:a17:90a:fa8c:: with SMTP id cu12mr1622575pjb.127.1604963638159; Mon, 09 Nov 2020 15:13:58 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:7220:84ff:fe09:1424]) by smtp.gmail.com with ESMTPSA id w16sm12375365pfn.45.2020.11.09.15.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 15:13:57 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Alexander Lobakin Subject: [PATCH net-next 2/2] inet: udp{4|6}_lib_lookup_skb() skb argument is const Date: Mon, 9 Nov 2020 15:13:49 -0800 Message-Id: <20201109231349.20946-3-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog In-Reply-To: <20201109231349.20946-1-eric.dumazet@gmail.com> References: <20201109231349.20946-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet The skb is needed only to fetch the keys for the lookup. Both functions are used from GRO stack, we do not want accidental modification of the skb. Signed-off-by: Eric Dumazet Cc: Alexander Lobakin --- include/net/udp.h | 6 +++--- net/ipv4/udp.c | 2 +- net/ipv6/udp.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/udp.h b/include/net/udp.h index 295d52a73598277dc5071536f777d1a87e7df1d1..877832bed4713a011a514a2f6f522728c8c89e20 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -164,7 +164,7 @@ static inline void udp_csum_pull_header(struct sk_buff *skb) UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr); } -typedef struct sock *(*udp_lookup_t)(struct sk_buff *skb, __be16 sport, +typedef struct sock *(*udp_lookup_t)(const struct sk_buff *skb, __be16 sport, __be16 dport); INDIRECT_CALLABLE_DECLARE(struct sk_buff *udp4_gro_receive(struct list_head *, @@ -313,7 +313,7 @@ struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, __be32 daddr, __be16 dport, int dif, int sdif, struct udp_table *tbl, struct sk_buff *skb); -struct sock *udp4_lib_lookup_skb(struct sk_buff *skb, +struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb, __be16 sport, __be16 dport); struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, @@ -324,7 +324,7 @@ struct sock *__udp6_lib_lookup(struct net *net, const struct in6_addr *daddr, __be16 dport, int dif, int sdif, struct udp_table *tbl, struct sk_buff *skb); -struct sock *udp6_lib_lookup_skb(struct sk_buff *skb, +struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb, __be16 sport, __be16 dport); /* UDP uses skb->dev_scratch to cache as much information as possible and avoid diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index ca04a8a35e52dbcff50b03da2710726dc6ee98bd..8c9f08343e171ba9b78ebe7bfe22e6508ab15c42 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -541,7 +541,7 @@ static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb, inet_sdif(skb), udptable, skb); } -struct sock *udp4_lib_lookup_skb(struct sk_buff *skb, +struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb, __be16 sport, __be16 dport) { const struct iphdr *iph = ip_hdr(skb); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index cde9b8874d4bce4cdbee557d89a0be0ddf3f87df..c32f50d2a0694580426ea71e52a1cee23ed07045 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -276,7 +276,7 @@ static struct sock *__udp6_lib_lookup_skb(struct sk_buff *skb, inet6_sdif(skb), udptable, skb); } -struct sock *udp6_lib_lookup_skb(struct sk_buff *skb, +struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb, __be16 sport, __be16 dport) { const struct ipv6hdr *iph = ipv6_hdr(skb);