Skip to content

Commit

Permalink
sched: move tcf_proto_destroy and tcf_destroy_chain helpers into cls_api
Browse files Browse the repository at this point in the history
Creation is done in this file, move destruction to be at the same place.

Signed-off-by: Jiri Pirko <[email protected]>
Acked-by: Jamal Hadi Salim <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jpirko authored and davem330 committed Feb 10, 2017
1 parent 79112c2 commit cf1facd
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 26 deletions.
2 changes: 2 additions & 0 deletions include/net/pkt_cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct tcf_walker {
int register_tcf_proto_ops(struct tcf_proto_ops *ops);
int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);

void tcf_destroy_chain(struct tcf_proto __rcu **fl);

static inline unsigned long
__cls_set_class(unsigned long *clp, unsigned long cl)
{
Expand Down
2 changes: 0 additions & 2 deletions include/net/sch_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,6 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
const struct Qdisc_ops *ops, u32 parentid);
void __qdisc_calculate_pkt_len(struct sk_buff *skb,
const struct qdisc_size_table *stab);
bool tcf_proto_destroy(struct tcf_proto *tp, bool force);
void tcf_destroy_chain(struct tcf_proto __rcu **fl);
int skb_do_redirect(struct sk_buff *);

static inline void skb_reset_tc(struct sk_buff *skb)
Expand Down
21 changes: 21 additions & 0 deletions net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ static inline u32 tcf_auto_prio(struct tcf_proto *tp)
return first;
}

static bool tcf_proto_destroy(struct tcf_proto *tp, bool force)
{
if (tp->ops->destroy(tp, force)) {
module_put(tp->ops->owner);
kfree_rcu(tp, rcu);
return true;
}
return false;
}

void tcf_destroy_chain(struct tcf_proto __rcu **fl)
{
struct tcf_proto *tp;

while ((tp = rtnl_dereference(*fl)) != NULL) {
RCU_INIT_POINTER(*fl, tp->next);
tcf_proto_destroy(tp, true);
}
}
EXPORT_SYMBOL(tcf_destroy_chain);

/* Add/change/delete/get a filter node */

static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
Expand Down
22 changes: 0 additions & 22 deletions net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1900,28 +1900,6 @@ int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
}
EXPORT_SYMBOL(tc_classify);

bool tcf_proto_destroy(struct tcf_proto *tp, bool force)
{
if (tp->ops->destroy(tp, force)) {
module_put(tp->ops->owner);
kfree_rcu(tp, rcu);
return true;
}

return false;
}

void tcf_destroy_chain(struct tcf_proto __rcu **fl)
{
struct tcf_proto *tp;

while ((tp = rtnl_dereference(*fl)) != NULL) {
RCU_INIT_POINTER(*fl, tp->next);
tcf_proto_destroy(tp, true);
}
}
EXPORT_SYMBOL(tcf_destroy_chain);

#ifdef CONFIG_PROC_FS
static int psched_show(struct seq_file *seq, void *v)
{
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_atm.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/file.h> /* for fput */
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>

/*
* The ATM queuing discipline provides a framework for invoking classifiers
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_cbq.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/skbuff.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>


/* Class-Based Queueing (CBQ) algorithm.
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_choke.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/skbuff.h>
#include <linux/vmalloc.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
#include <net/inet_ecn.h>
#include <net/red.h>
#include <net/flow_dissector.h>
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_dsmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/rtnetlink.h>
#include <linux/bitops.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
#include <net/dsfield.h>
#include <net/inet_ecn.h>
#include <asm/byteorder.h>
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_fq_codel.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/vmalloc.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
#include <net/codel.h>
#include <net/codel_impl.h>
#include <net/codel_qdisc.h>
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_htb.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <net/netlink.h>
#include <net/sch_generic.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>

/* HTB algorithm.
Author: [email protected]
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_ingress.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>

static struct Qdisc *ingress_leaf(struct Qdisc *sch, unsigned long arg)
{
Expand Down
2 changes: 1 addition & 1 deletion net/sched/sch_multiq.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <linux/skbuff.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>

#include <net/pkt_cls.h>

struct multiq_sched_data {
u16 bands;
Expand Down
2 changes: 1 addition & 1 deletion net/sched/sch_prio.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <linux/skbuff.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>

#include <net/pkt_cls.h>

struct prio_sched_data {
int bands;
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_sfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/jhash.h>
#include <net/ip.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
#include <net/inet_ecn.h>

/*
Expand Down
1 change: 1 addition & 0 deletions net/sched/sch_sfq.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/vmalloc.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
#include <net/red.h>


Expand Down

0 comments on commit cf1facd

Please sign in to comment.