include/net/route.h
Source file repositories/reference/linux-study-clean/include/net/route.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/route.h- Extension
.h- Size
- 12248 bytes
- Lines
- 431
- 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
net/dst.hnet/inetpeer.hnet/flow.hnet/inet_sock.hnet/ip_fib.hnet/arp.hnet/ndisc.hnet/inet_dscp.hnet/sock.hlinux/in_route.hlinux/rtnetlink.hlinux/rcupdate.hlinux/route.hlinux/ip.hlinux/cache.hlinux/security.h
Detected Declarations
struct ip_tunnel_infostruct fib_nhstruct fib_infostruct uncached_liststruct rtablestruct ip_rt_acctstruct rt_cache_statstruct in_devicestruct in_ifaddrfunction ip_sock_rt_scopefunction ip_sock_rt_tosfunction rt_is_input_routefunction rt_is_output_routefunction rt_nexthopfunction inet_sk_init_flowi4function ip_route_inputfunction ip_rt_putfunction rt_tos2priorityfunction ip_route_connectfunction inet_iiffunction ip4_dst_hoplimit
Annotated Snippet
struct rtable {
struct dst_entry dst;
int rt_genid;
unsigned int rt_flags;
__u16 rt_type;
__u8 rt_is_input;
__u8 rt_uses_gateway;
int rt_iif;
u8 rt_gw_family;
/* Info on neighbour */
union {
__be32 rt_gw4;
struct in6_addr rt_gw6;
};
/* Miscellaneous cached information */
u32 rt_mtu_locked:1,
rt_pmtu:31;
};
#define dst_rtable(_ptr) container_of_const(_ptr, struct rtable, dst)
/**
* skb_rtable - Returns the skb &rtable
* @skb: buffer
*/
static inline struct rtable *skb_rtable(const struct sk_buff *skb)
{
return dst_rtable(skb_dst(skb));
}
static inline bool rt_is_input_route(const struct rtable *rt)
{
return rt->rt_is_input != 0;
}
static inline bool rt_is_output_route(const struct rtable *rt)
{
return rt->rt_is_input == 0;
}
static inline __be32 rt_nexthop(const struct rtable *rt, __be32 daddr)
{
if (rt->rt_gw_family == AF_INET)
return rt->rt_gw4;
return daddr;
}
struct ip_rt_acct {
__u32 o_bytes;
__u32 o_packets;
__u32 i_bytes;
__u32 i_packets;
};
struct rt_cache_stat {
unsigned int in_slow_tot;
unsigned int in_slow_mc;
unsigned int in_no_route;
unsigned int in_brd;
unsigned int in_martian_dst;
unsigned int in_martian_src;
unsigned int out_slow_tot;
unsigned int out_slow_mc;
};
extern struct ip_rt_acct __percpu *ip_rt_acct;
struct in_device;
int ip_rt_init(void);
void rt_cache_flush(struct net *net);
void rt_flush_dev(struct net_device *dev);
static inline void inet_sk_init_flowi4(const struct inet_sock *inet,
struct flowi4 *fl4)
{
const struct ip_options_rcu *ip4_opt;
const struct sock *sk;
__be32 daddr;
rcu_read_lock();
ip4_opt = rcu_dereference(inet->inet_opt);
/* Source routing option overrides the socket destination address */
if (ip4_opt && ip4_opt->opt.srr)
daddr = ip4_opt->opt.faddr;
Annotation
- Immediate include surface: `net/dst.h`, `net/inetpeer.h`, `net/flow.h`, `net/inet_sock.h`, `net/ip_fib.h`, `net/arp.h`, `net/ndisc.h`, `net/inet_dscp.h`.
- Detected declarations: `struct ip_tunnel_info`, `struct fib_nh`, `struct fib_info`, `struct uncached_list`, `struct rtable`, `struct ip_rt_acct`, `struct rt_cache_stat`, `struct in_device`, `struct in_ifaddr`, `function ip_sock_rt_scope`.
- 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.