net/ipv6/ip6_output.c
Source file repositories/reference/linux-study-clean/net/ipv6/ip6_output.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ip6_output.c- Extension
.c- Size
- 54774 bytes
- Lines
- 2104
- 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/errno.hlinux/kernel.hlinux/string.hlinux/socket.hlinux/net.hlinux/netdevice.hlinux/if_arp.hlinux/in6.hlinux/tcp.hlinux/route.hlinux/module.hlinux/slab.hlinux/bpf-cgroup.hlinux/netfilter.hlinux/netfilter_ipv6.hnet/sock.hnet/snmp.hnet/gso.hnet/ipv6.hnet/ndisc.hnet/protocol.hnet/ip6_route.hnet/addrconf.hnet/rawv6.hnet/icmp.hnet/xfrm.hnet/checksum.hlinux/mroute6.hnet/l3mdev.hnet/lwtunnel.hnet/ip_tunnels.h
Detected Declarations
function ip6_finish_output2function ip6_finish_output_gso_slowpath_dropfunction skb_list_walk_safefunction ip6_finish_output_gsofunction __ip6_finish_outputfunction ip6_finish_outputfunction ip6_outputfunction ip6_autoflowlabelfunction ip6_dst_hoplimitfunction sk_bufffunction ip6_call_ra_chainfunction ip6_forward_proxy_checkfunction ip6_forward_finishfunction ip6_pkt_too_bigfunction ip6_forwardfunction pneigh_lookupfunction ip6_copy_metadatafunction ip6_fraglist_initfunction ip6_fraglist_preparefunction ip6_frag_initfunction ip6_fragmentfunction skb_walk_fragsfunction skb_walk_fragsfunction ip6_rt_checkfunction ip6_rt_checkfunction ip6_dst_lookup_tailfunction routingfunction ip6_dst_lookupfunction ip6_append_data_mtufunction ip6_setup_corkfunction __ip6_append_datafunction ip6_append_datafunction ip6_cork_steal_dstfunction ip6_cork_releasefunction ip6_send_skbfunction ip6_push_pending_framesfunction __ip6_flush_pending_framesfunction ip6_flush_pending_framesfunction getfragexport ip6_outputexport ip6_dst_hoplimitexport ip6_xmitexport ip6_fraglist_initexport ip6_fraglist_prepareexport ip6_frag_initexport ip6_frag_nextexport ip6_fragmentexport ip6_dst_lookup
Annotated Snippet
if (!skb) {
IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);
return -ENOMEM;
}
}
hdr = ipv6_hdr(skb);
daddr = &hdr->daddr;
if (unlikely(ipv6_addr_is_multicast(daddr))) {
if (!(dev->flags & IFF_LOOPBACK) && sk_mc_loop(sk) &&
((mroute6_is_socket(net, skb) &&
!(IP6CB(skb)->flags & IP6SKB_FORWARDED)) ||
ipv6_chk_mcast_addr(dev, daddr, &hdr->saddr))) {
struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
/* Do not check for IFF_ALLMULTI; multicast routing
is not supported in any case.
*/
if (newskb)
NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING,
net, sk, newskb, NULL, newskb->dev,
dev_loopback_xmit);
if (hdr->hop_limit == 0) {
IP6_INC_STATS(net, idev,
IPSTATS_MIB_OUTDISCARDS);
kfree_skb(skb);
return 0;
}
}
IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUTMCAST, skb->len);
if (IPV6_ADDR_MC_SCOPE(daddr) <= IPV6_ADDR_SCOPE_NODELOCAL &&
!(dev->flags & IFF_LOOPBACK)) {
kfree_skb(skb);
return 0;
}
}
if (lwtunnel_xmit_redirect(dst->lwtstate)) {
int res = lwtunnel_xmit(skb);
if (res != LWTUNNEL_XMIT_CONTINUE)
return res;
}
IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUT, skb->len);
nexthop = rt6_nexthop(dst_rt6_info(dst), daddr);
neigh = __ipv6_neigh_lookup_noref(dev, nexthop);
if (IS_ERR_OR_NULL(neigh)) {
if (unlikely(!neigh))
neigh = __neigh_create(&nd_tbl, nexthop, dev, false);
if (IS_ERR(neigh)) {
IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTNOROUTES);
kfree_skb_reason(skb, SKB_DROP_REASON_NEIGH_CREATEFAIL);
return -EINVAL;
}
}
sock_confirm_neigh(skb, neigh);
ret = neigh_output(neigh, skb, false);
return ret;
}
static int
ip6_finish_output_gso_slowpath_drop(struct net *net, struct sock *sk,
struct sk_buff *skb, unsigned int mtu)
{
struct sk_buff *segs, *nskb;
netdev_features_t features;
int ret = 0;
/* Please see corresponding comment in ip_finish_output_gso
* describing the cases where GSO segment length exceeds the
* egress MTU.
*/
features = netif_skb_features(skb);
segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
if (IS_ERR_OR_NULL(segs)) {
kfree_skb(skb);
return -ENOMEM;
}
consume_skb(skb);
skb_list_walk_safe(segs, segs, nskb) {
int err;
skb_mark_not_on_list(segs);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/kernel.h`, `linux/string.h`, `linux/socket.h`, `linux/net.h`, `linux/netdevice.h`, `linux/if_arp.h`, `linux/in6.h`.
- Detected declarations: `function ip6_finish_output2`, `function ip6_finish_output_gso_slowpath_drop`, `function skb_list_walk_safe`, `function ip6_finish_output_gso`, `function __ip6_finish_output`, `function ip6_finish_output`, `function ip6_output`, `function ip6_autoflowlabel`, `function ip6_dst_hoplimit`, `function sk_buff`.
- 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.