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

Commit 87d83093 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

net: sched: move tc_classify function to cls_api.c



Move tc_classify function to cls_api.c where it belongs, rename it to
fit the namespace.

Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c63fbb0b
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -19,10 +19,19 @@ int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);


#ifdef CONFIG_NET_CLS
#ifdef CONFIG_NET_CLS
void tcf_destroy_chain(struct tcf_proto __rcu **fl);
void tcf_destroy_chain(struct tcf_proto __rcu **fl);
int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
		 struct tcf_result *res, bool compat_mode);

#else
#else
static inline void tcf_destroy_chain(struct tcf_proto __rcu **fl)
static inline void tcf_destroy_chain(struct tcf_proto __rcu **fl)
{
{
}
}

static inline int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
			       struct tcf_result *res, bool compat_mode)
{
	return TC_ACT_UNSPEC;
}
#endif
#endif


static inline unsigned long
static inline unsigned long
+0 −3
Original line number Original line Diff line number Diff line
@@ -113,9 +113,6 @@ static inline void qdisc_run(struct Qdisc *q)
		__qdisc_run(q);
		__qdisc_run(q);
}
}


int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
		struct tcf_result *res, bool compat_mode);

static inline __be16 tc_skb_protocol(const struct sk_buff *skb)
static inline __be16 tc_skb_protocol(const struct sk_buff *skb)
{
{
	/* We need to take extra care in case the skb came via
	/* We need to take extra care in case the skb came via
+3 −2
Original line number Original line Diff line number Diff line
@@ -105,6 +105,7 @@
#include <net/dst.h>
#include <net/dst.h>
#include <net/dst_metadata.h>
#include <net/dst_metadata.h>
#include <net/pkt_sched.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
#include <net/checksum.h>
#include <net/checksum.h>
#include <net/xfrm.h>
#include <net/xfrm.h>
#include <linux/highmem.h>
#include <linux/highmem.h>
@@ -3178,7 +3179,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
	/* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */
	/* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */
	qdisc_bstats_cpu_update(cl->q, skb);
	qdisc_bstats_cpu_update(cl->q, skb);


	switch (tc_classify(skb, cl, &cl_res, false)) {
	switch (tcf_classify(skb, cl, &cl_res, false)) {
	case TC_ACT_OK:
	case TC_ACT_OK:
	case TC_ACT_RECLASSIFY:
	case TC_ACT_RECLASSIFY:
		skb->tc_index = TC_H_MIN(cl_res.classid);
		skb->tc_index = TC_H_MIN(cl_res.classid);
@@ -3948,7 +3949,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
	skb->tc_at_ingress = 1;
	skb->tc_at_ingress = 1;
	qdisc_bstats_cpu_update(cl->q, skb);
	qdisc_bstats_cpu_update(cl->q, skb);


	switch (tc_classify(skb, cl, &cl_res, false)) {
	switch (tcf_classify(skb, cl, &cl_res, false)) {
	case TC_ACT_OK:
	case TC_ACT_OK:
	case TC_ACT_RECLASSIFY:
	case TC_ACT_RECLASSIFY:
		skb->tc_index = TC_H_MIN(cl_res.classid);
		skb->tc_index = TC_H_MIN(cl_res.classid);
+48 −0
Original line number Original line Diff line number Diff line
@@ -196,6 +196,54 @@ void tcf_destroy_chain(struct tcf_proto __rcu **fl)
}
}
EXPORT_SYMBOL(tcf_destroy_chain);
EXPORT_SYMBOL(tcf_destroy_chain);


/* Main classifier routine: scans classifier chain attached
 * to this qdisc, (optionally) tests for protocol and asks
 * specific classifiers.
 */
int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
		 struct tcf_result *res, bool compat_mode)
{
	__be16 protocol = tc_skb_protocol(skb);
#ifdef CONFIG_NET_CLS_ACT
	const int max_reclassify_loop = 4;
	const struct tcf_proto *old_tp = tp;
	int limit = 0;

reclassify:
#endif
	for (; tp; tp = rcu_dereference_bh(tp->next)) {
		int err;

		if (tp->protocol != protocol &&
		    tp->protocol != htons(ETH_P_ALL))
			continue;

		err = tp->classify(skb, tp, res);
#ifdef CONFIG_NET_CLS_ACT
		if (unlikely(err == TC_ACT_RECLASSIFY && !compat_mode))
			goto reset;
#endif
		if (err >= 0)
			return err;
	}

	return TC_ACT_UNSPEC; /* signal: continue lookup */
#ifdef CONFIG_NET_CLS_ACT
reset:
	if (unlikely(limit++ >= max_reclassify_loop)) {
		net_notice_ratelimited("%s: reclassify loop, rule prio %u, protocol %02x\n",
				       tp->q->ops->id, tp->prio & 0xffff,
				       ntohs(tp->protocol));
		return TC_ACT_SHOT;
	}

	tp = old_tp;
	protocol = tc_skb_protocol(skb);
	goto reclassify;
#endif
}
EXPORT_SYMBOL(tcf_classify);

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


static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
+0 −48
Original line number Original line Diff line number Diff line
@@ -1878,54 +1878,6 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
	return skb->len;
	return skb->len;
}
}


/* Main classifier routine: scans classifier chain attached
 * to this qdisc, (optionally) tests for protocol and asks
 * specific classifiers.
 */
int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp,
		struct tcf_result *res, bool compat_mode)
{
	__be16 protocol = tc_skb_protocol(skb);
#ifdef CONFIG_NET_CLS_ACT
	const int max_reclassify_loop = 4;
	const struct tcf_proto *old_tp = tp;
	int limit = 0;

reclassify:
#endif
	for (; tp; tp = rcu_dereference_bh(tp->next)) {
		int err;

		if (tp->protocol != protocol &&
		    tp->protocol != htons(ETH_P_ALL))
			continue;

		err = tp->classify(skb, tp, res);
#ifdef CONFIG_NET_CLS_ACT
		if (unlikely(err == TC_ACT_RECLASSIFY && !compat_mode))
			goto reset;
#endif
		if (err >= 0)
			return err;
	}

	return TC_ACT_UNSPEC; /* signal: continue lookup */
#ifdef CONFIG_NET_CLS_ACT
reset:
	if (unlikely(limit++ >= max_reclassify_loop)) {
		net_notice_ratelimited("%s: reclassify loop, rule prio %u, protocol %02x\n",
				       tp->q->ops->id, tp->prio & 0xffff,
				       ntohs(tp->protocol));
		return TC_ACT_SHOT;
	}

	tp = old_tp;
	protocol = tc_skb_protocol(skb);
	goto reclassify;
#endif
}
EXPORT_SYMBOL(tc_classify);

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS
static int psched_show(struct seq_file *seq, void *v)
static int psched_show(struct seq_file *seq, void *v)
{
{
Loading