Commit 6e14313f authored by David S. Miller's avatar David S. Miller

Merge branch 'net-sched-fixes'

Jamal Hadi Salim says:

====================
Some actions were broken in allowing for late binding of actions.
Late binding workflow is as follows:
a) create an action and provide all necessary parameters for it
Optionally provide an index or let the kernel give you one.
Example:
sudo tc actions add action police rate 1kbit burst 90k drop index 1

b) later on bind to the pre-created action from a filter definition
by merely specifying the index.
Example:
sudo tc filter add dev lo parent ffff: protocol ip prio 8 \
u32 match ip src 127.0.0.8/32 flowid 1:8 action police index 1
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 84a527a4 4e8c8615
...@@ -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);
......
...@@ -96,7 +96,7 @@ static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla, ...@@ -96,7 +96,7 @@ static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
struct tcf_ipt *ipt; struct tcf_ipt *ipt;
struct xt_entry_target *td, *t; struct xt_entry_target *td, *t;
char *tname; char *tname;
int ret = 0, err; int ret = 0, err, exists = 0;
u32 hook = 0; u32 hook = 0;
u32 index = 0; u32 index = 0;
...@@ -107,18 +107,23 @@ static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla, ...@@ -107,18 +107,23 @@ static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
if (err < 0) if (err < 0)
return err; return err;
if (tb[TCA_IPT_HOOK] == NULL) if (tb[TCA_IPT_INDEX] != NULL)
return -EINVAL; index = nla_get_u32(tb[TCA_IPT_INDEX]);
if (tb[TCA_IPT_TARG] == NULL)
exists = tcf_hash_check(tn, index, a, bind);
if (exists && bind)
return 0;
if (tb[TCA_IPT_HOOK] == NULL || tb[TCA_IPT_TARG] == NULL) {
if (exists)
tcf_hash_release(a, bind);
return -EINVAL; return -EINVAL;
}
td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]); td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]);
if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size) if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size)
return -EINVAL; return -EINVAL;
if (tb[TCA_IPT_INDEX] != NULL)
index = nla_get_u32(tb[TCA_IPT_INDEX]);
if (!tcf_hash_check(tn, index, a, bind)) { if (!tcf_hash_check(tn, index, a, bind)) {
ret = tcf_hash_create(tn, index, est, a, sizeof(*ipt), bind, ret = tcf_hash_create(tn, index, est, a, sizeof(*ipt), bind,
false); false);
......
...@@ -61,7 +61,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, ...@@ -61,7 +61,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
struct tc_mirred *parm; struct tc_mirred *parm;
struct tcf_mirred *m; struct tcf_mirred *m;
struct net_device *dev; struct net_device *dev;
int ret, ok_push = 0; int ret, ok_push = 0, exists = 0;
if (nla == NULL) if (nla == NULL)
return -EINVAL; return -EINVAL;
...@@ -71,17 +71,27 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, ...@@ -71,17 +71,27 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
if (tb[TCA_MIRRED_PARMS] == NULL) if (tb[TCA_MIRRED_PARMS] == NULL)
return -EINVAL; return -EINVAL;
parm = nla_data(tb[TCA_MIRRED_PARMS]); parm = nla_data(tb[TCA_MIRRED_PARMS]);
exists = tcf_hash_check(tn, parm->index, a, bind);
if (exists && bind)
return 0;
switch (parm->eaction) { switch (parm->eaction) {
case TCA_EGRESS_MIRROR: case TCA_EGRESS_MIRROR:
case TCA_EGRESS_REDIR: case TCA_EGRESS_REDIR:
break; break;
default: default:
if (exists)
tcf_hash_release(a, bind);
return -EINVAL; return -EINVAL;
} }
if (parm->ifindex) { if (parm->ifindex) {
dev = __dev_get_by_index(net, parm->ifindex); dev = __dev_get_by_index(net, parm->ifindex);
if (dev == NULL) if (dev == NULL) {
if (exists)
tcf_hash_release(a, bind);
return -ENODEV; return -ENODEV;
}
switch (dev->type) { switch (dev->type) {
case ARPHRD_TUNNEL: case ARPHRD_TUNNEL:
case ARPHRD_TUNNEL6: case ARPHRD_TUNNEL6:
...@@ -99,7 +109,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, ...@@ -99,7 +109,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
dev = NULL; dev = NULL;
} }
if (!tcf_hash_check(tn, parm->index, a, bind)) { if (!exists) {
if (dev == NULL) if (dev == NULL)
return -EINVAL; return -EINVAL;
ret = tcf_hash_create(tn, parm->index, est, a, ret = tcf_hash_create(tn, parm->index, est, a,
...@@ -108,9 +118,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, ...@@ -108,9 +118,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
return ret; return ret;
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
if (bind)
return 0;
tcf_hash_release(a, bind); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
......
...@@ -87,7 +87,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, ...@@ -87,7 +87,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
struct tc_defact *parm; struct tc_defact *parm;
struct tcf_defact *d; struct tcf_defact *d;
char *defdata; char *defdata;
int ret = 0, err; int ret = 0, err, exists = 0;
if (nla == NULL) if (nla == NULL)
return -EINVAL; return -EINVAL;
...@@ -99,13 +99,21 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, ...@@ -99,13 +99,21 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
if (tb[TCA_DEF_PARMS] == NULL) if (tb[TCA_DEF_PARMS] == NULL)
return -EINVAL; return -EINVAL;
if (tb[TCA_DEF_DATA] == NULL)
return -EINVAL;
parm = nla_data(tb[TCA_DEF_PARMS]); parm = nla_data(tb[TCA_DEF_PARMS]);
exists = tcf_hash_check(tn, parm->index, a, bind);
if (exists && bind)
return 0;
if (tb[TCA_DEF_DATA] == NULL) {
if (exists)
tcf_hash_release(a, bind);
return -EINVAL;
}
defdata = nla_data(tb[TCA_DEF_DATA]); defdata = nla_data(tb[TCA_DEF_DATA]);
if (!tcf_hash_check(tn, parm->index, a, bind)) { if (!exists) {
ret = tcf_hash_create(tn, parm->index, est, a, ret = tcf_hash_create(tn, parm->index, est, a,
sizeof(*d), bind, false); sizeof(*d), bind, false);
if (ret) if (ret)
...@@ -122,8 +130,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, ...@@ -122,8 +130,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
} else { } else {
d = to_defact(a); d = to_defact(a);
if (bind)
return 0;
tcf_hash_release(a, bind); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
......
...@@ -69,7 +69,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, ...@@ -69,7 +69,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
struct tcf_skbedit *d; struct tcf_skbedit *d;
u32 flags = 0, *priority = NULL, *mark = NULL; u32 flags = 0, *priority = NULL, *mark = NULL;
u16 *queue_mapping = NULL; u16 *queue_mapping = NULL;
int ret = 0, err; int ret = 0, err, exists = 0;
if (nla == NULL) if (nla == NULL)
return -EINVAL; return -EINVAL;
...@@ -96,12 +96,18 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, ...@@ -96,12 +96,18 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
mark = nla_data(tb[TCA_SKBEDIT_MARK]); mark = nla_data(tb[TCA_SKBEDIT_MARK]);
} }
if (!flags)
return -EINVAL;
parm = nla_data(tb[TCA_SKBEDIT_PARMS]); parm = nla_data(tb[TCA_SKBEDIT_PARMS]);
if (!tcf_hash_check(tn, parm->index, a, bind)) { exists = tcf_hash_check(tn, parm->index, a, bind);
if (exists && bind)
return 0;
if (!flags) {
tcf_hash_release(a, bind);
return -EINVAL;
}
if (!exists) {
ret = tcf_hash_create(tn, parm->index, est, a, ret = tcf_hash_create(tn, parm->index, est, a,
sizeof(*d), bind, false); sizeof(*d), bind, false);
if (ret) if (ret)
...@@ -111,8 +117,6 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, ...@@ -111,8 +117,6 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
d = to_skbedit(a); d = to_skbedit(a);
if (bind)
return 0;
tcf_hash_release(a, bind); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
......
...@@ -77,7 +77,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ...@@ -77,7 +77,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;
int ret = 0; int ret = 0, exists = 0;
int err; int err;
if (!nla) if (!nla)
...@@ -90,15 +90,25 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ...@@ -90,15 +90,25 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
if (!tb[TCA_VLAN_PARMS]) if (!tb[TCA_VLAN_PARMS])
return -EINVAL; return -EINVAL;
parm = nla_data(tb[TCA_VLAN_PARMS]); parm = nla_data(tb[TCA_VLAN_PARMS]);
exists = tcf_hash_check(tn, parm->index, a, bind);
if (exists && bind)
return 0;
switch (parm->v_action) { switch (parm->v_action) {
case TCA_VLAN_ACT_POP: case TCA_VLAN_ACT_POP:
break; break;
case TCA_VLAN_ACT_PUSH: case TCA_VLAN_ACT_PUSH:
if (!tb[TCA_VLAN_PUSH_VLAN_ID]) if (!tb[TCA_VLAN_PUSH_VLAN_ID]) {
if (exists)
tcf_hash_release(a, bind);
return -EINVAL; return -EINVAL;
}
push_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]); push_vid = nla_get_u16(tb[TCA_VLAN_PUSH_VLAN_ID]);
if (push_vid >= VLAN_VID_MASK) if (push_vid >= VLAN_VID_MASK) {
if (exists)
tcf_hash_release(a, bind);
return -ERANGE; return -ERANGE;
}
if (tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]) { if (tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]) {
push_proto = nla_get_be16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]); push_proto = nla_get_be16(tb[TCA_VLAN_PUSH_VLAN_PROTOCOL]);
...@@ -114,11 +124,13 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ...@@ -114,11 +124,13 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
} }
break; break;
default: default:
if (exists)
tcf_hash_release(a, bind);
return -EINVAL; return -EINVAL;
} }
action = parm->v_action; action = parm->v_action;
if (!tcf_hash_check(tn, parm->index, a, bind)) { if (!exists) {
ret = tcf_hash_create(tn, parm->index, est, a, ret = tcf_hash_create(tn, parm->index, est, a,
sizeof(*v), bind, false); sizeof(*v), bind, false);
if (ret) if (ret)
...@@ -126,8 +138,6 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ...@@ -126,8 +138,6 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
if (bind)
return 0;
tcf_hash_release(a, bind); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
......
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