SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
©2016 Open-NFP 1
BPF and XDP Explained
Nic Viljoen
©2017 Open-NFP 2
Objectives of the Webinar
Give user a basic understanding of the architecture of eBPF
▪ What is it
▪ The programming model
▪ The kernel hooks
Give user a basic understanding of XDP
▪ What is it/Where is it
▪ How to use it (beginner level!)
▪ How to offload it
©2016 Open-NFP 3
What is eBPF?
eBPF is a simple way to extend the functionality of the kernel
at runtime
▪ Effectively a small kernel based machine
▪ 10 64bit registers
▪ 512 byte stack
▪ Data structures known as maps (unlimited size)
▪ 4K BPF instructions (Bytecode)
▪ Verifier to ensure kernel safe
▪ no loops, not more than 4K insns, not more than 64 maps etc…
▪ Can be JITed to ensure maximum performance
©2016 Open-NFP 4
Used Within Hyperscale-Not a Toy!
Those who have publically stated they are using BPF or are
planning to use BPF include
▪ Facebook-Load Balancing, Security
▪ Netflix-Network Monitoring
▪ Cilium Project
▪ Cloudflare-Security
▪ OVS-Virtual Switching
Due to its upstream safety and kernel support BPF
provides a safe, flexible and scalable networking tool
©2016 Open-NFP 5
The Programming Model
LLVM is used to compile from
supported languages
▪ C
▪ Go
▪ P4
When Programs are loaded
▪ Verifier is called-ensure safety
▪ Program is JITed-ensure perf
▪ Can also be offloaded
▪ nfp_bpf_jit upstream
LL VM
NFP
verifier.c
bpf_prog.go
bpf_prog.elf
bpf syscall
USER
JIT nfp_bfp_jit.c
Host CPU
KERNEL
HARDWARE
bpf_prog.p4
bpf_prog.c
©2016 Open-NFP 6
Maps-What They Are
Maps are key value stores
▪ Can be accessed from kernel or user space
▪ Used for interaction between kernel and user space programs
Number of different types of maps
▪ Used for interaction between kernel and user space programs
bpf_user.c
bpf_kern.c
Map
©2017 Open-NFP 7
Maps-How to use them
Creating Maps
▪ Option 1: create map with syscall
▪ bpf(BPF_MAP_CREATE, &bpf_attr, sizeof(bpf_attr))
▪ Option 2: define a struct bpf_map_def with an elf section
__attribute__ SEC(“maps”)-also uses syscall!
Option 1 Option 2
THIS IS AN OVERSIMPLIFICATION
©2017 Open-NFP 8
eBPF Bytecode: Quick Overview
eBPF Bytecode: op:8, dst_reg:4, src_reg:4, off:16, imm:32
▪ op code is divided into the sections
▪ Operation code (4bits) e.g BPF_MOV, BPF_JNE
▪ Source bit (1 bit) BPF_X (use src_reg and dst_reg) or BPF_K
(use dst_reg and 32 bit imm)
▪ instruction class (3 bits) e.g BPF_ALU, BPF_ALU64, BPF_JMP
▪ BPF_MOV | BPF_X | BPF_ALU64, 0x6, 0x1, 0x0000, 0x00000000
▪ Move contents of register 1 to register 6
▪ BPF_JNE | BPF_K | BPF_JMP, 0x1, 0x0, 0x0011, 0x00008100
▪ Jump 11 insns forward-can also jump backwards-if contents of
register 1 is not equal to 0x00008100
©2017 Open-NFP 9
BPF Kernel Hooks
Many hooks with different purposes
▪ kprobes
▪ socket filters-tcpdump-old school!
▪ seccomp
▪ netfilter (new)
▪ TC
▪ XDP(no skb-super fast!)
XDP will be our focus for the rest of this talk
©2017 Open-NFP 10
XDP
BPF hook in the driver
▪ Allows for high speed processing before skb is attached to packet
▪ Currently 4 return codes: XDP_ABORT, XDP_DROP, XDP_PASS,
XDP_TX
▪ XDP_REDIRECT in the pipeline
▪ Usecases include DDoS protection and load balancing
▪ Includes maximum of 256 bytes of prepend
▪ Metadata is just pointers to start of packet and end
©2017 Open-NFP 11
Program Example (xdp1_kern.c)
Simple drop example
▪ Note the use of standard header infrastructure
▪ Associated user space program maintaining a set of counters
▪ I am not going to go through line by line-for more detail check out
Andy and Jesper’s awesome tutorial-in links
▪ Will come back to this example later on…
This can be found in the recent (4.8+) kernels at
linux/samples/bpf
©2017 Open-NFP 12
Optimizing XDP
A simple checklist-not comprehensive!
▪ Ensure BPF JIT is enabled
▪ Pin queues to interfaces
▪ Set ringsize to an optimal level for your NIC and application
▪ To gain some idea of your NIC’s driver based XDP performance
check simple XDP_DROP and XDP_TX programs
▪ Many people use single core performance as a reasonable
benchmark
▪ To do this use the ethtool -X command
▪ You will NOT get the simple program performance if you build
something complex (Duh)
©2017 Open-NFP 13
Offloading XDP
Netronome have upstreamed the initial version of the
nfp_bpf_jit
▪ More to come!
©2017 Open-NFP 14
Offload Architecture
user space
kernel space
BPF syscall
● program
● type (sk filter, kprobe, cls, xdp)
● license
● ...
verifier
fd
host JIT
tc
TC
cls_bpf
modification
XDP
ctrl
offload
object
fd, skip_* flags
verification
fd, skip_* flags
driver
RX TXXDP
ndo
setup
tc
HW JIT /
translator
stats
&
maps
BPF
prog
©2017 Open-NFP 15
References
Kernel Docs: https://www.kernel.org/doc/Documentation/networking/filter.txt
Initial XDP Presentation: https://github.com/iovisor/bpf-docs/blob/master/
Express_Data_Path.pdf
More Docs: http://prototype-kernel.readthedocs.io/en/latest/README.html
Andy and Jesper’s Talk: https://netdevconf.org/2.1/slides/apr7/gospodarek-
Netdev2.1-XDP-for-the-Rest-of-Us_Final.pdf
Reading List: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/
Search: google.com :)
©2016 Open-NFP 16
ANY QUESTIONS?
Thanks!

