Commit 4e8c8615 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by David S. Miller

net sched: ife action fix late binding

The process below was broken and is fixed with this patch.

//add an ife action and give it an instance id of 1
sudo tc actions add action ife encode \
type 0xDEAD allow mark dst 02:15:15:15:15:15 index 1

//create a filter which binds to ife 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:11 action ife index 1

Message before fix was:
RTNETLINK answers: Invalid argument
We have an error talking to the kernel
Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5e1567ae
...@@ -423,7 +423,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, ...@@ -423,7 +423,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
u16 ife_type = 0; u16 ife_type = 0;
u8 *daddr = NULL; u8 *daddr = NULL;
u8 *saddr = NULL; u8 *saddr = NULL;
int ret = 0; int ret = 0, exists = 0;
int err; int err;
err = nla_parse_nested(tb, TCA_IFE_MAX, nla, ife_policy); err = nla_parse_nested(tb, TCA_IFE_MAX, nla, ife_policy);
...@@ -435,25 +435,29 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, ...@@ -435,25 +435,29 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
parm = nla_data(tb[TCA_IFE_PARMS]); parm = nla_data(tb[TCA_IFE_PARMS]);
exists = tcf_hash_check(tn, parm->index, a, bind);
if (exists && bind)
return 0;
if (parm->flags & IFE_ENCODE) { if (parm->flags & IFE_ENCODE) {
/* Until we get issued the ethertype, we cant have /* Until we get issued the ethertype, we cant have
* a default.. * a default..
**/ **/
if (!tb[TCA_IFE_TYPE]) { if (!tb[TCA_IFE_TYPE]) {
if (exists)
tcf_hash_release(a, bind);
pr_info("You MUST pass etherype for encoding\n"); pr_info("You MUST pass etherype for encoding\n");
return -EINVAL; return -EINVAL;
} }
} }
if (!tcf_hash_check(tn, parm->index, a, bind)) { if (!exists) {
ret = tcf_hash_create(tn, parm->index, est, a, sizeof(*ife), ret = tcf_hash_create(tn, parm->index, est, a, sizeof(*ife),
bind, false); bind, false);
if (ret) if (ret)
return ret; return ret;
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
if (bind) /* dont override defaults */
return 0;
tcf_hash_release(a, bind); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
...@@ -495,6 +499,8 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, ...@@ -495,6 +499,8 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
NULL); NULL);
if (err) { if (err) {
metadata_parse_err: metadata_parse_err:
if (exists)
tcf_hash_release(a, bind);
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
_tcf_ife_cleanup(a, bind); _tcf_ife_cleanup(a, bind);
......
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