From: Shmulik Ladkani <shmulik.ladkani@gmail.com>
To: Amir Vadai <amir@vadai.me>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Jiri Benc <jbenc@redhat.com>,
Jiri Pirko <jiri@mellanox.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Tom Herbert <tom@herbertland.com>,
Hadar Har-Zion <hadarh@mellanox.com>,
Or Gerlitz <ogerlitz@mellanox.com>
Subject: Re: [PATCH net-next V2 4/4] net/sched: Introduce act_tunnel_key
Date: Wed, 24 Aug 2016 22:05:32 +0300 [thread overview]
Message-ID: <20160824220532.57d2fe1b@halley> (raw)
In-Reply-To: <20160824122710.30356-5-amir@vadai.me>
Hi,
On Wed, 24 Aug 2016 15:27:10 +0300 Amir Vadai <amir@vadai.me> wrote:
> +config NET_ACT_TUNNEL_KEY
> + tristate "IP tunnel metadata manipulation"
> + depends on NET_CLS_ACT
> + ---help---
> + Say Y here to set/release ip tunnel metadata.
> +
> + If unsure, say N.
> +
> + To compile this code as a module, choose M here: the
> + module will be called act_tunnel.
actually looks like it's called "act_tunnel_key" ;)
> +static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
> + struct tcf_result *res)
> +{
> + struct tcf_tunnel_key *t = to_tunnel_key(a);
> + int action;
> +
> + spin_lock(&t->tcf_lock);
> + tcf_lastuse_update(&t->tcf_tm);
> + bstats_update(&t->tcf_bstats, skb);
> + action = t->tcf_action;
> +
> + switch (t->tcft_action) {
> + case TCA_TUNNEL_KEY_ACT_RELEASE:
> + skb_dst_set_noref(skb, NULL);
> + break;
> + case TCA_TUNNEL_KEY_ACT_SET:
> + skb_dst_set_noref(skb, &t->tcft_enc_metadata->dst);
> +
> + break;
nit: empty line unneeded here.
> +static int tunnel_key_init(struct net *net, struct nlattr *nla,
> + struct nlattr *est, struct tc_action **a,
> + int ovr, int bind)
> +{
> + struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
> + struct nlattr *tb[TCA_TUNNEL_KEY_MAX + 1];
> + struct metadata_dst *metadata = NULL;
> + struct tc_tunnel_key *parm;
> + struct tcf_tunnel_key *t;
> + __be64 key_id;
> + int encapdecap;
> + bool exists = false;
> + int ret = 0;
> + int err;
> +
> + if (!nla)
> + return -EINVAL;
> +
> + err = nla_parse_nested(tb, TCA_TUNNEL_KEY_MAX, nla, tunnel_key_policy);
> + if (err < 0)
> + return err;
> +
> + if (!tb[TCA_TUNNEL_KEY_PARMS])
> + return -EINVAL;
> +
> + parm = nla_data(tb[TCA_TUNNEL_KEY_PARMS]);
> + exists = tcf_hash_check(tn, parm->index, a, bind);
> + if (exists && bind)
> + return 0;
> +
> + encapdecap = parm->t_action;
> +
> + switch (encapdecap) {
As we no longer have "encapdecap" actions, either rename or just use
parm->t_action explicitly (only needed twice).
> +static int tunnel_key_dump_addresses(struct sk_buff *skb,
> + const struct ip_tunnel_info *info)
> +{
> + unsigned short family = ip_tunnel_info_af(info);
> +
> + if (family == AF_INET) {
> + __be32 saddr = info->key.u.ipv4.src;
> + __be32 daddr = info->key.u.ipv4.dst;
> +
> + if (!nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_IPV4_SRC, saddr) &&
> + !nla_put_be32(skb, TCA_TUNNEL_KEY_ENC_IPV4_DST, daddr))
> + return 0;
> + }
> +
> + if (family == AF_INET6) {
> + struct in6_addr saddr6 = info->key.u.ipv6.src;
> + struct in6_addr daddr6 = info->key.u.ipv6.dst;
Why the in6_addr copy? Point to the things, then pass the pointers to
nla_put_in6_addr().
Also, there are few lines too long.
Regards,
Shmulik
prev parent reply other threads:[~2016-08-24 19:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 12:27 [PATCH net-next V2 0/4] net/sched: ip tunnel metadata set/release/classify by using TC Amir Vadai
2016-08-24 12:27 ` [PATCH net-next V2 1/4] net/ip_tunnels: Introduce tunnel_id_to_key32() and key32_to_tunnel_id() Amir Vadai
2016-08-24 18:15 ` Shmulik Ladkani
2016-08-24 12:27 ` [PATCH net-next V2 2/4] net/dst: Utility functions to build dst_metadata without supplying an skb Amir Vadai
2016-08-24 18:26 ` Shmulik Ladkani
2016-08-24 18:53 ` Shmulik Ladkani
2016-08-24 12:27 ` [PATCH net-next V2 3/4] net/sched: cls_flower: Classify packet in ip tunnels Amir Vadai
2016-08-24 12:27 ` [PATCH net-next V2 4/4] net/sched: Introduce act_tunnel_key Amir Vadai
2016-08-24 19:05 ` Shmulik Ladkani [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160824220532.57d2fe1b@halley \
--to=shmulik.ladkani@gmail.com \
--cc=amir@vadai.me \
--cc=davem@davemloft.net \
--cc=hadarh@mellanox.com \
--cc=jbenc@redhat.com \
--cc=jhs@mojatatu.com \
--cc=jiri@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=tom@herbertland.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).