Skip to content

Commit

Permalink
net: sched: avoid atomic swap in tcf_exts_change
Browse files Browse the repository at this point in the history
tcf_exts_change is always called on newly created exts, which are not used
on fastpath. Therefore, simple struct copy is enough.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Aug 4, 2017
1 parent 705c709 commit 9b0d444
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
3 changes: 1 addition & 2 deletions include/net/pkt_cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
struct nlattr **tb, struct nlattr *rate_tlv,
struct tcf_exts *exts, bool ovr);
void tcf_exts_destroy(struct tcf_exts *exts);
void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
struct tcf_exts *src);
void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src);
int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts);
int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts);
int tcf_exts_get_dev(struct net_device *dev, struct tcf_exts *exts,
Expand Down
10 changes: 2 additions & 8 deletions net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,18 +883,12 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
}
EXPORT_SYMBOL(tcf_exts_validate);

void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
struct tcf_exts *src)
void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src)
{
#ifdef CONFIG_NET_CLS_ACT
struct tcf_exts old = *dst;

tcf_tree_lock(tp);
dst->nr_actions = src->nr_actions;
dst->actions = src->actions;
dst->type = src->type;
tcf_tree_unlock(tp);

*dst = *src;
tcf_exts_destroy(&old);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions net/sched/cls_rsvp.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb,
tcf_bind_filter(tp, &n->res, base);
}

tcf_exts_change(tp, &n->exts, &e);
tcf_exts_change(&n->exts, &e);
rsvp_replace(tp, n, handle);
return 0;
}
Expand Down Expand Up @@ -591,7 +591,7 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb,
if (f->tunnelhdr == 0)
tcf_bind_filter(tp, &f->res, base);

tcf_exts_change(tp, &f->exts, &e);
tcf_exts_change(&f->exts, &e);

fp = &s->ht[h2];
for (nfp = rtnl_dereference(*fp); nfp;
Expand Down
6 changes: 3 additions & 3 deletions net/sched/cls_tcindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
}

if (old_r)
tcf_exts_change(tp, &r->exts, &e);
tcf_exts_change(&r->exts, &e);
else
tcf_exts_change(tp, &cr.exts, &e);
tcf_exts_change(&cr.exts, &e);

if (old_r && old_r != r) {
err = tcindex_filter_result_init(old_r);
Expand All @@ -439,7 +439,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
struct tcindex_filter *nfp;
struct tcindex_filter __rcu **fp;

tcf_exts_change(tp, &f->result.exts, &r->exts);
tcf_exts_change(&f->result.exts, &r->exts);

fp = cp->h + (handle % cp->hash);
for (nfp = rtnl_dereference(*fp);
Expand Down

0 comments on commit 9b0d444

Please sign in to comment.