Liking cljdoc? Tell your friends :D

lb.programs.xdp-ingress

XDP ingress program for the load balancer. Handles incoming packets: parses headers, looks up routing, performs DNAT.

XDP ingress program for the load balancer.
Handles incoming packets: parses headers, looks up routing, performs DNAT.
raw docstring

attach-to-interfaceclj

(attach-to-interface prog iface & {:keys [mode] :or {mode :skb}})

Attach XDP program to a network interface.

prog: BpfProgram record or program FD iface: Interface name (e.g., "eth0") mode: :skb (generic), :drv (native), or :hw (hardware)

Attach XDP program to a network interface.

prog: BpfProgram record or program FD
iface: Interface name (e.g., "eth0")
mode: :skb (generic), :drv (native), or :hw (hardware)
sourceraw docstring

attach-to-interfacesclj

(attach-to-interfaces prog interfaces & opts)

Attach XDP program to multiple interfaces.

Attach XDP program to multiple interfaces.
sourceraw docstring

BPF-FUNC-csum-diffclj

source

BPF-FUNC-ktime-get-nsclj

source

build-ipv4-filter-programclj

(build-ipv4-filter-program)

Build XDP program that passes IPv4 packets and drops others. Uses clj-ebpf.net primitives for packet parsing.

Build XDP program that passes IPv4 packets and drops others.
Uses clj-ebpf.net primitives for packet parsing.
sourceraw docstring

build-xdp-dnat-programclj

(build-xdp-dnat-program listen-map-fd config-map-fd conntrack-map-fd)

Build XDP ingress program that performs DNAT on incoming packets.

This program:

  1. Parses IPv4/TCP or IPv4/UDP packets
  2. Looks up listen map by (ifindex, dst_port)
  3. Falls back to config map LPM lookup by source IP
  4. If match found, performs DNAT (rewrites dst IP and port)
  5. Updates IP and L4 checksums
  6. Creates conntrack entry for TC SNAT to use on reply path
  7. Returns XDP_PASS to let kernel routing deliver packet

Register allocation: r6 = saved XDP context (callee-saved) r7 = data pointer (callee-saved) r8 = data_end pointer (callee-saved) r9 = IP header pointer / map value ptr (callee-saved) r0-r5 = scratch, clobbered by helpers

Uses clj-ebpf.asm label-based assembly for automatic jump offset resolution.

Build XDP ingress program that performs DNAT on incoming packets.

This program:
1. Parses IPv4/TCP or IPv4/UDP packets
2. Looks up listen map by (ifindex, dst_port)
3. Falls back to config map LPM lookup by source IP
4. If match found, performs DNAT (rewrites dst IP and port)
5. Updates IP and L4 checksums
6. Creates conntrack entry for TC SNAT to use on reply path
7. Returns XDP_PASS to let kernel routing deliver packet

Register allocation:
r6 = saved XDP context (callee-saved)
r7 = data pointer (callee-saved)
r8 = data_end pointer (callee-saved)
r9 = IP header pointer / map value ptr (callee-saved)
r0-r5 = scratch, clobbered by helpers

Uses clj-ebpf.asm label-based assembly for automatic jump offset resolution.
sourceraw docstring

build-xdp-ingress-programclj

(build-xdp-ingress-program map-fds)

Build the XDP ingress program.

Performs DNAT on incoming packets:

  1. Looks up listen map by (ifindex, dst_port)
  2. Falls back to config map LPM lookup by source IP
  3. If match found, rewrites destination IP/port
  4. Updates IP and L4 checksums
  5. Creates conntrack entry for TC SNAT
  6. Returns XDP_PASS to let kernel routing deliver packet

map-fds: Map containing :listen-map, optionally :config-map and :conntrack-map

Build the XDP ingress program.

