net/netfilter/ipvs/ip_vs_xmit.c
Source file repositories/reference/linux-study-clean/net/netfilter/ipvs/ip_vs_xmit.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/ipvs/ip_vs_xmit.c- Extension
.c- Size
- 43901 bytes
- Lines
- 1673
- 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.
- 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/kernel.hlinux/slab.hlinux/tcp.hnet/ip.hnet/gue.hnet/gre.hnet/tcp.hnet/udp.hnet/icmp.hnet/route.hnet/ipv6.hnet/ip6_route.hnet/ip_tunnels.hnet/ip6_checksum.hnet/addrconf.hlinux/icmpv6.hlinux/netfilter.hlinux/netfilter_ipv4.hnet/ip_vs.h
Detected Declarations
function ip_vs_dest_dst_freefunction __ip_vs_dst_setfunction __ip_vs_dst_checkfunction ip_vs_exceeds_mtufunction __mtu_check_toobig_v6function __ip_vs_is_local_route6function crosses_local_route_boundaryfunction maybe_update_pmtufunction ensure_mtu_is_adequatefunction decrement_ttlfunction rt_dev_is_downfunction __ip_vs_get_out_rtfunction __ip_vs_route_output_v6function __ip_vs_get_out_rt_v6function ip_vs_tunnel_xmit_preparefunction socketfunction ip_vs_nat_send_or_contfunction ip_vs_send_or_contfunction transmitterfunction ip_vs_bypass_xmitfunction ip_vs_bypass_xmit_v6function transmitterfunction ip_vs_nat_xmit_v6function ipv6_addr_typefunction ip_vs_prepare_tunneled_skbfunction __tun_gso_type_maskfunction ipvs_gue_encapfunction ipvs_gre_encapfunction ip_vs_tunnel_xmitfunction ip_vs_tunnel_xmit_v6function ip_vs_dr_xmitfunction ip_vs_dr_xmit_v6function ip_vs_icmp_xmitfunction ip_vs_icmp_xmit_v6function ipv6_addr_type
Annotated Snippet
if (unlikely(__mtu_check_toobig_v6(skb, mtu))) {
if (!skb->dev)
skb->dev = net->loopback_dev;
/* only send ICMP too big on first fragment */
if (!ipvsh->fragoffs && !ip_vs_iph_icmp(ipvsh))
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
IP_VS_DBG(1, "frag needed for %pI6c\n",
&ipv6_hdr(skb)->saddr);
return false;
}
} else
#endif
{
/* If we're going to tunnel the packet and pmtu discovery
* is disabled, we'll just fragment it anyway
*/
if ((rt_mode & IP_VS_RT_MODE_TUNNEL) && !sysctl_pmtu_disc(ipvs))
return true;
if (unlikely(ip_hdr(skb)->frag_off & htons(IP_DF) &&
ip_vs_exceeds_mtu(skb, mtu) &&
!ip_vs_iph_icmp(ipvsh))) {
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
htonl(mtu));
IP_VS_DBG(1, "frag needed for %pI4\n",
&ip_hdr(skb)->saddr);
return false;
}
}
return true;
}
static inline bool decrement_ttl(struct netns_ipvs *ipvs,
int skb_af,
struct sk_buff *skb)
{
struct net *net = ipvs->net;
#ifdef CONFIG_IP_VS_IPV6
if (skb_af == AF_INET6) {
struct dst_entry *dst = skb_dst(skb);
/* check and decrement ttl */
if (ipv6_hdr(skb)->hop_limit <= 1) {
struct inet6_dev *idev = __in6_dev_get_safely(skb->dev);
/* Force OUTPUT device used as source address */
skb->dev = dst->dev;
icmpv6_send(skb, ICMPV6_TIME_EXCEED,
ICMPV6_EXC_HOPLIMIT, 0);
IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
return false;
}
/* don't propagate ttl change to cloned packets */
if (skb_ensure_writable(skb, sizeof(struct ipv6hdr)))
return false;
ipv6_hdr(skb)->hop_limit--;
} else
#endif
{
if (ip_hdr(skb)->ttl <= 1) {
/* Tell the sender its packet died... */
IP_INC_STATS(net, IPSTATS_MIB_INHDRERRORS);
icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0);
return false;
}
/* don't propagate ttl change to cloned packets */
if (skb_ensure_writable(skb, sizeof(struct iphdr)))
return false;
/* Decrease ttl */
ip_decrease_ttl(ip_hdr(skb));
}
return true;
}
/* rt has device that is down */
static bool rt_dev_is_down(const struct net_device *dev)
{
return dev && !netif_running(dev);
}
/* Get route to destination or remote server */
static int
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/tcp.h`, `net/ip.h`, `net/gue.h`, `net/gre.h`, `net/tcp.h`, `net/udp.h`.
- Detected declarations: `function ip_vs_dest_dst_free`, `function __ip_vs_dst_set`, `function __ip_vs_dst_check`, `function ip_vs_exceeds_mtu`, `function __mtu_check_toobig_v6`, `function __ip_vs_is_local_route6`, `function crosses_local_route_boundary`, `function maybe_update_pmtu`, `function ensure_mtu_is_adequate`, `function decrement_ttl`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.