Weitere ähnliche Inhalte

Was ist angesagt?

OpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouterOpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouterOpen-NFP
 
Whitebox Switches Deployment Experience
Whitebox Switches Deployment ExperienceWhitebox Switches Deployment Experience
Whitebox Switches Deployment ExperienceAPNIC
 
Data Plane and VNF Acceleration Mini Summit
Data Plane and VNF Acceleration Mini Summit Data Plane and VNF Acceleration Mini Summit
Data Plane and VNF Acceleration Mini Summit Open-NFP
 
Compiling P4 to XDP, IOVISOR Summit 2017
Compiling P4 to XDP, IOVISOR Summit 2017Compiling P4 to XDP, IOVISOR Summit 2017
Compiling P4 to XDP, IOVISOR Summit 2017Cheng-Chun William Tu
 
2016 NCTU P4 Workshop
2016 NCTU P4 Workshop2016 NCTU P4 Workshop
2016 NCTU P4 WorkshopYi Tseng
 
[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4Open Networking Summits
 
LF_DPDK17_GRO/GSO Libraries: Bring Significant Performance Gains to DPDK-base...
LF_DPDK17_GRO/GSO Libraries: Bring Significant Performance Gains to DPDK-base...LF_DPDK17_GRO/GSO Libraries: Bring Significant Performance Gains to DPDK-base...
LF_DPDK17_GRO/GSO Libraries: Bring Significant Performance Gains to DPDK-base...LF_DPDK
 
LinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVSLinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVSThomas Graf
 
Disaggregation a Primer: Optimizing design for Edge Cloud & Bare Metal applic...
Disaggregation a Primer: Optimizing design for Edge Cloud & Bare Metal applic...Disaggregation a Primer: Optimizing design for Edge Cloud & Bare Metal applic...
Disaggregation a Primer: Optimizing design for Edge Cloud & Bare Metal applic...Netronome
 
Comprehensive XDP Off‌load-handling the Edge Cases
Comprehensive XDP Off‌load-handling the Edge CasesComprehensive XDP Off‌load-handling the Edge Cases
Comprehensive XDP Off‌load-handling the Edge CasesNetronome
 
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RCThe Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RCThomas Graf
 
Cilium - BPF & XDP for containers
 Cilium - BPF & XDP for containers Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containersDocker, Inc.
 
Programmable data plane at terabit speeds
Programmable data plane at terabit speedsProgrammable data plane at terabit speeds
Programmable data plane at terabit speedsBarefoot Networks
 
Linux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network SecurityLinux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network SecurityThomas Graf
 
20170925 onos and p4
20170925 onos and p420170925 onos and p4
20170925 onos and p4Yi Tseng
 
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)Thomas Graf
 
