net/netfilter/nf_flow_table_path.c
Source file repositories/reference/linux-study-clean/net/netfilter/nf_flow_table_path.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/nf_flow_table_path.c- Extension
.c- Size
- 9582 bytes
- Lines
- 351
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/init.hlinux/etherdevice.hlinux/netlink.hlinux/netfilter.hlinux/spinlock.hlinux/netfilter/nf_conntrack_common.hlinux/netfilter/nf_tables.hnet/ip.hnet/inet_dscp.hnet/netfilter/nf_tables.hnet/netfilter/nf_tables_core.hnet/netfilter/nf_conntrack_core.hnet/netfilter/nf_conntrack_extend.hnet/netfilter/nf_flow_table.h
Detected Declarations
struct nft_forward_infostruct idfunction nft_xmit_typefunction nft_default_forward_pathfunction nft_is_valid_ether_devicefunction nft_dev_fill_forward_pathfunction nft_dev_path_infofunction nft_flowtable_find_devfunction list_for_each_entry_rcufunction nft_flow_tunnel_update_routefunction nft_dev_forward_pathfunction nft_flow_routeexport nft_flow_route
Annotated Snippet
struct nft_forward_info {
const struct net_device *indev;
const struct net_device *outdev;
struct id {
__u16 id;
__be16 proto;
} encap[NF_FLOW_TABLE_ENCAP_MAX];
u8 num_encaps;
struct flow_offload_tunnel tun;
u8 num_tuns;
u8 ingress_vlans;
u8 h_source[ETH_ALEN];
u8 h_dest[ETH_ALEN];
bool needs_gso_segment;
enum flow_offload_xmit_type xmit_type;
};
static int nft_dev_path_info(const struct net_device_path_stack *stack,
struct nft_forward_info *info,
unsigned char *ha, struct nf_flowtable *flowtable)
{
const struct net_device_path *path;
int i;
memcpy(info->h_dest, ha, ETH_ALEN);
for (i = 0; i < stack->num_paths; i++) {
path = &stack->path[i];
switch (path->type) {
case DEV_PATH_ETHERNET:
case DEV_PATH_DSA:
case DEV_PATH_VLAN:
case DEV_PATH_PPPOE:
case DEV_PATH_TUN:
info->indev = path->dev;
if (is_zero_ether_addr(info->h_source))
memcpy(info->h_source, path->dev->dev_addr, ETH_ALEN);
if (path->type == DEV_PATH_ETHERNET)
break;
if (path->type == DEV_PATH_DSA) {
i = stack->num_paths;
break;
}
/* DEV_PATH_VLAN, DEV_PATH_PPPOE and DEV_PATH_TUN */
if (path->type == DEV_PATH_TUN) {
if (info->num_tuns)
return -1;
info->tun.src_v6 = path->tun.src_v6;
info->tun.dst_v6 = path->tun.dst_v6;
info->tun.l3_proto = path->tun.l3_proto;
info->num_tuns++;
} else {
if (info->num_encaps >= NF_FLOW_TABLE_ENCAP_MAX)
return -1;
info->encap[info->num_encaps].id =
path->encap.id;
info->encap[info->num_encaps].proto =
path->encap.proto;
info->num_encaps++;
}
if (path->type == DEV_PATH_PPPOE) {
memcpy(info->h_dest, path->encap.h_dest, ETH_ALEN);
info->xmit_type = FLOW_OFFLOAD_XMIT_DIRECT;
info->needs_gso_segment = 1;
}
break;
case DEV_PATH_BRIDGE:
if (is_zero_ether_addr(info->h_source))
memcpy(info->h_source, path->dev->dev_addr, ETH_ALEN);
switch (path->bridge.vlan_mode) {
case DEV_PATH_BR_VLAN_UNTAG_HW:
if (info->num_encaps == 0)
return -1;
info->ingress_vlans |= BIT(info->num_encaps - 1);
break;
case DEV_PATH_BR_VLAN_TAG:
if (info->num_encaps >= NF_FLOW_TABLE_ENCAP_MAX)
return -1;
info->encap[info->num_encaps].id = path->bridge.vlan_id;
info->encap[info->num_encaps].proto = path->bridge.vlan_proto;
info->num_encaps++;
break;
case DEV_PATH_BR_VLAN_UNTAG:
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/etherdevice.h`, `linux/netlink.h`, `linux/netfilter.h`, `linux/spinlock.h`, `linux/netfilter/nf_conntrack_common.h`.
- Detected declarations: `struct nft_forward_info`, `struct id`, `function nft_xmit_type`, `function nft_default_forward_path`, `function nft_is_valid_ether_device`, `function nft_dev_fill_forward_path`, `function nft_dev_path_info`, `function nft_flowtable_find_dev`, `function list_for_each_entry_rcu`, `function nft_flow_tunnel_update_route`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.