net/core/flow_offload.c
Source file repositories/reference/linux-study-clean/net/core/flow_offload.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/flow_offload.c- Extension
.c- Size
- 16626 bytes
- Lines
- 637
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/slab.hnet/act_api.hnet/flow_offload.hlinux/rtnetlink.hlinux/mutex.hlinux/rhashtable.h
Detected Declarations
struct flow_indr_devstruct flow_indir_dev_infofunction flow_rule_match_metafunction flow_rule_match_basicfunction flow_rule_match_controlfunction flow_rule_match_eth_addrsfunction flow_rule_match_vlanfunction flow_rule_match_cvlanfunction flow_rule_match_arpfunction flow_rule_match_ipv4_addrsfunction flow_rule_match_ipv6_addrsfunction flow_rule_match_ipfunction flow_rule_match_portsfunction flow_rule_match_ports_rangefunction flow_rule_match_tcpfunction flow_rule_match_ipsecfunction flow_rule_match_icmpfunction flow_rule_match_mplsfunction flow_rule_match_enc_controlfunction flow_rule_match_enc_ipv4_addrsfunction flow_rule_match_enc_ipv6_addrsfunction flow_rule_match_enc_ipfunction flow_rule_match_enc_portsfunction flow_rule_match_enc_keyidfunction flow_rule_match_enc_optsfunction flow_action_cookie_destroyfunction flow_rule_match_ctfunction flow_rule_match_pppoefunction flow_rule_match_l2tpv3function voidfunction flow_block_cb_freefunction list_for_each_entryfunction flow_block_cb_increffunction flow_block_cb_decreffunction flow_block_cb_is_busyfunction list_for_each_entryfunction flow_block_cb_setup_simplefunction existing_qdiscs_registerfunction list_for_each_entryfunction flow_indr_dev_registerfunction __flow_block_indr_cleanupfunction list_for_each_entry_safefunction flow_block_indr_notifyfunction list_for_each_entry_safefunction flow_indr_dev_unregisterfunction flow_block_indr_initfunction voidfunction list_for_each_entry
Annotated Snippet
struct flow_indr_dev {
struct list_head list;
flow_indr_block_bind_cb_t *cb;
void *cb_priv;
refcount_t refcnt;
};
static struct flow_indr_dev *flow_indr_dev_alloc(flow_indr_block_bind_cb_t *cb,
void *cb_priv)
{
struct flow_indr_dev *indr_dev;
indr_dev = kmalloc_obj(*indr_dev);
if (!indr_dev)
return NULL;
indr_dev->cb = cb;
indr_dev->cb_priv = cb_priv;
refcount_set(&indr_dev->refcnt, 1);
return indr_dev;
}
struct flow_indir_dev_info {
void *data;
struct net_device *dev;
struct Qdisc *sch;
enum tc_setup_type type;
void (*cleanup)(struct flow_block_cb *block_cb);
struct list_head list;
enum flow_block_command command;
enum flow_block_binder_type binder_type;
struct list_head *cb_list;
};
static void existing_qdiscs_register(flow_indr_block_bind_cb_t *cb, void *cb_priv)
{
struct flow_block_offload bo;
struct flow_indir_dev_info *cur;
list_for_each_entry(cur, &flow_indir_dev_list, list) {
memset(&bo, 0, sizeof(bo));
bo.command = cur->command;
bo.binder_type = cur->binder_type;
INIT_LIST_HEAD(&bo.cb_list);
cb(cur->dev, cur->sch, cb_priv, cur->type, &bo, cur->data, cur->cleanup);
list_splice(&bo.cb_list, cur->cb_list);
}
}
int flow_indr_dev_register(flow_indr_block_bind_cb_t *cb, void *cb_priv)
{
struct flow_indr_dev *indr_dev;
mutex_lock(&flow_indr_block_lock);
list_for_each_entry(indr_dev, &flow_block_indr_dev_list, list) {
if (indr_dev->cb == cb &&
indr_dev->cb_priv == cb_priv) {
refcount_inc(&indr_dev->refcnt);
mutex_unlock(&flow_indr_block_lock);
return 0;
}
}
indr_dev = flow_indr_dev_alloc(cb, cb_priv);
if (!indr_dev) {
mutex_unlock(&flow_indr_block_lock);
return -ENOMEM;
}
list_add(&indr_dev->list, &flow_block_indr_dev_list);
existing_qdiscs_register(cb, cb_priv);
mutex_unlock(&flow_indr_block_lock);
tcf_action_reoffload_cb(cb, cb_priv, true);
return 0;
}
EXPORT_SYMBOL(flow_indr_dev_register);
static void __flow_block_indr_cleanup(void (*release)(void *cb_priv),
void *cb_priv,
struct list_head *cleanup_list)
{
struct flow_block_cb *this, *next;
list_for_each_entry_safe(this, next, &flow_block_indr_list, indr.list) {
if (this->release == release &&
this->indr.cb_priv == cb_priv)
list_move(&this->indr.list, cleanup_list);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `net/act_api.h`, `net/flow_offload.h`, `linux/rtnetlink.h`, `linux/mutex.h`, `linux/rhashtable.h`.
- Detected declarations: `struct flow_indr_dev`, `struct flow_indir_dev_info`, `function flow_rule_match_meta`, `function flow_rule_match_basic`, `function flow_rule_match_control`, `function flow_rule_match_eth_addrs`, `function flow_rule_match_vlan`, `function flow_rule_match_cvlan`, `function flow_rule_match_arp`, `function flow_rule_match_ipv4_addrs`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.