[][src]Module redbpf_probes::xdp

XDP (eXpress Data Path).

XDP provides high performance network processing capabilities in the kernel. For an overview of XDP and how it works, see https://www.iovisor.org/technology/xdp.

Example

Block all traffic directed to port 80:

#![no_std]
#![no_main]
use redbpf_probes::bindings::*;
use redbpf_probes::xdp::{XdpAction, XdpContext};
use redbpf_macros::{program, xdp};

program!(0xFFFFFFFE, "GPL");

#[xdp]
pub extern "C" fn block_port_80(ctx: XdpContext) -> XdpAction {
    if let Some(transport) = ctx.transport() {
        if transport.dest() == 80 {
            return XdpAction::Drop;
        }
    }

    XdpAction::Pass
}

Structs

Data

Data type returned by calling XdpContext::data()

PerfMap

Perf events map.

XdpContext

Context object provided to XDP programs.

Enums

Transport

The packet transport header.

XdpAction

The return type of XDP probes.