Skip to content

Commit 5026c9b

Browse files
jhsmtdavem330
authored andcommitted
net sched: vlan action fix late binding
Late vlan action binding was broken and is fixed with this patch. //add a vlan action to pop and give it an instance id of 1 sudo tc actions add action vlan pop index 1 //create filter which binds to vlan action id 1 sudo tc filter add dev $DEV parent ffff: protocol ip prio 1 u32 \ match ip dst 17.0.0.1/32 flowid 1:1 action vlan index 1 current message(before bug fix) was: RTNETLINK answers: Invalid argument We have an error talking to the kernel Signed-off-by: Jamal Hadi Salim <[email protected]> Reviewed-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 84a527a commit 5026c9b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

net/sched/act_vlan.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
7777
int action;
7878
__be16 push_vid = 0;
7979
__be16 push_proto = 0;
80-
int ret = 0;
80+
int ret = 0, exists = 0;
8181
int err;
8282

8383
if (!nla)
@@ -90,15 +90,25 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
9090
if (!tb[TCA_VLAN_PARMS])
9191
return -EINVAL;
9292
parm = nla_data(tb[TCA_VLAN_PARMS]);
93+
exists = tcf_hash_check(tn, parm->index, a, bind);
94+
if (exists && bind)
95+
return 0;
96+
9397
switch (parm->v_action) {
9498
case TCA_VLAN_ACT_POP:
9599
break;
96100
case TCA_VLAN_ACT_PUSH:
97-
if (!tb[TCA_VLAN_PUSH_VLAN_ID])
101+
if (!tb[TCA_VLAN_PUSH_VLAN_ID]) {
102+
if (exists)
103+
tcf_hash_release(a, bind);
98104
return -EINVAL;
105+
}
99106
push_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]);
100-
if (push_vid >= VLAN_VID_MASK)
107+
if (push_vid >= VLAN_VID_MASK) {
108+
if (exists)
109+
tcf_hash_release(a, bind);
101110
return -ERANGE;
111+
}
102112

103113
if (tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]) {
104114
push_proto = nla_get_be16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]);
@@ -114,20 +124,20 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
114124
}
115125
break;
116126
default:
127+
if (exists)
128+
tcf_hash_release(a, bind);
117129
return -EINVAL;
118130
}
119131
action = parm->v_action;
120132

121-
if (!tcf_hash_check(tn, parm->index, a, bind)) {
133+
if (!exists) {
122134
ret = tcf_hash_create(tn, parm->index, est, a,
123135
sizeof(*v), bind, false);
124136
if (ret)
125137
return ret;
126138

127139
ret = ACT_P_CREATED;
128140
} else {
129-
if (bind)
130-
return 0;
131141
tcf_hash_release(a, bind);
132142
if (!ovr)
133143
return -EEXIST;

0 commit comments

Comments
 (0)