Skip to content

Commit 0e5538a

Browse files
jhsmtdavem330
authored andcommitted
net sched: simple action fix late binding
The process below was broken and is fixed with this patch. //add a simple action and give it an instance id of 1 sudo tc actions add action simple sdata "foobar" index 1 //create a filter which binds to simple 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:10 action simple index 1 Message before 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 87dfbdc commit 0e5538a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

net/sched/act_simple.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
8787
struct tc_defact *parm;
8888
struct tcf_defact *d;
8989
char *defdata;
90-
int ret = 0, err;
90+
int ret = 0, err, exists = 0;
9191

9292
if (nla == NULL)
9393
return -EINVAL;
@@ -99,13 +99,21 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
9999
if (tb[TCA_DEF_PARMS] == NULL)
100100
return -EINVAL;
101101

102-
if (tb[TCA_DEF_DATA] == NULL)
103-
return -EINVAL;
104102

105103
parm = nla_data(tb[TCA_DEF_PARMS]);
104+
exists = tcf_hash_check(tn, parm->index, a, bind);
105+
if (exists && bind)
106+
return 0;
107+
108+
if (tb[TCA_DEF_DATA] == NULL) {
109+
if (exists)
110+
tcf_hash_release(a, bind);
111+
return -EINVAL;
112+
}
113+
106114
defdata = nla_data(tb[TCA_DEF_DATA]);
107115

108-
if (!tcf_hash_check(tn, parm->index, a, bind)) {
116+
if (!exists) {
109117
ret = tcf_hash_create(tn, parm->index, est, a,
110118
sizeof(*d), bind, false);
111119
if (ret)
@@ -122,8 +130,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
122130
} else {
123131
d = to_defact(a);
124132

125-
if (bind)
126-
return 0;
127133
tcf_hash_release(a, bind);
128134
if (!ovr)
129135
return -EEXIST;

0 commit comments

Comments
 (0)