From patchwork Thu Jun 2 06:24:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 629015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rKy044sJgz9sDG for ; Thu, 2 Jun 2016 16:25:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b=rSF74I1m; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 93C1122C39A; Wed, 1 Jun 2016 23:25:06 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 5771C106A8 for ; Wed, 1 Jun 2016 23:25:04 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id D672B1E037A for ; Thu, 2 Jun 2016 00:25:03 -0600 (MDT) X-ASG-Debug-ID: 1464848703-09eadd5c05dabb0001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar5.cudamail.com with ESMTP id 1kCBNfEVdTL6CkJc (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 02 Jun 2016 00:25:03 -0600 (MDT) X-Barracuda-Envelope-From: simon.horman@netronome.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mail-pa0-f48.google.com) (209.85.220.48) by mx3-pf3.cudamail.com with ESMTPS (AES128-SHA encrypted); 2 Jun 2016 06:25:02 -0000 Received-SPF: neutral (mx3-pf3.cudamail.com: 209.85.220.48 is neither permitted nor denied by SPF record at spf.mandrillapp.com) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.48 Received: by mail-pa0-f48.google.com with SMTP id xk1so3269477pac.2 for ; Wed, 01 Jun 2016 23:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4zK6yRqVf7yoFzkLxSdOZMur7huSKq9RyGX6QKMIk5Q=; b=rSF74I1mWE7A/CgbtAZaKO+0U/PeyjrTV3qVt/wu/JRdrXTBIKOZfQRtWYXuhHy3az Jcv6D2tjs5wmB0MpLwRBLkXF2hyrobxHBkZl1H6JP//AoBcQSY7L2uU4BdV0Fuy4Jw/A CD2iy1TFSPoHV9J7jht47ZVxUVnneN3DzmsYXZY4ppgpxsNhfnkT23yoCIKP8vDjGkBM 0gxCo2gsmK+R+rWrO9DSprRK8Bi/EKJ7Fmq8gs8hPpVgwPM95BmehAxQWBBfyH3rH1i9 GRbTMBY0JhtiQkgMlyhFDGTO/x2ZtZUgF+AL+CpeVhWzu+ftslHG/hGKWgKLxPJF8qST hj7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4zK6yRqVf7yoFzkLxSdOZMur7huSKq9RyGX6QKMIk5Q=; b=HA2Q8rMo7E9h+l09pG1cjYRV5bZ7elKBAInYbLtlR5k7wrRXpkJFcZk/aLSTiyQHUR MK2dtBHf0IJl/kFp4hNnTUu94wEwe7CSvSybxODb8h4AHrt2vFXIUM8XBPlMXlOA1ZlT YepUknKW6BVUl91EjuCue5e7FZmm6B1JWduCmKuLAlJ37HiigY3X1UST8q0nD34gipoV ZZkWJYmdvXsfe8Xeq9vqdUeuTk7QDiMHsqy8AP2RqiM4agr5MElbhzWV76NsuNxqfH7Z E6gzsvee8ZBE359SFfdyd8K/hKUZkp+wF38eg8PHYe/N8py1t8bfPfFcAu+nmydvrRCj KTbg== X-Gm-Message-State: ALyK8tKKvhNQOm2dUutzEGhlfPU+DuV1PPAhyzVRIymixSbt7UygQi4OP73RtIpbqa+7jN5d X-Received: by 10.66.151.237 with SMTP id ut13mr2940335pab.23.1464848702127; Wed, 01 Jun 2016 23:25:02 -0700 (PDT) Received: from reginn.isobedori.kobe.vergenet.net (p6216-ipbfp1501kobeminato.hyogo.ocn.ne.jp. [114.153.217.216]) by smtp.gmail.com with ESMTPSA id y2sm52444149pfi.39.2016.06.01.23.24.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 23:25:01 -0700 (PDT) X-CudaMail-Envelope-Sender: simon.horman@netronome.com X-Barracuda-Apparent-Source-IP: 114.153.217.216 From: Simon Horman To: netdev@vger.kernel.org X-CudaMail-MID: CM-V3-601000371 X-CudaMail-DTE: 060216 X-CudaMail-Originating-IP: 209.85.220.48 Date: Thu, 2 Jun 2016 15:24:44 +0900 X-ASG-Orig-Subj: [##CM-V3-601000371##][PATCH net-next v10 3/5] openvswitch: add support to push and pop mpls for layer3 packets Message-Id: <1464848686-7656-4-git-send-email-simon.horman@netronome.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464848686-7656-1-git-send-email-simon.horman@netronome.com> References: <1464848686-7656-1-git-send-email-simon.horman@netronome.com> X-GBUdb-Analysis: 0, 209.85.220.48, Ugly c=0.443535 p=-0.189189 Source Normal X-MessageSniffer-Rules: 0-0-0-6869-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1464848703 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC0_MISMATCH_TO, BSF_SC5_MJ1963, DKIM_SIGNED, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.30103 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH net-next v10 3/5] openvswitch: add support to push and pop mpls for layer3 packets X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Allow push and pop mpls actions to act on layer 3 packets by teaching them not to access non-existent L2 headers of such packets. Signed-off-by: Simon Horman --- v10 * Limit scope of hdr in {push,pop}_mpls() v9 * New Patch --- net/openvswitch/actions.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 9a3eb7a0ebf4..15f130e4c22b 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -172,7 +172,8 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key, skb_postpush_rcsum(skb, new_mpls_lse, MPLS_HLEN); - update_ethertype(skb, eth_hdr(skb), mpls->mpls_ethertype); + if (skb->mac_len) + update_ethertype(skb, eth_hdr(skb), mpls->mpls_ethertype); if (!skb->inner_protocol) skb_set_inner_protocol(skb, skb->protocol); skb->protocol = mpls->mpls_ethertype; @@ -184,7 +185,6 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key, static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, const __be16 ethertype) { - struct ethhdr *hdr; int err; err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN); @@ -199,11 +199,16 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, __skb_pull(skb, MPLS_HLEN); skb_reset_mac_header(skb); - /* skb_mpls_header() is used to locate the ethertype - * field correctly in the presence of VLAN tags. - */ - hdr = (struct ethhdr *)(skb_mpls_header(skb) - ETH_HLEN); - update_ethertype(skb, hdr, ethertype); + if (skb->mac_len) { + struct ethhdr *hdr; + + /* skb_mpls_header() is used to locate the ethertype + * field correctly in the presence of VLAN tags. + */ + hdr = (struct ethhdr *)(skb_mpls_header(skb) - ETH_HLEN); + update_ethertype(skb, hdr, ethertype); + } + if (eth_p_mpls(skb->protocol)) skb->protocol = ethertype;