include/net/ip.h
Source file repositories/reference/linux-study-clean/include/net/ip.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/ip.h- Extension
.h- Size
- 23888 bytes
- Lines
- 841
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/ip.hlinux/in.hlinux/skbuff.hlinux/jhash.hlinux/sockptr.hlinux/static_key.hnet/inet_sock.hnet/route.hnet/snmp.hnet/flow.hnet/flow_dissector.hnet/netns/hash.hnet/lwtunnel.hnet/inet_dscp.hnet/dst.hlinux/ipv6.h
Detected Declarations
struct sockstruct inet_skb_parmstruct ipcm_cookiestruct ip_ra_chainstruct msghdrstruct net_devicestruct packet_typestruct rtablestruct sockaddrstruct ip_fraglist_iterstruct ip_frag_statestruct ip_reply_argenum ip_defrag_usersfunction ipv4_l3mdev_skbfunction ip_hdrlenfunction ipcm_initfunction ipcm_init_skfunction inet_sdiffunction ip_sendmsg_scopefunction ip_reply_arg_flowi_flagsfunction snmp_get_cpu_fieldfunction snmp_get_cpu_field64function snmp_fold_field64function inet_get_local_port_rangefunction inet_is_local_reserved_portfunction sysctl_dev_name_is_allowedfunction inet_port_requires_bind_servicefunction inet_is_local_reserved_portfunction inet_port_requires_bind_servicefunction ip_is_fragmentfunction ip_decrease_ttlfunction ip4h_dscpfunction ip_mtu_lockedfunction ip_dont_fragmentfunction ip_sk_accept_pmtufunction ip_sk_use_pmtufunction ip_sk_ignore_dffunction ip_dst_mtu_maybe_forwardfunction ip_mtu_lockedfunction ip_skb_dst_mtufunction ip_fib_metrics_putfunction ip_dst_init_metricsfunction ip_dst_metrics_putfunction ip_select_ident_segsfunction ip_select_identfunction inet_compute_pseudofunction iph_to_flow_copy_v4addrsfunction ip_eth_mc_map
Annotated Snippet
struct inet_skb_parm {
int iif;
struct ip_options opt; /* Compiled IP options */
u16 flags;
#define IPSKB_FORWARDED BIT(0)
#define IPSKB_XFRM_TUNNEL_SIZE BIT(1)
#define IPSKB_XFRM_TRANSFORMED BIT(2)
#define IPSKB_FRAG_COMPLETE BIT(3)
#define IPSKB_REROUTED BIT(4)
#define IPSKB_DOREDIRECT BIT(5)
#define IPSKB_FRAG_PMTU BIT(6)
#define IPSKB_L3SLAVE BIT(7)
#define IPSKB_NOPOLICY BIT(8)
#define IPSKB_MULTIPATH BIT(9)
#define IPSKB_MCROUTE BIT(10)
u16 frag_max_size;
};
static inline bool ipv4_l3mdev_skb(u16 flags)
{
return !!(flags & IPSKB_L3SLAVE);
}
static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
{
return ip_hdr(skb)->ihl * 4;
}
struct ipcm_cookie {
struct sockcm_cookie sockc;
__be32 addr;
int oif;
struct ip_options_rcu *opt;
__u8 protocol;
__u8 ttl;
__s16 tos;
__u16 gso_size;
};
static inline void ipcm_init(struct ipcm_cookie *ipcm)
{
*ipcm = (struct ipcm_cookie) { .tos = -1 };
}
static inline void ipcm_init_sk(struct ipcm_cookie *ipcm,
const struct inet_sock *inet)
{
*ipcm = (struct ipcm_cookie) {
.tos = READ_ONCE(inet->tos),
};
sockcm_init(&ipcm->sockc, &inet->sk);
ipcm->oif = READ_ONCE(inet->sk.sk_bound_dev_if);
ipcm->addr = inet->inet_saddr;
ipcm->protocol = READ_ONCE(inet->inet_num);
}
#define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))
#define PKTINFO_SKB_CB(skb) ((struct in_pktinfo *)((skb)->cb))
/* return enslaved device index if relevant */
static inline int inet_sdif(const struct sk_buff *skb)
{
#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
if (skb && ipv4_l3mdev_skb(IPCB(skb)->flags))
return IPCB(skb)->iif;
#endif
return 0;
}
/* Special input handler for packets caught by router alert option.
They are selected only by protocol field, and then processed likely
local ones; but only if someone wants them! Otherwise, router
not running rsvpd will kill RSVP.
It is user level problem, what it will make with them.
I have no idea, how it will masquearde or NAT them (it is joke, joke :-)),
but receiver should be enough clever f.e. to forward mtrace requests,
sent to multicast group to reach destination designated router.
*/
struct ip_ra_chain {
struct ip_ra_chain __rcu *next;
struct sock *sk;
union {
void (*destructor)(struct sock *);
struct sock *saved_sk;
Annotation
- Immediate include surface: `linux/types.h`, `linux/ip.h`, `linux/in.h`, `linux/skbuff.h`, `linux/jhash.h`, `linux/sockptr.h`, `linux/static_key.h`, `net/inet_sock.h`.
- Detected declarations: `struct sock`, `struct inet_skb_parm`, `struct ipcm_cookie`, `struct ip_ra_chain`, `struct msghdr`, `struct net_device`, `struct packet_type`, `struct rtable`, `struct sockaddr`, `struct ip_fraglist_iter`.
- 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.