Skip to content

Instantly share code, notes, and snippets.

View YutaroHayakawa's full-sized avatar
🌴
On vacation

Yutaro Hayakawa YutaroHayakawa

🌴
On vacation
  • Isovalent at Cisco
  • San Jose, California, US
  • 03:59 (UTC -07:00)
  • X @YutaroHayakawa
View GitHub Profile
@YutaroHayakawa
YutaroHayakawa / fedora_chroot.bash
Last active January 4, 2023 01:56
Bash script to setup simple Fedora chroot environment from container layer image
#!/bin/bash
# You can find the container image for each release from here. Please rewrite below url to your nearest one.
# https://admin.fedoraproject.org/mirrormanager/
CONTAINER_IMAGE="http://mirror.crucial.com.au/fedora/linux/releases/30/Container/x86_64/images/Fedora-Container-Base-30-1.2.x86_64.tar.xz"
function setup() {
local CHROOT=$1
@YutaroHayakawa
YutaroHayakawa / Makefile
Last active January 17, 2019 12:57
Detect deletion of kernel internal TCP socket structure on Linux using ULP and eventfd.
obj-m:=tcp_monitor.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean
@YutaroHayakawa
YutaroHayakawa / report.lua
Created October 10, 2016 14:10
Lua script for formatting output of wrk to csv
done = function(summary, latency, requests)
-- open output file
f = io.open("result.csv", "a+")
-- write below results to file
-- minimum latency
-- max latency
-- mean of latency
-- standard deviation of latency
-- 50percentile latency
@YutaroHayakawa
YutaroHayakawa / get_ip4_addr.c
Created April 29, 2016 05:52
Get IPv4 address from interface name in FreeBSD
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <net/if.h>
#include <ifaddrs.h>
#define FORMAT_IP4_ADDR "%u.%u.%u.%u"
@YutaroHayakawa
YutaroHayakawa / get_eth_addr.c
Last active April 29, 2016 05:52
Get ethernet address from interface name in FreeBSD
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/ethernet.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <ifaddrs.h>
@YutaroHayakawa
YutaroHayakawa / list.h
Created April 13, 2016 14:27
Linux kernel linked list, modified for userspace
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
#include <stdio.h>
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.