Skip to content

Instantly share code, notes, and snippets.

View astoycos's full-sized avatar
🐝

Andrew Stoycos astoycos

🐝
View GitHub Profile
@astoycos
astoycos / invisibleSCTP.md
Last active June 16, 2022 21:59
bpf-cgroup-connect4-issues

The Issue

SCTP based connect calls are not being recorded by BPF_PROG_TYPE_CGROUP_SOCK_ADDR BPF programs when attached to the BPF_CGROUP_INET4_CONNECT hook point in the default Cgroup.

As shown below (with strace) all TCP, UDP, and SCTP clients produce connect syscalls when sending data

Syscalls made by TCP Client

socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 5
@astoycos
astoycos / Attempt-500.md
Created June 16, 2022 22:26
SCTP-Redirect-Try
SEC("cgroup/skb")
int bpf_sockops_sctp_load(struct __sk_buff *skb)
{
    void *data = (void *)(long)skb->data;
    struct eth_hdr *eth = data;
    void *data_end = (void *)(long)skb->data_end;

    __u32 dstAddr;
    int ret;
@astoycos
astoycos / xdp_redirect_ex.c
Last active February 18, 2024 02:09
XDP_REDIRECT_EX
SEC("xdp")
int xdp_nodeport_redirect(struct xdp_md *ctx)
{
void *data_end = (void *)(long)ctx->data_end;
void *data = (void *)(long)ctx->data;
struct bpf_fib_lookup fib_params = {};
struct ethhdr *eth = data;
struct tcphdr *tcph;
u16 h_proto;
u64 nh_off;
{
"start": {
"connected": [{
"socket": 5,
"local_host": "192.168.122.1",
"local_port": 47192,
"remote_host": "192.168.122.91",
"remote_port": 8789
}],
"version": "iperf 3.10.1",
@astoycos
astoycos / testing.txt
Last active March 7, 2024 06:52
First Round Proxy Testing (proxy + sk_msg)
Using Socket proxy from -> https://github.com/astoycos/netns-proxy
Native Socket redirction from -> https://github.com/astoycos/net-ebpf-playground/tree/demo/socket-redirection
1. No bpf redirection
```
[astoycos@localhost net-ebpf-playground]$ iperf3 -4 -c 192.168.122.91 -p 8789
Connecting to host 192.168.122.91, port 8789
[ 5] local 192.168.122.1 port 58868 connected to 192.168.122.91 port 8789
@astoycos
astoycos / bpf-in-ovs.md
Created September 19, 2022 18:40
Running a TC example BPF program on an Ovn-K Kind cluster
  1. Spin up an ovn-k kind cluster
  • git clone https://github.com/ovn-org/ovn-kubernetes
  • ./contrib/kind.sh
  1. Start the Aya Loader pod
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
@astoycos
astoycos / errors.txt
Last active November 8, 2022 16:49
Mac-M1-Errors
astoycos@astoycos-mac ~ % sudo ./apex-installer.sh -i
WARNING -- This script will install software on your system. It will:
* Install Homebrew (brew) if not already installed.
* Install wireguard-tools with brew.
* Download the apex agent and install it to /usr/local/sbin/apex
Continue? (y/n): y
[ ACTION ] Wireguard is not installed. Installing WireGuard...
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
@astoycos
astoycos / gist:72a9e48be8b1da174dde821c5bccf8d1
Last active January 26, 2023 02:17
Bpfd_ignfw_passing_e2e
@astoycos
astoycos / promTest.go
Created April 18, 2023 15:36
Quick example of a Prometheus probe in a golang application
// You can edit this code!
// Click here and start typing.
package main
import (
"context"
"fmt"
"time"
"net/http"
@astoycos
astoycos / Demo.md
Last active July 10, 2023 12:20
Bpfd-Heart-K8s-Demo
  1. Create Kind Cluster
kind create cluster --name=test-bpfd
  1. Deploy Cert manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml