include/net/udp_tunnel.h
Source file repositories/reference/linux-study-clean/include/net/udp_tunnel.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/udp_tunnel.h- Extension
.h- Size
- 14998 bytes
- Lines
- 482
- 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
net/ip_tunnels.hnet/udp.hnet/ipv6.h
Detected Declarations
struct udp_port_cfgstruct udp_tunnel_sock_cfgstruct udp_tunnel_infostruct udp_tunnel_nicstruct udp_tunnel_nic_sharedstruct udp_tunnel_nic_shared_nodestruct udp_tunnel_nic_infostruct udp_tunnel_nic_table_infostruct udp_tunnel_nic_opsenum udp_parsable_tunnel_typeenum udp_tunnel_nic_info_flagsfunction udp_sock_create6function udp_sock_createfunction udp_tunnel_handle_partialfunction udp_tunnel_set_inner_protocolfunction udp_tunnel_handle_offloadsfunction udp_tunnel_update_gro_lookupfunction udp_tunnel_encap_enablefunction udp_tunnel_nic_get_portfunction udp_tunnel_nic_set_port_privfunction udp_tunnel_nic_assert_lockedfunction udp_tunnel_nic_lockfunction udp_tunnel_nic_unlockfunction udp_tunnel_nic_add_portfunction udp_tunnel_nic_del_portfunction udp_tunnel_nic_reset_ntffunction udp_tunnel_nic_dump_sizefunction udp_tunnel_nic_dump_writefunction udp_tunnel_get_rx_infofunction udp_tunnel_drop_rx_info
Annotated Snippet
struct udp_port_cfg {
u8 family;
/* Used only for kernel-created sockets */
union {
struct in_addr local_ip;
#if IS_ENABLED(CONFIG_IPV6)
struct in6_addr local_ip6;
#endif
};
union {
struct in_addr peer_ip;
#if IS_ENABLED(CONFIG_IPV6)
struct in6_addr peer_ip6;
#endif
};
__be16 local_udp_port;
__be16 peer_udp_port;
int bind_ifindex;
unsigned int use_udp_checksums:1,
use_udp6_tx_checksums:1,
use_udp6_rx_checksums:1,
ipv6_v6only:1;
};
int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg,
struct socket **sockp);
#if IS_ENABLED(CONFIG_IPV6)
int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
struct socket **sockp);
#else
static inline int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
struct socket **sockp)
{
return -EPFNOSUPPORT;
}
#endif
static inline int udp_sock_create(struct net *net,
struct udp_port_cfg *cfg,
struct socket **sockp)
{
if (cfg->family == AF_INET)
return udp_sock_create4(net, cfg, sockp);
if (cfg->family == AF_INET6)
return udp_sock_create6(net, cfg, sockp);
return -EPFNOSUPPORT;
}
typedef int (*udp_tunnel_encap_rcv_t)(struct sock *sk, struct sk_buff *skb);
typedef int (*udp_tunnel_encap_err_lookup_t)(struct sock *sk,
struct sk_buff *skb);
typedef void (*udp_tunnel_encap_err_rcv_t)(struct sock *sk,
struct sk_buff *skb, int err,
__be16 port, u32 info, u8 *payload);
typedef void (*udp_tunnel_encap_destroy_t)(struct sock *sk);
typedef struct sk_buff *(*udp_tunnel_gro_receive_t)(struct sock *sk,
struct list_head *head,
struct sk_buff *skb);
typedef int (*udp_tunnel_gro_complete_t)(struct sock *sk, struct sk_buff *skb,
int nhoff);
struct udp_tunnel_sock_cfg {
void *sk_user_data; /* user data used by encap_rcv call back */
/* Used for setting up udp_sock fields, see udp.h for details */
__u8 encap_type;
udp_tunnel_encap_rcv_t encap_rcv;
udp_tunnel_encap_err_lookup_t encap_err_lookup;
udp_tunnel_encap_err_rcv_t encap_err_rcv;
udp_tunnel_encap_destroy_t encap_destroy;
udp_tunnel_gro_receive_t gro_receive;
udp_tunnel_gro_complete_t gro_complete;
};
/* Setup the given (UDP) sock to receive UDP encapsulated packets */
void setup_udp_tunnel_sock(struct net *net, struct sock *sk,
struct udp_tunnel_sock_cfg *sock_cfg);
/* -- List of parsable UDP tunnel types --
*
* Adding to this list will result in serious debate. The main issue is
* that this list is essentially a list of workarounds for either poorly
* designed tunnels, or poorly designed device offloads.
*
* The parsing supported via these types should really be used for Rx
Annotation
- Immediate include surface: `net/ip_tunnels.h`, `net/udp.h`, `net/ipv6.h`.
- Detected declarations: `struct udp_port_cfg`, `struct udp_tunnel_sock_cfg`, `struct udp_tunnel_info`, `struct udp_tunnel_nic`, `struct udp_tunnel_nic_shared`, `struct udp_tunnel_nic_shared_node`, `struct udp_tunnel_nic_info`, `struct udp_tunnel_nic_table_info`, `struct udp_tunnel_nic_ops`, `enum udp_parsable_tunnel_type`.
- 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.