{"id":16161425,"url":"https://github.com/gamemann/xdp-stats","last_synced_at":"2026-03-08T04:31:45.430Z","repository":{"id":92735946,"uuid":"406548453","full_name":"gamemann/XDP-Stats","owner":"gamemann","description":"XDP programs that increment stat counters for packets/bytes.","archived":false,"fork":false,"pushed_at":"2022-12-09T12:16:38.000Z","size":38,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T13:41:23.511Z","etag":null,"topics":["bpf","bytes","c","increment","libbpf","packets","stats","xdp"],"latest_commit_sha":null,"homepage":"https://moddingcommunity.com/forums/topic/74-xdp-stats-net-programming","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gamemann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2021-09-14T23:19:04.000Z","updated_at":"2025-02-16T12:56:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea7d9ff0-24cc-4c3b-977b-3ba0e6fb4427","html_url":"https://github.com/gamemann/XDP-Stats","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gamemann/XDP-Stats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FXDP-Stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FXDP-Stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FXDP-Stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FXDP-Stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamemann","download_url":"https://codeload.github.com/gamemann/XDP-Stats/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FXDP-Stats/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30245220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T00:58:18.660Z","status":"online","status_checked_at":"2026-03-08T02:00:06.215Z","response_time":56,"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":["bpf","bytes","c","increment","libbpf","packets","stats","xdp"],"created_at":"2024-10-10T02:25:13.692Z","updated_at":"2026-03-08T04:31:45.408Z","avatar_url":"https://github.com/gamemann.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XDP Stats\n## Description\nThis is a program that calculates stats inside of an XDP program (support for both dropping and TX'ing the packet). As of right now, the stats are just the amount of packets and bytes (including per second).\n\nThe stats are calculated to **UDP** packets with the destination port `27015` by default. You may adjust the port inside of `src/include.h`. If you comment out the `TARGETPORT` define with `//`, it will calculate stats for packets on all ports.\n\n## Command Line Options\nThere are two command line options for this program which may be found below.\n\n* `-i --interface` =\u003e The interface name to attempt to attach the XDP program to (**required**).\n* `-t --time` =\u003e How long to run the program for in seconds.\n* `-x --afxdp` =\u003e Calculate packet counters inside of an AF_XDP program and drop or TX them.\n* `-r --tx` =\u003e TX the packet instead of dropping it (supports both XDP and AF_XDP).\n* `-c --cores` =\u003e If AF_XDP is specified, use this flag to override how many threads/AF_XDP sockets are spun up (keep in mind this should be the amount of RX queue you have since these bind to an individual RX queue).\n* `-s --skb` =\u003e Force SKB mode.\n* `-o --offload` =\u003e Try loading the XDP program in offload mode.\n\n## TX Modes\nThere are two modes and they must be adjusted inside of the source file. By default, an FIB lookup is performed inside of the XDP program and if a match is found, it will TX the packet + update the stats in the raw XDP or AF_XDP programs. Otherwise, the packet is dropped.\n\nThe second mode simply switches the ethernet header's source and destination MAC address and TX's the packet back out. For performance reasons, I didn't include it as a command line option. Instead, you will need to go to `src/xdp/raw_xdp_tx.c` (for raw XDP) or `src/af_xdp/raw_xdp_tx.c` and comment out the `#define FIBLOOKUP` line by adding `//` in-front. For example:\n\n```C\n//#define FIBLOOKUP\n```\n\n## Building\nYou may use the following to build the program.\n\n```\n# Clone the repository and libbpf (with the --recursive flag).\ngit clone --recursive https://github.com/gamemann/XDP-Stats.git\n\n# Change directory to the repository.\ncd XDP-Stats\n\n# Build the program.\nmake\n\n# Install the program. The program is installed to /usr/bin/xdpstats\nsudo make install\n```\n\n## Credits\n* [Christian Deacon](https://github.com/gamemann)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemann%2Fxdp-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamemann%2Fxdp-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemann%2Fxdp-stats/lists"}