include/net/tc_wrapper.h

Source file repositories/reference/linux-study-clean/include/net/tc_wrapper.h

File Facts

System
Linux kernel
Corpus path
include/net/tc_wrapper.h
Extension
.h
Size
7660 bytes
Lines
270
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef __NET_TC_WRAPPER_H
#define __NET_TC_WRAPPER_H

#include <net/pkt_cls.h>

#if IS_ENABLED(CONFIG_MITIGATION_RETPOLINE)

#include <linux/cpufeature.h>
#include <linux/static_key.h>
#include <linux/indirect_call_wrapper.h>

#define TC_INDIRECT_SCOPE

extern struct static_key_false tc_skip_wrapper_act;
extern struct static_key_false tc_skip_wrapper_cls;

/* TC Actions */
#ifdef CONFIG_NET_CLS_ACT

#define TC_INDIRECT_ACTION_DECLARE(fname)                              \
	INDIRECT_CALLABLE_DECLARE(int fname(struct sk_buff *skb,       \
					    const struct tc_action *a, \
					    struct tcf_result *res))

TC_INDIRECT_ACTION_DECLARE(tcf_bpf_act);
TC_INDIRECT_ACTION_DECLARE(tcf_connmark_act);
TC_INDIRECT_ACTION_DECLARE(tcf_csum_act);
TC_INDIRECT_ACTION_DECLARE(tcf_ct_act);
TC_INDIRECT_ACTION_DECLARE(tcf_ctinfo_act);
TC_INDIRECT_ACTION_DECLARE(tcf_gact_act);
TC_INDIRECT_ACTION_DECLARE(tcf_gate_act);
TC_INDIRECT_ACTION_DECLARE(tcf_ife_act);
TC_INDIRECT_ACTION_DECLARE(tcf_ipt_act);
TC_INDIRECT_ACTION_DECLARE(tcf_mirred_act);
TC_INDIRECT_ACTION_DECLARE(tcf_mpls_act);
TC_INDIRECT_ACTION_DECLARE(tcf_nat_act);
TC_INDIRECT_ACTION_DECLARE(tcf_pedit_act);
TC_INDIRECT_ACTION_DECLARE(tcf_police_act);
TC_INDIRECT_ACTION_DECLARE(tcf_sample_act);
TC_INDIRECT_ACTION_DECLARE(tcf_simp_act);
TC_INDIRECT_ACTION_DECLARE(tcf_skbedit_act);
TC_INDIRECT_ACTION_DECLARE(tcf_skbmod_act);
TC_INDIRECT_ACTION_DECLARE(tcf_vlan_act);
TC_INDIRECT_ACTION_DECLARE(tunnel_key_act);

static inline int tc_act(struct sk_buff *skb, const struct tc_action *a,
			   struct tcf_result *res)
{
	if (static_branch_likely(&tc_skip_wrapper_act))
		goto skip;

#if IS_BUILTIN(CONFIG_NET_ACT_GACT)
	if (a->ops->act == tcf_gact_act)
		return tcf_gact_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_MIRRED)
	if (a->ops->act == tcf_mirred_act)
		return tcf_mirred_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_PEDIT)
	if (a->ops->act == tcf_pedit_act)
		return tcf_pedit_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_SKBEDIT)
	if (a->ops->act == tcf_skbedit_act)
		return tcf_skbedit_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_SKBMOD)
	if (a->ops->act == tcf_skbmod_act)
		return tcf_skbmod_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_POLICE)
	if (a->ops->act == tcf_police_act)
		return tcf_police_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_BPF)
	if (a->ops->act == tcf_bpf_act)
		return tcf_bpf_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_CONNMARK)
	if (a->ops->act == tcf_connmark_act)
		return tcf_connmark_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_CSUM)
	if (a->ops->act == tcf_csum_act)
		return tcf_csum_act(skb, a, res);
#endif
#if IS_BUILTIN(CONFIG_NET_ACT_CT)
	if (a->ops->act == tcf_ct_act)
		return tcf_ct_act(skb, a, res);

Annotation

Implementation Notes