include/net/gre.h
Source file repositories/reference/linux-study-clean/include/net/gre.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/gre.h- Extension
.h- Size
- 3883 bytes
- Lines
- 148
- 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
linux/skbuff.hnet/ip_tunnels.h
Detected Declarations
struct gre_base_hdrstruct gre_full_hdrstruct gre_protocolfunction netif_is_gretapfunction netif_is_ip6gretapfunction gre_calc_hlenfunction gre_flags_to_tnl_flagsfunction gre_tnl_flags_to_gre_flagsfunction gre_build_header
Annotated Snippet
struct gre_base_hdr {
__be16 flags;
__be16 protocol;
} __packed;
struct gre_full_hdr {
struct gre_base_hdr fixed_header;
__be16 csum;
__be16 reserved1;
__be32 key;
__be32 seq;
} __packed;
#define GRE_HEADER_SECTION 4
#define GREPROTO_CISCO 0
#define GREPROTO_PPTP 1
#define GREPROTO_MAX 2
#define GRE_IP_PROTO_MAX 2
struct gre_protocol {
int (*handler)(struct sk_buff *skb);
void (*err_handler)(struct sk_buff *skb, u32 info);
};
int gre_add_protocol(const struct gre_protocol *proto, u8 version);
int gre_del_protocol(const struct gre_protocol *proto, u8 version);
struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
u8 name_assign_type);
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
bool *csum_err, __be16 proto, int nhs);
static inline bool netif_is_gretap(const struct net_device *dev)
{
return dev->rtnl_link_ops &&
!strcmp(dev->rtnl_link_ops->kind, "gretap");
}
static inline bool netif_is_ip6gretap(const struct net_device *dev)
{
return dev->rtnl_link_ops &&
!strcmp(dev->rtnl_link_ops->kind, "ip6gretap");
}
static inline int gre_calc_hlen(const unsigned long *o_flags)
{
int addend = 4;
if (test_bit(IP_TUNNEL_CSUM_BIT, o_flags))
addend += 4;
if (test_bit(IP_TUNNEL_KEY_BIT, o_flags))
addend += 4;
if (test_bit(IP_TUNNEL_SEQ_BIT, o_flags))
addend += 4;
return addend;
}
static inline void gre_flags_to_tnl_flags(unsigned long *dst, __be16 flags)
{
IP_TUNNEL_DECLARE_FLAGS(res) = { };
__assign_bit(IP_TUNNEL_CSUM_BIT, res, flags & GRE_CSUM);
__assign_bit(IP_TUNNEL_ROUTING_BIT, res, flags & GRE_ROUTING);
__assign_bit(IP_TUNNEL_KEY_BIT, res, flags & GRE_KEY);
__assign_bit(IP_TUNNEL_SEQ_BIT, res, flags & GRE_SEQ);
__assign_bit(IP_TUNNEL_STRICT_BIT, res, flags & GRE_STRICT);
__assign_bit(IP_TUNNEL_REC_BIT, res, flags & GRE_REC);
__assign_bit(IP_TUNNEL_VERSION_BIT, res, flags & GRE_VERSION);
ip_tunnel_flags_copy(dst, res);
}
static inline __be16 gre_tnl_flags_to_gre_flags(const unsigned long *tflags)
{
__be16 flags = 0;
if (test_bit(IP_TUNNEL_CSUM_BIT, tflags))
flags |= GRE_CSUM;
if (test_bit(IP_TUNNEL_ROUTING_BIT, tflags))
flags |= GRE_ROUTING;
if (test_bit(IP_TUNNEL_KEY_BIT, tflags))
flags |= GRE_KEY;
if (test_bit(IP_TUNNEL_SEQ_BIT, tflags))
flags |= GRE_SEQ;
if (test_bit(IP_TUNNEL_STRICT_BIT, tflags))
flags |= GRE_STRICT;
if (test_bit(IP_TUNNEL_REC_BIT, tflags))
flags |= GRE_REC;
if (test_bit(IP_TUNNEL_VERSION_BIT, tflags))
flags |= GRE_VERSION;
Annotation
- Immediate include surface: `linux/skbuff.h`, `net/ip_tunnels.h`.
- Detected declarations: `struct gre_base_hdr`, `struct gre_full_hdr`, `struct gre_protocol`, `function netif_is_gretap`, `function netif_is_ip6gretap`, `function gre_calc_hlen`, `function gre_flags_to_tnl_flags`, `function gre_tnl_flags_to_gre_flags`, `function gre_build_header`.
- 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.