Performs DNAT on incoming packets:
1. Looks up listen map by (ifindex, dst_port)
2. Falls back to config map LPM lookup by source IP
3. If match found, rewrites destination IP/port
4. Updates IP and L4 checksums
5. Creates conntrack entry for TC SNAT
6. Returns XDP_PASS to let kernel routing deliver packet

map-fds: Map containing :listen-map, optionally :config-map and :conntrack-map
sourceraw docstring

build-xdp-pass-programclj

(build-xdp-pass-program)

Build a simple XDP program that passes all packets. This is useful for initial testing of program loading/attachment.

Build a simple XDP program that passes all packets.
This is useful for initial testing of program loading/attachment.
sourceraw docstring

detach-from-interfaceclj

(detach-from-interface iface & {:keys [mode] :or {mode :skb}})

Detach XDP program from an interface.

Detach XDP program from an interface.
sourceraw docstring

detach-from-interfacesclj

(detach-from-interfaces interfaces & opts)

Detach XDP program from multiple interfaces.

Detach XDP program from multiple interfaces.
sourceraw docstring

dump-program-bytecodeclj

(dump-program-bytecode maps)

Dump program bytecode for debugging.

Dump program bytecode for debugging.
sourceraw docstring

load-programclj

(load-program maps)

Load the XDP ingress program. Returns a BpfProgram record.

Load the XDP ingress program.
Returns a BpfProgram record.
sourceraw docstring

verify-programclj

(verify-program maps)

Verify the XDP program can be loaded (dry run). Returns {:valid true} or {:valid false :error <message>}

Verify the XDP program can be loaded (dry run).
Returns {:valid true} or {:valid false :error <message>}
sourceraw docstring

xdp-apply-csum-diffclj

(xdp-apply-csum-diff old-csum-reg diff-reg scratch-reg)

Apply a checksum difference to an existing checksum. old-csum-reg: Register containing old checksum (16-bit, will be modified) diff-reg: Register containing the difference from csum_diff scratch-reg: Scratch register

Result: old-csum-reg contains new 16-bit checksum

Apply a checksum difference to an existing checksum.
old-csum-reg: Register containing old checksum (16-bit, will be modified)
diff-reg: Register containing the difference from csum_diff
scratch-reg: Scratch register

Result: old-csum-reg contains new 16-bit checksum
sourceraw docstring

xdp-fold-csumclj

(xdp-fold-csum csum-reg scratch-reg)

Fold a 32-bit checksum to 16 bits in XDP. csum-reg will contain the folded result. scratch-reg is clobbered.

Fold a 32-bit checksum to 16 bits in XDP.
csum-reg will contain the folded result.
scratch-reg is clobbered.
sourceraw docstring

xdp-load-data-ptrs-32clj

(xdp-load-data-ptrs-32 data-reg data-end-reg ctx-reg)

Load data and data_end pointers from XDP context using 32-bit loads. The kernel requires 32-bit access to xdp_md fields.

data-reg: Register to store data pointer data-end-reg: Register to store data_end pointer ctx-reg: XDP context register (typically :r1)

Load data and data_end pointers from XDP context using 32-bit loads.
The kernel requires 32-bit access to xdp_md fields.

data-reg: Register to store data pointer
data-end-reg: Register to store data_end pointer
ctx-reg: XDP context register (typically :r1)
sourceraw docstring

xdp-update-csum-for-port-changeclj

(xdp-update-csum-for-port-change csum-reg old-port-reg new-port-reg scratch-reg)

Update checksum for a 2-byte port change. csum-reg: Register containing current checksum (will be modified) old-port-reg: Register containing old port value new-port-reg: Register containing new port value scratch-reg: Scratch register

Uses incremental checksum: new_csum = ~(~old_csum + ~old_val + new_val)

Update checksum for a 2-byte port change.
csum-reg: Register containing current checksum (will be modified)
old-port-reg: Register containing old port value
new-port-reg: Register containing new port value
scratch-reg: Scratch register

Uses incremental checksum: new_csum = ~(~old_csum + ~old_val + new_val)
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close