diff options
author | Jamal Hadi Salim <jhs@mojatatu.com> | 2016-05-10 16:49:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-05-10 23:50:15 -0400 |
commit | 0e5538ab2b59ec205411949d839de6dbab663730 (patch) | |
tree | 93298461dd8092562ae4c374106e75e12b6297c4 | |
parent | 87dfbdc6c7478018c5489897d4495a27a626cda1 (diff) |
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 <jhs@mojatatu.com>
Reviewed-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/sched/act_simple.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index 75b2be13fbcc..3a33fb648a6d 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c | |||
@@ -87,7 +87,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
87 | struct tc_defact *parm; | 87 | struct tc_defact *parm; |
88 | struct tcf_defact *d; | 88 | struct tcf_defact *d; |
89 | char *defdata; | 89 | char *defdata; |
90 | int ret = 0, err; | 90 | int ret = 0, err, exists = 0; |
91 | 91 | ||
92 | if (nla == NULL) | 92 | if (nla == NULL) |
93 | return -EINVAL; | 93 | return -EINVAL; |
@@ -99,13 +99,21 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
99 | if (tb[TCA_DEF_PARMS] == NULL) | 99 | if (tb[TCA_DEF_PARMS] == NULL) |
100 | return -EINVAL; | 100 | return -EINVAL; |
101 | 101 | ||
102 | if (tb[TCA_DEF_DATA] == NULL) | ||
103 | return -EINVAL; | ||
104 | 102 | ||
105 | parm = nla_data(tb[TCA_DEF_PARMS]); | 103 | 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 | |||
106 | defdata = nla_data(tb[TCA_DEF_DATA]); | 114 | defdata = nla_data(tb[TCA_DEF_DATA]); |
107 | 115 | ||
108 | if (!tcf_hash_check(tn, parm->index, a, bind)) { | 116 | if (!exists) { |
109 | ret = tcf_hash_create(tn, parm->index, est, a, | 117 | ret = tcf_hash_create(tn, parm->index, est, a, |
110 | sizeof(*d), bind, false); | 118 | sizeof(*d), bind, false); |
111 | if (ret) | 119 | if (ret) |
@@ -122,8 +130,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
122 | } else { | 130 | } else { |
123 | d = to_defact(a); | 131 | d = to_defact(a); |
124 | 132 | ||
125 | if (bind) | ||
126 | return 0; | ||
127 | tcf_hash_release(a, bind); | 133 | tcf_hash_release(a, bind); |
128 | if (!ovr) | 134 | if (!ovr) |
129 | return -EEXIST; | 135 | return -EEXIST; |