From patchwork Wed Mar 7 23:38:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 882865 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fCeZunRo"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zxVTy1RJsz9sh3 for ; Thu, 8 Mar 2018 10:39:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754965AbeCGXjM (ORCPT ); Wed, 7 Mar 2018 18:39:12 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34902 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754932AbeCGXjL (ORCPT ); Wed, 7 Mar 2018 18:39:11 -0500 Received: by mail-pg0-f65.google.com with SMTP id l131so1519015pga.2 for ; Wed, 07 Mar 2018 15:39:11 -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; bh=xOnQyoA9sNeHvubZA+28ZFH1S7eeWFZxUm0dDkw9vUY=; b=fCeZunRoyT1KmyfbUtLA3fTjTTa7xbUmwDR8ZjT6tQfg+jR/cH9rGoKEyENxNYV1ig Qa6SJ3uEQ9P0VHQ2olMG8zjoUMotj2yV6prQQPbCGp5P97p981l+xoh8f9XR/7ZKam2m Ax65s2Yg8TOyuNuv8BTtD4QKgtVkajkYY+XjiXNtIS+wkyX9O557/2MRuYWwdegUDWci ToC3GiRHd7lX3+LFpXtNQzVWpXbkSrCaPxaDXHOCcvtkrw0arAo2KRIDiLU1i+WsbCI5 oqHUBiy/7r/ep4l839FmDxxJ5waM/mFTuukY5KNPeBAj8Go6KVvwxUH7Fl62Md9LLh6L Kkug== 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; bh=xOnQyoA9sNeHvubZA+28ZFH1S7eeWFZxUm0dDkw9vUY=; b=qQYpcABRNs5ZL7kS27S1qwqq5dd4JkaIdH0ZzIBS0srQfG+iGNMeBAMQrWonjRAq1r envLsP6DqqIy5it2J2gYgmWamdt1BQmE6RBEFL9qckoBLoAGPYNTDm6ldOaU4huk4Mfv E1/aRY2QJWyZ6Sd8U8nuKJcueTIwLEI1gX/zcoSwB2SIIofUl1vyPwJlCeEBkQU4sAMo CVIj69UfoSODwtbJp1TPoCBeye3FHPcnkwG0Pj4sQGmHg4RdzyMJcXaVWlMNVAxlYMLv u8dRyDW5C7/Z7daGzSCkSllerEe9799cq5nhPRRXzy53YcWfIzlxbIYFfwb/RFVkW9Up 6eJw== X-Gm-Message-State: APf1xPCJRDjeqfRlDt/ipOyHp3TaGNDkv2lOAKyh0O22L85NvWUM8ZIS 7PkEO2hoI9vwA0AOTat20SyfeEo9 X-Google-Smtp-Source: AG47ELsObV6xlKZCHRAodm55JmU/hznCUDMCZmOVCmxPXbcWqscWl0eDKSw8H+z3rfNGvev5N7vGVA== X-Received: by 10.99.179.14 with SMTP id i14mr19395020pgf.45.1520465950604; Wed, 07 Mar 2018 15:39:10 -0800 (PST) Received: from william-virtual-machine.eng.vmware.com ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id b72sm27973853pfl.21.2018.03.07.15.39.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Mar 2018 15:39:09 -0800 (PST) From: William Tu To: netdev@vger.kernel.org Cc: pshelar@ovn.org, jbenc@redhat.com Subject: [PATCHv2 net-next] openvswitch: fix vport packet length check. Date: Wed, 7 Mar 2018 15:38:48 -0800 Message-Id: <1520465928-22181-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When sending a packet to a tunnel device, the dev's hard_header_len could be larger than the skb->len in function packet_length(). In the case of ip6gretap/erspan, hard_header_len = LL_MAX_HEADER + t_hlen, which is around 180, and an ARP packet sent to this tunnel has skb->len = 42. This causes the 'unsign int length' to become super large because it is negative value, causing the later ovs_vport_send to drop it due to over-mtu size. The patch fixes it by setting it to 0. Signed-off-by: William Tu Acked-by: Pravin B Shelar --- v1->v2: replace the return type from unsigned int to int --- net/openvswitch/vport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index b6c8524032a0..f81c1d0ddff4 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c @@ -464,10 +464,10 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb, return 0; } -static unsigned int packet_length(const struct sk_buff *skb, - struct net_device *dev) +static int packet_length(const struct sk_buff *skb, + struct net_device *dev) { - unsigned int length = skb->len - dev->hard_header_len; + int length = skb->len - dev->hard_header_len; if (!skb_vlan_tag_present(skb) && eth_type_vlan(skb->protocol)) @@ -478,7 +478,7 @@ static unsigned int packet_length(const struct sk_buff *skb, * account for 802.1ad. e.g. is_skb_forwardable(). */ - return length; + return length > 0 ? length : 0; } void ovs_vport_send(struct vport *vport, struct sk_buff *skb, u8 mac_proto)