Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17584115rwd; Tue, 27 Jun 2023 05:13:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HP/27769dnre9TNjw+G/IzO/fK0P1w0gf96VVnAY8wrk7c06FlPWBmuDZa4gggxj/JZk/ X-Received: by 2002:a92:cb03:0:b0:345:8d1e:67fd with SMTP id s3-20020a92cb03000000b003458d1e67fdmr8627728ilo.14.1687868004273; Tue, 27 Jun 2023 05:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687868004; cv=none; d=google.com; s=arc-20160816; b=SmnlT/AQo4CJf3y2hXP/7YeVhFj5nZeWK0j9jTLkQx1WaorsbUqSLNl0ULk3q/LAzV 8BuZvFoPhyrzIMmmpAX1+7DvXsmImi3Z27vytWKXPvvFl9H5P4w14Ji6mx/By9RBQ0J/ an3rxeyB2G2NJ5iSGgWMKSqgU1beskD9vAYaw0hm8OWNWsY7QP+Amcto5OgIJwTMcudo voYACll4M4RWHgMwdstqfA0HXuHtVptxct25966NaiRT4RYo4u183At/VgyNCxy8Sbju mN55ezupvEC0ss+FN/mVmnj8qs6MvV1wlF3I/pEgVGEkrHcVjZQOhxt8Y425tcd4qhGK hWFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hLCPa6nZQpfPgSc4juymFKG8/hs+ZrwGVBkAUJ3rTuc=; fh=cKPqV5Nvoty24nXUueYQhlQlPOt0s+T0MOl/vFzM6ow=; b=y9Rd3ZToHEwjiJsmbL7xNrCEuY4wYaA5RV6i/c6nU2woFFrTMqjJH/IGR/OGMav0X4 v5jQzHowcnMvwvZyjVeWfk4GU0f0eYllfJotb1V5VnBmrAoGLJqjwKEZkEJ5Pmme+u0Y DteoecCwPcvAljfJj+Zpo1KSbNovZBCaU0GvY2/p1wWIjaZoYgIfSmD1uHyfbvo0LhD2 As5AtjMTR9pVkt4QFmB/HUIL1+9aHccLyYDd+1H0aKoeIW7wyARMxbtmeNQFebMcBlGN BGaOMp7fwSWikz4EOWQoHY9NkwQ+DuiQMLKFlJ3XQ2rtNwjHyC8Blm4StkIQ6PJvSBEP CH8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=CVJ860h2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l186-20020a6391c3000000b005573bd5add3si7215580pge.214.2023.06.27.05.13.12; Tue, 27 Jun 2023 05:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=CVJ860h2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229838AbjF0Lly (ORCPT + 99 others); Tue, 27 Jun 2023 07:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjF0Llx (ORCPT ); Tue, 27 Jun 2023 07:41:53 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51E57102; Tue, 27 Jun 2023 04:41:52 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-98e109525d6so528158466b.0; Tue, 27 Jun 2023 04:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687866111; x=1690458111; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hLCPa6nZQpfPgSc4juymFKG8/hs+ZrwGVBkAUJ3rTuc=; b=CVJ860h2ZOdFWZmQWFaZ2hwikkPWxh3VLPLwpmYMq+YkC6He/p0IMJ06XEDR3ausYm KdE8UDNEILn0UtI1mp7SG6nRLAWrpKNzcvV4E3QOgsd20b6xYsxDMh+zHLEbi2jMuf4j sRdAoVRj1fJndbTKFHsyfPoyT+hOCNf2ykVpMfT5WfiezYvLdXBzEVSstrotXZpdxjD0 jnomQ0jmmhiQaW//XoY7MDjkoO9VsZTws/7cd6+JBDRjgrjzqdfSNXubXJ1tS+WierDU XrXX5ldQePOSNQdIoukUrSkW7p2pQ2SteInIiw0cR2VwmpKWEXpSx8VEjv+no8FOPuq7 L9OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687866111; x=1690458111; 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=hLCPa6nZQpfPgSc4juymFKG8/hs+ZrwGVBkAUJ3rTuc=; b=Dh35mFL14SyadhxmEcS3JG6a9W+l8FCS0q4rZclLa0qDCOzAVzK2c/U0LT4oIpanj6 04D0zNnHj05ZPhRRGsilGdJOncD5D8bSY2JG6JdASvdh9TRh0qMrRbzvi9AeBC1PbYMN sIAn2mkSx9GEWsorZxXNtjUPWhRklKzQt+qOGPpplnrTTFsz/aDVgQV2+WVXTXYjFGK7 Te5vJT/wl/9V1JM2l9q6A1e0jNlR0njMYdphqPJzY7IslndV+0jvh+fiGqNuYGF1qvbk 5IRrGCuw9e1FX4+CK72JkG9H49oWaLB7UuoTMfvoO4axce13n26hKjKxaTqDr2El4cbF Qvyw== X-Gm-Message-State: AC+VfDyX75OrBexAyueZWs6R5PGI07b7uVygJvwuF+EzaWBxMuEGdHfQ /I88a2z03dUphwpuDB8B2UA= X-Received: by 2002:a17:907:6e06:b0:98f:8481:24b3 with SMTP id sd6-20020a1709076e0600b0098f848124b3mr6264974ejc.37.1687866110530; Tue, 27 Jun 2023 04:41:50 -0700 (PDT) Received: from skbuf ([188.25.159.134]) by smtp.gmail.com with ESMTPSA id ha22-20020a170906a89600b0098e0c0cfb66sm3869302ejb.38.2023.06.27.04.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 04:41:50 -0700 (PDT) Date: Tue, 27 Jun 2023 14:41:48 +0300 From: Vladimir Oltean To: Simon Horman Cc: Vladimir Oltean , netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: Re: [PATCH net 2/2] net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT Message-ID: <20230627114148.lpyopy6ttuvvciww@skbuf> References: <20230626155112.3155993-1-vladimir.oltean@nxp.com> <20230626155112.3155993-3-vladimir.oltean@nxp.com> <20230626221828.qzjeo6dedjnyme6k@skbuf> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 27, 2023 at 01:15:03PM +0200, Simon Horman wrote: > On Tue, Jun 27, 2023 at 01:18:28AM +0300, Vladimir Oltean wrote: > > Hi Simon, > > > > On Mon, Jun 26, 2023 at 08:11:53PM +0200, Simon Horman wrote: > > > Hi Vladimir, > > > > > > A similar comment to that made for [1], though the code is somewhat > > > different to that case: are you sure vid is initialised here? > > > GCC 12 and Smatch seem unsure about it. > > > > > > [1] Re: [PATCH net-next v2 4/7] net: dsa: vsc73xx: Add dsa tagging based on 8021q > > > https://lore.kernel.org/all/ZJg2M+Qvg3Fv73CH@corigine.com/ > > > > "vid" can be uninitialized if the tagger is fed a junk packet (a > > non-link-local, non-meta packet that also has no tag_8021q header). > > > > The immediate answer that comes to mind is: it depends on how the driver > > configures the hardware to send packets to the CPU (and it will never > > configure the switch in that way). > > > > But, between the sja1105 driver configuring the switch in a certain way > > and the tag_sja1105 driver seeing the results of that, there's also the > > DSA master driver (can be any net_device) which can alter the packet in > > a nonsensical way, like remove the VLAN header for some reason. > > > > Considering the fact that the DSA master can have tc rules on its > > ingress path which do just that, it would probably be wise to be > > defensive about this. So I can probably add: > > > > if (sja1105_skb_has_tag_8021q(skb)) { > > ... // existing call to sja1105_vlan_rcv() here > > } else if (source_port == -1 && switch_id == -1) { > > /* Packets with no source information have no chance of > > * getting accepted, drop them straight away. > > */ > > return NULL; > > } > > > > This "else if" block should ensure that when "vid" is uninitialized, > > either "source_port" and "switch_id", or "vbid", always have valid values. > > This is kind of complex :) > > Can I clarify that either: > > 1. Both source_port and switch_id are -1; or > 2. Neither source_port nor switch_id are -1 > > If so, I agree with your proposal. They are integers assigned from the same code blocks in all cases, starting with -1 and later being assigned rvalues either from u64 fields limited to 0-255 (meta->source_port, meta->switch_id) or from unsigned char fields (hdr->h_dest[3], hdr->h_dest[4]), or from dsa_8021q_rx_source_port() and dsa_8021q_rx_switch_id() which return limited-size positive integers due to their implementation.