Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <pcap/pcap.h>
#include <errno.h>
#include <string.h>
void hd(void *data, int size)
{
/* dumps size bytes of *data to stdout. Looks like:
--- a/net/tipc/topsrv.c
+++ b/net/tipc/topsrv.c
@@ -222,6 +222,17 @@ static struct tipc_conn *tipc_conn_lookup(struct tipc_topsrv *s, int conid)
return con;
}
+static bool sub_match(struct tipc_subscr *left, struct tipc_subscr *right) {
+
+ if (memcmp(&left->seq, &right->seq, sizeof(struct tipc_service_range)) != 0)
+ return false;
@Hugne
Hugne / spam.c
Last active June 8, 2016 19:36
tipc connection spam test
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <linux/tipc.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <unistd.h>
static void diep(const char *msg)
{
@Hugne
Hugne / gist:239658ab50d49799f77e
Created March 1, 2016 19:55
tipc UDP media OOPS
[root@kdev ]# tipc bearer ena media udp name v6ll localip fe80::5054:ff:fec8:260
2%eth0
[ 232.842738] Enabled bearer <udp:v6ll>, discovery domain <1.1.0>, priority 10
[root@kdev ]# [ 280.482496] skbuff: skb_under_panic: text:ffffffff81762e58 len:122 put:14 head:ffff88001f903800 data:ffff88001f9037f6 tail:0x70 end:0x2c0 dev:eth0
[ 280.484495] ------------[ cut here ]------------
[ 280.484495] kernel BUG at net/core/skbuff.c:102!
[ 280.484495] invalid opcode: 0000 [#1] SMP
[ 280.484495] Modules linked in: tipc ip6_udp_tunnel udp_tunnel virtio_net virtio_pci virtio_ring virtio [last unloaded: ip6_udp_tunnel]
[ 280.484495] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.0-rc6+ #8
[ 280.484495] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
@Hugne
Hugne / dock.txt
Last active September 29, 2015 07:52
Fix display setup at laptop dock/undock
#Create a file, /etc/udev/rules.d/90-docking-station.rules with the following content.
#You will need to change the USB ID to match the docking station for your laptop brand,
#or some USB device attached to the dock
## ID 413c:2513 Dell Computer Corp. internal USB Hub of E-Port Replicator
SUBSYSTEM=="usb", ENV{ID_SERIAL}=="413c_2513", ACTION=="add|remove", RUN+="/usr/local/bin/dock-action $env{ACTION}"
#Create this file and chmod a+x it, /usr/local/bin/dock-action
#In addition to 'yourloginname', you will have to change the output names (DP2/DP3) to match your
# displays and their orientation. Execute xrandr to see the available outputs
@Hugne
Hugne / epoll_server.c
Last active September 10, 2015 13:06
Epoll test
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/epoll.h>
Date: Fri, 14 Aug 2015 13:48:34 +0200
From: XXXX
To: XXXX
Cc: XXXX, XXXX
Subject: Re: crash on ns deletion
User-Agent: Mutt/1.5.21 (2010-09-15)
On Fri, Aug 14, 2015 at 01:46:02PM +0200, XXX wrote:
> Here's plan B, Only spawn topology server in the initial namespace:
>
@Hugne
Hugne / schedtest.c
Created July 28, 2015 10:59
schedtest.c
#include <stdio.h>
#include <stdint.h>
#include <sched.h>
#include <assert.h>
void doit(void)
{
struct sched_param sp1 = {
.sched_priority = 50
};
resolve () {
#lolers way of resolving an mdns service
res=`avahi-browse -vrptk $SERV_TYPE`
if [ $? -ne 0 ]; then
echo "avahi-browse fail" >&2
exit 1
fi
srv=`echo "$res" | awk '$1 ~ /=/ && match($0, /'$SERV_NAME'/) {gsub(";"," "); print $8":"$9;}'`
URL="http://$srv"
}
@Hugne
Hugne / sctp.c
Last active August 29, 2015 14:22
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <linux/sctp.h>
#include <stdio.h>
/**
* Small program to flood a system with SCTP assoc requests
* (needs libsctp/libsctp-dev packages to build)
* gcc sctp.c -o sctp -lsctp