Skip to content

Instantly share code, notes, and snippets.

 INTERFACE PROTOCOL STATE DATA 
┌ br0 ethernet up  0a:60:83:13:6f:d3
└────────────────── bridge vlan:10t,20t
┌ e1 ethernet up  12:61:ed:de:ed:09
└────────────────── bridge forwarding upper:br0 vlan:10t,20t
┌ e2 ethernet up  0a:60:83:13:6f:d3
└────────────────── bridge BLOCKING  upper:br0 vlan:10t,20t
usage()
{
cat <<EOF
usage: $0 [-h] [-a <period>]
Measure bridge ingress times. Without -a, print each packet's ingress
time. With -a, aggregate data in <period> sized buckets (in
nanoseconds).
EOF
import subprocess
def vmlinux_kaslr_base():
out = subprocess.run("awk '/ _text$/ { print($1); exit(0); }' /proc/kallsyms",
shell=True, capture_output=True)
if out.returncode != 0:
raise Exception("Unable to determine the running kernel's base address")
base = int(out.stdout.decode(), 16)
if base == 0:
@wkz
wkz / kfunc-get.sh
Created June 30, 2022 22:54
fzf + pahole = <3
#!/bin/sh
describe()
{
{
pfunct -f "$1"
echo
pfunct -f "$1" --no_parm_names | awk '
{
gsub("[a-zA-Z0-9_]+\\(","");
@wkz
wkz / sniff.sh
Created April 28, 2018 15:02
Mirror a set of interfaces to a sniffer interface, ignoring 802.1Q tag information.
#/!bin/sh
# usage: sniff.sh <interface> [<interface>...]
# create a dummy to mirror all traffic to
ip link add dev sniffer type dummy
ip link set dev sniffer up
# intermediate dummy, needed because AF_PACKET-sockets gets the packet
# as seen before any tc-actions have been applied to it.
ip link add dev untag type dummy
@wkz
wkz / moxa-usb-console.md
Created March 13, 2018 09:17
Moxa USB Console on Linux

Moxa's ethernet switches come with a USB console that is not recognized by the Linux kernel. Moxa have drivers available for download on their website, but only for Windows.

The device shows up in lsusb as:

Bus X Device Y: ID 110a:3001 Moxa Technologies Co., Ltd. 
@wkz
wkz / printxf.c
Last active October 25, 2017 09:30
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "printxf.h"
struct printxf printxf_default;
@wkz
wkz / lisp.c
Created October 21, 2017 22:13
/* {
* @t[0] = time();
* @reads[pid()] = quantize(arg2)
* }
*/
prog->ast =
node_expr("",
node_expr("=",
node_expr("[]",
node_ident("@t"),
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <ev.h>
#include <linux/udp.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
@wkz
wkz / lpm.py
Last active September 21, 2016 06:53
lpm
# http://web.mit.edu/devavrat/www/tcam.pdf
import random
import time
class Row(object):
valid = False
ip = None
prefix = None