net/core/dst.c
Source file repositories/reference/linux-study-clean/net/core/dst.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/dst.c- Extension
.c- Size
- 8892 bytes
- Lines
- 356
- 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.
- 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/bitops.hlinux/errno.hlinux/init.hlinux/kernel.hlinux/workqueue.hlinux/mm.hlinux/module.hlinux/slab.hlinux/netdevice.hlinux/skbuff.hlinux/string.hlinux/types.hnet/net_namespace.hlinux/sched.hlinux/prefetch.hnet/lwtunnel.hnet/xfrm.hnet/dst.hnet/dst_metadata.h
Detected Declarations
function dst_discard_outfunction dst_initfunction dst_destroyfunction dst_destroy_rcufunction dst_dev_putfunction dst_count_decfunction dst_releasefunction dst_release_immediatefunction __dst_destroy_metrics_genericfunction dst_blackhole_update_pmtufunction dst_blackhole_redirectfunction dst_blackhole_mtufunction __metadata_dst_initfunction metadata_dst_freefunction metadata_dst_alloc_percpufunction metadata_dst_free_percpufunction for_each_possible_cpuexport dst_discard_outexport dst_default_metricsexport dst_initexport dst_allocexport dst_dev_putexport dst_releaseexport dst_release_immediateexport dst_cow_metrics_genericexport __dst_destroy_metrics_genericexport dst_blackhole_update_pmtuexport dst_blackhole_redirectexport dst_blackhole_mtuexport metadata_dst_allocexport metadata_dst_freeexport metadata_dst_alloc_percpuexport metadata_dst_free_percpu
Annotated Snippet
if (dst->flags & DST_METADATA) {
struct metadata_dst *md_dst = (struct metadata_dst *)dst;
if (md_dst->type == METADATA_IP_TUNNEL)
dst_cache_reset_now(&md_dst->u.tun_info.dst_cache);
}
#endif
dst_count_dec(dst);
call_rcu_hurry(&dst->rcu_head, dst_destroy_rcu);
}
}
EXPORT_SYMBOL(dst_release);
void dst_release_immediate(struct dst_entry *dst)
{
if (dst && rcuref_put(&dst->__rcuref)) {
dst_count_dec(dst);
dst_destroy(dst);
}
}
EXPORT_SYMBOL(dst_release_immediate);
u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old)
{
struct dst_metrics *p = kmalloc_obj(*p, GFP_ATOMIC);
if (p) {
struct dst_metrics *old_p = (struct dst_metrics *)__DST_METRICS_PTR(old);
unsigned long prev, new;
refcount_set(&p->refcnt, 1);
memcpy(p->metrics, old_p->metrics, sizeof(p->metrics));
new = (unsigned long) p;
prev = cmpxchg(&dst->_metrics, old, new);
if (prev != old) {
kfree(p);
p = (struct dst_metrics *)__DST_METRICS_PTR(prev);
if (prev & DST_METRICS_READ_ONLY)
p = NULL;
} else if (prev & DST_METRICS_REFCOUNTED) {
if (refcount_dec_and_test(&old_p->refcnt))
kfree(old_p);
}
}
BUILD_BUG_ON(offsetof(struct dst_metrics, metrics) != 0);
return (u32 *)p;
}
EXPORT_SYMBOL(dst_cow_metrics_generic);
/* Caller asserts that dst_metrics_read_only(dst) is false. */
void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old)
{
unsigned long prev, new;
new = ((unsigned long) &dst_default_metrics) | DST_METRICS_READ_ONLY;
prev = cmpxchg(&dst->_metrics, old, new);
if (prev == old)
kfree(__DST_METRICS_PTR(old));
}
EXPORT_SYMBOL(__dst_destroy_metrics_generic);
struct dst_entry *dst_blackhole_check(struct dst_entry *dst, u32 cookie)
{
return NULL;
}
u32 *dst_blackhole_cow_metrics(struct dst_entry *dst, unsigned long old)
{
return NULL;
}
struct neighbour *dst_blackhole_neigh_lookup(const struct dst_entry *dst,
struct sk_buff *skb,
const void *daddr)
{
return NULL;
}
void dst_blackhole_update_pmtu(struct dst_entry *dst, struct sock *sk,
struct sk_buff *skb, u32 mtu,
bool confirm_neigh)
{
}
EXPORT_SYMBOL_GPL(dst_blackhole_update_pmtu);
void dst_blackhole_redirect(struct dst_entry *dst, struct sock *sk,
struct sk_buff *skb)
{
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/errno.h`, `linux/init.h`, `linux/kernel.h`, `linux/workqueue.h`, `linux/mm.h`, `linux/module.h`, `linux/slab.h`.
- Detected declarations: `function dst_discard_out`, `function dst_init`, `function dst_destroy`, `function dst_destroy_rcu`, `function dst_dev_put`, `function dst_count_dec`, `function dst_release`, `function dst_release_immediate`, `function __dst_destroy_metrics_generic`, `function dst_blackhole_update_pmtu`.
- 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.