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

Commit 720f22fe authored by John Hurley's avatar John Hurley Committed by David S. Miller
Browse files

net: sched: refactor reinsert action



The TC_ACT_REINSERT return type was added as an in-kernel only option to
allow a packet ingress or egress redirect. This is used to avoid
unnecessary skb clones in situations where they are not required. If a TC
hook returns this code then the packet is 'reinserted' and no skb consume
is carried out as no clone took place.

This return type is only used in act_mirred. Rather than have the reinsert
called from the main datapath, call it directly in act_mirred. Instead of
returning TC_ACT_REINSERT, change the type to the new TC_ACT_CONSUMED
which tells the caller that the packet has been stolen by another process
and that no consume call is required.

Moving all redirect calls to the act_mirred code is in preparation for
tracking recursion created by act_mirred.

Signed-off-by: default avatarJohn Hurley <john.hurley@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5cdda5f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
#include <net/net_namespace.h>

/* TC action not accessible from user space */
#define TC_ACT_REINSERT		(TC_ACT_VALUE_MAX + 1)
#define TC_ACT_CONSUMED		(TC_ACT_VALUE_MAX + 1)

/* Basic packet classifier frontend definitions. */

+1 −1
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ struct tcf_result {
		};
		const struct tcf_proto *goto_tp;

		/* used by the TC_ACT_REINSERT action */
		/* used in the skb_tc_reinsert function */
		struct {
			bool		ingress;
			struct gnet_stats_queue *qstats;
+1 −3
Original line number Diff line number Diff line
@@ -4689,9 +4689,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
		__skb_push(skb, skb->mac_len);
		skb_do_redirect(skb);
		return NULL;
	case TC_ACT_REINSERT:
		/* this does not scrub the packet, and updates stats on error */
		skb_tc_reinsert(skb, &cl_res);
	case TC_ACT_CONSUMED:
		return NULL;
	default:
		break;
+2 −1
Original line number Diff line number Diff line
@@ -277,7 +277,8 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
		if (use_reinsert) {
			res->ingress = want_ingress;
			res->qstats = this_cpu_ptr(m->common.cpu_qstats);
			return TC_ACT_REINSERT;
			skb_tc_reinsert(skb, res);
			return TC_ACT_CONSUMED;
		}
	}