{"id":13611969,"url":"https://github.com/xdp-project/xdp-tutorial","last_synced_at":"2025-05-13T23:08:14.512Z","repository":{"id":37752295,"uuid":"172523426","full_name":"xdp-project/xdp-tutorial","owner":"xdp-project","description":"XDP tutorial","archived":false,"fork":false,"pushed_at":"2025-03-13T12:36:58.000Z","size":570,"stargazers_count":2636,"open_issues_count":168,"forks_count":609,"subscribers_count":64,"default_branch":"main","last_synced_at":"2025-04-10T20:06:06.148Z","etag":null,"topics":["bpf","libbpf","tutorial","xdp"],"latest_commit_sha":null,"homepage":null,"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/xdp-project.png","metadata":{"files":{"readme":"README.org","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-02-25T14:40:51.000Z","updated_at":"2025-04-10T12:02:53.000Z","dependencies_parsed_at":"2025-01-23T04:01:30.239Z","dependency_job_id":"86786215-d651-4f2c-8264-97db208e2a92","html_url":"https://github.com/xdp-project/xdp-tutorial","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdp-project%2Fxdp-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdp-project%2Fxdp-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdp-project%2Fxdp-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdp-project%2Fxdp-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xdp-project","download_url":"https://codeload.github.com/xdp-project/xdp-tutorial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254041531,"owners_count":22004736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","libbpf","tutorial","xdp"],"created_at":"2024-08-01T20:00:20.105Z","updated_at":"2025-05-13T23:08:09.497Z","avatar_url":"https://github.com/xdp-project.png","language":"C","readme":"# -*- fill-column: 76; -*-\n#+TITLE: XDP Programming Hands-On Tutorial\n#+OPTIONS: ^:nil\n\nThis repository contains a tutorial that aims to introduce you to the basic\nsteps needed to effectively write programs for the eXpress Data Path (XDP)\nsystem in the Linux kernel, which offers high-performance programmable\npacket processing integrated with the kernel.\n\nThe tutorial is composed of a number of lessons, each of which has its own\nrepository. Start with the lessons starting with \"basicXX\", and read the\nREADME.org file in each repository for instructions for that lesson.\n\nKeep reading below for an introduction to XDP and an overview of what you\nwill learn in this tutorial, or jump [[file:basic01-xdp-pass/README.org][straight to the first lesson]].\n\n* Table of Contents                                                     :TOC:\n- [[#introduction][Introduction]]\n- [[#first-step-setup-dependencies][First step: Setup dependencies]]\n- [[#how-the-lessons-are-organised][How the lessons are organised]]\n  - [[#basic-setup-lessons][Basic setup lessons]]\n  - [[#packet-processing-lessons][Packet processing lessons]]\n  - [[#advanced-lessons][Advanced lessons]]\n\n* Introduction\n\nXDP is a part of the upstream Linux kernel, and enables users to install\npacket processing programs into the kernel, that will be executed for each\narriving packet, before the kernel does any other processing on the data.\nThe programs are written in restricted C, and compiled into the eBPF byte\ncode format that is executed and JIT-compiled in the kernel, after being\nverified for safety. This approach offers great flexibility and high\nperformance, and integrates well with the rest of the system. For a general\nintroduction to XDP, read [[https://github.com/xdp-project/xdp-paper/blob/master/xdp-the-express-data-path.pdf][the academic paper (pdf)]], or the [[https://cilium.readthedocs.io/en/latest/bpf/][Cilium BPF\nreference guide]].\n\nThis tutorial aims to be a practical introduction to the different steps\nneeded to successfully write useful programs using the XDP system. We assume\nyou have a basic understanding of Linux networking and how to configure it\nwith the =iproute2= suite of tools, but assume no prior experience with eBPF\nor XDP. Prior programming experience is also helpful: the lessons are all\nwritten in C and they include some basic pointer arithmetic and aliasing.\n\nThe tutorial is a work in progress, and was initially created for use as a\nlive tutorial at the [[https://www.netdevconf.org/0x13/session.html?tutorial-XDP-hands-on][Netdev Conference]] in Prague in March 2019. Since the\nkernel BPF subsystem continues to develop at a rapid pace, this tutorial has\nnot kept up with all developments. However, everything presented here will\nwork with recent kernels, and this tutorial functions as a self-contained\nintroduction that anyone can go through to learn the XDP basics. Input and\ncontributions to advance towards this goal are very welcome; just open\nissues or pull requests in the [[https://github.com/xdp-project/xdp-tutorial/][Github repository]].\n\n* First step: Setup dependencies\n\nBefore you can start completing step in this tutorial, you will need to\ninstall a few dependencies on your system. These are described in\n[[file:setup_dependencies.org]].\n\nWe also provide a helper script that will set up a test environment with\nvirtual interfaces for you to test your code on. This is introduced in the\nbasic lessons, and also has [[file:testenv/README.org][it's own README file]].\n\n* How the lessons are organised\nThe tutorial is organised into a number of lessons; each lesson has its own\nsubdirectory, and the lessons are grouped by category:\n\n- Basic setup (directories starting with basicXX)\n- Packet processing (directories starting with packetXX)\n- Advanced topics (directories starting with advancedXX)\n\nWe recommend you start with the \"basic\" lessons, and follow the lessons in\neach category in numerical order. Read the README.org file in each lesson\ndirectory for instructions on how to complete the lesson.\n\n** Basic setup lessons\nWe recommend you start with these lessons, as they will teach you how to\ncompile and inspect the eBPF programs that will implement your packet\nprocessing code, how to load them into the kernel, and how to inspect the\nstate afterwards. As part of the basic lessons you will also be writing an\neBPF program loader that you will need in subsequent lessons.\n\n** Packet processing lessons\nOnce you have the basics figured out and know how to load programs into the\nkernel, you are ready to start processing some packets. The lessons in the\npacket processing category will teach you about the different steps needed\nto process data packets, including parsing, rewriting, instructing the\nkernel about what to do with the packet after processing, and how to use\nhelpers to access existing kernel functionality.\n\n** Advanced lessons\nAfter having completed the lessons in the basic and packet processing\ncategories, you should be all set to write your first real XDP program that\nwill do useful processing of the packets coming into the system. However,\nthere are some slightly more advanced topics that will probably be useful\nonce you start expanding your program to do more things.\n\nThe topics covered in the advanced lessons include how to make eBPF programs\nin other parts of the kernel interact with your XDP program, passing\nmetadata between programs, best practices for interacting with user space and\nkernel features, and how to run multiple XDP programs on a single interface.\n","funding_links":[],"categories":["Tutorials","C","Starter:","教程"],"sub_categories":["Hardware Offload","硬件卸载"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdp-project%2Fxdp-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxdp-project%2Fxdp-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdp-project%2Fxdp-tutorial/lists"}