Skip to content

BPF opcodes

Alex Petrov edited this page Nov 20, 2024 · 2 revisions
Load and Store Instructions:
LD_ABS (0x20): Load 32-bit word from packet.
LD_IND (0x28): Load 32-bit word with indirect offset.
LDX_MEM (0x61): Load from memory to index register.
ST_MEM (0x62): Store into memory.

Arithmetic and Logical Instructions:
ADD (0x07): Addition.
SUB (0x1F): Subtraction.
MUL (0x27): Multiplication.
DIV (0x37): Division.
AND (0x57): Bitwise AND.
OR (0x67): Bitwise OR.

Control Flow:
JMP (0x05): Unconditional jump.
JEQ (0x15): Jump if equal.
JGT (0x35): Jump if greater.
JSET (0x55): Jump if AND is true.

Call and Return:
CALL (0x85): Call a helper function.
EXIT (0x95): Exit program.

Special Instructions:
MOV (0xB7): Move.