Subject: Re: [patch net-next 2/2] sched: introduce vlan action

From: Jamal Hadi Salim <[email-masked]>
Date: Wed, 12 Nov 2014 08:03:40 -0500

On 11/12/14 07:34, Jiri Pirko wrote:
> Tue, Nov 11, 2014 at 11:33:21PM CET, [email-masked] wrote:
>> On Tue, Nov 11, 2014 at 2:13 AM, Jiri Pirko <[email-masked]> 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() ?
>
> No. I made this the same as it is done in net/8021q/vlan_netlink.c
>

It just happens that user space passes it to you in BE already.
So this works out because skb_vlan_push expects that to be in BE
as in:
int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)

cheers,
jamal