Commit 956af371 authored by Hadar Hen Zion's avatar Hadar Hen Zion Committed by David S. Miller

net_sched: act_vlan: Add priority option

The current vlan push action supports only vid and protocol options.
Add priority option.

Example script that adds vlan push action with vid and
priority:

tc filter add dev veth0 protocol ip parent ffff: \
	   flower \
	   	indev veth0 \
	   action vlan push id 100 priority 5
Signed-off-by: default avatarHadar Hen Zion <hadarh@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9399ae9a
...@@ -20,6 +20,7 @@ struct tcf_vlan { ...@@ -20,6 +20,7 @@ struct tcf_vlan {
int tcfv_action; int tcfv_action;
u16 tcfv_push_vid; u16 tcfv_push_vid;
__be16 tcfv_push_proto; __be16 tcfv_push_proto;
u8 tcfv_push_prio;
}; };
#define to_vlan(a) ((struct tcf_vlan *)a) #define to_vlan(a) ((struct tcf_vlan *)a)
......
...@@ -29,6 +29,7 @@ enum { ...@@ -29,6 +29,7 @@ enum {
TCA_VLAN_PUSH_VLAN_ID, TCA_VLAN_PUSH_VLAN_ID,
TCA_VLAN_PUSH_VLAN_PROTOCOL, TCA_VLAN_PUSH_VLAN_PROTOCOL,
TCA_VLAN_PAD, TCA_VLAN_PAD,
TCA_VLAN_PUSH_VLAN_PRIORITY,
__TCA_VLAN_MAX, __TCA_VLAN_MAX,
}; };
#define TCA_VLAN_MAX (__TCA_VLAN_MAX - 1) #define TCA_VLAN_MAX (__TCA_VLAN_MAX - 1)
......
...@@ -43,7 +43,8 @@ static int tcf_vlan(struct sk_buff *skb, const struct tc_action *a, ...@@ -43,7 +43,8 @@ static int tcf_vlan(struct sk_buff *skb, const struct tc_action *a,
goto drop; goto drop;
break; break;
case TCA_VLAN_ACT_PUSH: case TCA_VLAN_ACT_PUSH:
err = skb_vlan_push(skb, v->tcfv_push_proto, v->tcfv_push_vid); err = skb_vlan_push(skb, v->tcfv_push_proto, v->tcfv_push_vid |
(v->tcfv_push_prio << VLAN_PRIO_SHIFT));
if (err) if (err)
goto drop; goto drop;
break; break;
...@@ -65,6 +66,7 @@ static const struct nla_policy vlan_policy[TCA_VLAN_MAX + 1] = { ...@@ -65,6 +66,7 @@ static const struct nla_policy vlan_policy[TCA_VLAN_MAX + 1] = {
[TCA_VLAN_PARMS] = { .len = sizeof(struct tc_vlan) }, [TCA_VLAN_PARMS] = { .len = sizeof(struct tc_vlan) },
[TCA_VLAN_PUSH_VLAN_ID] = { .type = NLA_U16 }, [TCA_VLAN_PUSH_VLAN_ID] = { .type = NLA_U16 },
[TCA_VLAN_PUSH_VLAN_PROTOCOL] = { .type = NLA_U16 }, [TCA_VLAN_PUSH_VLAN_PROTOCOL] = { .type = NLA_U16 },
[TCA_VLAN_PUSH_VLAN_PRIORITY] = { .type = NLA_U8 },
}; };
static int tcf_vlan_init(struct net *net, struct nlattr *nla, static int tcf_vlan_init(struct net *net, struct nlattr *nla,
...@@ -78,6 +80,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ...@@ -78,6 +80,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
int action; int action;
__be16 push_vid = 0; __be16 push_vid = 0;
__be16 push_proto = 0; __be16 push_proto = 0;
u8 push_prio = 0;
bool exists = false; bool exists = false;
int ret = 0, err; int ret = 0, err;
...@@ -123,6 +126,9 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ...@@ -123,6 +126,9 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
} else { } else {
push_proto = htons(ETH_P_8021Q); push_proto = htons(ETH_P_8021Q);
} }
if (tb[TCA_VLAN_PUSH_VLAN_PRIORITY])
push_prio = nla_get_u8(tb[TCA_VLAN_PUSH_VLAN_PRIORITY]);
break; break;
default: default:
if (exists) if (exists)
...@@ -150,6 +156,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ...@@ -150,6 +156,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
v->tcfv_action = action; v->tcfv_action = action;
v->tcfv_push_vid = push_vid; v->tcfv_push_vid = push_vid;
v->tcfv_push_prio = push_prio;
v->tcfv_push_proto = push_proto; v->tcfv_push_proto = push_proto;
v->tcf_action = parm->action; v->tcf_action = parm->action;
...@@ -181,7 +188,9 @@ static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -181,7 +188,9 @@ static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a,
if (v->tcfv_action == TCA_VLAN_ACT_PUSH && 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_ID, v->tcfv_push_vid) ||
nla_put_be16(skb, TCA_VLAN_PUSH_VLAN_PROTOCOL, nla_put_be16(skb, TCA_VLAN_PUSH_VLAN_PROTOCOL,
v->tcfv_push_proto))) v->tcfv_push_proto) ||
(nla_put_u8(skb, TCA_VLAN_PUSH_VLAN_PRIORITY,
v->tcfv_push_prio))))
goto nla_put_failure; goto nla_put_failure;
tcf_tm_dump(&t, &v->tcf_tm); tcf_tm_dump(&t, &v->tcf_tm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment