From 496c02496ef91b6c3f4942c32da0c669faf999c0 Mon Sep 17 00:00:00 2001 From: Martin Teichmann <martin.teichmann@xfel.eu> Date: Thu, 4 Mar 2021 23:39:46 +0000 Subject: [PATCH] quickly document XDP --- ebpfcat/xdp.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ebpfcat/xdp.py b/ebpfcat/xdp.py index 522b376..60b7a1a 100644 --- a/ebpfcat/xdp.py +++ b/ebpfcat/xdp.py @@ -1,3 +1,4 @@ +"""support for XDP programs""" from asyncio import DatagramProtocol, Future, get_event_loop from enum import Enum from contextlib import contextmanager @@ -18,6 +19,8 @@ class XDPExitCode(Enum): class XDRFD(DatagramProtocol): + """just implement enough of the NETLINK protocol to attach programs""" + def __init__(self, ifindex, fd, future): self.ifindex = ifindex self.fd = fd @@ -70,6 +73,7 @@ class XDRFD(DatagramProtocol): class PacketArray: + """access a packet like a Python array""" def __init__(self, ebpf, no, memory): self.ebpf = ebpf self.no = no @@ -123,12 +127,14 @@ class PacketSize: class XDP(EBPF): + """the base class for XDP programs""" def __init__(self, **kwargs): super().__init__(prog_type=ProgType.XDP, **kwargs) self.packetSize = PacketSize(self) async def attach(self, network): + """attach this program to a `network`""" ifindex = if_nametoindex(network) fd, _ = self.load(log_level=1) future = Future() -- GitLab