Linux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesLinux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesKernel TLV
 
eBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux KerneleBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux KernelThomas Graf
 
Host Data Plane Acceleration: SmartNIC Deployment Models
Host Data Plane Acceleration: SmartNIC Deployment ModelsHost Data Plane Acceleration: SmartNIC Deployment Models
Host Data Plane Acceleration: SmartNIC Deployment ModelsNetronome
 

Was ist angesagt? (20)

OpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouterOpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouter
 
Whitebox Switches Deployment Experience
Whitebox Switches Deployment ExperienceWhitebox Switches Deployment Experience
Whitebox Switches Deployment Experience
 
Data Plane and VNF Acceleration Mini Summit
Data Plane and VNF Acceleration Mini Summit Data Plane and VNF Acceleration Mini Summit
Data Plane and VNF Acceleration Mini Summit
 
Compiling P4 to XDP, IOVISOR Summit 2017
Compiling P4 to XDP, IOVISOR Summit 2017Compiling P4 to XDP, IOVISOR Summit 2017
Compiling P4 to XDP, IOVISOR Summit 2017
 
2016 NCTU P4 Workshop
2016 NCTU P4 Workshop2016 NCTU P4 Workshop
2016 NCTU P4 Workshop
 
[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4
 
LF_DPDK17_GRO/GSO Libraries: Bring Significant Performance Gains to DPDK-base...
LF_DPDK17_GRO/GSO Libraries: Bring Significant Performance Gains to DPDK-base...LF_DPDK17_GRO/GSO Libraries: Bring Significant Performance Gains to DPDK-base...
LF_DPDK17_GRO/GSO Libraries: Bring Significant Performance Gains to DPDK-base...
 
LinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVSLinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVS
 
Disaggregation a Primer: Optimizing design for Edge Cloud & Bare Metal applic...
Disaggregation a Primer: Optimizing design for Edge Cloud & Bare Metal applic...Disaggregation a Primer: Optimizing design for Edge Cloud & Bare Metal applic...
Disaggregation a Primer: Optimizing design for Edge Cloud & Bare Metal applic...
 
Comprehensive XDP Off‌load-handling the Edge Cases
Comprehensive XDP Off‌load-handling the Edge CasesComprehensive XDP Off‌load-handling the Edge Cases
Comprehensive XDP Off‌load-handling the Edge Cases
 
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RCThe Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
 
Cilium - BPF & XDP for containers
 Cilium - BPF & XDP for containers Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containers
 
Ebpf ovsconf-2016
Ebpf ovsconf-2016Ebpf ovsconf-2016
Ebpf ovsconf-2016
 
Programmable data plane at terabit speeds
Programmable data plane at terabit speedsProgrammable data plane at terabit speeds
Programmable data plane at terabit speeds
 
Linux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network SecurityLinux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network Security
 
20170925 onos and p4
20170925 onos and p420170925 onos and p4
20170925 onos and p4
 
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)
Taking Security Groups to Ludicrous Speed with OVS (OpenStack Summit 2015)
 
Linux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesLinux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use Cases
 
eBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux KerneleBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux Kernel
 
Host Data Plane Acceleration: SmartNIC Deployment Models
Host Data Plane Acceleration: SmartNIC Deployment ModelsHost Data Plane Acceleration: SmartNIC Deployment Models
Host Data Plane Acceleration: SmartNIC Deployment Models
 

