Skip to content

Instantly share code, notes, and snippets.

@cwyang
cwyang / aes_gcm.c
Created May 24, 2024 16:01
bug reporting on VPP native aes_gcm
// src/plugins/crypto_native/aes_gcm.c
static void test_aes_gcm()
{
  u8 src[32] = {0}, dst[32] = {0}, check[32] = {0};
  u8 aad[32] = {0}, iv[12] = {0}, tag[16] = {0}, key[32];
  aes_key_size_t ks = AES_KEY_256;
  aes_gcm_key_data_t kd;
  // prepare key
handle SIGUSR1 nostop noprint pass
set print pretty on
define pvec
print *$arg0@vl($arg0)
end
document pvec
pvec - display all elements of vector. Takes vector as argument
*** WARNING - SEGV likely if you put in the wrong thing
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "bento/ubuntu-22.04"
config.vm.box_check_update = false
vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 8)
vmram=(ENV['VPP_VAGRANT_VMRAM'] || 12192)
@cwyang
cwyang / test_packet.py
Created May 26, 2022 13:58
os-ken & logger perf
import sys
import logging
from os_ken.ofproto import ether, inet
from os_ken.lib.packet import ethernet
from os_ken.lib.packet import ipv4, ipv6
from os_ken.lib.packet import tcp, udp
from os_ken.lib.packet import packet, packet_utils
from os_ken.lib import addrconv
@cwyang
cwyang / ssltest.py
Created June 8, 2021 12:03
ssl teardown test
import socket, ssl, sys
if len(sys.argv) == 1:
hostname = 'www.naver.com'
else:
hostname = sys.argv[1]
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
import os
import socket
import struct
# These constants map to constants in the Linux kernel. This is a crappy
# way to get at them, but it'll do for now.
RTMGRP_LINK = 1
NLMSG_NOOP = 1
NLMSG_ERROR = 2
#!/usr/bin/env python3
import os
import time
import fnmatch
from vpp_papi import VPPApiClient
def init_vpp(vpp_json_dir='/usr/share/vpp/api/core/'):
jsonfiles = []
@cwyang
cwyang / ssl_keepalive.py
Last active February 16, 2021 02:07
open SSL connection with TCP keepalive
import socket
import ssl
def set_keepalive_linux(sock, after_idle_sec=1, interval_sec=3, max_fails=5):
"""Set TCP keepalive on an open socket.
It activates after 1 second (after_idle_sec) of idleness,
then sends a keepalive ping once every 3 seconds (interval_sec),
and closes the connection after 5 failed ping (max_fails), or 15 seconds
"""
#!/usr/bin/perl
#
# 21 Apr 2020
# Chul-Woong Yang
#
# Client (C) Proxy (P1) Proxy (P2)
# 10.10.1.1/24 10.10.2.1/24 10.10.3.1/24
# veth0 veth0 veth0
# | | |
# veth pair veth pair veth pair
img