Preserving Buffer Cache State - 2011-07-25 00:00:00

When archiving big files (for example a big database) rsync feeds uselessly the disk cache. Thanks to the posix_fadvise linux system call we can tell the operating system that keeping archived data in cache is useless, leaving the disk cache for other applications (ie: the database). Tobi Oetiker explains this on his blog and made a patch for rsync. The patch does not work out of the box and needed little modifications.

Colored less output - 2011-07-26 00:00:00

To colorize the output of less, use the GNU Source-highlight tool. Install Debian package: $ sudo apt-get install source-highlight Add this to your shell configuration file: export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s" export LESS=' -R '

Various reminders about OpenSSL and Certificates - 2011-07-29 00:00:00

Create a self-signed Certificate authority Create an RSA key Use the genrsa command to create the server private key with the following properties: The key is protected with the symetric AES256 algorithm. (protecting the key is not mandatory) The key is 2048 bits long. Here is the command: $ openssl genrsa -aes256 -out private/server.key 2048 Generating RSA private key, 2048 bit long modulus ...............................................................................................+++ ..+++ unable to write 'random state' e is 65537 (0x10001) Enter pass phrase for test.

Using a free CDN, Cloudflare - 2011-08-08 00:00:00

CDN: Content delivery network A CDN act as a cache for static ressources of your web server. One famous CDN is Akamai but is quite expensive. CDN architecture is quite complex with a set of multiple proxies located in multiple datacenters around the world. The goal is to reduce the distance to the minimum between the served ressource and the user asking for the ressource. A CDN not only saves the bandwith and load of your server but also global Internet peers involved between the client and the server.

Standalone Python project/installation - 2011-08-16 00:00:00

Let’s take an example of installing Django without using Debian apt command. We will use virtualenv to make a self-contained python directory. First create your installation directory: $ mkdir -p project/django $ cd project/django Get the virtualenv tool: $ wget --no-check-certificate 'https://raw.github.com/pypa/virtualenv/develop/virtualenv.py' Create the virtual environment: $ python virtualenv.py --no-site-packages --distribute python_django_env Note interesting parameters:: --no-site-packages Don't give access to the global site-packages dir to the virtual environment --distribute Use Distribute instead of Setuptools.

C pointers & Ksplice challenge - 2011-10-19 00:00:00

C pointers & Ksplice challenge The Ksplice Pointer Challenge. #include <stdio.h> int main() { int x[5]; printf("%p\n", x); printf("%p\n", x+1); printf("%p\n", &x); printf("%p\n", &x+1); return 0; } On a 64bits architecture: 0x7fffe4a594d0 0x7fffe4a594d4 0x7fffe4a594d0 0x7fffe4a594e4

Pipe Viewer - 2012-05-25 00:00:00

Pipe Viewer To visualize data throughput through a pipe use Pipe Viewer tool. $ sudo apt-get install pv For example just replace every pipe with | pv |: $ cat bigfile.txt | gzip -9 > /tmp/test.gz $ ```shell $ cat bigfile.txt | pv | gzip -9 > /tmp/test.gz 14MB 0:00:00 [22.6MB/s] [ <=> ] $

Trickle, lightweight userspace bandwidth shaper - 2012-07-10 00:00:00

What “Trickle is a portable lightweight userspace bandwidth shaper. It can run in collaborative mode (together with trickled) or in stand alone mode.” Before, no limitation: $ wget 'http://wwww.example.org/somefile' --2012-07-10 14:46:13-- http://wwww.example.org/somefile [ ... ] 2012-07-10 14:46:13 (866 KB/s) - `somefile' saved [12485] After, limited to 40 kbit/s: $ trickle -v -s -d 40 wget 'http://www.example.org/somefile' --2012-07-10 14:50:27-- http://wwww.example.org/somefile [ ... ] wget: [trickle] avg: 20.8 KB/s; win: 20.8 KB/s wget: [trickle] avg: 40.

Updating IP routes programmatically - 2012-12-10 00:00:00

ioctl(2) is a special system call used when no other system call can handle a specific I/O operation. For exemple, the generic write(2) syscall is used for writing to a specified file descriptor but there is neither syscall to open the CD-tray nor syscall to manage routing tables: ioctl is here as a fit-all syscall. From the man page: NAME ioctl - control device SYNOPSIS #include <sys/ioctl.h> int ioctl(int d, int request, void *args); DESCRIPTION The ioctl() function manipulates the underlying device parameters of special files.

Linking Rust Library with C - 2014-12-17 00:00:00

Introduction Rust is a system programming Language developed by Mozilla. For a C-like language, it features interesting paradigms: functional style, actors, object oriented, safe memory allocation and free In this article we will link a Rust library with a C program. Tools used: rustc 0.13.0-nightly (5484d6f6d 2014-12-02) gcc (Debian 4.9.1-19) 4.9.1 docker Installation Compiling the Rust compiler takes quite some time, so I decided to use a nightly built container of the compiler:

Playing with the Erlang Linc Switch - 2014-12-19 00:00:00

Introduction Linc is a software switch in Erlang, which support Openflow 1.4. Here we will try to install it and make it run in a simple scenario. Later we will try to use it with an openflow compatible Controller (maybe Opendaylight or FlowER). Installation $ git clone https://github.com/FlowForwarding/LINC-Switch.git $ sudo apt-get install libpcap0.8-dev $ cd LINC-Switch $ cp rel/files/sys.config.orig rel/files/sys.config $ make Note that at some point during installation, root privileges are required to use the setcap utility.

Installing Lineage OS to a Samsung Galaxy A3 - 2020-02-18 00:00:00

Introduction Heimdal Build Heimdal git clone https://gitlab.com/BenjaminDobell/Heimdall.git sudo dnf install libusb-devel.x86_64 cd Heimdall mkdir build; cd build cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_FRONTEND .. make Check installation Put your device in download mode, on the A3 it’s: 1 Switch OFF device 2 Volume Down + Home button + Power button. 3 Choose Download mode: Volume Up $ sudo ./heimdal detect Download PIT file $ sudo ./heimdall download-pit --output 'a3-2020-02-20.pit' --verbose Heimdall v1.

OpenSSH related stuff - 2020-04-02 00:00:00

Create a ed25519 SSH key ECC: Elliptic Curve Cryptography is a family of algorithms (ECDSA, ed25519) Curve25519: name of the elliptic curve Ed25519: Name of the signature algorithm $ ssh-keygen -a 100 -t ed25519 -b 521 -f ~/.ssh/id_ed25519.barbot.org -C "julien@barbot.org" You can look at explainshell.com to understand each parameters. Use this key for specific hosts: $ cat .ssh/config Host github.com IdentityFile ~/.

Playing with the P4 language - 2020-04-02 00:00:00

Introduction P4 is a domain-specific compiled programming language for network data forwarding. It does not know anything about already existing protocols: it doesn’t know IP, nor TCP. A P4 program is compiled to something that is understandable by the P4 aware device. Such device can be a really hardware switch, a software switch, a FPGA. In this article we will try to use a software switch. More precisely, the uBPF backend.

Playing with uBPF - 2020-04-02 00:00:00

Introduction uBPF is a user-land implementation of the eBPF VM. Installation $ git clone https://github.com/iovisor/ubpf.git $ cd ubpf $ make -C vm This compiles the ubpf library (libubpf.a) and a test program to use this library. Run a simple eBPF program with uBPF static int idouble(int a) { return (a * 2); } int bpf_prog(void *ctx) { int a = 1; a = idouble(a); return (a); } Compile to a BPF binary, which is executable by the kernel eBPF VM, or, in our specific case, the user-land uBFP VM.