Ähnlich wie Transparent eBPF Offload: Playing Nice with the Linux Kernel

Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...Anne Nicolas
 
P4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC OffloadP4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC OffloadOpen-NFP
 
BPF Hardware Offload Deep Dive
BPF Hardware Offload Deep DiveBPF Hardware Offload Deep Dive
BPF Hardware Offload Deep DiveNetronome
 
eBPF in the view of a storage developer
eBPF in the view of a storage developereBPF in the view of a storage developer
eBPF in the view of a storage developerRichárd Kovács
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringScyllaDB
 
Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!Ray Jenkins
 
P4+ONOS SRv6 tutorial.pptx
P4+ONOS SRv6 tutorial.pptxP4+ONOS SRv6 tutorial.pptx
P4+ONOS SRv6 tutorial.pptxtampham61268
 
DEF CON 27 - JEFF DILEO - evil e bpf in depth
DEF CON 27 - JEFF DILEO - evil e bpf in depthDEF CON 27 - JEFF DILEO - evil e bpf in depth
DEF CON 27 - JEFF DILEO - evil e bpf in depthFelipe Prado
 
The Past, Present, and Future of OpenACC
The Past, Present, and Future of OpenACCThe Past, Present, and Future of OpenACC
The Past, Present, and Future of OpenACCinside-BigData.com
 
OpenStack and NetApp - Chen Reuven - OpenStack Day Israel 2017
OpenStack and NetApp - Chen Reuven - OpenStack Day Israel 2017OpenStack and NetApp - Chen Reuven - OpenStack Day Israel 2017
OpenStack and NetApp - Chen Reuven - OpenStack Day Israel 2017Cloud Native Day Tel Aviv
 
OpenPOWER Application Optimization
OpenPOWER Application Optimization OpenPOWER Application Optimization
OpenPOWER Application Optimization Ganesan Narayanasamy
 
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core ArchitecturesPerformance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core ArchitecturesDr. Fabio Baruffa
 
FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)Kirill Tsym
 
FD.IO Vector Packet Processing
FD.IO Vector Packet ProcessingFD.IO Vector Packet Processing
FD.IO Vector Packet ProcessingKernel TLV
 
BUD17-300: Journey of a packet
BUD17-300: Journey of a packetBUD17-300: Journey of a packet
BUD17-300: Journey of a packetLinaro
 
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)Yuuki Takano
 
Rlite software-architecture (1)
Rlite software-architecture (1)Rlite software-architecture (1)
Rlite software-architecture (1)ARCFIRE ICT
 
CAPI and OpenCAPI Hardware acceleration enablement
CAPI and OpenCAPI Hardware acceleration enablementCAPI and OpenCAPI Hardware acceleration enablement
CAPI and OpenCAPI Hardware acceleration enablementGanesan Narayanasamy
 

Ähnlich wie Transparent eBPF Offload: Playing Nice with the Linux Kernel (20)

Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
 
P4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC OffloadP4, EPBF, and Linux TC Offload
P4, EPBF, and Linux TC Offload
 
BPF Hardware Offload Deep Dive
BPF Hardware Offload Deep DiveBPF Hardware Offload Deep Dive
BPF Hardware Offload Deep Dive
 
eBPF in the view of a storage developer
eBPF in the view of a storage developereBPF in the view of a storage developer
eBPF in the view of a storage developer
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
 
Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!
 
P4+ONOS SRv6 tutorial.pptx
P4+ONOS SRv6 tutorial.pptxP4+ONOS SRv6 tutorial.pptx
P4+ONOS SRv6 tutorial.pptx
 
eBPF Basics
eBPF BasicseBPF Basics
eBPF Basics
 
DEF CON 27 - JEFF DILEO - evil e bpf in depth
DEF CON 27 - JEFF DILEO - evil e bpf in depthDEF CON 27 - JEFF DILEO - evil e bpf in depth
DEF CON 27 - JEFF DILEO - evil e bpf in depth
 
The Past, Present, and Future of OpenACC
The Past, Present, and Future of OpenACCThe Past, Present, and Future of OpenACC
The Past, Present, and Future of OpenACC
 
