Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2568965pxf; Sun, 14 Mar 2021 04:15:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynJLV7bx4qUPnUFweVCEWN922yOik9yigJdQEGzpw6Ugf1Qma2eJz/rU2aQELSWB7f2iTS X-Received: by 2002:a17:906:95d1:: with SMTP id n17mr17720923ejy.394.1615720537917; Sun, 14 Mar 2021 04:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615720537; cv=none; d=google.com; s=arc-20160816; b=wRsEaz0gUmKuPXNm+ReziHiqlcWQAnlMn5rIOFSReZ5jqSvxvwLkMhbGTOwTjFh6w8 ISac3nfNQIxCPTXOPL0+BPn40k55MV1QxF/mt3duPjuc3HUoiP7K+rRV27jC7889jjX+ 4VLKSBZvIsQJ9GsIxDkh78gTUgytHRfzoSQgG21QFseUv/pkR8PiMgus1al44GawdhU/ G8xXMfcUiqhPodfd2IWPG6kT22nfxfqMW9vL17o0e2wvC/Pq6VoLdt8Ij94DNSASovWh iFegvi+9jGZtZL/5Db+Z9sGuTp8m8ZKG+t1XeqKXzxsx9hbrOXfyjpgtiLomcDojtNW/ GQ9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=IxbwbJnHu5lmMBsWrCVS91QKvDGCTFdZfa9iKi412cw=; b=w+/bUp3vZt1kW6QQgEdqnwmAFqSG/AE+hmuQHXQr78wwZ2iYr7FVweQCVxIlqf1q0c XQuF6vZsFGz8aUUG3SF8LAbbS2efoopMhI70oMYd4SBzic9MO7tXg75kWeCyUttvE1qs Y41e3EzA9Dah8k0CLCnu84IZO3yDhvKefkgH639UHk++VWZ1TiuHGxalTcE/8i7BG2pB rZTn3c21ff7tI9jYaEWhVcUthrGCId9jjmZzJj/GDV8pKaE6aqOslQzcIF7p1WXFkaNV i/hvAXuTTxzxGxrFC31g7SXR3E6nOeNSpFzdOtKOPoq+cSbkwEWoZLmksxr31CU9ykk6 pM8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=QmDaMQLb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si3332559edn.416.2021.03.14.04.15.16; Sun, 14 Mar 2021 04:15:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=QmDaMQLb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235318AbhCNLMJ (ORCPT + 99 others); Sun, 14 Mar 2021 07:12:09 -0400 Received: from mail-40131.protonmail.ch ([185.70.40.131]:46661 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235279AbhCNLLd (ORCPT ); Sun, 14 Mar 2021 07:11:33 -0400 Date: Sun, 14 Mar 2021 11:11:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1615720291; bh=IxbwbJnHu5lmMBsWrCVS91QKvDGCTFdZfa9iKi412cw=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=QmDaMQLbV1xldPojQ4nHV+q4+8aXFlHyozvqKNDLxZllpATxMaVzACYF/RzX2NlOE vQVBqZJidFalQ83QNwqbZxSXhOv/SPk4DuVGSYT4MlONEn/IllzjAjFDucBh+KuHrP mc6Yc1a26Jv1UUqqFSl2q32j/pm0scPHCjFfA/5fPlQ8CztlPsinsSnCQ79xlztBBe 9Iau0rNVH+N45n4SEbDrk5Exnkpy6tksERz6j3oJRYGCSKNiAEcTaxjgV93CLCJHTS 8FWg7jrK+MJtGWStAeCK2k1WqI72iBZNiDWKPx3Kse8mg3tqU2WqrWmUGNTL6mMWu3 14a6V+e4QPpRA== To: "David S. Miller" , Jakub Kicinski From: Alexander Lobakin Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jonathan Lemon , Alexander Lobakin , Eric Dumazet , Willem de Bruijn , Kevin Hao , Pablo Neira Ayuso , Jakub Sitnicki , Marco Elver , Dexuan Cui , Vladimir Oltean , Ariel Levkovich , Wang Qing , Davide Caratti , Guillaume Nault , Eran Ben Elisha , Mauro Carvalho Chehab , Kirill Tkhai , Bartosz Golaszewski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v3 net-next 3/6] flow_dissector: constify raw input data argument Message-ID: <20210314111027.7657-4-alobakin@pm.me> In-Reply-To: <20210314111027.7657-1-alobakin@pm.me> References: <20210314111027.7657-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Flow Dissector code never modifies the input buffer, neither skb nor raw data. Make 'data' argument const for all of the Flow dissector's functions. Signed-off-by: Alexander Lobakin --- include/linux/skbuff.h | 15 ++++++------- include/net/flow_dissector.h | 2 +- net/core/flow_dissector.c | 41 +++++++++++++++++++----------------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index d6ea3dc3eddb..46c61e127e9f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1292,10 +1292,10 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, = bool is_l4) void __skb_get_hash(struct sk_buff *skb); u32 __skb_get_hash_symmetric(const struct sk_buff *skb); u32 skb_get_poff(const struct sk_buff *skb); -u32 __skb_get_poff(const struct sk_buff *skb, void *data, +u32 __skb_get_poff(const struct sk_buff *skb, const void *data, =09=09 const struct flow_keys_basic *keys, int hlen); __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_pr= oto, -=09=09=09 void *data, int hlen_proto); +=09=09=09 const void *data, int hlen_proto); static inline __be32 skb_flow_get_ports(const struct sk_buff *skb, =09=09=09=09=09int thoff, u8 ip_proto) @@ -1314,9 +1314,8 @@ bool bpf_flow_dissect(struct bpf_prog *prog, struct b= pf_flow_dissector *ctx, bool __skb_flow_dissect(const struct net *net, =09=09=09const struct sk_buff *skb, =09=09=09struct flow_dissector *flow_dissector, -=09=09=09void *target_container, -=09=09=09void *data, __be16 proto, int nhoff, int hlen, -=09=09=09unsigned int flags); +=09=09=09void *target_container, const void *data, +=09=09=09__be16 proto, int nhoff, int hlen, unsigned int flags); static inline bool skb_flow_dissect(const struct sk_buff *skb, =09=09=09=09 struct flow_dissector *flow_dissector, @@ -1338,9 +1337,9 @@ static inline bool skb_flow_dissect_flow_keys(const s= truct sk_buff *skb, static inline bool skb_flow_dissect_flow_keys_basic(const struct net *net, =09=09=09=09 const struct sk_buff *skb, -=09=09=09=09 struct flow_keys_basic *flow, void *data, -=09=09=09=09 __be16 proto, int nhoff, int hlen, -=09=09=09=09 unsigned int flags) +=09=09=09=09 struct flow_keys_basic *flow, +=09=09=09=09 const void *data, __be16 proto, +=09=09=09=09 int nhoff, int hlen, unsigned int flags) { =09memset(flow, 0, sizeof(*flow)); =09return __skb_flow_dissect(net, skb, &flow_keys_basic_dissector, flow, diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h index bf00e71816ed..ffd386ea0dbb 100644 --- a/include/net/flow_dissector.h +++ b/include/net/flow_dissector.h @@ -350,7 +350,7 @@ static inline bool flow_keys_have_l4(const struct flow_= keys *keys) u32 flow_hash_from_keys(struct flow_keys *keys); void skb_flow_get_icmp_tci(const struct sk_buff *skb, =09=09=09 struct flow_dissector_key_icmp *key_icmp, -=09=09=09 void *data, int thoff, int hlen); +=09=09=09 const void *data, int thoff, int hlen); static inline bool dissector_uses_key(const struct flow_dissector *flow_di= ssector, =09=09=09=09 enum flow_dissector_key_id key_id) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 2ef2224b3bff..2ed380d096ce 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -114,7 +114,7 @@ int flow_dissector_bpf_prog_attach_check(struct net *ne= t, * is the protocol port offset returned from proto_ports_offset */ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_pr= oto, -=09=09=09 void *data, int hlen) +=09=09=09 const void *data, int hlen) { =09int poff =3D proto_ports_offset(ip_proto); @@ -161,7 +161,7 @@ static bool icmp_has_id(u8 type) */ void skb_flow_get_icmp_tci(const struct sk_buff *skb, =09=09=09 struct flow_dissector_key_icmp *key_icmp, -=09=09=09 void *data, int thoff, int hlen) +=09=09=09 const void *data, int thoff, int hlen) { =09struct icmphdr *ih, _ih; @@ -187,8 +187,8 @@ EXPORT_SYMBOL(skb_flow_get_icmp_tci); */ static void __skb_flow_dissect_icmp(const struct sk_buff *skb, =09=09=09=09 struct flow_dissector *flow_dissector, -=09=09=09=09 void *target_container, -=09=09=09=09 void *data, int thoff, int hlen) +=09=09=09=09 void *target_container, const void *data, +=09=09=09=09 int thoff, int hlen) { =09struct flow_dissector_key_icmp *key_icmp; @@ -409,8 +409,8 @@ EXPORT_SYMBOL(skb_flow_dissect_hash); static enum flow_dissect_ret __skb_flow_dissect_mpls(const struct sk_buff *skb, =09=09=09struct flow_dissector *flow_dissector, -=09=09=09void *target_container, void *data, int nhoff, int hlen, -=09=09=09int lse_index, bool *entropy_label) +=09=09=09void *target_container, const void *data, int nhoff, +=09=09=09int hlen, int lse_index, bool *entropy_label) { =09struct mpls_label *hdr, _hdr; =09u32 entry, label, bos; @@ -467,7 +467,8 @@ __skb_flow_dissect_mpls(const struct sk_buff *skb, static enum flow_dissect_ret __skb_flow_dissect_arp(const struct sk_buff *skb, =09=09 struct flow_dissector *flow_dissector, -=09=09 void *target_container, void *data, int nhoff, int hlen) +=09=09 void *target_container, const void *data, +=09=09 int nhoff, int hlen) { =09struct flow_dissector_key_arp *key_arp; =09struct { @@ -523,7 +524,7 @@ static enum flow_dissect_ret __skb_flow_dissect_gre(const struct sk_buff *skb, =09=09 struct flow_dissector_key_control *key_control, =09=09 struct flow_dissector *flow_dissector, -=09=09 void *target_container, void *data, +=09=09 void *target_container, const void *data, =09=09 __be16 *p_proto, int *p_nhoff, int *p_hlen, =09=09 unsigned int flags) { @@ -663,8 +664,8 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, static enum flow_dissect_ret __skb_flow_dissect_batadv(const struct sk_buff *skb, =09=09=09 struct flow_dissector_key_control *key_control, -=09=09=09 void *data, __be16 *p_proto, int *p_nhoff, int hlen, -=09=09=09 unsigned int flags) +=09=09=09 const void *data, __be16 *p_proto, int *p_nhoff, +=09=09=09 int hlen, unsigned int flags) { =09struct { =09=09struct batadv_unicast_packet batadv_unicast; @@ -695,7 +696,8 @@ __skb_flow_dissect_batadv(const struct sk_buff *skb, static void __skb_flow_dissect_tcp(const struct sk_buff *skb, =09=09 struct flow_dissector *flow_dissector, -=09=09 void *target_container, void *data, int thoff, int hlen) +=09=09 void *target_container, const void *data, +=09=09 int thoff, int hlen) { =09struct flow_dissector_key_tcp *key_tcp; =09struct tcphdr *th, _th; @@ -719,8 +721,8 @@ __skb_flow_dissect_tcp(const struct sk_buff *skb, static void __skb_flow_dissect_ports(const struct sk_buff *skb, =09=09=09 struct flow_dissector *flow_dissector, -=09=09=09 void *target_container, void *data, int nhoff, -=09=09=09 u8 ip_proto, int hlen) +=09=09=09 void *target_container, const void *data, +=09=09=09 int nhoff, u8 ip_proto, int hlen) { =09enum flow_dissector_key_id dissector_ports =3D FLOW_DISSECTOR_KEY_MAX; =09struct flow_dissector_key_ports *key_ports; @@ -744,7 +746,8 @@ __skb_flow_dissect_ports(const struct sk_buff *skb, static void __skb_flow_dissect_ipv4(const struct sk_buff *skb, =09=09=09struct flow_dissector *flow_dissector, -=09=09=09void *target_container, void *data, const struct iphdr *iph) +=09=09=09void *target_container, const void *data, +=09=09=09const struct iphdr *iph) { =09struct flow_dissector_key_ip *key_ip; @@ -761,7 +764,8 @@ __skb_flow_dissect_ipv4(const struct sk_buff *skb, static void __skb_flow_dissect_ipv6(const struct sk_buff *skb, =09=09=09struct flow_dissector *flow_dissector, -=09=09=09void *target_container, void *data, const struct ipv6hdr *iph) +=09=09=09void *target_container, const void *data, +=09=09=09const struct ipv6hdr *iph) { =09struct flow_dissector_key_ip *key_ip; @@ -908,9 +912,8 @@ bool bpf_flow_dissect(struct bpf_prog *prog, struct bpf= _flow_dissector *ctx, bool __skb_flow_dissect(const struct net *net, =09=09=09const struct sk_buff *skb, =09=09=09struct flow_dissector *flow_dissector, -=09=09=09void *target_container, -=09=09=09void *data, __be16 proto, int nhoff, int hlen, -=09=09=09unsigned int flags) +=09=09=09void *target_container, const void *data, +=09=09=09__be16 proto, int nhoff, int hlen, unsigned int flags) { =09struct flow_dissector_key_control *key_control; =09struct flow_dissector_key_basic *key_basic; @@ -1642,7 +1645,7 @@ __u32 skb_get_hash_perturb(const struct sk_buff *skb, } EXPORT_SYMBOL(skb_get_hash_perturb); -u32 __skb_get_poff(const struct sk_buff *skb, void *data, +u32 __skb_get_poff(const struct sk_buff *skb, const void *data, =09=09 const struct flow_keys_basic *keys, int hlen) { =09u32 poff =3D keys->control.thoff; -- 2.30.2