roce

package
v0.714.0 Latest Latest
Warning

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

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

Documentation

Overview

Package roce decodes the InfiniBand Base Transport Header (BTH) of RoCE — RDMA over Converged Ethernet — the datacenter Remote Direct Memory Access fabric. RoCEv2 carries the InfiniBand transport over UDP (destination port 4791), letting one host read and write another host's memory directly, bypassing the remote CPU. It is the fabric under high-performance storage (NVMe-oF), GPU clusters (NCCL / GPUDirect) and HPC. RDMA is a real and often-overlooked attack surface: the wire protocol is unencrypted and unauthenticated by default, isolation rests only on the 16-bit Partition Key (P_Key) and the Queue-Pair number, and an attacker on the fabric who can forge a BTH can issue RDMA READ / WRITE operations against a remote host's registered memory regions. A captured RoCE BTH identifies the **RDMA operation** in flight — an RDMA READ / WRITE (direct remote memory access), an atomic compare-swap / fetch-add, a SEND, an ACK or a congestion-notification (CNP) — together with the **destination Queue Pair**, the **Partition Key** (the fabric isolation domain) and the packet sequence number, which is the recon headline for RDMA-fabric reconnaissance. It is the InfiniBand transport member of the project's network-decoder family, a distinct domain.

Wrap-vs-native judgement

Native. The BTH is a fixed 12-byte header — a byte opcode + a handful of
bit-fields (flags, P_Key, a 24-bit destination QP, a 24-bit PSN). A
byte/bit read + an opcode lookup; stdlib only, no new go.mod dep.

Verifiable / no confidently-wrong output

The 12-byte BTH layout and the 57-entry opcode table were verified
field-for-field against scapy's RoCE layer (scapy.contrib.roce). The
opcode name table is code-generated from scapy's authoritative map (not
hand-transcribed). Only the always-present BTH is decoded: the per-opcode
extended transport headers (RETH for RDMA, AETH for ACKs, AtomicETH, the
ImmDt / immediate data) and the payload vary by opcode and are surfaced
as raw hex — the trailing 4 bytes are the ICRC. The transport-service
type is derived from the opcode's top three bits per the IBA spec; an
opcode outside the known table is reported by value with a note rather
than guessed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Opcode           int      `json:"opcode"`
	OpcodeHex        string   `json:"opcode_hex"`
	OpcodeName       string   `json:"opcode_name"`
	TransportService string   `json:"transport_service"`
	Solicited        bool     `json:"solicited"`
	MigReq           bool     `json:"mig_req"`
	PadCount         int      `json:"pad_count"`
	HeaderVersion    int      `json:"header_version"`
	PKey             string   `json:"p_key"`
	FECN             bool     `json:"fecn"`
	BECN             bool     `json:"becn"`
	DestQP           string   `json:"dest_qp"`
	AckReq           bool     `json:"ack_req"`
	PSN              int      `json:"psn"`
	PayloadHex       string   `json:"payload_hex,omitempty"`
	Notes            []string `json:"notes,omitempty"`
}

Result is the decoded view of a RoCE InfiniBand Base Transport Header.

func Decode

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

Decode parses a RoCE Base Transport Header (the UDP-port-4791 payload, or the IB BTH directly) from hex (whitespace / ':' / '-' / '_' separators and a '0x' prefix tolerated).

Jump to

Keyboard shortcuts

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