net/ipv6/xfrm6_policy.c
Source file repositories/reference/linux-study-clean/net/ipv6/xfrm6_policy.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/xfrm6_policy.c- Extension
.c- Size
- 7194 bytes
- Lines
- 322
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/kernel.hlinux/netdevice.hnet/addrconf.hnet/dst.hnet/xfrm.hnet/ip.hnet/ipv6.hnet/ip6_route.hnet/l3mdev.h
Detected Declarations
function xfrm6_get_saddrfunction xfrm6_fill_dstfunction xfrm6_update_pmtufunction xfrm6_redirectfunction xfrm6_dst_destroyfunction xfrm6_dst_ifdownfunction xfrm6_policy_initfunction xfrm6_policy_finifunction xfrm6_net_sysctl_initfunction xfrm6_net_sysctl_exitfunction xfrm6_net_sysctl_initfunction xfrm6_net_sysctl_exitfunction xfrm6_net_exitfunction xfrm6_initfunction xfrm6_fini
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* xfrm6_policy.c: based on xfrm4_policy.c
*
* Authors:
* Mitsuru KANDA @USAGI
* Kazunori MIYAZAWA @USAGI
* Kunihiro Ishiguro <kunihiro@ipinfusion.com>
* IPv6 support
* YOSHIFUJI Hideaki
* Split up af-specific portion
*
*/
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <net/addrconf.h>
#include <net/dst.h>
#include <net/xfrm.h>
#include <net/ip.h>
#include <net/ipv6.h>
#include <net/ip6_route.h>
#include <net/l3mdev.h>
static struct dst_entry *xfrm6_dst_lookup(const struct xfrm_dst_lookup_params *params)
{
struct flowi6 fl6;
struct dst_entry *dst;
int err;
memset(&fl6, 0, sizeof(fl6));
fl6.flowi6_l3mdev = l3mdev_master_ifindex_by_index(params->net,
params->oif);
fl6.flowi6_mark = params->mark;
memcpy(&fl6.daddr, params->daddr, sizeof(fl6.daddr));
if (params->saddr)
memcpy(&fl6.saddr, params->saddr, sizeof(fl6.saddr));
fl6.flowi4_proto = params->ipproto;
fl6.uli = params->uli;
dst = ip6_route_output(params->net, NULL, &fl6);
err = dst->error;
if (dst->error) {
dst_release(dst);
dst = ERR_PTR(err);
}
return dst;
}
static int xfrm6_get_saddr(xfrm_address_t *saddr,
const struct xfrm_dst_lookup_params *params)
{
struct dst_entry *dst;
struct net_device *dev;
struct inet6_dev *idev;
int err;
dst = xfrm6_dst_lookup(params);
if (IS_ERR(dst))
return -EHOSTUNREACH;
idev = ip6_dst_idev(dst);
if (!idev) {
dst_release(dst);
return -EHOSTUNREACH;
}
dev = idev->dev;
err = ipv6_dev_get_saddr(dev_net(dev), dev, ¶ms->daddr->in6, 0,
&saddr->in6);
dst_release(dst);
if (err)
return -EHOSTUNREACH;
return 0;
}
static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
const struct flowi *fl)
{
struct rt6_info *rt = dst_rt6_info(xdst->route);
xdst->u.dst.dev = dev;
netdev_hold(dev, &xdst->u.dst.dev_tracker, GFP_ATOMIC);
xdst->u.rt6.rt6i_idev = in6_dev_get(dev);
if (!xdst->u.rt6.rt6i_idev) {
netdev_put(dev, &xdst->u.dst.dev_tracker);
Annotation
- Immediate include surface: `linux/err.h`, `linux/kernel.h`, `linux/netdevice.h`, `net/addrconf.h`, `net/dst.h`, `net/xfrm.h`, `net/ip.h`, `net/ipv6.h`.
- Detected declarations: `function xfrm6_get_saddr`, `function xfrm6_fill_dst`, `function xfrm6_update_pmtu`, `function xfrm6_redirect`, `function xfrm6_dst_destroy`, `function xfrm6_dst_ifdown`, `function xfrm6_policy_init`, `function xfrm6_policy_fini`, `function xfrm6_net_sysctl_init`, `function xfrm6_net_sysctl_exit`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.