get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/805912/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 805912,
    "url": "http://patchwork.ozlabs.org/api/patches/805912/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/1503670805-31051-4-git-send-email-yi.y.yang@intel.com/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "git@github.com:openvswitch/ovs.git",
        "webscm_url": "https://github.com/openvswitch/ovs",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1503670805-31051-4-git-send-email-yi.y.yang@intel.com>",
    "list_archive_url": null,
    "date": "2017-08-25T14:20:05",
    "name": "[ovs-dev,net-next,v6,3/3] openvswitch: enable NSH support",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "d7bb95f4021fb0ce59be8813737eedd1446bbeb2",
    "submitter": {
        "id": 68962,
        "url": "http://patchwork.ozlabs.org/api/people/68962/?format=api",
        "name": "Yang, Yi",
        "email": "yi.y.yang@intel.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/1503670805-31051-4-git-send-email-yi.y.yang@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/805912/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/805912/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@mail.linuxfoundation.org"
        ],
        "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=openvswitch.org\n\t(client-ip=140.211.169.12; helo=mail.linuxfoundation.org;\n\tenvelope-from=ovs-dev-bounces@openvswitch.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xf3QP0vssz9sNv\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 26 Aug 2017 00:27:09 +1000 (AEST)",
            "from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id 23206AD2;\n\tFri, 25 Aug 2017 14:25:50 +0000 (UTC)",
            "from smtp1.linuxfoundation.org (smtp1.linux-foundation.org\n\t[172.17.192.35])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id 5E885A86\n\tfor <dev@openvswitch.org>; Fri, 25 Aug 2017 14:25:49 +0000 (UTC)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby smtp1.linuxfoundation.org (Postfix) with ESMTPS id 05B5C237\n\tfor <dev@openvswitch.org>; Fri, 25 Aug 2017 14:24:59 +0000 (UTC)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t25 Aug 2017 07:24:09 -0700",
            "from unknown (HELO localhost.localdomain.bj.intel.com)\n\t([10.240.224.185])\n\tby fmsmga004.fm.intel.com with ESMTP; 25 Aug 2017 07:24:07 -0700"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.41,426,1498546800\"; d=\"scan'208\";a=\"304381279\"",
        "From": "Yi Yang <yi.y.yang@intel.com>",
        "To": "netdev@vger.kernel.org",
        "Date": "Fri, 25 Aug 2017 22:20:05 +0800",
        "Message-Id": "<1503670805-31051-4-git-send-email-yi.y.yang@intel.com>",
        "X-Mailer": "git-send-email 2.1.0",
        "In-Reply-To": "<1503670805-31051-1-git-send-email-yi.y.yang@intel.com>",
        "References": "<1503670805-31051-1-git-send-email-yi.y.yang@intel.com>",
        "X-Spam-Status": "No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED,\n\tRP_MATCHES_RCVD autolearn=unavailable version=3.3.1",
        "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp1.linux-foundation.org",
        "Cc": "dev@openvswitch.org, jbenc@redhat.com, e@erig.me",
        "Subject": "[ovs-dev] [PATCH net-next v6 3/3] openvswitch: enable NSH support",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.12",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "ovs-dev-bounces@openvswitch.org",
        "Errors-To": "ovs-dev-bounces@openvswitch.org"
    },
    "content": "OVS master and 2.8 branch has merged NSH userspace\npatch series, this patch is to enable NSH support\nin kernel data path in order that OVS can support\nNSH in compat mode by porting this.\n\nSigned-off-by: Yi Yang <yi.y.yang@intel.com>\n---\n drivers/net/vxlan.c              |   7 +\n include/uapi/linux/openvswitch.h |  28 +++\n net/openvswitch/actions.c        | 178 +++++++++++++++++\n net/openvswitch/flow.c           |  55 ++++++\n net/openvswitch/flow.h           |  11 ++\n net/openvswitch/flow_netlink.c   | 404 ++++++++++++++++++++++++++++++++++++++-\n net/openvswitch/flow_netlink.h   |   4 +\n 7 files changed, 686 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c\nindex ae3a1da..a36c41e 100644\n--- a/drivers/net/vxlan.c\n+++ b/drivers/net/vxlan.c\n@@ -27,6 +27,7 @@\n #include <net/net_namespace.h>\n #include <net/netns/generic.h>\n #include <net/vxlan.h>\n+#include <net/nsh.h>\n \n #if IS_ENABLED(CONFIG_IPV6)\n #include <net/ip6_tunnel.h>\n@@ -1268,6 +1269,9 @@ static bool vxlan_parse_gpe_hdr(struct vxlanhdr *unparsed,\n \tcase VXLAN_GPE_NP_IPV6:\n \t\t*protocol = htons(ETH_P_IPV6);\n \t\tbreak;\n+\tcase VXLAN_GPE_NP_NSH:\n+\t\t*protocol = htons(ETH_P_NSH);\n+\t\tbreak;\n \tcase VXLAN_GPE_NP_ETHERNET:\n \t\t*protocol = htons(ETH_P_TEB);\n \t\tbreak;\n@@ -1807,6 +1811,9 @@ static int vxlan_build_gpe_hdr(struct vxlanhdr *vxh, u32 vxflags,\n \tcase htons(ETH_P_IPV6):\n \t\tgpe->next_protocol = VXLAN_GPE_NP_IPV6;\n \t\treturn 0;\n+\tcase htons(ETH_P_NSH):\n+\t\tgpe->next_protocol = VXLAN_GPE_NP_NSH;\n+\t\treturn 0;\n \tcase htons(ETH_P_TEB):\n \t\tgpe->next_protocol = VXLAN_GPE_NP_ETHERNET;\n \t\treturn 0;\ndiff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h\nindex 156ee4c..91dee5b 100644\n--- a/include/uapi/linux/openvswitch.h\n+++ b/include/uapi/linux/openvswitch.h\n@@ -333,6 +333,7 @@ enum ovs_key_attr {\n \tOVS_KEY_ATTR_CT_LABELS,\t/* 16-octet connection tracking label */\n \tOVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4,   /* struct ovs_key_ct_tuple_ipv4 */\n \tOVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6,   /* struct ovs_key_ct_tuple_ipv6 */\n+\tOVS_KEY_ATTR_NSH,       /* Nested set of ovs_nsh_key_* */\n \n #ifdef __KERNEL__\n \tOVS_KEY_ATTR_TUNNEL_INFO,  /* struct ip_tunnel_info */\n@@ -491,6 +492,29 @@ struct ovs_key_ct_tuple_ipv6 {\n \t__u8   ipv6_proto;\n };\n \n+enum ovs_nsh_key_attr {\n+\tOVS_NSH_KEY_ATTR_BASE,  /* struct ovs_nsh_key_base. */\n+\tOVS_NSH_KEY_ATTR_MD1,   /* struct ovs_nsh_key_md1. */\n+\tOVS_NSH_KEY_ATTR_MD2,   /* variable-length octets for MD type 2. */\n+\t__OVS_NSH_KEY_ATTR_MAX\n+};\n+\n+#define OVS_NSH_KEY_ATTR_MAX (__OVS_NSH_KEY_ATTR_MAX - 1)\n+\n+struct ovs_nsh_key_base {\n+\t__u8 flags;\n+\t__u8 ttl;\n+\t__u8 mdtype;\n+\t__u8 np;\n+\t__be32 path_hdr;\n+};\n+\n+#define NSH_MD1_CONTEXT_SIZE 4\n+\n+struct ovs_nsh_key_md1 {\n+\t__be32 context[NSH_MD1_CONTEXT_SIZE];\n+};\n+\n /**\n  * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands.\n  * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow\n@@ -806,6 +830,8 @@ struct ovs_action_push_eth {\n  * packet.\n  * @OVS_ACTION_ATTR_POP_ETH: Pop the outermost Ethernet header off the\n  * packet.\n+ * @OVS_ACTION_ATTR_PUSH_NSH: push NSH header to the packet.\n+ * @OVS_ACTION_ATTR_POP_NSH: pop the outermost NSH header off the packet.\n  *\n  * Only a single header can be set with a single %OVS_ACTION_ATTR_SET.  Not all\n  * fields within a header are modifiable, e.g. the IPv4 protocol and fragment\n@@ -835,6 +861,8 @@ enum ovs_action_attr {\n \tOVS_ACTION_ATTR_TRUNC,        /* u32 struct ovs_action_trunc. */\n \tOVS_ACTION_ATTR_PUSH_ETH,     /* struct ovs_action_push_eth. */\n \tOVS_ACTION_ATTR_POP_ETH,      /* No argument. */\n+\tOVS_ACTION_ATTR_PUSH_NSH,     /* Nested OVS_NSH_KEY_ATTR_*. */\n+\tOVS_ACTION_ATTR_POP_NSH,      /* No argument. */\n \n \t__OVS_ACTION_ATTR_MAX,\t      /* Nothing past this will be accepted\n \t\t\t\t       * from userspace. */\ndiff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c\nindex a54a556..9ca1a84 100644\n--- a/net/openvswitch/actions.c\n+++ b/net/openvswitch/actions.c\n@@ -43,6 +43,7 @@\n #include \"flow.h\"\n #include \"conntrack.h\"\n #include \"vport.h\"\n+#include \"flow_netlink.h\"\n \n struct deferred_action {\n \tstruct sk_buff *skb;\n@@ -380,6 +381,95 @@ static int push_eth(struct sk_buff *skb, struct sw_flow_key *key,\n \treturn 0;\n }\n \n+static int push_nsh(struct sk_buff *skb, struct sw_flow_key *key,\n+\t\t    const struct nsh_hdr *nsh_src)\n+{\n+\tstruct nsh_hdr *nsh;\n+\tsize_t length = nsh_hdr_len(nsh_src);\n+\tu8 next_proto;\n+\n+\tif (key->mac_proto == MAC_PROTO_ETHERNET) {\n+\t\tnext_proto = NSH_P_ETHERNET;\n+\t} else {\n+\t\tswitch (ntohs(skb->protocol)) {\n+\t\tcase ETH_P_IP:\n+\t\t\tnext_proto = NSH_P_IPV4;\n+\t\t\tbreak;\n+\t\tcase ETH_P_IPV6:\n+\t\t\tnext_proto = NSH_P_IPV6;\n+\t\t\tbreak;\n+\t\tcase ETH_P_NSH:\n+\t\t\tnext_proto = NSH_P_NSH;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\treturn -ENOTSUPP;\n+\t\t}\n+\t}\n+\n+\t/* Add the NSH header */\n+\tif (skb_cow_head(skb, length) < 0)\n+\t\treturn -ENOMEM;\n+\n+\tskb_push(skb, length);\n+\tnsh = (struct nsh_hdr *)(skb->data);\n+\tmemcpy(nsh, nsh_src, length);\n+\tnsh->np = next_proto;\n+\tnsh->mdtype &= NSH_MDTYPE_MASK;\n+\n+\tskb->protocol = htons(ETH_P_NSH);\n+\tkey->eth.type = htons(ETH_P_NSH);\n+\tskb_reset_mac_header(skb);\n+\tskb_reset_mac_len(skb);\n+\n+\t/* safe right before invalidate_flow_key */\n+\tkey->mac_proto = MAC_PROTO_NONE;\n+\tinvalidate_flow_key(key);\n+\treturn 0;\n+}\n+\n+static int pop_nsh(struct sk_buff *skb, struct sw_flow_key *key)\n+{\n+\tstruct nsh_hdr *nsh = (struct nsh_hdr *)(skb->data);\n+\tsize_t length;\n+\tu16 inner_proto;\n+\n+\tif (ovs_key_mac_proto(key) != MAC_PROTO_NONE ||\n+\t    skb->protocol != htons(ETH_P_NSH)) {\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tswitch (nsh->np) {\n+\tcase NSH_P_ETHERNET:\n+\t\tinner_proto = htons(ETH_P_TEB);\n+\t\tbreak;\n+\tcase NSH_P_IPV4:\n+\t\tinner_proto = htons(ETH_P_IP);\n+\t\tbreak;\n+\tcase NSH_P_IPV6:\n+\t\tinner_proto = htons(ETH_P_IPV6);\n+\t\tbreak;\n+\tcase NSH_P_NSH:\n+\t\tinner_proto = htons(ETH_P_NSH);\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -ENOTSUPP;\n+\t}\n+\n+\tlength = nsh_hdr_len(nsh);\n+\tskb_pull(skb, length);\n+\tskb_reset_mac_header(skb);\n+\tskb_reset_mac_len(skb);\n+\tskb->protocol = inner_proto;\n+\n+\t/* safe right before invalidate_flow_key */\n+\tif (inner_proto == htons(ETH_P_TEB))\n+\t\tkey->mac_proto = MAC_PROTO_ETHERNET;\n+\telse\n+\t\tkey->mac_proto = MAC_PROTO_NONE;\n+\tinvalidate_flow_key(key);\n+\treturn 0;\n+}\n+\n static void update_ip_l4_checksum(struct sk_buff *skb, struct iphdr *nh,\n \t\t\t\t  __be32 addr, __be32 new_addr)\n {\n@@ -602,6 +692,53 @@ static int set_ipv6(struct sk_buff *skb, struct sw_flow_key *flow_key,\n \treturn 0;\n }\n \n+static int set_nsh(struct sk_buff *skb, struct sw_flow_key *flow_key,\n+\t\t   const struct ovs_key_nsh *key,\n+\t\t   const struct ovs_key_nsh *mask)\n+{\n+\tstruct nsh_hdr *nsh;\n+\tint err;\n+\tu8 flags;\n+\tu8 ttl;\n+\tint i;\n+\n+\terr = skb_ensure_writable(skb, skb_network_offset(skb) +\n+\t\t\t\t  sizeof(struct nsh_hdr));\n+\tif (unlikely(err))\n+\t\treturn err;\n+\n+\tnsh = (struct nsh_hdr *)skb_network_header(skb);\n+\n+\tflags = nsh_get_flags(nsh);\n+\tflags = OVS_MASKED(flags, key->flags, mask->flags);\n+\tflow_key->nsh.flags = flags;\n+\tttl = nsh_get_ttl(nsh);\n+\tttl = OVS_MASKED(ttl, key->ttl, mask->ttl);\n+\tflow_key->nsh.ttl = ttl;\n+\tnsh_set_flags_and_ttl(nsh, flags, ttl);\n+\tnsh->path_hdr = OVS_MASKED(nsh->path_hdr, key->path_hdr,\n+\t\t\t\t   mask->path_hdr);\n+\tflow_key->nsh.path_hdr = nsh->path_hdr;\n+\tswitch (nsh->mdtype) {\n+\tcase NSH_M_TYPE1:\n+\t\tfor (i = 0; i < NSH_MD1_CONTEXT_SIZE; i++) {\n+\t\t\tnsh->md1.context[i] =\n+\t\t\t    OVS_MASKED(nsh->md1.context[i], key->context[i],\n+\t\t\t\t       mask->context[i]);\n+\t\t}\n+\t\tmemcpy(flow_key->nsh.context, nsh->md1.context,\n+\t\t       sizeof(nsh->md1.context));\n+\t\tbreak;\n+\tcase NSH_M_TYPE2:\n+\t\tmemset(flow_key->nsh.context, 0,\n+\t\t       sizeof(flow_key->nsh.context));\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\treturn 0;\n+}\n+\n /* Must follow skb_ensure_writable() since that can move the skb data. */\n static void set_tp_port(struct sk_buff *skb, __be16 *port,\n \t\t\t__be16 new_port, __sum16 *check)\n@@ -1024,6 +1161,32 @@ static int execute_masked_set_action(struct sk_buff *skb,\n \t\t\t\t   get_mask(a, struct ovs_key_ethernet *));\n \t\tbreak;\n \n+\tcase OVS_KEY_ATTR_NSH: {\n+\t\tstruct ovs_key_nsh nsh;\n+\t\tstruct ovs_key_nsh nsh_mask;\n+\t\tsize_t size = nla_len(a) / 2;\n+\t\tstruct {\n+\t\t\tstruct nlattr nla;\n+\t\t\tu8 data[size];\n+\t\t} attr, mask;\n+\n+\t\tattr.nla.nla_type = nla_type(a);\n+\t\tattr.nla.nla_len = NLA_HDRLEN + size;\n+\t\tmemcpy(attr.data, (char *)(a + 1), size);\n+\n+\t\tmask.nla = attr.nla;\n+\t\tmemcpy(mask.data, (char *)(a + 1) + size, size);\n+\n+\t\terr = nsh_key_from_nlattr(&attr.nla, &nsh);\n+\t\tif (err)\n+\t\t\tbreak;\n+\t\terr = nsh_key_from_nlattr(&mask.nla, &nsh_mask);\n+\t\tif (err)\n+\t\t\tbreak;\n+\t\terr = set_nsh(skb, flow_key, &nsh, &nsh_mask);\n+\t\tbreak;\n+\t}\n+\n \tcase OVS_KEY_ATTR_IPV4:\n \t\terr = set_ipv4(skb, flow_key, nla_data(a),\n \t\t\t       get_mask(a, struct ovs_key_ipv4 *));\n@@ -1210,6 +1373,21 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,\n \t\tcase OVS_ACTION_ATTR_POP_ETH:\n \t\t\terr = pop_eth(skb, key);\n \t\t\tbreak;\n+\n+\t\tcase OVS_ACTION_ATTR_PUSH_NSH: {\n+\t\t\tu8 buffer[NSH_HDR_MAX_LEN];\n+\t\t\tstruct nsh_hdr *nsh_hdr = (struct nsh_hdr *)buffer;\n+\t\t\tconst struct nsh_hdr *nsh_src = nsh_hdr;\n+\n+\t\t\tnsh_hdr_from_nlattr(nla_data(a), nsh_hdr,\n+\t\t\t\t\t    NSH_HDR_MAX_LEN);\n+\t\t\terr = push_nsh(skb, key, nsh_src);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tcase OVS_ACTION_ATTR_POP_NSH:\n+\t\t\terr = pop_nsh(skb, key);\n+\t\t\tbreak;\n \t\t}\n \n \t\tif (unlikely(err)) {\ndiff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c\nindex 8c94cef..34865b5 100644\n--- a/net/openvswitch/flow.c\n+++ b/net/openvswitch/flow.c\n@@ -46,6 +46,7 @@\n #include <net/ipv6.h>\n #include <net/mpls.h>\n #include <net/ndisc.h>\n+#include <net/nsh.h>\n \n #include \"conntrack.h\"\n #include \"datapath.h\"\n@@ -490,6 +491,56 @@ static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key,\n \treturn 0;\n }\n \n+static int parse_nsh(struct sk_buff *skb, struct sw_flow_key *key)\n+{\n+\tstruct nsh_hdr *nsh;\n+\tunsigned int nh_ofs = skb_network_offset(skb);\n+\tu8 version, length;\n+\tint err;\n+\n+\terr = check_header(skb, nh_ofs + NSH_BASE_HDR_LEN);\n+\tif (unlikely(err))\n+\t\treturn err;\n+\n+\tnsh = (struct nsh_hdr *)skb_network_header(skb);\n+\tversion = nsh_get_ver(nsh);\n+\tlength = nsh_hdr_len(nsh);\n+\n+\tif (version != 0)\n+\t\treturn -EINVAL;\n+\n+\terr = check_header(skb, nh_ofs + length);\n+\tif (unlikely(err))\n+\t\treturn err;\n+\n+\tnsh = (struct nsh_hdr *)skb_network_header(skb);\n+\tkey->nsh.flags = nsh_get_flags(nsh);\n+\tkey->nsh.ttl = nsh_get_ttl(nsh);\n+\tkey->nsh.mdtype = nsh->mdtype;\n+\tkey->nsh.np = nsh->np;\n+\tkey->nsh.path_hdr = nsh->path_hdr;\n+\tswitch (key->nsh.mdtype) {\n+\tcase NSH_M_TYPE1:\n+\t\tif (length != NSH_M_TYPE1_LEN)\n+\t\t\treturn -EINVAL;\n+\t\tmemcpy(key->nsh.context, nsh->md1.context,\n+\t\t       sizeof(nsh->md1));\n+\t\tbreak;\n+\tcase NSH_M_TYPE2:\n+\t\t/* Don't support MD type 2 metedata parsing yet */\n+\t\tif (length < NSH_BASE_HDR_LEN)\n+\t\t\treturn -EINVAL;\n+\n+\t\tmemset(key->nsh.context, 0,\n+\t\t       sizeof(nsh->md1));\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n /**\n  * key_extract - extracts a flow key from an Ethernet frame.\n  * @skb: sk_buff that contains the frame, with skb->data pointing to the\n@@ -735,6 +786,10 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key)\n \t\t\t\tmemset(&key->tp, 0, sizeof(key->tp));\n \t\t\t}\n \t\t}\n+\t} else if (key->eth.type == htons(ETH_P_NSH)) {\n+\t\terror = parse_nsh(skb, key);\n+\t\tif (error)\n+\t\t\treturn error;\n \t}\n \treturn 0;\n }\ndiff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h\nindex 1875bba..6a3cd9c 100644\n--- a/net/openvswitch/flow.h\n+++ b/net/openvswitch/flow.h\n@@ -35,6 +35,7 @@\n #include <net/inet_ecn.h>\n #include <net/ip_tunnels.h>\n #include <net/dst_metadata.h>\n+#include <net/nsh.h>\n \n struct sk_buff;\n \n@@ -66,6 +67,15 @@ struct vlan_head {\n \t(offsetof(struct sw_flow_key, recirc_id) +\t\\\n \tFIELD_SIZEOF(struct sw_flow_key, recirc_id))\n \n+struct ovs_key_nsh {\n+\tu8 flags;\n+\tu8 ttl;\n+\tu8 mdtype;\n+\tu8 np;\n+\t__be32 path_hdr;\n+\t__be32 context[NSH_MD1_CONTEXT_SIZE];\n+};\n+\n struct sw_flow_key {\n \tu8 tun_opts[IP_TUNNEL_OPTS_MAX];\n \tu8 tun_opts_len;\n@@ -144,6 +154,7 @@ struct sw_flow_key {\n \t\t\t};\n \t\t} ipv6;\n \t};\n+\tstruct ovs_key_nsh nsh;         /* network service header */\n \tstruct {\n \t\t/* Connection tracking fields not packed above. */\n \t\tstruct {\ndiff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c\nindex e8eb427..3b7f166 100644\n--- a/net/openvswitch/flow_netlink.c\n+++ b/net/openvswitch/flow_netlink.c\n@@ -78,9 +78,11 @@ static bool actions_may_change_flow(const struct nlattr *actions)\n \t\tcase OVS_ACTION_ATTR_HASH:\n \t\tcase OVS_ACTION_ATTR_POP_ETH:\n \t\tcase OVS_ACTION_ATTR_POP_MPLS:\n+\t\tcase OVS_ACTION_ATTR_POP_NSH:\n \t\tcase OVS_ACTION_ATTR_POP_VLAN:\n \t\tcase OVS_ACTION_ATTR_PUSH_ETH:\n \t\tcase OVS_ACTION_ATTR_PUSH_MPLS:\n+\t\tcase OVS_ACTION_ATTR_PUSH_NSH:\n \t\tcase OVS_ACTION_ATTR_PUSH_VLAN:\n \t\tcase OVS_ACTION_ATTR_SAMPLE:\n \t\tcase OVS_ACTION_ATTR_SET:\n@@ -322,12 +324,27 @@ size_t ovs_tun_key_attr_size(void)\n \t\t+ nla_total_size(2);   /* OVS_TUNNEL_KEY_ATTR_TP_DST */\n }\n \n+size_t ovs_nsh_key_attr_size(void)\n+{\n+\t/* Whenever adding new OVS_NSH_KEY_ FIELDS, we should consider\n+\t * updating this function.\n+\t */\n+\treturn  nla_total_size(NSH_BASE_HDR_LEN) /* OVS_NSH_KEY_ATTR_BASE */\n+\t\t/* OVS_NSH_KEY_ATTR_MD1 and OVS_NSH_KEY_ATTR_MD2 are\n+\t\t * mutually exclusive, so the bigger one can cover\n+\t\t * the small one.\n+\t\t *\n+\t\t * OVS_NSH_KEY_ATTR_MD2\n+\t\t */\n+\t\t+ nla_total_size(NSH_CTX_HDRS_MAX_LEN);\n+}\n+\n size_t ovs_key_attr_size(void)\n {\n \t/* Whenever adding new OVS_KEY_ FIELDS, we should consider\n \t * updating this function.\n \t */\n-\tBUILD_BUG_ON(OVS_KEY_ATTR_TUNNEL_INFO != 28);\n+\tBUILD_BUG_ON(OVS_KEY_ATTR_TUNNEL_INFO != 29);\n \n \treturn    nla_total_size(4)   /* OVS_KEY_ATTR_PRIORITY */\n \t\t+ nla_total_size(0)   /* OVS_KEY_ATTR_TUNNEL */\n@@ -341,6 +358,8 @@ size_t ovs_key_attr_size(void)\n \t\t+ nla_total_size(4)   /* OVS_KEY_ATTR_CT_MARK */\n \t\t+ nla_total_size(16)  /* OVS_KEY_ATTR_CT_LABELS */\n \t\t+ nla_total_size(40)  /* OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6 */\n+\t\t+ nla_total_size(0)   /* OVS_KEY_ATTR_NSH */\n+\t\t  + ovs_nsh_key_attr_size()\n \t\t+ nla_total_size(12)  /* OVS_KEY_ATTR_ETHERNET */\n \t\t+ nla_total_size(2)   /* OVS_KEY_ATTR_ETHERTYPE */\n \t\t+ nla_total_size(4)   /* OVS_KEY_ATTR_VLAN */\n@@ -373,6 +392,13 @@ static const struct ovs_len_tbl ovs_tunnel_key_lens[OVS_TUNNEL_KEY_ATTR_MAX + 1]\n \t[OVS_TUNNEL_KEY_ATTR_IPV6_DST]      = { .len = sizeof(struct in6_addr) },\n };\n \n+static const struct ovs_len_tbl\n+ovs_nsh_key_attr_lens[OVS_NSH_KEY_ATTR_MAX + 1] = {\n+\t[OVS_NSH_KEY_ATTR_BASE]     = { .len = 8 },\n+\t[OVS_NSH_KEY_ATTR_MD1]      = { .len = 16 },\n+\t[OVS_NSH_KEY_ATTR_MD2]      = { .len = OVS_ATTR_VARIABLE },\n+};\n+\n /* The size of the argument for each %OVS_KEY_ATTR_* Netlink attribute.  */\n static const struct ovs_len_tbl ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {\n \t[OVS_KEY_ATTR_ENCAP]\t = { .len = OVS_ATTR_NESTED },\n@@ -405,6 +431,8 @@ static const struct ovs_len_tbl ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {\n \t\t.len = sizeof(struct ovs_key_ct_tuple_ipv4) },\n \t[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6] = {\n \t\t.len = sizeof(struct ovs_key_ct_tuple_ipv6) },\n+\t[OVS_KEY_ATTR_NSH]       = { .len = OVS_ATTR_NESTED,\n+\t\t\t\t     .next = ovs_nsh_key_attr_lens, },\n };\n \n static bool check_attr_len(unsigned int attr_len, unsigned int expected_len)\n@@ -1179,6 +1207,303 @@ static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match,\n \treturn 0;\n }\n \n+int nsh_hdr_from_nlattr(const struct nlattr *attr,\n+\t\t\tstruct nsh_hdr *nsh, size_t size)\n+{\n+\tstruct nlattr *a;\n+\tint rem;\n+\tu8 flags = 0;\n+\tu8 ttl = 0;\n+\tint mdlen = 0;\n+\tbool has_md1 = false;\n+\tbool has_md2 = false;\n+\tu8 len;\n+\n+\tnla_for_each_nested(a, attr, rem) {\n+\t\tint type = nla_type(a);\n+\n+\t\tif (type > OVS_NSH_KEY_ATTR_MAX) {\n+\t\t\tOVS_NLERR(1, \"nsh attr %d is out of range max %d\",\n+\t\t\t\t  type, OVS_NSH_KEY_ATTR_MAX);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tif (!check_attr_len(nla_len(a),\n+\t\t\t\t    ovs_nsh_key_attr_lens[type].len)) {\n+\t\t\tOVS_NLERR(\n+\t\t\t    1,\n+\t\t\t    \"nsh attr %d has unexpected len %d expected %d\",\n+\t\t\t    type,\n+\t\t\t    nla_len(a),\n+\t\t\t    ovs_nsh_key_attr_lens[type].len\n+\t\t\t);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tswitch (type) {\n+\t\tcase OVS_NSH_KEY_ATTR_BASE: {\n+\t\t\tconst struct ovs_nsh_key_base *base =\n+\t\t\t\t(struct ovs_nsh_key_base *)nla_data(a);\n+\t\t\tflags = base->flags;\n+\t\t\tttl = base->ttl;\n+\t\t\tnsh->np = base->np;\n+\t\t\tnsh->mdtype = base->mdtype;\n+\t\t\tnsh->path_hdr = base->path_hdr;\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase OVS_NSH_KEY_ATTR_MD1: {\n+\t\t\tconst struct ovs_nsh_key_md1 *md1 =\n+\t\t\t\t(struct ovs_nsh_key_md1 *)nla_data(a);\n+\t\t\tstruct nsh_md1_ctx *md1_dst = &nsh->md1;\n+\n+\t\t\thas_md1 = true;\n+\t\t\tmdlen = nla_len(a);\n+\t\t\tif (((mdlen + NSH_BASE_HDR_LEN) != NSH_M_TYPE1_LEN) ||\n+\t\t\t    ((mdlen + NSH_BASE_HDR_LEN) > size) ||\n+\t\t\t    (mdlen <= 0)) {\n+\t\t\t\tOVS_NLERR(\n+\t\t\t\t    1,\n+\t\t\t\t    \"length %d of nsh attr %d is invalid\",\n+\t\t\t\t    mdlen,\n+\t\t\t\t    type\n+\t\t\t\t);\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\t\t\tmemcpy(md1_dst, md1, mdlen);\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase OVS_NSH_KEY_ATTR_MD2: {\n+\t\t\tconst struct u8 *md2 = nla_data(a);\n+\t\t\tstruct nsh_md2_tlv *md2_dst = &nsh->md2;\n+\n+\t\t\thas_md2 = true;\n+\t\t\tmdlen = nla_len(a);\n+\t\t\tif (((mdlen + NSH_BASE_HDR_LEN) > size) ||\n+\t\t\t    (mdlen <= 0)) {\n+\t\t\t\tOVS_NLERR(\n+\t\t\t\t    1,\n+\t\t\t\t    \"length %d of nsh attr %d is invalid\",\n+\t\t\t\t    mdlen,\n+\t\t\t\t    type\n+\t\t\t\t);\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\t\t\tmemcpy(md2_dst, md2, mdlen);\n+\t\t\tbreak;\n+\t\t}\n+\t\tdefault:\n+\t\t\tOVS_NLERR(1, \"Unknown nsh attribute %d\",\n+\t\t\t\t  type);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (rem > 0) {\n+\t\tOVS_NLERR(1, \"nsh attribute has %d unknown bytes.\", rem);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif ((has_md1 && nsh->mdtype != NSH_M_TYPE1) ||\n+\t    (has_md2 && nsh->mdtype != NSH_M_TYPE2)) {\n+\t\tOVS_NLERR(1,\n+\t\t\t  \"nsh attribute has unmatched MD type %d.\",\n+\t\t\t  nsh->mdtype);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (unlikely(has_md1 && has_md2)) {\n+\t\tOVS_NLERR(1, \"both nsh md1 and md2 attribute are there\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (unlikely(!has_md1 && !has_md2)) {\n+\t\tOVS_NLERR(1, \"neither nsh md1 nor md2 attribute is there\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* nsh header length  = NSH_BASE_HDR_LEN + mdlen */\n+\tlen = NSH_BASE_HDR_LEN + mdlen;\n+\tnsh_set_flags_ttl_len(nsh, flags, ttl, len);\n+\n+\treturn 0;\n+}\n+\n+int nsh_key_from_nlattr(const struct nlattr *attr,\n+\t\t\tstruct ovs_key_nsh *nsh)\n+{\n+\tstruct nlattr *a;\n+\tint rem;\n+\tbool has_md1 = false;\n+\n+\tnla_for_each_nested(a, attr, rem) {\n+\t\tint type = nla_type(a);\n+\n+\t\tif (type > OVS_NSH_KEY_ATTR_MAX) {\n+\t\t\tOVS_NLERR(1, \"nsh attr %d is out of range max %d\",\n+\t\t\t\t  type, OVS_NSH_KEY_ATTR_MAX);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tif (!check_attr_len(nla_len(a),\n+\t\t\t\t    ovs_nsh_key_attr_lens[type].len)) {\n+\t\t\tOVS_NLERR(\n+\t\t\t    1,\n+\t\t\t    \"nsh attr %d has unexpected len %d expected %d\",\n+\t\t\t    type,\n+\t\t\t    nla_len(a),\n+\t\t\t    ovs_nsh_key_attr_lens[type].len\n+\t\t\t);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tswitch (type) {\n+\t\tcase OVS_NSH_KEY_ATTR_BASE: {\n+\t\t\tconst struct ovs_nsh_key_base *base =\n+\t\t\t\t(struct ovs_nsh_key_base *)nla_data(a);\n+\n+\t\t\tmemcpy(nsh, base, sizeof(*base));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase OVS_NSH_KEY_ATTR_MD1: {\n+\t\t\tconst struct ovs_nsh_key_md1 *md1 =\n+\t\t\t\t(struct ovs_nsh_key_md1 *)nla_data(a);\n+\n+\t\t\thas_md1 = true;\n+\t\t\tmemcpy(nsh->context, md1->context, sizeof(*md1));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase OVS_NSH_KEY_ATTR_MD2:\n+\t\t\t/* Not supported yet */\n+\t\t\treturn -ENOTSUPP;\n+\t\tdefault:\n+\t\t\tOVS_NLERR(1, \"Unknown nsh attribute %d\",\n+\t\t\t\t  type);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (rem > 0) {\n+\t\tOVS_NLERR(1, \"nsh attribute has %d unknown bytes.\", rem);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif ((has_md1 && nsh->mdtype != NSH_M_TYPE1)) {\n+\t\tOVS_NLERR(1, \"nsh attribute has unmatched MD type %d.\",\n+\t\t\t  nsh->mdtype);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int nsh_key_put_from_nlattr(const struct nlattr *attr,\n+\t\t\t\t   struct sw_flow_match *match, bool is_mask,\n+\t\t\t\t   bool is_push_nsh, bool log)\n+{\n+\tstruct nlattr *a;\n+\tint rem;\n+\tbool has_md1 = false;\n+\tbool has_md2 = false;\n+\tu8 mdtype = 0;\n+\tint mdlen = 0;\n+\n+\tnla_for_each_nested(a, attr, rem) {\n+\t\tint type = nla_type(a);\n+\t\tint i;\n+\n+\t\tif (type > OVS_NSH_KEY_ATTR_MAX) {\n+\t\t\tOVS_NLERR(log, \"nsh attr %d is out of range max %d\",\n+\t\t\t\t  type, OVS_NSH_KEY_ATTR_MAX);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tif (!check_attr_len(nla_len(a),\n+\t\t\t\t    ovs_nsh_key_attr_lens[type].len)) {\n+\t\t\tOVS_NLERR(\n+\t\t\t    log,\n+\t\t\t    \"nsh attr %d has unexpected len %d expected %d\",\n+\t\t\t    type,\n+\t\t\t    nla_len(a),\n+\t\t\t    ovs_nsh_key_attr_lens[type].len\n+\t\t\t);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tswitch (type) {\n+\t\tcase OVS_NSH_KEY_ATTR_BASE: {\n+\t\t\tconst struct ovs_nsh_key_base *base =\n+\t\t\t\t(struct ovs_nsh_key_base *)nla_data(a);\n+\n+\t\t\tmdtype = base->mdtype;\n+\t\t\tSW_FLOW_KEY_PUT(match, nsh.flags,\n+\t\t\t\t\tbase->flags, is_mask);\n+\t\t\tSW_FLOW_KEY_PUT(match, nsh.ttl,\n+\t\t\t\t\tbase->ttl, is_mask);\n+\t\t\tSW_FLOW_KEY_PUT(match, nsh.mdtype,\n+\t\t\t\t\tbase->mdtype, is_mask);\n+\t\t\tSW_FLOW_KEY_PUT(match, nsh.np,\n+\t\t\t\t\tbase->np, is_mask);\n+\t\t\tSW_FLOW_KEY_PUT(match, nsh.path_hdr,\n+\t\t\t\t\tbase->path_hdr, is_mask);\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase OVS_NSH_KEY_ATTR_MD1: {\n+\t\t\tconst struct ovs_nsh_key_md1 *md1 =\n+\t\t\t\t(struct ovs_nsh_key_md1 *)nla_data(a);\n+\n+\t\t\thas_md1 = true;\n+\t\t\tfor (i = 0; i < NSH_MD1_CONTEXT_SIZE; i++)\n+\t\t\t\tSW_FLOW_KEY_PUT(match, nsh.context[i],\n+\t\t\t\t\t\tmd1->context[i], is_mask);\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase OVS_NSH_KEY_ATTR_MD2:\n+\t\t\tif (!is_push_nsh) /* Not supported MD type 2 yet */\n+\t\t\t\treturn -ENOTSUPP;\n+\n+\t\t\thas_md2 = true;\n+\t\t\tmdlen = nla_len(a);\n+\t\t\tif ((mdlen > NSH_CTX_HDRS_MAX_LEN) ||\n+\t\t\t    (mdlen <= 0))\n+\t\t\t\treturn -EINVAL;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tOVS_NLERR(log, \"Unknown nsh attribute %d\",\n+\t\t\t\t  type);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (rem > 0) {\n+\t\tOVS_NLERR(log, \"nsh attribute has %d unknown bytes.\", rem);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (!is_mask) {\n+\t\tif ((has_md1 && mdtype != NSH_M_TYPE1)) {\n+\t\t\tOVS_NLERR(1, \"nsh attribute has unmatched MD type %d.\",\n+\t\t\t\t  mdtype);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (is_push_nsh & !is_mask) {\n+\t\tif ((has_md1 && mdtype != NSH_M_TYPE1) ||\n+\t\t    (has_md2 && mdtype != NSH_M_TYPE2) ||\n+\t\t    (has_md1 && has_md2) ||\n+\t\t    (!has_md1 && !has_md2)) {\n+\t\t\tOVS_NLERR(\n+\t\t\t    1,\n+\t\t\t    \"push nsh attributes are invalid for type %d.\",\n+\t\t\t    mdtype\n+\t\t\t);\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int ovs_key_from_nlattrs(struct net *net, struct sw_flow_match *match,\n \t\t\t\tu64 attrs, const struct nlattr **a,\n \t\t\t\tbool is_mask, bool log)\n@@ -1306,6 +1631,13 @@ static int ovs_key_from_nlattrs(struct net *net, struct sw_flow_match *match,\n \t\tattrs &= ~(1 << OVS_KEY_ATTR_ARP);\n \t}\n \n+\tif (attrs & (1 << OVS_KEY_ATTR_NSH)) {\n+\t\tif (nsh_key_put_from_nlattr(a[OVS_KEY_ATTR_NSH], match,\n+\t\t\t\t\t    is_mask, false, log) < 0)\n+\t\t\treturn -EINVAL;\n+\t\tattrs &= ~(1 << OVS_KEY_ATTR_NSH);\n+\t}\n+\n \tif (attrs & (1 << OVS_KEY_ATTR_MPLS)) {\n \t\tconst struct ovs_key_mpls *mpls_key;\n \n@@ -1622,6 +1954,40 @@ static int ovs_nla_put_vlan(struct sk_buff *skb, const struct vlan_head *vh,\n \treturn 0;\n }\n \n+static int nsh_key_to_nlattr(const struct ovs_key_nsh *nsh, bool is_mask,\n+\t\t\t     struct sk_buff *skb)\n+{\n+\tstruct nlattr *start;\n+\tstruct ovs_nsh_key_base base;\n+\tstruct ovs_nsh_key_md1 md1;\n+\n+\tmemcpy(&base, nsh, sizeof(base));\n+\n+\tif (is_mask || nsh->mdtype == NSH_M_TYPE1)\n+\t\tmemcpy(md1.context, nsh->context, sizeof(md1));\n+\n+\tstart = nla_nest_start(skb, OVS_KEY_ATTR_NSH);\n+\tif (!start)\n+\t\treturn -EMSGSIZE;\n+\n+\tif (nla_put(skb, OVS_NSH_KEY_ATTR_BASE, sizeof(base), &base))\n+\t\tgoto nla_put_failure;\n+\n+\tif (is_mask || nsh->mdtype == NSH_M_TYPE1) {\n+\t\tif (nla_put(skb, OVS_NSH_KEY_ATTR_MD1, sizeof(md1), &md1))\n+\t\t\tgoto nla_put_failure;\n+\t}\n+\n+\t/* Don't support MD type 2 yet */\n+\n+\tnla_nest_end(skb, start);\n+\n+\treturn 0;\n+\n+nla_put_failure:\n+\treturn -EMSGSIZE;\n+}\n+\n static int __ovs_nla_put_key(const struct sw_flow_key *swkey,\n \t\t\t     const struct sw_flow_key *output, bool is_mask,\n \t\t\t     struct sk_buff *skb)\n@@ -1750,6 +2116,9 @@ static int __ovs_nla_put_key(const struct sw_flow_key *swkey,\n \t\tipv6_key->ipv6_tclass = output->ip.tos;\n \t\tipv6_key->ipv6_hlimit = output->ip.ttl;\n \t\tipv6_key->ipv6_frag = output->ip.frag;\n+\t} else if (swkey->eth.type == htons(ETH_P_NSH)) {\n+\t\tif (nsh_key_to_nlattr(&output->nsh, is_mask, skb))\n+\t\t\tgoto nla_put_failure;\n \t} else if (swkey->eth.type == htons(ETH_P_ARP) ||\n \t\t   swkey->eth.type == htons(ETH_P_RARP)) {\n \t\tstruct ovs_key_arp *arp_key;\n@@ -2242,6 +2611,19 @@ static int validate_and_copy_set_tun(const struct nlattr *attr,\n \treturn err;\n }\n \n+static bool validate_nsh(const struct nlattr *attr, bool is_mask,\n+\t\t\t bool is_push_nsh, bool log)\n+{\n+\tstruct sw_flow_match match;\n+\tstruct sw_flow_key key;\n+\tint ret = 0;\n+\n+\tovs_match_init(&match, &key, true, NULL);\n+\tret = nsh_key_put_from_nlattr(attr, &match, is_mask,\n+\t\t\t\t      is_push_nsh, log);\n+\treturn ((ret != 0) ? false : true);\n+}\n+\n /* Return false if there are any non-masked bits set.\n  * Mask follows data immediately, before any netlink padding.\n  */\n@@ -2384,6 +2766,11 @@ static int validate_set(const struct nlattr *a,\n \n \t\tbreak;\n \n+\tcase OVS_KEY_ATTR_NSH:\n+\t\tif (!validate_nsh(nla_data(a), masked, false, log))\n+\t\t\treturn -EINVAL;\n+\t\tbreak;\n+\n \tdefault:\n \t\treturn -EINVAL;\n \t}\n@@ -2482,6 +2869,8 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,\n \t\t\t[OVS_ACTION_ATTR_TRUNC] = sizeof(struct ovs_action_trunc),\n \t\t\t[OVS_ACTION_ATTR_PUSH_ETH] = sizeof(struct ovs_action_push_eth),\n \t\t\t[OVS_ACTION_ATTR_POP_ETH] = 0,\n+\t\t\t[OVS_ACTION_ATTR_PUSH_NSH] = (u32)-1,\n+\t\t\t[OVS_ACTION_ATTR_POP_NSH] = 0,\n \t\t};\n \t\tconst struct ovs_action_push_vlan *vlan;\n \t\tint type = nla_type(a);\n@@ -2636,6 +3025,19 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,\n \t\t\tmac_proto = MAC_PROTO_ETHERNET;\n \t\t\tbreak;\n \n+\t\tcase OVS_ACTION_ATTR_PUSH_NSH:\n+\t\t\tmac_proto = MAC_PROTO_NONE;\n+\t\t\tif (!validate_nsh(nla_data(a), false, true, true))\n+\t\t\t\treturn -EINVAL;\n+\t\t\tbreak;\n+\n+\t\tcase OVS_ACTION_ATTR_POP_NSH:\n+\t\t\tif (key->nsh.np == NSH_P_ETHERNET)\n+\t\t\t\tmac_proto = MAC_PROTO_ETHERNET;\n+\t\t\telse\n+\t\t\t\tmac_proto = MAC_PROTO_NONE;\n+\t\t\tbreak;\n+\n \t\tdefault:\n \t\t\tOVS_NLERR(log, \"Unknown Action type %d\", type);\n \t\t\treturn -EINVAL;\ndiff --git a/net/openvswitch/flow_netlink.h b/net/openvswitch/flow_netlink.h\nindex 929c665..a849945 100644\n--- a/net/openvswitch/flow_netlink.h\n+++ b/net/openvswitch/flow_netlink.h\n@@ -79,4 +79,8 @@ int ovs_nla_put_actions(const struct nlattr *attr,\n void ovs_nla_free_flow_actions(struct sw_flow_actions *);\n void ovs_nla_free_flow_actions_rcu(struct sw_flow_actions *);\n \n+int nsh_key_from_nlattr(const struct nlattr *attr, struct ovs_key_nsh *nsh);\n+int nsh_hdr_from_nlattr(const struct nlattr *attr, struct nsh_hdr *nsh_src,\n+\t\t\tsize_t size);\n+\n #endif /* flow_netlink.h */\n",
    "prefixes": [
        "ovs-dev",
        "net-next",
        "v6",
        "3/3"
    ]
}