[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 11 Nov 2014 14:33:21 -0800
From: Cong Wang <cwang@...pensource.com>
To: Jiri Pirko <jiri@...nulli.us>
Cc: netdev <netdev@...r.kernel.org>,
David Miller <davem@...emloft.net>,
Jamal Hadi Salim <jhs@...atatu.com>,
Pravin B Shelar <pshelar@...ira.com>,
Tom Herbert <therbert@...gle.com>,
Eric Dumazet <edumazet@...gle.com>, willemb@...gle.com,
Daniel Borkmann <dborkman@...hat.com>, mst@...hat.com,
Florian Westphal <fw@...len.de>, Paul.Durrant@...rix.com,
Thomas Graf <tgraf@...g.ch>
Subject: Re: [patch net-next 2/2] sched: introduce vlan action
On Tue, Nov 11, 2014 at 2:13 AM, Jiri Pirko <jiri@...nulli.us> wrote:
> +static int tcf_vlan_init(struct net *net, struct nlattr *nla,
> + struct nlattr *est, struct tc_action *a,
> + int ovr, int bind)
> +{
> + struct nlattr *tb[TCA_VLAN_MAX + 1];
> + struct tc_vlan *parm;
> + struct tcf_vlan *v;
> + int action;
> + __be16 push_vid = 0;
> + __be16 push_proto = 0;
> + int ret = 0;
> + int err;
> +
> + if (!nla)
> + return -EINVAL;
> +
> + err = nla_parse_nested(tb, TCA_VLAN_MAX, nla, vlan_policy);
> + if (err < 0)
> + return err;
> +
> + if (!tb[TCA_VLAN_PARMS])
> + return -EINVAL;
> + parm = nla_data(tb[TCA_VLAN_PARMS]);
> + switch (parm->v_action) {
> + case TCA_VLAN_ACT_POP:
> + break;
> + case TCA_VLAN_ACT_PUSH:
> + if (!tb[TCA_VLAN_PUSH_VLAN_ID])
> + return -EINVAL;
> + push_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]);
nla_get_be16() ?
> + if (push_vid >= VLAN_VID_MASK)
> + return -ERANGE;
> +
htons() ?
[...]
> +static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a,
> + int bind, int ref)
> +{
> + unsigned char *b = skb_tail_pointer(skb);
> + struct tcf_vlan *v = a->priv;
> + struct tc_vlan opt = {
> + .index = v->tcf_index,
> + .refcnt = v->tcf_refcnt - ref,
> + .bindcnt = v->tcf_bindcnt - bind,
> + .action = v->tcf_action,
> + .v_action = v->tcfv_action,
> + };
> + struct tcf_t t;
> +
> + if (nla_put(skb, TCA_VLAN_PARMS, sizeof(opt), &opt))
> + goto nla_put_failure;
> +
> + if (v->tcfv_action == TCA_VLAN_ACT_PUSH &&
> + nla_put_u16(skb, TCA_VLAN_PUSH_VLAN_ID, v->tcfv_push_vid) &&
> + nla_put_u16(skb, TCA_VLAN_PUSH_VLAN_PROTOCOL, v->tcfv_push_proto))
> + goto nla_put_failure;
nla_put_be16() ?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists