Skip to content

Instantly share code, notes, and snippets.

@williamtu
williamtu / xdp3.S
Created February 3, 2017 03:15
xdp3.S
xdp3.o: file format ELF64-BPF
Disassembly of section prog:
ebpf_filter:
; int ebpf_filter(struct xdp_md* skb){
0: r6 = r1
; void* ebpf_packetEnd = ((void*)(long)skb->data_end);
1: r4 = *(u32 *)(r6 + 4)
; void* ebpf_packetStart = ((void*)(long)skb->data);
@williamtu
williamtu / xdp3.c
Created February 3, 2017 03:11
xdp3.c
#define KBUILD_MODNAME "xdptest"
#include <linux/bpf.h>
#include "bpf_helpers.h"
#define load_byte(data, b) (*(u8 *)(data + (b)))
#define load_half(data, b) __constant_ntohs(*(u16 *)(data + (b)))
#define load_word(data, b) __constant_ntohl(*(u32 *)(data + (b)))
#define htonl(d) __constant_htonl(d)
#define htons(d) __constant_htons(d)
enum ebpf_errorCodes {
import curses
import sys, os, time, optparse, ctypes
from ctypes import *
class DebugfsProvider(object):
def __init__(self):
self.base = '/sys/kernel/debug/kvm'
self._fields = os.listdir(self.base)
def fields(self):
return self._fields