From patchwork Mon Dec 16 14:02:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Varghese X-Patchwork-Id: 1210424 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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="ecEMBKX3"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47c2zh04F7z9sPn for ; Tue, 17 Dec 2019 01:03:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbfLPODK (ORCPT ); Mon, 16 Dec 2019 09:03:10 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43538 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727979AbfLPODK (ORCPT ); Mon, 16 Dec 2019 09:03:10 -0500 Received: by mail-pg1-f195.google.com with SMTP id k197so3749090pga.10 for ; Mon, 16 Dec 2019 06:03:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=bzIfo5QToARCZWLeqG3x/wMqUmg7NXaLyDxKE0gqU2E=; b=ecEMBKX35YsZArRPQ0gjOPR2B1e77K4/6Dar4BMOdWAhHDNCAz88nnZTb8dkMLo2ef LNO4tgjXPudTO79f15A4nfrszL0xHDdsIH8ZTUAMLZTQtaav9gip3YJb1QhhCmlO5OE6 Zwx8MdA0tvZCViitSuiSpNUCupK/RMurwU+uJoqny2a5rSEsZ4EiDNbOVf9iJ6taO5Pu PKy2a4agh6frNiidPvVCqmzpxl5SwhHs7Cb9Odrx5avjz12nTtJMET2cKc6s3zw5eDkC Pprg8QQRpafEie3UYcvQEbvw6qAp/vOlVShJLCi6jznlmkx60aQwATTj2jhkfaUTHh3D /BcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=bzIfo5QToARCZWLeqG3x/wMqUmg7NXaLyDxKE0gqU2E=; b=lYwF6HpVWTzjPHvb/jwx/zfKs+jjGaojTMZjEBJ/t+swMolyPtANMQ8j0E2yt9JMGk e2EoO7ByBNsK1I5vEo3zpe458GeTHl+3CPJctJRZCTlQ+Fhn1RInTf1zU6PZoSTrj7fx nc4AOZtvIvThf4w6d+oA3VW2xAwZfz3QHEKzA/0ru2XV29shBjf+V6dp9RgsaBoRXjid joXxa3a+u1iC/C1Z7B6foJOAVvErCbB4xaNvqXyenvOKSWCZa7bgeYVkYa0XStZN/r7Y Q0CUTIcX5ek305xbjn35qZqXPpMDB6z207qTgCIKqcLK/gA2qL7910zAFjDMLreAvoei RKCg== X-Gm-Message-State: APjAAAUm/Vf/r7V6fI9USUAsJLdA5raFKYjAEURIsPABktpeD0xVzJ0u 5s/RaegMYL4m/lnY8VQXotrxnTaW X-Google-Smtp-Source: APXvYqwtQtx5VoS9RmgiRtDKTQYKU86+tgV4Vt5s0U0a5zlITBxwktrt3iAYP232zT0c/Sl9r+I6vg== X-Received: by 2002:a63:510e:: with SMTP id f14mr18460738pgb.35.1576504989599; Mon, 16 Dec 2019 06:03:09 -0800 (PST) Received: from martin-VirtualBox.dlink.router ([122.182.209.142]) by smtp.gmail.com with ESMTPSA id k3sm22777541pgc.3.2019.12.16.06.03.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Dec 2019 06:03:09 -0800 (PST) From: Martin Varghese To: netdev@vger.kernel.org, davem@davemloft.net, pshelar@ovn.org, scott.drennan@nokia.com, jbenc@redhat.com, martin.varghese@nokia.com Subject: [PATCH net-next v3 1/3] net: skb_mpls_push() modified to allow MPLS header push at start of packet. Date: Mon, 16 Dec 2019 19:32:50 +0530 Message-Id: <5dbc2dbc222ff778861ef08b4e0a68a49a7afeb1.1576488935.git.martin.varghese@nokia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Martin Varghese The existing skb_mpls_push() implementation always inserts mpls header after the mac header. L2 VPN use cases requires MPLS header to be inserted before the ethernet header as the ethernet packet gets tunnelled inside MPLS header in those cases. Signed-off-by: Martin Varghese --- Changes in v2: - Fixed comments section of skb_mpls_push(). - Added skb_reset_mac_len() in skb_mpls_push(). The mac len changes when MPLS header in inserted at the start of the packet. net/core/skbuff.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 973a71f..d90c827 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5472,12 +5472,15 @@ static void skb_mod_eth_type(struct sk_buff *skb, struct ethhdr *hdr, } /** - * skb_mpls_push() - push a new MPLS header after the mac header + * skb_mpls_push() - push a new MPLS header after mac_len bytes from start of + * the packet * * @skb: buffer * @mpls_lse: MPLS label stack entry to push * @mpls_proto: ethertype of the new MPLS header (expects 0x8847 or 0x8848) * @mac_len: length of the MAC header + * @ethernet: flag to indicate if the resulting packet after skb_mpls_push is + * ethernet * * Expects skb->data at mac header. * @@ -5501,7 +5504,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto, return err; if (!skb->inner_protocol) { - skb_set_inner_network_header(skb, mac_len); + skb_set_inner_network_header(skb, skb_network_offset(skb)); skb_set_inner_protocol(skb, skb->protocol); } @@ -5510,6 +5513,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto, mac_len); skb_reset_mac_header(skb); skb_set_network_header(skb, mac_len); + skb_reset_mac_len(skb); lse = mpls_hdr(skb); lse->label_stack_entry = mpls_lse; From patchwork Mon Dec 16 14:03:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Varghese X-Patchwork-Id: 1210425 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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="QTORjUxS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47c30H4H0tz9sPn for ; Tue, 17 Dec 2019 01:03:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728073AbfLPODm (ORCPT ); Mon, 16 Dec 2019 09:03:42 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44532 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728017AbfLPODl (ORCPT ); Mon, 16 Dec 2019 09:03:41 -0500 Received: by mail-pf1-f194.google.com with SMTP id d199so5626712pfd.11 for ; Mon, 16 Dec 2019 06:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=b3hiJ3A3rMjBROFjEn7dlrVf4haGfG2YX4vYzJvUu0g=; b=QTORjUxSkLpv8447E8IVH2iLE1iPtHes6kNxq/YYpU6wdEkFJ/Ulr1WsC9450jdjig rgGHQJ8sqQxe9U+a/hIoWSofUai8f3NVdBTejp2W06pDH8sqTLjvEhsdFny+hLlo90k8 paBaMER1NxuJh/dZOJEBVnmO1ZZyPL9sAtFStsw0zcCgEAPEofRaVaNKP34ZC5Gy0GZa gx+9zt6QYV/uMciy4Xn6Fe+frwBSKMtu+OzmJTuwmBGzYEN/hL0J1I+Gjt/AllEQHi9d EZ7b50V/f+cP7e+3MCXm8ZAbUVeTucKGc2zryBkGYHBrmSJPj2Rpr9spjsqXYdA7Iw5X A32w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=b3hiJ3A3rMjBROFjEn7dlrVf4haGfG2YX4vYzJvUu0g=; b=FwXCe0xUwFru9A9nUrJn98NpSrxT3jwZhTMEcxDpFS8QfvpAK3IbaXHxxy4947u5eF 4C4FJEXS9755tzPRAD1IvYsM9SCrCL83QcloDIjtLUcefa2p8bguAax2RGIWJ8SYV4ad pbhjP52CA+ldkRXrd0aRlHg2wluhHIsCmHK6qPg+e5vAWpagGUxQLui0SdMlLZZ6oEV/ LoRRwZoyaeiyvq4bHAYvLUTU9HAnSA/ZfAhvy0ctwUHtZy5LQeVKO3H6tb6Q61pGVBwR ubYT9T/fr6bdeC3jyn1U5sPjUBgEsV9elMlvObdw4m7+k/PVOvZLLUHRTwBnzMWDonrg ygeA== X-Gm-Message-State: APjAAAXoytpMuu5FxP6B/1QJD27W7BCeDa0CmPTLcsqtpGbh7wd2pPQ/ AxyKBedM/aG/p70T0coaT1Gnr1jS X-Google-Smtp-Source: APXvYqzCANBob2ooKw7HaGNQf+2DdDZ1r2oleN2TiHwfYpiR+kCX/v4xe8Kbk1M0uaNpAXZAK3zeiA== X-Received: by 2002:a62:aa09:: with SMTP id e9mr15914903pff.154.1576505021023; Mon, 16 Dec 2019 06:03:41 -0800 (PST) Received: from martin-VirtualBox.dlink.router ([122.182.209.142]) by smtp.gmail.com with ESMTPSA id f9sm22384764pfd.141.2019.12.16.06.03.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Dec 2019 06:03:40 -0800 (PST) From: Martin Varghese To: netdev@vger.kernel.org, davem@davemloft.net, pshelar@ovn.org, scott.drennan@nokia.com, jbenc@redhat.com, martin.varghese@nokia.com Subject: [PATCH net-next v3 2/3] net: Rephrased comments section of skb_mpls_pop() Date: Mon, 16 Dec 2019 19:33:23 +0530 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Martin Varghese Rephrased comments section of skb_mpls_pop() to align it with comments section of skb_mpls_push(). Signed-off-by: Martin Varghese --- net/core/skbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index d90c827..44b0894 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5533,7 +5533,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto, * @skb: buffer * @next_proto: ethertype of header after popped MPLS header * @mac_len: length of the MAC header - * @ethernet: flag to indicate if ethernet header is present in packet + * @ethernet: flag to indicate if the packet is ethernet * * Expects skb->data at mac header. * From patchwork Mon Dec 16 14:03:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Varghese X-Patchwork-Id: 1210426 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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="LScD+18g"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47c30g46Xgz9sPc for ; Tue, 17 Dec 2019 01:04:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbfLPOEC (ORCPT ); Mon, 16 Dec 2019 09:04:02 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32982 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727952AbfLPOEB (ORCPT ); Mon, 16 Dec 2019 09:04:01 -0500 Received: by mail-pg1-f195.google.com with SMTP id 6so3772972pgk.0 for ; Mon, 16 Dec 2019 06:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=Ym7SciDlvx8fLR2cijF98p7DQ5JcVODiKgLxRuHXrdg=; b=LScD+18gemiZ3G3aq9DIeVDEGxTGWHDrbkII5kEi96PZ79uxFAv7AZ69jFP1N8cbpG /Nn5FS/RzUomVPwYK0ALphcgQeid7i+1LtlvMklpJwamVvfM1pQOpJeekQnqvxDXPqD/ blY5pgK2pUtjZRQMcUvPjWra/0+h0umKa0jvWP/sRdlq/cA/o+52jPL7U+JfU6juuyGW hiyH+C8m8Eb3dJ/GmxCcpo1Jn3RXxVwOjabhdUEU8XOehyMYOsYAUm/zPbot+Z9zHxZ+ wVhjnMu3ph4ltZ+K73bIyx+Shr/DHKy8q8MJguoya4S2ivzIEBvTNe9MSKLgQ7HkWFNX wxDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Ym7SciDlvx8fLR2cijF98p7DQ5JcVODiKgLxRuHXrdg=; b=gJJOwYBSmuAfccMV3jnGgqND1UUHwM0KP/TqpY9jUplymoobk6Zr2A+0aLr11uHbAB LSU4vNZqaS55IhFLxKBo3/ioBrYK3NoqraYfQqBCw0htlEwvgLXz9tOK3PZ/VADH5R4m m3nrY8JDU1FbBZgD3ccOap7YAZRKKgKFj/+v75Ob6ipWKbF9loooPLInrlwUaYjYmQkw geNV+SYD/GI0/s7TjlZBbj96CVMRjp4Iew0hrv5GlcosEj4TVNkvg653U71nRUyrjO2C vgOfWcGghDPQxV9YrP38T97tPDNWvemHWyf5Uk3tlXtJaQ894ubxajspnNJkDedq8Txm Sn9w== X-Gm-Message-State: APjAAAV5qGxzkenLuEFZ1o53aWMGipd40G768p1vqqiX9QHG52WHkJXD qSoD2YaAzRAI7aRokOmVJBBpsiSX X-Google-Smtp-Source: APXvYqwpNkciHo8GUOFnGIVpa2o+uVD9OUlSkOX+Mv3tNJpbxc3Jq3gVtsoc1JTLtGbfSq5+oN0TBg== X-Received: by 2002:a63:6b07:: with SMTP id g7mr18031829pgc.243.1576505040465; Mon, 16 Dec 2019 06:04:00 -0800 (PST) Received: from martin-VirtualBox.dlink.router ([122.182.209.142]) by smtp.gmail.com with ESMTPSA id r28sm16590340pgk.39.2019.12.16.06.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Dec 2019 06:04:00 -0800 (PST) From: Martin Varghese To: netdev@vger.kernel.org, davem@davemloft.net, pshelar@ovn.org, scott.drennan@nokia.com, jbenc@redhat.com, martin.varghese@nokia.com Subject: [PATCH net-next v3 3/3] openvswitch: New MPLS actions for layer 2 tunnelling Date: Mon, 16 Dec 2019 19:33:43 +0530 Message-Id: <9e3b73cd6967927fc6654cbdcd7b9e7431441c3f.1576488935.git.martin.varghese@nokia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Martin Varghese The existing PUSH MPLS action inserts MPLS header between ethernet header and the IP header. Though this behaviour is fine for L3 VPN where an IP packet is encapsulated inside a MPLS tunnel, it does not suffice the L2 VPN (l2 tunnelling) requirements. In L2 VPN the MPLS header should encapsulate the ethernet packet. The new mpls action PTAP_PUSH_MPLS inserts MPLS header at the start of the packet or at the start of the l3 header depending on the value of l2 tunnel flag in the PTAP_PUSH_MPLS arguments. POP_MPLS action is extended to support ethertype 0x6558. Signed-off-by: Martin Varghese --- Changes in v2: - PTAP_POP_MPLS action removed. - Special handling for ethertype 0 added in PUSH_MPLS. - Refactored push_mpls function to cater existing push_mpls and ptap_push_mpls actions. - mac len to specify the MPLS header location added in PTAP_PUSH_MPLS arguments. Changes in v3: - Special handling for ethertype 0 removed. - Added support for ether type 0x6558. - Removed mac len from PTAP_PUSH_MPLS argument list - used l2_tun flag to distinguish l2 and l3 tunnelling. - Extended PTAP_PUSH_MPLS handling to cater PUSH_MPLS action also. include/uapi/linux/openvswitch.h | 23 ++++++++++++++++++++++- net/openvswitch/actions.c | 30 ++++++++++++++++++++++++------ net/openvswitch/flow_netlink.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 7 deletions(-) diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h index a87b44c..b7221ad 100644 --- a/include/uapi/linux/openvswitch.h +++ b/include/uapi/linux/openvswitch.h @@ -673,6 +673,25 @@ struct ovs_action_push_mpls { }; /** + * struct ovs_action_ptap_push_mpls - %OVS_ACTION_ATTR_PTAP_PUSH_MPLS action + * argument. + * @mpls_lse: MPLS label stack entry to push. + * @mpls_ethertype: Ethertype to set in the encapsulating ethernet frame. + * @l2_tun: Flag to specify the place of insertion of MPLS header. + * When true, the MPLS header will be inserted at the start of the packet. + * When false, the MPLS header will be inserted at the start of the l3 header. + * + * The only values @mpls_ethertype should ever be given are %ETH_P_MPLS_UC and + * %ETH_P_MPLS_MC, indicating MPLS unicast or multicast. Other are rejected. + */ +struct ovs_action_ptap_push_mpls { + __be32 mpls_lse; + __be16 mpls_ethertype; /* Either %ETH_P_MPLS_UC or %ETH_P_MPLS_MC */ + bool l2_tun; +}; + + +/** * struct ovs_action_push_vlan - %OVS_ACTION_ATTR_PUSH_VLAN action argument. * @vlan_tpid: Tag protocol identifier (TPID) to push. * @vlan_tci: Tag control identifier (TCI) to push. The CFI bit must be set @@ -892,7 +911,8 @@ struct check_pkt_len_arg { * @OVS_ACTION_ATTR_CHECK_PKT_LEN: Check the packet length and execute a set * of actions if greater than the specified packet length, else execute * another set of actions. - * + * @OVS_ACTION_ATTR_PUSH_MPLS: Push a new MPLS label stack entry at specified + * offset from start of packet. * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all * fields within a header are modifiable, e.g. the IPv4 protocol and fragment * type may not be changed. @@ -927,6 +947,7 @@ enum ovs_action_attr { OVS_ACTION_ATTR_METER, /* u32 meter ID. */ OVS_ACTION_ATTR_CLONE, /* Nested OVS_CLONE_ATTR_*. */ OVS_ACTION_ATTR_CHECK_PKT_LEN, /* Nested OVS_CHECK_PKT_LEN_ATTR_*. */ + OVS_ACTION_ATTR_PTAP_PUSH_MPLS, /* struct ovs_action_ptap_push_mpls. */ __OVS_ACTION_ATTR_MAX, /* Nothing past this will be accepted * from userspace. */ diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index 4c83954..5138473 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -161,16 +161,17 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, const struct nlattr *attr, int len); static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key, - const struct ovs_action_push_mpls *mpls) + __be32 mpls_lse, __be16 mpls_ethertype, __u16 mac_len) { int err; - err = skb_mpls_push(skb, mpls->mpls_lse, mpls->mpls_ethertype, - skb->mac_len, - ovs_key_mac_proto(key) == MAC_PROTO_ETHERNET); + err = skb_mpls_push(skb, mpls_lse, mpls_ethertype, mac_len, !!mac_len); if (err) return err; + if (!mac_len) + key->mac_proto = MAC_PROTO_NONE; + invalidate_flow_key(key); return 0; } @@ -185,6 +186,9 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, if (err) return err; + if (ethertype == htons(ETH_P_TEB)) + key->mac_proto = MAC_PROTO_ETHERNET; + invalidate_flow_key(key); return 0; } @@ -1229,10 +1233,24 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, execute_hash(skb, key, a); break; - case OVS_ACTION_ATTR_PUSH_MPLS: - err = push_mpls(skb, key, nla_data(a)); + case OVS_ACTION_ATTR_PUSH_MPLS: { + struct ovs_action_push_mpls *mpls = nla_data(a); + + err = push_mpls(skb, key, mpls->mpls_lse, + mpls->mpls_ethertype, skb->mac_len); break; + } + case OVS_ACTION_ATTR_PTAP_PUSH_MPLS: { + struct ovs_action_ptap_push_mpls *mpls = nla_data(a); + __u16 mac_len = 0; + + if (!mpls->l2_tun) + mac_len = skb->mac_len; + err = push_mpls(skb, key, mpls->mpls_lse, + mpls->mpls_ethertype, mac_len); + break; + } case OVS_ACTION_ATTR_POP_MPLS: err = pop_mpls(skb, key, nla_get_be16(a)); break; diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index 65c2e34..8d650e3 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c @@ -79,6 +79,7 @@ static bool actions_may_change_flow(const struct nlattr *actions) case OVS_ACTION_ATTR_SET_MASKED: case OVS_ACTION_ATTR_METER: case OVS_ACTION_ATTR_CHECK_PKT_LEN: + case OVS_ACTION_ATTR_PTAP_PUSH_MPLS: default: return true; } @@ -3005,6 +3006,7 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr, [OVS_ACTION_ATTR_METER] = sizeof(u32), [OVS_ACTION_ATTR_CLONE] = (u32)-1, [OVS_ACTION_ATTR_CHECK_PKT_LEN] = (u32)-1, + [OVS_ACTION_ATTR_PTAP_PUSH_MPLS] = sizeof(struct ovs_action_ptap_push_mpls), }; const struct ovs_action_push_vlan *vlan; int type = nla_type(a); @@ -3072,6 +3074,33 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr, case OVS_ACTION_ATTR_RECIRC: break; + case OVS_ACTION_ATTR_PTAP_PUSH_MPLS: { + const struct ovs_action_ptap_push_mpls *mpls = nla_data(a); + + if (!eth_p_mpls(mpls->mpls_ethertype)) + return -EINVAL; + + if (!mpls->l2_tun) { + if (vlan_tci & htons(VLAN_CFI_MASK) || + (eth_type != htons(ETH_P_IP) && + eth_type != htons(ETH_P_IPV6) && + eth_type != htons(ETH_P_ARP) && + eth_type != htons(ETH_P_RARP) && + !eth_p_mpls(eth_type))) + return -EINVAL; + mpls_label_count++; + } else { + if (mac_proto != MAC_PROTO_NONE) { + mpls_label_count = 1; + mac_proto = MAC_PROTO_NONE; + } else { + mpls_label_count++; + } + } + eth_type = mpls->mpls_ethertype; + break; + } + case OVS_ACTION_ATTR_PUSH_MPLS: { const struct ovs_action_push_mpls *mpls = nla_data(a); @@ -3109,6 +3138,11 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr, * recirculation. */ proto = nla_get_be16(a); + + if (proto == htons(ETH_P_TEB) && + mac_proto != MAC_PROTO_NONE) + return -EINVAL; + mpls_label_count--; if (!eth_p_mpls(proto) || !mpls_label_count)