get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 807622,
    "url": "http://patchwork.ozlabs.org/api/patches/807622/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1504096752-102003-1-git-send-email-yi.y.yang@intel.com/",
    "project": {
        "id": 7,
        "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api",
        "name": "Linux network development",
        "link_name": "netdev",
        "list_id": "netdev.vger.kernel.org",
        "list_email": "netdev@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1504096752-102003-1-git-send-email-yi.y.yang@intel.com>",
    "list_archive_url": null,
    "date": "2017-08-30T12:39:12",
    "name": "[net-next,v7] openvswitch: enable NSH support",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "8f9914f7e330281df4106564a5a6a29bff889518",
    "submitter": {
        "id": 68962,
        "url": "http://patchwork.ozlabs.org/api/people/68962/?format=api",
        "name": "Yang, Yi",
        "email": "yi.y.yang@intel.com"
    },
    "delegate": {
        "id": 34,
        "url": "http://patchwork.ozlabs.org/api/users/34/?format=api",
        "username": "davem",
        "first_name": "David",
        "last_name": "Miller",
        "email": "davem@davemloft.net"
    },
    "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1504096752-102003-1-git-send-email-yi.y.yang@intel.com/mbox/",
    "series": [
        {
            "id": 606,
            "url": "http://patchwork.ozlabs.org/api/series/606/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=606",
            "date": "2017-08-30T12:39:12",
            "name": "[net-next,v7] openvswitch: enable NSH support",
            "version": 7,
            "mbox": "http://patchwork.ozlabs.org/series/606/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/807622/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/807622/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netdev-owner@vger.kernel.org>",
        "X-Original-To": "patchwork-incoming@ozlabs.org",
        "Delivered-To": "patchwork-incoming@ozlabs.org",
        "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xj4tB1fZWz9sNn\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 30 Aug 2017 22:43:14 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751357AbdH3MnM (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 30 Aug 2017 08:43:12 -0400",
            "from mga07.intel.com ([134.134.136.100]:31532 \"EHLO\n\tmga07.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751317AbdH3MnK (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tWed, 30 Aug 2017 08:43:10 -0400",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby orsmga105.jf.intel.com with ESMTP; 30 Aug 2017 05:43:10 -0700",
            "from unknown (HELO localhost.localdomain.bj.intel.com)\n\t([10.240.224.185])\n\tby orsmga005.jf.intel.com with ESMTP; 30 Aug 2017 05:43:08 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.41,448,1498546800\"; d=\"scan'208\";a=\"143666459\"",
        "From": "Yi Yang <yi.y.yang@intel.com>",
        "To": "netdev@vger.kernel.org",
        "Cc": "davem@davemloft.net, dev@openvswitch.org, jbenc@redhat.com,\n\te@erig.me, blp@ovn.org, jan.scheurich@ericsson.com,\n\tYi Yang <yi.y.yang@intel.com>",
        "Subject": "[PATCH net-next v7] openvswitch: enable NSH support",
        "Date": "Wed, 30 Aug 2017 20:39:12 +0800",
        "Message-Id": "<1504096752-102003-1-git-send-email-yi.y.yang@intel.com>",
        "X-Mailer": "git-send-email 2.1.0",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "v6->v7\n - Remove NSH GSO patches in v6 because Jiri Benc\n   reworked it as another patch series and they have\n   been merged.\n - Change it to adapt to nsh kernel module added by NSH\n   GSO patch series\n\nv5->v6\n - Fix the rest comments for v4.\n - Add NSH GSO support for VxLAN-gpe + NSH and\n   Eth + NSH.\n\nv4->v5\n - Fix many comments by Jiri Benc and Eric Garver\n   for v4.\n\nv3->v4\n - Add new NSH match field ttl\n - Update NSH header to the latest format\n   which will be final format and won't change\n   per its author's confirmation.\n - Fix comments for v3.\n\nv2->v3\n - Change OVS_KEY_ATTR_NSH to nested key to handle\n   length-fixed attributes and length-variable\n   attriubte more flexibly.\n - Remove struct ovs_action_push_nsh completely\n - Add code to handle nested attribute for SET_MASKED\n - Change PUSH_NSH to use the nested OVS_KEY_ATTR_NSH\n   to transfer NSH header data.\n - Fix comments and coding style issues by Jiri and Eric\n\nv1->v2\n - Change encap_nsh and decap_nsh to push_nsh and pop_nsh\n - Dynamically allocate struct ovs_action_push_nsh for\n   length-variable metadata.\n\nOVS 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 include/net/nsh.h                |   3 +\n include/uapi/linux/openvswitch.h |  28 +++\n net/nsh/nsh.c                    |  41 ++++\n net/openvswitch/actions.c        | 141 ++++++++++++++\n net/openvswitch/flow.c           |  55 ++++++\n net/openvswitch/flow.h           |  11 ++\n net/openvswitch/flow_netlink.c   | 406 ++++++++++++++++++++++++++++++++++++++-\n net/openvswitch/flow_netlink.h   |   4 +\n 8 files changed, 688 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/net/nsh.h b/include/net/nsh.h\nindex a1eaea2..6c0cd57 100644\n--- a/include/net/nsh.h\n+++ b/include/net/nsh.h\n@@ -304,4 +304,7 @@ static inline void nsh_set_flags_ttl_len(struct nshhdr *nsh, u8 flags,\n \t\t\tNSH_FLAGS_MASK | NSH_TTL_MASK | NSH_LEN_MASK);\n }\n \n+int skb_push_nsh(struct sk_buff *skb, const struct nshhdr *nsh_src,\n+\t\t bool is_eth);\n+\n #endif /* __NET_NSH_H */\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/nsh/nsh.c b/net/nsh/nsh.c\nindex 58fb827..ad689b5 100644\n--- a/net/nsh/nsh.c\n+++ b/net/nsh/nsh.c\n@@ -14,6 +14,47 @@\n #include <net/nsh.h>\n #include <net/tun_proto.h>\n \n+int skb_push_nsh(struct sk_buff *skb, const struct nshhdr *nsh_src, bool is_eth)\n+{\n+\tstruct nshhdr *nsh;\n+\tsize_t length = nsh_hdr_len(nsh_src);\n+\tu8 next_proto;\n+\n+\tif (is_eth) {\n+\t\tnext_proto = TUN_P_ETHERNET;\n+\t} else {\n+\t\tnext_proto = tun_p_from_eth_p(skb->protocol);\n+\t\tif (!next_proto)\n+\t\t\treturn -ENOTSUPP;\n+\t}\n+\n+\t/* Add the NSH header */\n+\tif (skb_cow_head(skb, length) < 0)\n+\t\treturn -ENOMEM;\n+\n+\t/* Add the NSH header */\n+\tif (skb_cow_head(skb, length) < 0)\n+\t\treturn -ENOMEM;\n+\n+\tif (!skb->inner_protocol) {\n+\t\tskb_set_inner_network_header(skb, skb->mac_len);\n+\t\tskb_set_inner_protocol(skb, skb->protocol);\n+\t}\n+\n+\tskb_push(skb, length);\n+\tnsh = (struct nshhdr *)(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+\tskb_reset_mac_header(skb);\n+\tskb_reset_mac_len(skb);\n+\n+\treturn 0;\n+}\n+EXPORT_SYMBOL_GPL(skb_push_nsh);\n+\n static struct sk_buff *nsh_gso_segment(struct sk_buff *skb,\n \t\t\t\t       netdev_features_t features)\n {\ndiff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c\nindex a54a556..e969fad 100644\n--- a/net/openvswitch/actions.c\n+++ b/net/openvswitch/actions.c\n@@ -38,11 +38,13 @@\n #include <net/dsfield.h>\n #include <net/mpls.h>\n #include <net/sctp/checksum.h>\n+#include <net/tun_proto.h>\n \n #include \"datapath.h\"\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 +382,57 @@ 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 nshhdr *nsh_src)\n+{\n+\tbool is_eth = false;\n+\tint ret;\n+\n+\tif (key->mac_proto == MAC_PROTO_ETHERNET)\n+\t\tis_eth = true;\n+\n+\tret = skb_push_nsh(skb, nsh_src, is_eth);\n+\tif (ret != 0)\n+\t\treturn ret;\n+\n+\tkey->eth.type = htons(ETH_P_NSH);\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 nshhdr *nsh = (struct nshhdr *)(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+\tinner_proto = tun_p_to_eth_p(nsh->np);\n+\tif (!inner_proto)\n+\t\treturn -ENOTSUPP;\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 +655,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 nshhdr *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 nshhdr));\n+\tif (unlikely(err))\n+\t\treturn err;\n+\n+\tnsh = (struct nshhdr *)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 +1124,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 +1336,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 nshhdr *nsh_hdr = (struct nshhdr *)buffer;\n+\t\t\tconst struct nshhdr *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..7a178d1 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 nshhdr *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 nshhdr *)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 nshhdr *)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..17df00a 100644\n--- a/net/openvswitch/flow_netlink.c\n+++ b/net/openvswitch/flow_netlink.c\n@@ -48,6 +48,7 @@\n #include <net/ndisc.h>\n #include <net/mpls.h>\n #include <net/vxlan.h>\n+#include <net/tun_proto.h>\n \n #include \"flow_netlink.h\"\n \n@@ -78,9 +79,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 +325,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 +359,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 +393,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 +432,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 +1208,304 @@ 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 nshhdr *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+\tnsh->ver_flags_ttl_len = 0;\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 +1633,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 +1956,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 +2118,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 +2613,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 +2768,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 +2871,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 +3027,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 == TUN_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..7be6750 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 nshhdr *nsh_src,\n+\t\t\tsize_t size);\n+\n #endif /* flow_netlink.h */\n",
    "prefixes": [
        "net-next",
        "v7"
    ]
}