From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE27DEB64DD for ; Fri, 21 Jul 2023 15:21:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 88F966139D; Fri, 21 Jul 2023 15:21:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 88F966139D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1689952881; bh=5dk2TUzFFxX4+OO069u+dgzSmXwLUNFRBWqd2juOaWk=; h=Date:From:To:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=aAAmsajRqALutBFvr262vH21KMmqQvqgBdetym9uhTTLonj3MY4fPZ5PXWa2s2HTm N3mYhjx5SrST4AxUyMCQe8WWf5MVMlbdNMOBZX1Jz+4HfeHW7TjSKST9nkvHMgyt1q 1zHAb3ccbf25ditiF63PFhSpLVmuqeQFbuffqZaVbc1roFuh+2VsXlQwwwA4bY88Nr nH1T+5H6XOJUVUqorfaXyvsX6D+AHr+XWusp6sec0mG2WgEK7kIfc71CONratOvz2x w0ozJDoPHVuIMdioTfhyN6UM5PLRQl+pllgIYkCr0hO5L3A5IbwUap0SAmsMJ7x9LZ 2/K+dFyRLCfgg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y-ODSH1Mk2TI; Fri, 21 Jul 2023 15:21:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id CA7F761377; Fri, 21 Jul 2023 15:21:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CA7F761377 Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id EAEAF1BF287 for ; Fri, 21 Jul 2023 14:29:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id BEFAC4178F for ; Fri, 21 Jul 2023 14:29:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org BEFAC4178F X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3g-Ej-Za6eEG for ; Fri, 21 Jul 2023 14:29:02 +0000 (UTC) X-Greylist: delayed 424 seconds by postgrey-1.37 at util1.osuosl.org; Fri, 21 Jul 2023 14:29:02 UTC DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0803D41785 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0803D41785 for ; Fri, 21 Jul 2023 14:29:01 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="346632489" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="346632489" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 07:21:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="718837285" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="718837285" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga007.jf.intel.com with ESMTP; 21 Jul 2023 07:21:53 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qMr0x-0085eg-2U; Fri, 21 Jul 2023 17:21:51 +0300 Date: Fri, 21 Jul 2023 17:21:51 +0300 From: Andy Shevchenko To: Marcin Szycik Message-ID: References: <20230721071532.613888-1-marcin.szycik@linux.intel.com> <20230721071532.613888-2-marcin.szycik@linux.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230721071532.613888-2-marcin.szycik@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Mailman-Approved-At: Fri, 21 Jul 2023 15:21:09 +0000 Subject: Re: [Intel-wired-lan] [PATCH iwl-next v3 1/6] ip_tunnel: use a separate struct to store tunnel params in the kernel X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiri@resnulli.us, netdev@vger.kernel.org, idosch@nvidia.com, jesse.brandeburg@intel.com, intel-wired-lan@lists.osuosl.org, kuba@kernel.org, simon.horman@corigine.com, pabeni@redhat.com, davem@davemloft.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Fri, Jul 21, 2023 at 09:15:27AM +0200, Marcin Szycik wrote: > From: Alexander Lobakin > > Unlike IPv6 tunnels which use purely-kernel __ip6_tnl_parm structure > to store params inside the kernel, IPv4 tunnel code uses the same > ip_tunnel_parm which is being used to talk with the userspace. > This makes it difficult to alter or add any fields or use a > different format for whatever data. > Define struct ip_tunnel_parm_kern, a 1:1 copy of ip_tunnel_parm for > now, and use it throughout the code. The two places where the latter > is used to interact with the userspace, now do a conversion from one > type to another, with manual field-by-field assignments. > Must be done at once, since ip_tunnel::parms is being used in most > of those places. ... > + strscpy(kp.name, p.name, sizeof(kp.name)); > + kp.link = p.link; > + kp.i_flags = p.i_flags; > + kp.o_flags = p.o_flags; > + kp.i_key = p.i_key; > + kp.o_key = p.o_key; > + memcpy(&kp.iph, &p.iph, min(sizeof(kp.iph), sizeof(p.iph))); > + > + err = dev->netdev_ops->ndo_tunnel_ctl(dev, &kp, cmd); > + if (err) > + return err; > + > + strscpy(p.name, kp.name, sizeof(p.name)); > + p.link = kp.link; > + p.i_flags = kp.i_flags; > + p.o_flags = kp.o_flags; > + p.i_key = kp.i_key; > + p.o_key = kp.o_key; > + memcpy(&p.iph, &kp.iph, min(sizeof(p.iph), sizeof(kp.iph))); > + strscpy(kp.name, p.name, sizeof(kp.name)); > + kp.link = p.link; > + kp.i_flags = p.i_flags; > + kp.o_flags = p.o_flags; > + kp.i_key = p.i_key; > + kp.o_key = p.o_key; > + memcpy(&kp.iph, &p.iph, min(sizeof(p.iph), sizeof(kp.iph))); Seems to me these two deserves separate helpers to avoid such a duplication(s). -- With Best Regards, Andy Shevchenko _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan