include/net/act_api.h
Source file repositories/reference/linux-study-clean/include/net/act_api.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/act_api.h- Extension
.h- Size
- 9572 bytes
- Lines
- 302
- 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.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/refcount.hnet/flow_offload.hnet/sch_generic.hnet/pkt_sched.hnet/net_namespace.hnet/netns/generic.h
Detected Declarations
struct tcf_idrinfostruct tc_action_opsstruct tc_actionstruct tc_action_opsstruct tc_action_netfunction tcf_lastuse_updatefunction tcf_tm_dumpfunction tc_act_hw_statsfunction tc_action_net_initfunction tc_action_net_exitfunction list_for_each_entryfunction tcf_action_update_bstatsfunction tcf_action_inc_drop_qstatsfunction tcf_action_inc_overlimit_qstatsfunction tcf_action_reoffload_cbfunction tcf_action_stats_update
Annotated Snippet
struct tcf_idrinfo {
struct mutex lock;
struct idr action_idr;
struct net *net;
};
struct tc_action_ops;
struct tc_action {
const struct tc_action_ops *ops;
__u32 type; /* for backward compat(TCA_OLD_COMPAT) */
struct tcf_idrinfo *idrinfo;
u32 tcfa_index;
refcount_t tcfa_refcnt;
atomic_t tcfa_bindcnt;
int tcfa_action;
struct tcf_t tcfa_tm;
struct gnet_stats_basic_sync tcfa_bstats;
struct gnet_stats_basic_sync tcfa_bstats_hw;
atomic_t tcfa_drops;
atomic_t tcfa_overlimits;
struct net_rate_estimator __rcu *tcfa_rate_est;
spinlock_t tcfa_lock;
struct gnet_stats_basic_sync __percpu *cpu_bstats;
struct gnet_stats_basic_sync __percpu *cpu_bstats_hw;
struct gnet_stats_queue __percpu *cpu_qstats;
struct tc_cookie __rcu *user_cookie;
struct tcf_chain __rcu *goto_chain;
u32 tcfa_flags;
struct rcu_head tcfa_rcu;
u8 hw_stats;
u8 used_hw_stats;
bool used_hw_stats_valid;
u32 in_hw_count;
};
#define tcf_index common.tcfa_index
#define tcf_refcnt common.tcfa_refcnt
#define tcf_bindcnt common.tcfa_bindcnt
#define tcf_action common.tcfa_action
#define tcf_tm common.tcfa_tm
#define tcf_bstats common.tcfa_bstats
#define tcf_rate_est common.tcfa_rate_est
#define tcf_lock common.tcfa_lock
#define TCA_ACT_HW_STATS_ANY (TCA_ACT_HW_STATS_IMMEDIATE | \
TCA_ACT_HW_STATS_DELAYED)
/* Reserve 16 bits for user-space. See TCA_ACT_FLAGS_NO_PERCPU_STATS. */
#define TCA_ACT_FLAGS_USER_BITS 16
#define TCA_ACT_FLAGS_USER_MASK 0xffff
#define TCA_ACT_FLAGS_POLICE (1U << TCA_ACT_FLAGS_USER_BITS)
#define TCA_ACT_FLAGS_BIND (1U << (TCA_ACT_FLAGS_USER_BITS + 1))
#define TCA_ACT_FLAGS_REPLACE (1U << (TCA_ACT_FLAGS_USER_BITS + 2))
#define TCA_ACT_FLAGS_NO_RTNL (1U << (TCA_ACT_FLAGS_USER_BITS + 3))
#define TCA_ACT_FLAGS_AT_INGRESS (1U << (TCA_ACT_FLAGS_USER_BITS + 4))
#define TCA_ACT_FLAGS_AT_INGRESS_OR_CLSACT (1U << (TCA_ACT_FLAGS_USER_BITS + 5))
/* Update lastuse only if needed, to avoid dirtying a cache line.
* We use a temp variable to avoid fetching jiffies twice.
*/
static inline void tcf_lastuse_update(struct tcf_t *tm)
{
unsigned long now = jiffies;
if (READ_ONCE(tm->lastuse) != now)
WRITE_ONCE(tm->lastuse, now);
if (unlikely(!READ_ONCE(tm->firstuse)))
WRITE_ONCE(tm->firstuse, now);
}
static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm)
{
unsigned long firstuse, now = jiffies;
dtm->install = jiffies_to_clock_t(now - READ_ONCE(stm->install));
dtm->lastuse = jiffies_to_clock_t(now - READ_ONCE(stm->lastuse));
firstuse = READ_ONCE(stm->firstuse);
dtm->firstuse = firstuse ?
jiffies_to_clock_t(now - firstuse) : 0;
dtm->expires = jiffies_to_clock_t(READ_ONCE(stm->expires));
}
static inline enum flow_action_hw_stats tc_act_hw_stats(u8 hw_stats)
{
if (WARN_ON_ONCE(hw_stats > TCA_ACT_HW_STATS_ANY))
Annotation
- Immediate include surface: `linux/refcount.h`, `net/flow_offload.h`, `net/sch_generic.h`, `net/pkt_sched.h`, `net/net_namespace.h`, `net/netns/generic.h`.
- Detected declarations: `struct tcf_idrinfo`, `struct tc_action_ops`, `struct tc_action`, `struct tc_action_ops`, `struct tc_action_net`, `function tcf_lastuse_update`, `function tcf_tm_dump`, `function tc_act_hw_stats`, `function tc_action_net_init`, `function tc_action_net_exit`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.