Skip to content

Instantly share code, notes, and snippets.

View brb's full-sized avatar

Martynas Pumputis brb

View GitHub Profile
#!/usr/bin/env bash
# Copyright (C) 2013 Tom Hendrikx <tom@whyscream.net>. All Rights Reserved.
# This file is licensed under the GPLv2+. Please see COPYING for more information.
export=$1
IFS=" " # tab character
cat "$export" | while read uuid group name login passwd notes; do
test "$uuid" = "# passwordsafe version 2.0 database" && continue
test "$uuid" = "uuid" && continue
@brb
brb / libbpf.diff
Created July 22, 2021 13:49
libbpf map pin race
diff --git a/src/libbpf.c b/src/libbpf.c
index a97490c..4587950 100644
--- a/src/libbpf.c
+++ b/src/libbpf.c
@@ -4686,10 +4686,13 @@ bpf_object__create_maps(struct bpf_object *obj)
char *cp, errmsg[STRERR_BUFSIZE];
unsigned int i, j;
int err;
+ bool retried;
@brb
brb / dmesg
Last active March 8, 2019 20:00
vmalloc two failures
2019-03-08T19:36:39,224208+0000 tc: vmalloc: allocation failure, allocated 59392000 of 75501568 bytes, mode:0x6090c0(GFP_KERNEL|__GFP_NORETRY|__GFP_ZERO), nodemask=(null),cpuset=b389e318420d891300ad9658f8e056b59972fda9547dd566245a922c34bb9e42,mems_allowed=0
2019-03-08T19:36:39,224215+0000 CPU: 0 PID: 17378 Comm: tc Tainted: G C OE 5.0.0+ #1
2019-03-08T19:36:39,224216+0000 Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
2019-03-08T19:36:39,224217+0000 Call Trace:
2019-03-08T19:36:39,224233+0000 dump_stack+0x63/0x85
2019-03-08T19:36:39,224240+0000 warn_alloc+0x10b/0x190
2019-03-08T19:36:39,224242+0000 __vmalloc_node_range+0x173/0x270
2019-03-08T19:36:39,224244+0000 __vmalloc_node_flags_caller+0x47/0x50
2019-03-08T19:36:39,224246+0000 ? htab_map_alloc+0x2e4/0x4e0
2019-03-08T19:36:39,224247+0000 bpf_map_area_alloc+0x45/0x50
@brb
brb / proc-meminfo
Created March 8, 2019 11:06
vmalloc fails to alloc 75MB, Linux 5.0
MemTotal: 4037048 kB
MemFree: 170752 kB
MemAvailable: 2848280 kB
Buffers: 238708 kB
Cached: 2553912 kB
SwapCached: 0 kB
Active: 1720420 kB
Inactive: 1682980 kB
Active(anon): 612384 kB
Inactive(anon): 844 kB
@brb
brb / ipvlan.patch
Created February 12, 2019 13:47
ipvlan-no-netfilter.patch applied to v4.15.18
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 0936da592..589d7f3a5 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -145,13 +145,15 @@ config MACVTAP
To compile this driver as a module, choose M here: the module
will be called macvtap.
+config IPVLAN_L3S
+ depends on NETFILTER
@brb
brb / main.c
Created January 31, 2019 08:33
bpf_num_possible_cpus
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
static inline unsigned int bpf_num_possible_cpus(void)
{
static const char *fcpu = "/tmp/foo";
unsigned int start, end, possible_cpus = 0;
char buff[128];
@brb
brb / keybase.md
Created August 1, 2018 12:16
keybase.md

Keybase proof

I hereby claim:

  • I am brb on github.
  • I am martynasp (https://keybase.io/martynasp) on keybase.
  • I have a public key whose fingerprint is 26E3 A522 51B3 4AD1 C2CD E5CB 5385 B938 B74F 0D71

To claim this, I am signing this object:

@brb
brb / battery.sh
Created June 3, 2017 15:41
battery.sh
#!/bin/sh
# * * * * * battery.sh /home/brb/Dropbox/battery-stats.txt
set -eu
for b in /sys/class/power_supply/BAT*; do
echo "$(basename "$b") $(date +%s) $(cat ${b}/power_now) $(cat ${b}/energy_now)" >> $1
done
@brb
brb / vagabonds-img-resize.sh
Created April 8, 2017 18:55
vagabonds-img-resize.sh
#!/bin/sh
DIR="$1"
#echo "Renaming JPG -> jpg ..."
#for f in $DIR/*; do
# mv "$f" $(echo "$f" | tr '[:upper:]' '[:lower:]')
#done
for f in $DIR/*; do
@brb
brb / tshark-esp.sh
Created February 10, 2017 16:29
Decrypt AES-GCM ESP (VXLAN) packets
#!/bin/sh
set -eu
HOST=$1
PCAP=$2
AWK_CMD='{print "\"IPv4\",\"" $2 "\",\"" substr($4, 1, length($4)-1) "\",\"" $8 "\",\"AES-GCM [RFC4106]\",\"" $19 "\",\"ANY 128 bit authentication [no checking]\",\"\""}'
ssh $HOST "sudo ip -o xfrm state" | awk "$AWK_CMD" >> $HOME/.config/wireshark/esp_sa
tshark -o esp.enable_encryption_decode:TRUE -d udp.port==6784,vxlan -nr $PCAP esp