{"id":812869,"url":"http://patchwork.ozlabs.org/api/patches/812869/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1505226037-2758-2-git-send-email-simon.horman@netronome.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","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":"<1505226037-2758-2-git-send-email-simon.horman@netronome.com>","list_archive_url":null,"date":"2017-09-12T14:20:36","name":"[PATCH/RFC,net-next,1/2] net/sched: add tunnel option support to act_tunnel_key","commit_ref":null,"pull_url":null,"state":"rfc","archived":true,"hash":"9b91b1ccb1e422a22afa08f53b9683f70d568d19","submitter":{"id":64714,"url":"http://patchwork.ozlabs.org/api/people/64714/?format=json","name":"Simon Horman","email":"simon.horman@netronome.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/1505226037-2758-2-git-send-email-simon.horman@netronome.com/mbox/","series":[{"id":2713,"url":"http://patchwork.ozlabs.org/api/series/2713/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=2713","date":"2017-09-12T14:20:35","name":"net/sched: support tunnel options in cls_flower and act_tunnel_key","version":1,"mbox":"http://patchwork.ozlabs.org/series/2713/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812869/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812869/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>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=netronome-com.20150623.gappssmtp.com\n\theader.i=@netronome-com.20150623.gappssmtp.com\n\theader.b=\"fCOQ9Wf1\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xs6SV3XMcz9s0Z\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 13 Sep 2017 00:22:18 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751512AbdILOV6 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 12 Sep 2017 10:21:58 -0400","from mail-wm0-f42.google.com ([74.125.82.42]:43321 \"EHLO\n\tmail-wm0-f42.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751476AbdILOVs (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 12 Sep 2017 10:21:48 -0400","by mail-wm0-f42.google.com with SMTP id a137so19781wma.0\n\tfor <netdev@vger.kernel.org>; Tue, 12 Sep 2017 07:21:47 -0700 (PDT)","from reginn.horms.nl (52D9BC73.cm-11-1c.dynamic.ziggo.nl.\n\t[82.217.188.115]) by smtp.gmail.com with ESMTPSA id\n\tx29sm708851eda.51.2017.09.12.07.21.44\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 12 Sep 2017 07:21:45 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=netronome-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=3GBKc9ShWsnBP3BDWrBnS0+yE5mI3ghX07JDrsNZVy4=;\n\tb=fCOQ9Wf17qmINFV8olEDs+JFTQ+rKi4qAoNWCmdUKOREnL6JTj1JlUoBZWqI9HGUh2\n\tQjUORPHlE12hL6YBVjrA2SNDEr+DX2WlEeGkndmRLKxjiNDZQoz2iLz3XHMo+RzIvsd/\n\tEoAWNMR4ZMG62IVNP509HxT7EEZbkxdRRhVhTGZNhd1LKONyOXBLejt6cABwEXO03MJV\n\twkp4U4B1nIZXSoWmCYAkLU59/U6RhU7Md/wYhHOowjnhGvouQbQiUK+uOJMg0LuG3Dge\n\tG/703nIjXhH2LhUkxO0Nz5WCwJLqnQhKuM2lhoPQcgZMssOXRVHB3ymGmEx84AIDybF7\n\tk2XA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=3GBKc9ShWsnBP3BDWrBnS0+yE5mI3ghX07JDrsNZVy4=;\n\tb=SuEOhbgCYzvdyg8nkNV8R6f00E4b7AaE5UyMfSh68gPziAAl7MWfi8x0CKhdLlB05b\n\t6+meTqZkaj7c4lAMSa1UQpRvO+PsLhsKn8AqkfhT/BOSxht1BJalsPCwSh1z9kgOplzj\n\tvTI5F/442UMzkklXCgw+T8DYfwDj1seAzMdaKBAfoI9xVPwO6W7jpmS1qbsOmVfGF7v/\n\t2jO/Orxc7VGhvhzXIpYiv965x7cnSwtYsjJL+0IR8Nh1l7De1lKwGdFB0CiH0oTHOlD+\n\tp47AcBH7ioMJrvlzLHUfkH9AeUiegoP1y21BnOukwBocDsASmkF04zoIk531V9bfbbLY\n\tDRXw==","X-Gm-Message-State":"AHPjjUjHqj1Fb1wAsahJdHDfQr3Jpg2uJbv7by3hap2Sb0M6JGLRNzoA\n\t9DWJCUfJdDNsIeMd","X-Google-Smtp-Source":"ADKCNb6Hdh7JJ6xT7GESMV4hu+KOcJ8v1L9pVE11GFgI3DJXDSMkqjCZL2K/FJ9Yq5yjj/o57xwuYA==","X-Received":"by 10.80.184.225 with SMTP id l88mr12489526ede.53.1505226105853; \n\tTue, 12 Sep 2017 07:21:45 -0700 (PDT)","From":"Simon Horman <simon.horman@netronome.com>","To":"Jiri Pirko <jiri@mellanox.com>, Jamal Hadi Salim <jhs@mojatatu.com>,\n\tCong Wang <xiyou.wangcong@gmail.com>","Cc":"netdev@vger.kernel.org, oss-drivers@netronome.com,\n\tSimon Horman <simon.horman@netronome.com>","Subject":"[PATCH/RFC net-next 1/2] net/sched: add tunnel option support to\n\tact_tunnel_key","Date":"Tue, 12 Sep 2017 16:20:36 +0200","Message-Id":"<1505226037-2758-2-git-send-email-simon.horman@netronome.com>","X-Mailer":"git-send-email 2.1.4","In-Reply-To":"<1505226037-2758-1-git-send-email-simon.horman@netronome.com>","References":"<1505226037-2758-1-git-send-email-simon.horman@netronome.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Allow setting tunnel options using the act_tunnel_key action.\n\nOptions are a bitwise maskable bytestring of up to 256 bytes.\nTunnel implementations may support less or more options,\nor no options at all.\n\ne.g.\n # ip link add name geneve0 type geneve dstport 0 external\n # tc qdisc del dev geneve0 ingress\n # tc filter add dev geneve0 protocol ip parent ffff: \\\n     flower \\\n       enc_src_ip 10.0.99.192 \\\n       enc_dst_ip 10.0.99.193 \\\n       enc_key_id 11 \\\n       enc_opts 0102800100800020/fffffffffffffff0 \\\n       ip_proto udp \\\n       action mirred egress redirect dev eth1\n\nSigned-off-by: Simon Horman <simon.horman@netronome.com>\nReviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>\n---\n include/uapi/linux/tc_act/tc_tunnel_key.h |  1 +\n net/sched/act_tunnel_key.c                | 26 +++++++++++++++++++++-----\n 2 files changed, 22 insertions(+), 5 deletions(-)","diff":"diff --git a/include/uapi/linux/tc_act/tc_tunnel_key.h b/include/uapi/linux/tc_act/tc_tunnel_key.h\nindex afcd4be953e2..e0cb1121d132 100644\n--- a/include/uapi/linux/tc_act/tc_tunnel_key.h\n+++ b/include/uapi/linux/tc_act/tc_tunnel_key.h\n@@ -35,6 +35,7 @@ enum {\n \tTCA_TUNNEL_KEY_PAD,\n \tTCA_TUNNEL_KEY_ENC_DST_PORT,\t/* be16 */\n \tTCA_TUNNEL_KEY_NO_CSUM,\t\t/* u8 */\n+\tTCA_TUNNEL_KEY_ENC_OPTS,\n \t__TCA_TUNNEL_KEY_MAX,\n };\n \ndiff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c\nindex 30c96274c638..77b5890a48b9 100644\n--- a/net/sched/act_tunnel_key.c\n+++ b/net/sched/act_tunnel_key.c\n@@ -66,6 +66,7 @@ static const struct nla_policy tunnel_key_policy[TCA_TUNNEL_KEY_MAX + 1] = {\n \t[TCA_TUNNEL_KEY_ENC_KEY_ID]   = { .type = NLA_U32 },\n \t[TCA_TUNNEL_KEY_ENC_DST_PORT] = {.type = NLA_U16},\n \t[TCA_TUNNEL_KEY_NO_CSUM]      = { .type = NLA_U8 },\n+\t[TCA_TUNNEL_KEY_ENC_OPTS]     = { .type = NLA_BINARY },\n };\n \n static int tunnel_key_init(struct net *net, struct nlattr *nla,\n@@ -81,9 +82,11 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,\n \tstruct tcf_tunnel_key *t;\n \tbool exists = false;\n \t__be16 dst_port = 0;\n+\tint opts_len = 0;\n \t__be64 key_id;\n \t__be16 flags;\n \tint ret = 0;\n+\tu8 *opts;\n \tint err;\n \n \tif (!nla)\n@@ -121,6 +124,11 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,\n \t\tif (tb[TCA_TUNNEL_KEY_ENC_DST_PORT])\n \t\t\tdst_port = nla_get_be16(tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);\n \n+\t\tif (tb[TCA_TUNNEL_KEY_ENC_OPTS]) {\n+\t\t\topts = nla_data(tb[TCA_TUNNEL_KEY_ENC_OPTS]);\n+\t\t\topts_len = nla_len(tb[TCA_TUNNEL_KEY_ENC_OPTS]);\n+\t\t}\n+\n \t\tif (tb[TCA_TUNNEL_KEY_ENC_IPV4_SRC] &&\n \t\t    tb[TCA_TUNNEL_KEY_ENC_IPV4_DST]) {\n \t\t\t__be32 saddr;\n@@ -131,7 +139,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,\n \n \t\t\tmetadata = __ip_tun_set_dst(saddr, daddr, 0, 0,\n \t\t\t\t\t\t    dst_port, flags,\n-\t\t\t\t\t\t    key_id, 0);\n+\t\t\t\t\t\t    key_id, opts_len);\n \t\t} else if (tb[TCA_TUNNEL_KEY_ENC_IPV6_SRC] &&\n \t\t\t   tb[TCA_TUNNEL_KEY_ENC_IPV6_DST]) {\n \t\t\tstruct in6_addr saddr;\n@@ -142,9 +150,13 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,\n \n \t\t\tmetadata = __ipv6_tun_set_dst(&saddr, &daddr, 0, 0, dst_port,\n \t\t\t\t\t\t      0, flags,\n-\t\t\t\t\t\t      key_id, 0);\n+\t\t\t\t\t\t      key_id, opts_len);\n \t\t}\n \n+\t\tif (opts_len)\n+\t\t\tip_tunnel_info_opts_set(&metadata->u.tun_info,\n+\t\t\t\t\t\topts, opts_len);\n+\n \t\tif (!metadata) {\n \t\t\tret = -EINVAL;\n \t\t\tgoto err_out;\n@@ -264,8 +276,9 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,\n \t\tgoto nla_put_failure;\n \n \tif (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET) {\n-\t\tstruct ip_tunnel_key *key =\n-\t\t\t&params->tcft_enc_metadata->u.tun_info.key;\n+\t\tstruct ip_tunnel_info *info =\n+\t\t\t&params->tcft_enc_metadata->u.tun_info;\n+\t\tstruct ip_tunnel_key *key = &info->key;\n \t\t__be32 key_id = tunnel_id_to_key32(key->tun_id);\n \n \t\tif (nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_KEY_ID, key_id) ||\n@@ -273,7 +286,10 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,\n \t\t\t\t\t      &params->tcft_enc_metadata->u.tun_info) ||\n \t\t    nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_DST_PORT, key->tp_dst) ||\n \t\t    nla_put_u8(skb, TCA_TUNNEL_KEY_NO_CSUM,\n-\t\t\t       !(key->tun_flags & TUNNEL_CSUM)))\n+\t\t\t       !(key->tun_flags & TUNNEL_CSUM)) ||\n+\t\t    (info->options_len &&\n+\t\t     nla_put(skb, TCA_TUNNEL_KEY_ENC_OPTS, info->options_len,\n+\t\t\t     info + 1)))\n \t\t\tgoto nla_put_failure;\n \t}\n \n","prefixes":["PATCH/RFC","net-next","1/2"]}