vxlan

package
v0.331.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package vxlan decodes Virtual Extensible LAN packets per RFC 7348, plus per-vendor variants: Cisco's Group-Based Policy (VXLAN-GBP, draft-smith-vxlan-group-policy) and the Generic Protocol Extension (VXLAN-GPE, draft-ietf-nvo3- vxlan-gpe).

Wrap-vs-native judgement

Native. RFC 7348 is fully public; the VXLAN header is
a tight 8-byte field plus the encapsulated original
Ethernet frame. No crypto, no compression, no varints.
Operators paste UDP-payload bytes (standard UDP dest
port 4789) from a Wireshark Follow-UDP-Stream view, a
`tcpdump -X udp port 4789` line, or any VXLAN-emitting
tool and get the documented header plus the inner
Ethernet header peek for routing into a downstream
decoder.

What this package covers

  • **8-byte VXLAN header** (RFC 7348 §5):

  • byte 0: Flags. Bit 3 (I-flag, mask 0x08) MUST be 1 in standard VXLAN to indicate the VNI is valid; the other 7 bits are reserved and MUST be 0. VXLAN-GBP (Cisco extension) overloads bit 0 as G (Group Policy Applied) and bit 4 as D (Don't Learn).

  • bytes 1-3: Reserved 1 (24 bits, must be 0 in standard VXLAN). VXLAN-GBP overloads as 16-bit Group Policy ID (with 8 reserved bits).

  • bytes 4-6: VNI (24-bit VXLAN Network Identifier; like a 24-bit VLAN ID, 16M possible).

  • byte 7: Reserved 2 (must be 0 in standard VXLAN). VXLAN-GPE overloads as Next Protocol (1 IPv4 / 2 IPv6 / 3 Ethernet / 4 NSH / 5 MPLS).

  • **RFC 7348 conformance check**: surfaces a Note when the I-flag is not set or when reserved bits are non-zero (which the operator can investigate as middlebox abuse / non-standard variant / corrupt frame).

  • **Variant detection**: if the I-flag is set AND any reserved bits are non-zero, attempt to interpret as VXLAN-GBP or VXLAN-GPE based on the pattern.

  • **Inner Ethernet peek**: the bytes after the VXLAN header are the encapsulated original Ethernet frame. We surface the dst MAC, src MAC, and EtherType (with name lookup against the same 10-entry table used by `vlan_decode`); operators pipe the post-Ethernet bytes to the appropriate decoder.

What this package does NOT cover (deliberately out of scope)

  • UDP / IP framing — feed the UDP payload bytes after the outer IP+UDP headers (standard outer UDP dest port 4789).

  • Inner Ethernet payload decoding beyond the EtherType identification — operators pipe the post-header bytes to `vlan_decode` / `ip_packet_decode` / etc.

  • VXLAN-GPE Next Protocol body dissection — only the Next Protocol byte is decoded; the body is the encapsulated IPv4 / IPv6 / Ethernet payload.

  • Geneve (RFC 8926) — a different overlay with a TLV options block; a future Spec.

  • VXLAN flooding / BUM (Broadcast / Unknown unicast / Multicast) replication semantics — this is a per- packet decoder, not a session tracker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GBPFields

type GBPFields struct {
	GroupPolicyApplied bool   `json:"group_policy_applied"`
	DontLearn          bool   `json:"dont_learn"`
	GroupPolicyID      int    `json:"group_policy_id"`
	GroupPolicyIDHex   string `json:"group_policy_id_hex"`
}

GBPFields is the Cisco Group-Based Policy extension overlay.

type GPEFields

type GPEFields struct {
	NextProtocol     int    `json:"next_protocol"`
	NextProtocolName string `json:"next_protocol_name"`
}

GPEFields is the Generic Protocol Extension overlay.

type InnerEthernet

type InnerEthernet struct {
	DstMAC         string `json:"dst_mac"`
	SrcMAC         string `json:"src_mac"`
	EtherType      int    `json:"ether_type"`
	EtherTypeHex   string `json:"ether_type_hex"`
	EtherTypeName  string `json:"ether_type_name"`
	PayloadOffset  int    `json:"payload_offset"`
	RemainingBytes int    `json:"remaining_bytes"`
}

InnerEthernet is the peek at the encapsulated Ethernet frame's header (dst MAC + src MAC + EtherType).

type Result

type Result struct {
	Flags         int            `json:"flags"`
	FlagsHex      string         `json:"flags_hex"`
	IFlag         bool           `json:"i_flag"`
	Reserved1Hex  string         `json:"reserved_1_hex"`
	Reserved1Zero bool           `json:"reserved_1_zero"`
	VNI           uint32         `json:"vni"`
	Reserved2     int            `json:"reserved_2"`
	Reserved2Zero bool           `json:"reserved_2_zero"`
	Variant       string         `json:"variant"`
	InnerEthernet *InnerEthernet `json:"inner_ethernet,omitempty"`
	GBP           *GBPFields     `json:"vxlan_gbp,omitempty"`
	GPE           *GPEFields     `json:"vxlan_gpe,omitempty"`
	TotalBytes    int            `json:"total_bytes"`
	Notes         []string       `json:"notes,omitempty"`
}

Result is the top-level decoded view.

func Decode

func Decode(hexStr string) (*Result, error)

Decode parses a VXLAN packet from hex.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL