Code Monkey home page Code Monkey logo

ebpf-test's Introduction

How to build

  1. GOPACKAGE=main bpf2go -cc clang -cflags '-O2 -g -Wall -Werror' -target bpfel,bpfeb bpf main.bpf.c -- -I /ebpf-test/headers
  2. CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go build -o main ./main.go ./bpf_bpfel.go

How to run

  1. run: ./main
  2. add iptables rule: iptables -t mangle -I POSTROUTING -m bpf --object-pinned /sys/fs/bpf/ebpf-test

terminal print:

2024/04/16 11:37:52 number of packets: 0
2024/04/16 11:37:53 number of packets: 0
2024/04/16 11:37:54 number of packets: 0
2024/04/16 11:37:55 number of packets: 0
2024/04/16 11:37:56 number of packets: 0
2024/04/16 11:37:57 number of packets: 0
2024/04/16 11:37:58 number of packets: 0
2024/04/16 11:37:59 number of packets: 3042
2024/04/16 11:38:00 number of packets: 8872
2024/04/16 11:38:01 number of packets: 15375
2024/04/16 11:38:02 number of packets: 20769
2024/04/16 11:38:03 number of packets: 27420
^C2024/04/16 11:38:04 quit
2024/04/16 11:38:06 unpin

ebpf-test's People

Watchers

Ponny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.