Skip to content

Instantly share code, notes, and snippets.

View pavel-odintsov's full-sized avatar
🛡️
On mission to deliver affordable DDoS protection

Pavel Odintsov pavel-odintsov

🛡️
On mission to deliver affordable DDoS protection
View GitHub Profile
@pavel-odintsov
pavel-odintsov / patricia_performance_tests.cpp
Last active February 20, 2022 21:04
Patricia performance test for Medium
#include <arpa/inet.h>
#include <fstream>
#include <iostream>
#include <math.h>
#include <netinet/in.h>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <sys/socket.h>
#include <sys/time.h>
@pavel-odintsov
pavel-odintsov / vimrc
Last active May 8, 2022 13:23
vimrc_odintsov
"
" First of all, pleae install latest vim for convinience: https://launchpad.net/~jonathonf/+archive/ubuntu/vim
" Then install vim go
" git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
"
" Fix arrow keys that display A B C D on remote shell:
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
@pavel-odintsov
pavel-odintsov / pps.sh
Created November 3, 2015 11:41 — forked from evgenypim/pps.sh
pps.sh for habrahabr
#!/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
package qxp;
use strict;
# code from: https://code.google.com/p/qxp/source/browse/qxp/qxp.pm
sub H($){pack'H*',$_[0]}
sub by{map{[splice@_,1,$_[0]]}!($#_%$_[0])..$#_/$_[0]}
sub is($){$_ eq$_[0]}
sub cat{join'',@_}
sub list{@_}
@pavel-odintsov
pavel-odintsov / irq_balance_habrahabr.sh
Created June 25, 2015 12:25
irq_balance_habrahabr.sh
#!/bin/bash
# from http://habrahabr.ru/post/108240/
ncpus=`grep -ciw ^processor /proc/cpuinfo`
test "$ncpus" -gt 1 || exit 1
n=0
for irq in `cat /proc/interrupts | grep eth | awk '{print $1}' | sed s/\://g`
do
f="/proc/irq/$irq/smp_affinity"
@pavel-odintsov
pavel-odintsov / pps.sh
Last active August 27, 2023 20:21
Simple script to print packet rate for interface
#!/bin/bash
# Interval of calculation in seconds
INTERVAL="1"
if [ -z "$1" ]; then
echo
echo usage: $0 [network-interface]
echo
echo e.g. $0 eth0
@pavel-odintsov
pavel-odintsov / af_packet_rx_ring.c
Last active March 4, 2024 11:04
af_packet_rx_ring_habrahabr.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <unistd.h>
#include <boost/thread.hpp>
#include <sys/mman.h>
#include <poll.h>
#include <arpa/inet.h>
@pavel-odintsov
pavel-odintsov / af_packet_classic.c
Last active March 4, 2022 16:14
af_packet_classic_habrahabr
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <unistd.h>
#include <boost/thread.hpp>
#include <arpa/inet.h>
#include <sys/socket.h>
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
/*
@pavel-odintsov
pavel-odintsov / irq_balance_manually.sh
Created June 1, 2015 11:47
irq_balance_manually.sh
#!/bin/bash
# from http://habrahabr.ru/post/108240/
ncpus=`grep -ciw ^processor /proc/cpuinfo`
test "$ncpus" -gt 1 || exit 1
n=0
for irq in `cat /proc/interrupts | grep eth | awk '{print $1}' | sed s/\://g`
do
f="/proc/irq/$irq/smp_affinity"