Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a29321e authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by David S. Miller
Browse files

net_sched: act: Dont increment refcnt on replace



 This is a bug fix. The existing code tries to kill many
 birds with one stone: Handling binding of actions to
 filters, new actions and replacing of action
 attributes. A simple test case to illustrate:

XXXX
 moja@fe1:~$ sudo tc actions add action drop index 12
 moja@fe1:~$ actions get action gact index 12
 action order 1: gact action drop
  random type none pass val 0
  index 12 ref 1 bind 0
 moja@fe1:~$ sudo tc actions replace action ok index 12
 moja@fe1:~$ actions get action gact index 12
 action order 1: gact action drop
  random type none pass val 0
  index 12 ref 2 bind 0
XXXX

The above shows the refcounf being wrongly incremented on replace.
There are more complex scenarios with binding of actions to filters
that i am leaving out that didnt work as well...

Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c2349758
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -77,16 +77,16 @@ static int tcf_csum_init(struct net *n, struct nlattr *nla, struct nlattr *est,
				     &csum_idx_gen, &csum_hash_info);
		if (IS_ERR(pc))
			return PTR_ERR(pc);
		p = to_tcf_csum(pc);
		ret = ACT_P_CREATED;
	} else {
		p = to_tcf_csum(pc);
		if (!ovr) {
		if (bind)/* dont override defaults */
			return 0;
		tcf_hash_release(pc, bind, &csum_hash_info);
		if (!ovr)
			return -EEXIST;
	}
	}

	p = to_tcf_csum(pc);
	spin_lock_bh(&p->tcf_lock);
	p->tcf_action = parm->action;
	p->update_flags = parm->update_flags;
+4 −3
Original line number Diff line number Diff line
@@ -102,11 +102,12 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
			return PTR_ERR(pc);
		ret = ACT_P_CREATED;
	} else {
		if (!ovr) {
		if (bind)/* dont override defaults */
			return 0;
		tcf_hash_release(pc, bind, &gact_hash_info);
		if (!ovr)
			return -EEXIST;
	}
	}

	gact = to_gact(pc);

+5 −3
Original line number Diff line number Diff line
@@ -141,11 +141,13 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est,
			return PTR_ERR(pc);
		ret = ACT_P_CREATED;
	} else {
		if (!ovr) {
		if (bind)/* dont override defaults */
			return 0;
		tcf_ipt_release(to_ipt(pc), bind);

		if (!ovr)
			return -EEXIST;
	}
	}
	ipt = to_ipt(pc);

	hook = nla_get_u32(tb[TCA_IPT_HOOK]);
+5 −5
Original line number Diff line number Diff line
@@ -70,15 +70,15 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est,
				     &nat_idx_gen, &nat_hash_info);
		if (IS_ERR(pc))
			return PTR_ERR(pc);
		p = to_tcf_nat(pc);
		ret = ACT_P_CREATED;
	} else {
		p = to_tcf_nat(pc);
		if (!ovr) {
		if (bind)
			return 0;
		tcf_hash_release(pc, bind, &nat_hash_info);
		if (!ovr)
			return -EEXIST;
	}
	}
	p = to_tcf_nat(pc);

	spin_lock_bh(&p->tcf_lock);
	p->old_addr = parm->old_addr;
+5 −3
Original line number Diff line number Diff line
@@ -84,10 +84,12 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
		ret = ACT_P_CREATED;
	} else {
		p = to_pedit(pc);
		if (!ovr) {
		tcf_hash_release(pc, bind, &pedit_hash_info);
		if (bind)
			return 0;
		if (!ovr)
			return -EEXIST;
		}

		if (p->tcfp_nkeys && p->tcfp_nkeys != parm->nkeys) {
			keys = kmalloc(ksize, GFP_KERNEL);
			if (keys == NULL)
Loading