Skip to content

Instantly share code, notes, and snippets.

Pavel Odintsov pavel-odintsov

Block or report user

Report or block pavel-odintsov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pavel-odintsov
pavel-odintsov / rawfilter.c
Created Apr 27, 2018 — forked from oro350/rawfilter.c
SO_ATTACH_FILTER usage
View rawfilter.c
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/ethernet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <netpacket/packet.h>
@pavel-odintsov
pavel-odintsov / sshd.go
Created May 1, 2017 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
View sshd.go
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@pavel-odintsov
pavel-odintsov / cookiemonster.go
Created Feb 28, 2017 — forked from dacort/cookiemonster.go
Simple script to extract (encrypted) cookies out of Chrome OS X cookie store. Usage: ./cookiemonster domain.com
View cookiemonster.go
package main
import (
"golang.org/x/crypto/pbkdf2"
"crypto/aes"
"crypto/cipher"
"crypto/sha1"
"database/sql"
"fmt"
"log"
@pavel-odintsov
pavel-odintsov / stabtest.cpp
Created Feb 17, 2016 — forked from cameron314/stabtest.cpp
Simple stability test that I whipped up for exercising my lock-free queue. Compile with g++ -std=c++11 -DNDEBUG stabtest.cpp -O3 -pthread
View stabtest.cpp
#include "readerwriterqueue.h"
using namespace moodycamel;
#include <exception>
#include <fstream>
#include <thread>
#include <cstdlib> // rand()
#include <unistd.h> // usleep()
View monitor_notify.patch
diff --git a/sys/dev/netmap/netmap_monitor.c b/sys/dev/netmap/netmap_monitor.c
index 037d8e9..4027981 100644
--- a/sys/dev/netmap/netmap_monitor.c
+++ b/sys/dev/netmap/netmap_monitor.c
@@ -672,6 +672,7 @@ static int
netmap_monitor_parent_notify(struct netmap_kring *kring, int flags)
{
int error = 0;
+ int (*notify)(struct netmap_kring*, int);
ND(5, "%s %x", kring->name, flags);
@pavel-odintsov
pavel-odintsov / pps.sh
Created Nov 3, 2015 — forked from evgenypim/pps.sh
pps.sh for habrahabr
View pps.sh
#!/bin/bash
INTERVAL="1" # update interval in seconds
if [ -z "$1" ]; then
echo
echo usage: $0 [network-interface]
echo
echo e.g. $0 eth0
echo
View bit_flip.c
/*
* for use with software DIR-24-8-basic.
* personal implementation.
*/
void flip_state(uint32_t &prefix, uint8_t &position){
prefix = prefix ^ 1<<position;
}
View dir_24_8_lookup.c
// http://www.sigcomm.org/sites/default/files/ccr/papers/2012/October/2378956-2378961.pdf
int dir_24_8_lookup(uint32_t dst) {
int nh = tbl_0_23[dst >> 8]; // index in the next hop table
if (nh & 0x8000)nh = tbl_24_31[((nh & 0x7fff) << 8) | (dst & 0xff)];
return nh;
}
View README.md

This is a simple example of a low-level script that uses the Snabb Switch 82599 10G ethernet device driver directly to feed packets into a C function provided as a shared library. Written for a discussion with Pavel Odintsov.

Here is now to run it:

  1. Compile snabbswitch to get snabb executable.
  2. Compile a C callback function to a shared library e.g. capturecallback.c below.
  3. Run: sudo ./snabb snsh capture2c <pciaddress> <filename.so>

The output should look something like this:

View ixgbe-single-queue.diff
diff -Nraup ixgbe-linux-netmap/ixgbe-3.23.2.1/src/ixgbe_main.c ixgbe-linux-netmap-single-queue/ixgbe-3.23.2.1/src/ixgbe_main.c
--- ixgbe-linux-netmap/ixgbe-3.23.2.1/src/ixgbe_main.c 2015-06-20 14:23:38.457783634 +0100
+++ ixgbe-linux-netmap-single-queue/ixgbe-3.23.2.1/src/ixgbe_main.c 2015-06-20 14:23:31.330496612 +0100
@@ -686,6 +686,7 @@ static bool ixgbe_clean_tx_irq(struct ix
if (test_bit(__IXGBE_DOWN, &adapter->state))
return true;
+ if (tx_ring->queue_index == 0) {
#ifdef DEV_NETMAP
/*
You can’t perform that action at this time.