net/ipv6/fib6_rules.c
Source file repositories/reference/linux-study-clean/net/ipv6/fib6_rules.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/fib6_rules.c- Extension
.c- Size
- 16306 bytes
- Lines
- 667
- 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/netdevice.hlinux/notifier.hlinux/export.hlinux/indirect_call_wrapper.hnet/fib_rules.hnet/inet_dscp.hnet/ipv6.hnet/addrconf.hnet/ip6_route.hnet/netlink.h
Detected Declarations
struct fib6_rulefunction fib6_rule_matchallfunction fib6_rule_defaultfunction fib6_rules_dumpfunction fib6_rules_seq_readfunction fib6_lookupfunction fib6_rule_saddrfunction fib6_rule_action_altfunction __fib6_rule_actionfunction fib6_rule_actionfunction fib6_rule_suppressfunction fib6_rule_matchfunction fib6_nl2rule_dscpfunction fib6_nl2rule_dscp_maskfunction fib6_nl2rule_flowlabelfunction fib6_rule_configurefunction fib6_rule_deletefunction fib6_rule_comparefunction fib6_rule_fillfunction fib6_rule_nlmsg_payloadfunction fib6_rule_flush_cachefunction fib6_rules_net_initfunction fib6_rules_net_exit_batchfunction fib6_rules_initfunction fib6_rules_cleanupexport fib6_rule_defaultexport fib6_lookup
Annotated Snippet
struct fib6_rule {
struct fib_rule common;
struct rt6key src;
struct rt6key dst;
__be32 flowlabel;
__be32 flowlabel_mask;
dscp_t dscp;
dscp_t dscp_mask;
u8 dscp_full:1; /* DSCP or TOS selector */
};
static bool fib6_rule_matchall(const struct fib_rule *rule)
{
struct fib6_rule *r = container_of(rule, struct fib6_rule, common);
if (r->dst.plen || r->src.plen || r->dscp || r->flowlabel_mask)
return false;
return fib_rule_matchall(rule);
}
bool fib6_rule_default(const struct fib_rule *rule)
{
if (!fib6_rule_matchall(rule) || rule->action != FR_ACT_TO_TBL ||
rule->l3mdev)
return false;
if (rule->table != RT6_TABLE_LOCAL && rule->table != RT6_TABLE_MAIN)
return false;
return true;
}
EXPORT_SYMBOL_GPL(fib6_rule_default);
int fib6_rules_dump(struct net *net, struct notifier_block *nb,
struct netlink_ext_ack *extack)
{
return fib_rules_dump(net, nb, AF_INET6, extack);
}
unsigned int fib6_rules_seq_read(const struct net *net)
{
return fib_rules_seq_read(net, AF_INET6);
}
/* called with rcu lock held; no reference taken on fib6_info */
int fib6_lookup(struct net *net, int oif, struct flowi6 *fl6,
struct fib6_result *res, int flags)
{
int err;
if (net->ipv6.fib6_has_custom_rules) {
struct fib_lookup_arg arg = {
.lookup_ptr = fib6_table_lookup,
.lookup_data = &oif,
.result = res,
.flags = FIB_LOOKUP_NOREF,
};
l3mdev_update_flow(net, flowi6_to_flowi(fl6));
err = fib_rules_lookup(net->ipv6.fib6_rules_ops,
flowi6_to_flowi(fl6), flags, &arg);
} else {
err = fib6_table_lookup(net, net->ipv6.fib6_local_tbl, oif,
fl6, res, flags);
if (err || res->f6i == net->ipv6.fib6_null_entry)
err = fib6_table_lookup(net, net->ipv6.fib6_main_tbl,
oif, fl6, res, flags);
}
return err;
}
#if IS_MODULE(CONFIG_NFT_FIB_IPV6)
EXPORT_SYMBOL_GPL(fib6_lookup);
#endif
struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
const struct sk_buff *skb,
int flags, pol_lookup_t lookup)
{
if (net->ipv6.fib6_has_custom_rules) {
struct fib6_result res = {};
struct fib_lookup_arg arg = {
.lookup_ptr = lookup,
.lookup_data = skb,
.result = &res,
.flags = FIB_LOOKUP_NOREF,
};
/* update flow if oif or iif point to device enslaved to l3mdev */
l3mdev_update_flow(net, flowi6_to_flowi(fl6));
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/notifier.h`, `linux/export.h`, `linux/indirect_call_wrapper.h`, `net/fib_rules.h`, `net/inet_dscp.h`, `net/ipv6.h`, `net/addrconf.h`.
- Detected declarations: `struct fib6_rule`, `function fib6_rule_matchall`, `function fib6_rule_default`, `function fib6_rules_dump`, `function fib6_rules_seq_read`, `function fib6_lookup`, `function fib6_rule_saddr`, `function fib6_rule_action_alt`, `function __fib6_rule_action`, `function fib6_rule_action`.
- 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.