{"id":19268574,"url":"https://github.com/moolen/udpf","last_synced_at":"2026-06-10T20:31:04.621Z","repository":{"id":146316801,"uuid":"165509445","full_name":"moolen/udpf","owner":"moolen","description":"UDP packet replicator","archived":false,"fork":false,"pushed_at":"2019-01-13T13:49:52.000Z","size":126,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T19:46:22.346Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moolen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-13T13:38:00.000Z","updated_at":"2019-01-13T13:49:54.000Z","dependencies_parsed_at":"2023-07-02T14:30:42.551Z","dependency_job_id":null,"html_url":"https://github.com/moolen/udpf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/moolen/udpf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moolen%2Fudpf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moolen%2Fudpf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moolen%2Fudpf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moolen%2Fudpf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moolen","download_url":"https://codeload.github.com/moolen/udpf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moolen%2Fudpf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34170162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T20:16:44.113Z","updated_at":"2026-06-10T20:31:04.597Z","avatar_url":"https://github.com/moolen.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# udpf\n\nudpf is a udp packet forwarder using eBPF in the traffic control layer.\n\n## Prerequisites\n\n* clang\n* make\n* go\n\n## Installation\n\nUse `make build TARGET=1.2.3.4` to build the go binary aswell as the bpf bytecode.\n\n* Run `sudo ./udpf -iface xxxx` to load and inject the bpf bytecode into the tc ingress\n\n## Testing\n\nuse docker-compose\n```\n$ docker-compose build; docker-compose up\n\n# get address of udpf\n$ docker inspect udpf_udpf_1 -f \"{{.NetworkSettings.Networks.udpf_default.IPAddress}}\"\n\u003e 172.22.0.4\n\n# continuously send packets there\n$ watch 'echo \"omegalul\" | nc -c -u 172.22.0.4 8125'\n\n# dump udp traffic on all devices\n$ sudo tcpdump -vvXX -eni any udp port 8125\n# [bridge -\u003e udpf] and [udpf -\u003e target_one]\n172.22.0.1.56511 \u003e 172.22.0.4.8125: [udp sum ok] UDP, length 9\n172.22.0.4.56511 \u003e 172.22.0.2.8125: [udp sum ok] UDP, length 9\n\n# check bpf debug output\n$ sudo tc exec bpf dbg\nnc-17894 [005] ..s1 16840.571481: 0: target: 33560236 48415\nnc-17894 [005] ..s1 16840.571505: 0: fib lookup successful: addr= 33560236, dmac= ffff8b984a543c22, smac= ffff8b984a543c1c\nnc-17894 [005] ..s1 16840.571513: 0: clone redirect succeeded\n\n```\n\nnow recompile bytecode with new endpoint\n```\n$ curl -i \"http://localhost:8080/reconfigure?target=reddit.com\"\n\n\n# traffic should go to target_two\n$ sudo tcpdump -vvXX -eni any udp port 8125\n# [bridge -\u003e udpf] and [udpf -\u003e target_two]\n172.22.0.1.56511 \u003e 172.22.0.4.8125: [udp sum ok] UDP, length 9\n172.22.0.4.56511 \u003e 172.22.0.3.8125: [udp sum ok] UDP, length 9\n\n```\n\n### Debugging\n\n```\n# check if progs are loaded properly\n$ sudo bpftool prog list\n[...]\n103: sched_cls  tag 59904229c5a1f55d  gpl\n\tloaded_at 2019-01-12T15:28:29+0100  uid 0\n\txlated 24B  jited 64B  memlock 4096B\n104: sched_act  tag a0410ba1cee9558a  gpl\n\tloaded_at 2019-01-12T15:28:29+0100  uid 0\n\txlated 3104B  jited 1820B  memlock 4096B\n\n# send packet to device\n$ echo \"omegalul\" | nc -c -u 127.0.0.1 8125\n\n$ sudo tc exec bpf debug\nnc-20303 [007] ..s1 17981.908325: 0: udp dest 8125\nnc-20303 [007] ..s1 17981.908334: 0: fib lookup successful: addr= 393914560, dmac= ffff919eca5c3c22, smac= ffff919eca5c3c1c\nnc-20303 [007] ..s1 17981.908345: 0: clone redirect succeeded\n\n\n# if you see `packet not forwarded` do\n$ echo 1 \u003e /proc/sys/net/ipv4/ip_forward\n\n\n# if you see: `no neighbor` do\n# to update the fib table\n$ ping -c 1 \u003cTARGET\u003e\n\n# you might want to disable checksum offloading\nsudo ethtool --offload \u003cdevice\u003e rx off tx off ; sudo ethtool -K \u003cdevice\u003e gso off\n\n```\n\n## TODO\n\n* fix fib lookup if neighbor is not known (send packet up the stack)\n* support ipv6\n\n\n## Digging deeper\n\n* Man pages `bpf(2)`, `tc-bpf(8)`\n* everything upstream in kernel, llvm and iproute2\n\t* check out linux kernel examples at `samples/bpf`\n\t* check out examples from iproute2 at `examples/bpf`\n\t* LKML bpf_fib initial impl: https://www.mail-archive.com/netdev@vger.kernel.org/msg231391.html\n* data plane programming with `P4`\n\t* http://vger.kernel.org/lpc_net2018_talks/p4-xdp-lpc18-paper.pdf\n\t* https://github.com/p4lang/p4c\n* linux tc cls-act architecture\n\t* https://people.netfilter.org/pablo/netdev0.1/papers/Linux-Traffic-Control-Classifier-Action-Subsystem-Architecture.pdf\n\t* https://www.youtube.com/watch?v=cyeJYjZHv5M\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoolen%2Fudpf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoolen%2Fudpf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoolen%2Fudpf/lists"}