From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v2] gro: add missing invalid packet checks Date: Mon, 14 Jan 2019 17:00:28 -0800 Message-ID: <20190114170028.68bdd4d7@hermes.lan> References: <1546927725-68831-1-git-send-email-jiayu.hu@intel.com> <1547132768-2384-1-git-send-email-jiayu.hu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, konstantin.ananyev@intel.com, thomas@monjalon.net, stable@dpdk.org To: Jiayu Hu Return-path: Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 7CFB91B10D for ; Tue, 15 Jan 2019 02:00:32 +0100 (CET) Received: by mail-pf1-f193.google.com with SMTP id z9so461493pfi.2 for ; Mon, 14 Jan 2019 17:00:32 -0800 (PST) In-Reply-To: <1547132768-2384-1-git-send-email-jiayu.hu@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, 10 Jan 2019 23:06:08 +0800 Jiayu Hu wrote: > + > +#define ILLEGAL_ETHER_HDRLEN(len) ((len) != ETHER_HDR_LEN) > +#define ILLEGAL_ETHER_VXLAN_HDRLEN(len) \ > + ((len) != (ETHER_VXLAN_HLEN + ETHER_HDR_LEN)) > +#define ILLEGAL_IPV4_HDRLEN(len) ((len) != sizeof(struct ipv4_hdr)) > +#define ILLEGAL_TCP_HDRLEN(len) \ > + (((len) < sizeof(struct tcp_hdr)) || ((len) > TCP_MAX_HLEN)) > + Why not inline (which keeps type checking) instead of macro. Results in same code. Also, prefer "invalid" instead "ILLEGAL" . There is no government inforcing a rule on packet headers. Also, what about ipv4 options, or TCP options? And even VXLAN header check should be more rigorous. What about not allowing fragments in IP header for example. If you are going to do enforcement, be as strict as you can.