OpenStack and NetApp - Chen Reuven - OpenStack Day Israel 2017
OpenStack and NetApp - Chen Reuven - OpenStack Day Israel 2017OpenStack and NetApp - Chen Reuven - OpenStack Day Israel 2017
OpenStack and NetApp - Chen Reuven - OpenStack Day Israel 2017
 
OpenPOWER Application Optimization
OpenPOWER Application Optimization OpenPOWER Application Optimization
OpenPOWER Application Optimization
 
Meetup 2009
Meetup 2009Meetup 2009
Meetup 2009
 
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core ArchitecturesPerformance Optimization of SPH Algorithms for Multi/Many-Core Architectures
Performance Optimization of SPH Algorithms for Multi/Many-Core Architectures
 
FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)FD.io Vector Packet Processing (VPP)
FD.io Vector Packet Processing (VPP)
 
FD.IO Vector Packet Processing
FD.IO Vector Packet ProcessingFD.IO Vector Packet Processing
FD.IO Vector Packet Processing
 
BUD17-300: Journey of a packet
BUD17-300: Journey of a packetBUD17-300: Journey of a packet
BUD17-300: Journey of a packet
 
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
 
Rlite software-architecture (1)
Rlite software-architecture (1)Rlite software-architecture (1)
Rlite software-architecture (1)
 
CAPI and OpenCAPI Hardware acceleration enablement
CAPI and OpenCAPI Hardware acceleration enablementCAPI and OpenCAPI Hardware acceleration enablement
CAPI and OpenCAPI Hardware acceleration enablement
 

Kürzlich hochgeladen

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Kürzlich hochgeladen (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Transparent eBPF Offload: Playing Nice with the Linux Kernel

  • 1. ©2016 Open-NFP 1 BPF and XDP Explained Nic Viljoen
  • 2. ©2017 Open-NFP 2 Objectives of the Webinar Give user a basic understanding of the architecture of eBPF ▪ What is it ▪ The programming model ▪ The kernel hooks Give user a basic understanding of XDP ▪ What is it/Where is it ▪ How to use it (beginner level!) ▪ How to offload it
  • 3. ©2016 Open-NFP 3 What is eBPF? eBPF is a simple way to extend the functionality of the kernel at runtime ▪ Effectively a small kernel based machine ▪ 10 64bit registers ▪ 512 byte stack ▪ Data structures known as maps (unlimited size) ▪ 4K BPF instructions (Bytecode) ▪ Verifier to ensure kernel safe ▪ no loops, not more than 4K insns, not more than 64 maps etc… ▪ Can be JITed to ensure maximum performance
  • 4. ©2016 Open-NFP 4 Used Within Hyperscale-Not a Toy! Those who have publically stated they are using BPF or are planning to use BPF include ▪ Facebook-Load Balancing, Security ▪ Netflix-Network Monitoring ▪ Cilium Project ▪ Cloudflare-Security ▪ OVS-Virtual Switching Due to its upstream safety and kernel support BPF provides a safe, flexible and scalable networking tool
  • 5. ©2016 Open-NFP 5 The Programming Model LLVM is used to compile from supported languages ▪ C ▪ Go ▪ P4 When Programs are loaded ▪ Verifier is called-ensure safety ▪ Program is JITed-ensure perf ▪ Can also be offloaded ▪ nfp_bpf_jit upstream LL VM NFP verifier.c bpf_prog.go bpf_prog.elf bpf syscall USER JIT nfp_bfp_jit.c Host CPU KERNEL HARDWARE bpf_prog.p4 bpf_prog.c
  • 6. ©2016 Open-NFP 6 Maps-What They Are Maps are key value stores ▪ Can be accessed from kernel or user space ▪ Used for interaction between kernel and user space programs Number of different types of maps ▪ Used for interaction between kernel and user space programs bpf_user.c bpf_kern.c Map
  • 7. ©2017 Open-NFP 7 Maps-How to use them Creating Maps ▪ Option 1: create map with syscall ▪ bpf(BPF_MAP_CREATE, &bpf_attr, sizeof(bpf_attr)) ▪ Option 2: define a struct bpf_map_def with an elf section __attribute__ SEC(“maps”)-also uses syscall! Option 1 Option 2 THIS IS AN OVERSIMPLIFICATION
  • 8. ©2017 Open-NFP 8 eBPF Bytecode: Quick Overview eBPF Bytecode: op:8, dst_reg:4, src_reg:4, off:16, imm:32 ▪ op code is divided into the sections ▪ Operation code (4bits) e.g BPF_MOV, BPF_JNE ▪ Source bit (1 bit) BPF_X (use src_reg and dst_reg) or BPF_K (use dst_reg and 32 bit imm) ▪ instruction class (3 bits) e.g BPF_ALU, BPF_ALU64, BPF_JMP ▪ BPF_MOV | BPF_X | BPF_ALU64, 0x6, 0x1, 0x0000, 0x00000000 ▪ Move contents of register 1 to register 6 ▪ BPF_JNE | BPF_K | BPF_JMP, 0x1, 0x0, 0x0011, 0x00008100 ▪ Jump 11 insns forward-can also jump backwards-if contents of register 1 is not equal to 0x00008100
  • 9. ©2017 Open-NFP 9 BPF Kernel Hooks Many hooks with different purposes ▪ kprobes ▪ socket filters-tcpdump-old school! ▪ seccomp ▪ netfilter (new) ▪ TC ▪ XDP(no skb-super fast!) XDP will be our focus for the rest of this talk
  • 10. ©2017 Open-NFP 10 XDP BPF hook in the driver ▪ Allows for high speed processing before skb is attached to packet ▪ Currently 4 return codes: XDP_ABORT, XDP_DROP, XDP_PASS, XDP_TX ▪ XDP_REDIRECT in the pipeline ▪ Usecases include DDoS protection and load balancing ▪ Includes maximum of 256 bytes of prepend ▪ Metadata is just pointers to start of packet and end
  • 11. ©2017 Open-NFP 11 Program Example (xdp1_kern.c) Simple drop example ▪ Note the use of standard header infrastructure ▪ Associated user space program maintaining a set of counters ▪ I am not going to go through line by line-for more detail check out Andy and Jesper’s awesome tutorial-in links ▪ Will come back to this example later on… This can be found in the recent (4.8+) kernels at linux/samples/bpf
  • 12. ©2017 Open-NFP 12 Optimizing XDP A simple checklist-not comprehensive! ▪ Ensure BPF JIT is enabled ▪ Pin queues to interfaces ▪ Set ringsize to an optimal level for your NIC and application ▪ To gain some idea of your NIC’s driver based XDP performance check simple XDP_DROP and XDP_TX programs ▪ Many people use single core performance as a reasonable benchmark ▪ To do this use the ethtool -X command ▪ You will NOT get the simple program performance if you build something complex (Duh)
  • 13. ©2017 Open-NFP 13 Offloading XDP Netronome have upstreamed the initial version of the nfp_bpf_jit ▪ More to come!
  • 14. ©2017 Open-NFP 14 Offload Architecture user space kernel space BPF syscall ● program ● type (sk filter, kprobe, cls, xdp) ● license ● ... verifier fd host JIT tc TC cls_bpf modification XDP ctrl offload object fd, skip_* flags verification fd, skip_* flags driver RX TXXDP ndo setup tc HW JIT / translator stats & maps BPF prog
  • 15. ©2017 Open-NFP 15 References Kernel Docs: https://www.kernel.org/doc/Documentation/networking/filter.txt Initial XDP Presentation: https://github.com/iovisor/bpf-docs/blob/master/ Express_Data_Path.pdf More Docs: http://prototype-kernel.readthedocs.io/en/latest/README.html Andy and Jesper’s Talk: https://netdevconf.org/2.1/slides/apr7/gospodarek- Netdev2.1-XDP-for-the-Rest-of-Us_Final.pdf Reading List: https://qmonnet.github.io/whirl-offload/2016/09/01/dive-into-bpf/ Search: google.com :)
  • 16. ©2016 Open-NFP 16 ANY QUESTIONS? Thanks!