SlideShare a Scribd company logo
Comparison of 
eBPF, XDP and DPDK
for packet inspection
Marian Marinov <mm@yuhu.biz>
Chief System Architect of SiteGround
Linux Piter 2019
Who am I?Who am I?
❖❖ Who am I?Who am I?
- Chief System Architect of SiteGround.com- Chief System Architect of SiteGround.com
- Sysadmin since 1996- Sysadmin since 1996
- Organizer of OpenFest, BG Perl- Organizer of OpenFest, BG Perl
Workshops, LUG-BG, RailsGirls and othersWorkshops, LUG-BG, RailsGirls and others
- Teaching Network Security and Linux- Teaching Network Security and Linux
System Administration courses in SofiaSystem Administration courses in Sofia
University and SoftUniUniversity and SoftUni
Why do we need this?Why do we need this?
Frequency of DoS/DDoS attacks to ourFrequency of DoS/DDoS attacks to our
infrastructureinfrastructure
➢ 4-10 Gbps 6-8 times a month4-10 Gbps 6-8 times a month
➢ 10-40 Gbps maybe 2-3 times a month10-40 Gbps maybe 2-3 times a month
➢ 100+ Gbps around 2 times a month100+ Gbps around 2 times a month
More statsMore stats
Attacks resulting in service degradation:Attacks resulting in service degradation:
➢ for the past 276 days we had 31 DDoS attacks
➢ some of the months, no attackssome of the months, no attacks
➢ but some months, up to 9but some months, up to 9
➢ 2019 – 31 attacks2019 – 31 attacks
➢ 2018 – 75 attacks2018 – 75 attacks
➢ 2017 – 69 attacks2017 – 69 attacks
➢ 2016 – 84 attacks2016 – 84 attacks
Note: I have manually counted the e-mails. The numbers can be slightly inaccurate.Note: I have manually counted the e-mails. The numbers can be slightly inaccurate.
Most attacks are basicMost attacks are basic
➢ 20k pps toward ISC Bind can consume20k pps toward ISC Bind can consume
up to 30 CPU coresup to 30 CPU cores
➢ a child can generate that on its laptop, at homea child can generate that on its laptop, at home
General solutionsGeneral solutions
➢ Buy additional bandwidthBuy additional bandwidth
➢ Buy a very expensive scrubbing deviceBuy a very expensive scrubbing device
OROR
➢ Offload this task to other companies, likeOffload this task to other companies, like
CloudFlareCloudFlare
Hosted solution issuesHosted solution issues
➢ Not every DataCenter is wiling to invest inNot every DataCenter is wiling to invest in
these devicesthese devices
➢ Shared devicesShared devices
➢ Attacks can be larger then the capacity of theAttacks can be larger then the capacity of the
devicedevice
➢ Larger attacks almost always result in null routeLarger attacks almost always result in null route
➢ Attacks saturating the uplinks can affect otherAttacks saturating the uplinks can affect other
machines in the rack and/or rowmachines in the rack and/or row
Cloud solution issuesCloud solution issues
➢ You have to point your DNS to the serviceYou have to point your DNS to the service
providerprovider
➢ Controlling your DNS is now only API basedControlling your DNS is now only API based
➢ Large DNS updates become an issueLarge DNS updates become an issue
➢ Not suitable for hosting companiesNot suitable for hosting companies
Requirements?Requirements?
➢ Build a VM that can handle 10Gbps withBuild a VM that can handle 10Gbps with
~8Mpps~8Mpps
➢ Why a VM?Why a VM?
➢ scrub UDP DNS and NTP trafficscrub UDP DNS and NTP traffic
➢ scrub TCP traffic by implementing SYN cookiesscrub TCP traffic by implementing SYN cookies
➢ scrub all unrelated trafficscrub all unrelated traffic
➢ cache HTTP responses(wishful thinking) :)cache HTTP responses(wishful thinking) :)
Linux Network FlowLinux Network Flow
Linux Network FlowLinux Network Flow
Linux Network FlowLinux Network Flow
Linux Network FlowLinux Network Flowreceived
packet
XDP
eBPF
alloc_skb
ingress
(qdisc)
bridge
check
broute
brouting
bridge
check
nat
prerouting
raw
prerouting
mangle
forward
nat
prerouting
bridging
decision
filter
forward
filter
input
routing
decision
filter
forward
mangle
prerouting
mangle
forward
filter
forward
mangle
forward
nat
postrouting
mangle
postrouting
mangle
postrouting
nat
postrouting
nat
postrouting
conntrack
nat
output
filter
output
nat
postrouting
bdrige
netfilter
egress
(qdisc)
other net
10M packet drop10M packet drop
➢ in 2018 CloudFlare published the article:in 2018 CloudFlare published the article:
How to drop 10m packetsHow to drop 10m packets
➢ I confirm their results with a few additions:I confirm their results with a few additions:
➢ iptables can drop at best 2m ppsiptables can drop at best 2m pps
Note: with only one entry in the PREROUTING chain of the mangle tableNote: with only one entry in the PREROUTING chain of the mangle table
➢ heaving multiple entries in that chain easilyheaving multiple entries in that chain easily
becomes a problembecomes a problem
➢ even if you use ipset with that, you have a bigeven if you use ipset with that, you have a big
problem when updating that informationproblem when updating that information
CloudFlare resultsCloudFlare results
CloudFlare results XDPCloudFlare results XDP
10M packet drop10M packet drop
➢ CloudFlare demo code can be found on
GitHub
So, how I started?So, how I started?
➢ I already knew about XDPI already knew about XDP
➢ But I decided to be “smart ass” and wrote anBut I decided to be “smart ass” and wrote an
iptables module...iptables module...
➢ It could handle between 260k and 280k ppsIt could handle between 260k and 280k pps
Not good enough... eBPFNot good enough... eBPF
➢ I also knew I can use eBPF for that...I also knew I can use eBPF for that...
➢ from the talk of Daniel Borkmann fromfrom the talk of Daniel Borkmann from
FOSDEM 2016FOSDEM 2016
➢ It was better, but not enough...It was better, but not enough...
➢ 320-350k pps drop rate320-350k pps drop rate
➢ with 2000 domains and UDP packet checkingwith 2000 domains and UDP packet checking
➢ no checksums thouno checksums thou
DPDKDPDK
➢ I had previous experience with DPDK
➢ So I ordered one Intel and one SolarFlare NICs
➢ With both I managed to drop anything that was
below the 10G limit of the cards
➢ With SolarFlare I even tested uploading code
into the NIC it self
Data
Plane
Development
Kit
Complex DPDKComplex DPDK
➢ Nobody, except me, was interested in
supporting DPDK code
➢ Writing and updating DPDK is not trivial
➢ DPDK required specific HW that may not be
available in the DataCenter
Data
Plane
Development
Kit
DPDK and P4DPDK and P4
➢ A friend(Boyan Krosnov) told me about P4A friend(Boyan Krosnov) told me about P4
➢ P4 made updating the logic and content of theP4 made updating the logic and content of the
filter program a lot simpler for me...filter program a lot simpler for me...
Data
Plane
Development
Kit
P4 and peopleP4 and people
➢ P what?P what?
➢ If we were to use DPDK with P4, everyone hadIf we were to use DPDK with P4, everyone had
to learn the language :(to learn the language :(
Data
Plane
Development
Kit
And then came XDPAnd then came XDPreceived
packet
XDP
eBPF
alloc_skb
ingress
(qdisc)
bridge
check
broute
brouting
bridge
check
nat
prerouting
raw
prerouting
mangle
forward
nat
prerouting
bridging
decision
filter
forward
filter
input
routing
decision
filter
forward
mangle
prerouting
mangle
forward
filter
forward
mangle
forward
nat
postrouting
mangle
postrouting
mangle
postrouting
nat
postrouting
nat
postrouting
conntrack
nat
output
filter
output
nat
postrouting
bdrige
netfilter
egress
(qdisc)
other net
And then came XDPAnd then came XDP
➢ Extremely fast and closest to the NIC, same asExtremely fast and closest to the NIC, same as
DPDKDPDK
➢ Supported by many driversSupported by many drivers
➢ Extendable with eBPF functionsExtendable with eBPF functions
➢ Developed by Jasper BrouerDeveloped by Jasper Brouer
eXpress
Data
Path
What I ended up, with?What I ended up, with?
➢ A filter similar to what CF did with their DROP
example
➢ instead of a comparing a single prefix, I'm
extracting the UDP data if the packet is UDP
➢ then the extracted data is compared with a BPF
map
➢ I wrote a simple user space tool, that updates
the map in the kernel
➢ voila I had a fast scrubber
eXpress
Data
Path
the UDP scrubberthe UDP scrubber
➢ if the DNS request is not for a domain that is
within the list in the map I drop the packet
➢ ToDo: add caching of responses with TTL
eXpress
Data
Path
the TCP scrubberthe TCP scrubber
This is where I had to stop :(
➢ compare the packet's dst port and allow it only
if it is:
➢ SYN to a port that is allowed
➢ send and receive SYN cookies here
➢ part of already existing connection by
examining its own db of tuples and the supplied
by the user space(other VMs)
eXpress
Data
Path
the TCP scrubberthe TCP scrubber
This is where I had to stop :(
➢ It should handle the SYN cookie for the servers
behind and replay the initial SYN if correct
SYN,ACK is received
eXpress
Data
Path
Testing the bastardTesting the bastard
I knew I was able to drop packets fast...
But I needed a proof ;)
➢ I had a talk with Jasper at Linux Plumbers 2019I had a talk with Jasper at Linux Plumbers 2019
➢ He pointed me toHe pointed me to
his patched version of pktgenhis patched version of pktgen on GitHub :)on GitHub :)
Now...Now...
How to get from 10GbpsHow to get from 10Gbps
to 200Gbps?to 200Gbps?
Now...Now...
How to get from 10GbpsHow to get from 10Gbps
to 200Gbps?to 200Gbps?
➢ Combining multiple VMs with ECMP
➢ I did that directly on the switch :)
LinksLinks
How to drop 10 million packets per secondHow to drop 10 million packets per second
https://blog.cloudflare.com/how-to-drop-10-million-packets/
https://github.com/cloudflare/cloudflare-blog/tree/master/2018-0
7-dropping-packets
XDP tutorialXDP tutorial
https://github.com/xdp-project/xdp-tutorial
More XDP materials:More XDP materials:
https://www.iovisor.org/technology/xdp
Enhanced pktgen by JasperEnhanced pktgen by Jasper
https://github.com/netoptimizer/network-testing
LinksLinks
Linux tc and eBPFLinux tc and eBPF
https://archive.fosdem.org/2016/schedule/event/ebpf/attachments/s
lides/1159/export/events/attachments/ebpf/slides/1159/ebpf.pdf
man pagesman pages
http://man7.org/linux/man-pages/man8/tc-bpf.8.html
http://man7.org/linux/man-pages/man2/bpf.2.html
SolarFlare AOR firmware development kitSolarFlare AOR firmware development kit
https://www.colfaxdirect.com/store/pc/viewPrd.asp?idproduct=1585
Data Plane Development KitData Plane Development Kit
https://www.dpdk.org/
P4 Language SpecificationP4 Language Specification
https://p4.org/p4-spec/docs/P4-16-v1.0.0-spec.pdf
P4 meets DPDKP4 meets DPDK
https://www.dpdk.org/wp-content/uploads/sites/35/2017/09/DP
DK-Userspace2017-Day2-12-SANDOR_LAKI-T4P4S.pdf
DoS and DDoS mitigations with eBPF, XDP and DPDK
Thank you!Thank you!

More Related Content

ODP
Dpdk performance
PDF
Linux Networking Explained
PDF
Introduction to eBPF
PDF
BPF: Tracing and more
PDF
eBPF - Rethinking the Linux Kernel
PPTX
Linux Network Stack
PDF
SRv6 study
PDF
BPF Internals (eBPF)
Dpdk performance
Linux Networking Explained
Introduction to eBPF
BPF: Tracing and more
eBPF - Rethinking the Linux Kernel
Linux Network Stack
SRv6 study
BPF Internals (eBPF)

What's hot (20)

PDF
Using eBPF for High-Performance Networking in Cilium
PDF
LinuxCon 2015 Linux Kernel Networking Walkthrough
PDF
EBPF and Linux Networking
PDF
Using GTP on Linux with libgtpnl
PDF
仮想化環境におけるパケットフォワーディング
PDF
eBPF Trace from Kernel to Userspace
PDF
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
PDF
LISA2019 Linux Systems Performance
PDF
"SRv6の現状と展望" ENOG53@上越
PDF
XDP in Practice: DDoS Mitigation @Cloudflare
PPTX
Introduction to DPDK
PDF
Systems@Scale 2021 BPF Performance Getting Started
PDF
Performance Wins with BPF: Getting Started
PDF
netfilter and iptables
PDF
Linux 4.x Tracing: Performance Analysis with bcc/BPF
PDF
Meet cute-between-ebpf-and-tracing
PDF
Performance Wins with eBPF: Getting Started (2021)
ODP
Introduction to Ansible
PPTX
コンテナネットワーキング(CNI)最前線
PDF
UM2019 Extended BPF: A New Type of Software
Using eBPF for High-Performance Networking in Cilium
LinuxCon 2015 Linux Kernel Networking Walkthrough
EBPF and Linux Networking
Using GTP on Linux with libgtpnl
仮想化環境におけるパケットフォワーディング
eBPF Trace from Kernel to Userspace
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
LISA2019 Linux Systems Performance
"SRv6の現状と展望" ENOG53@上越
XDP in Practice: DDoS Mitigation @Cloudflare
Introduction to DPDK
Systems@Scale 2021 BPF Performance Getting Started
Performance Wins with BPF: Getting Started
netfilter and iptables
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Meet cute-between-ebpf-and-tracing
Performance Wins with eBPF: Getting Started (2021)
Introduction to Ansible
コンテナネットワーキング(CNI)最前線
UM2019 Extended BPF: A New Type of Software
Ad

Similar to DoS and DDoS mitigations with eBPF, XDP and DPDK (20)

PPTX
Helen Tabunshchyk "Handling large amounts of traffic on the Edge"
PDF
Faster packet processing in Linux: XDP
PDF
Userspace networking
PPT
Linux Based Advanced Routing with Firewall and Traffic Control
PDF
100 M pps on PC.
PDF
DDoS Mitigation Tools and Techniques
PDF
Introduction to eBPF and XDP
PDF
Introduction to Software Defined Networking (SDN)
PDF
[Draft] Fast Prototyping with DPDK and eBPF in Containernet
PPT
flowspec @ APF 2013
PPTX
DPDK summit 2015: It's kind of fun to do the impossible with DPDK
ODP
LinuxCon2009: 10Gbit/s Bi-Directional Routing on standard hardware running Linux
PDF
DPDK Summit 2015 - NTT - Yoshihiro Nakajima
PPTX
PLNOG16: Obsługa 100M pps na platformie PC , Przemysław Frasunek, Paweł Mała...
PPTX
BGP Flowspec (RFC5575) Case study and Discussion
PPTX
High performace network of Cloud Native Taiwan User Group
PPTX
DeiC DDoS Prevention System - DDPS
PDF
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
PPTX
Cardigan at ISCC 2014
Helen Tabunshchyk "Handling large amounts of traffic on the Edge"
Faster packet processing in Linux: XDP
Userspace networking
Linux Based Advanced Routing with Firewall and Traffic Control
100 M pps on PC.
DDoS Mitigation Tools and Techniques
Introduction to eBPF and XDP
Introduction to Software Defined Networking (SDN)
[Draft] Fast Prototyping with DPDK and eBPF in Containernet
flowspec @ APF 2013
DPDK summit 2015: It's kind of fun to do the impossible with DPDK
LinuxCon2009: 10Gbit/s Bi-Directional Routing on standard hardware running Linux
DPDK Summit 2015 - NTT - Yoshihiro Nakajima
PLNOG16: Obsługa 100M pps na platformie PC , Przemysław Frasunek, Paweł Mała...
BGP Flowspec (RFC5575) Case study and Discussion
High performace network of Cloud Native Taiwan User Group
DeiC DDoS Prevention System - DDPS
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Cardigan at ISCC 2014
Ad

More from Marian Marinov (20)

PDF
How to start and then move forward in IT
PDF
Thinking about highly-available systems and their setup
PDF
Understanding your memory usage under Linux
PDF
How to implement PassKeys in your application
PDF
Dev.bg DevOps March 2024 Monitoring & Logging
PDF
Basic presentation of cryptography mechanisms
PDF
Microservices: Benefits, drawbacks and are they for me?
PDF
Introduction and replication to DragonflyDB
PDF
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
PDF
How to successfully migrate to DevOps .pdf
PDF
How to survive in the work from home era
PDF
Managing sysadmins
PDF
Improve your storage with bcachefs
PDF
Control your service resources with systemd
PDF
Comparison of-foss-distributed-storage
PDF
Защо и как да обогатяваме знанията си?
PDF
Securing your MySQL server
PDF
Sysadmin vs. dev ops
PDF
Challenges with high density networks
PDF
SiteGround building automation
How to start and then move forward in IT
Thinking about highly-available systems and their setup
Understanding your memory usage under Linux
How to implement PassKeys in your application
Dev.bg DevOps March 2024 Monitoring & Logging
Basic presentation of cryptography mechanisms
Microservices: Benefits, drawbacks and are they for me?
Introduction and replication to DragonflyDB
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
How to successfully migrate to DevOps .pdf
How to survive in the work from home era
Managing sysadmins
Improve your storage with bcachefs
Control your service resources with systemd
Comparison of-foss-distributed-storage
Защо и как да обогатяваме знанията си?
Securing your MySQL server
Sysadmin vs. dev ops
Challenges with high density networks
SiteGround building automation

Recently uploaded (20)

PPT
Mechanical Engineering MATERIALS Selection
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Geodesy 1.pptx...............................................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
PPT on Performance Review to get promotions
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Sustainable Sites - Green Building Construction
Mechanical Engineering MATERIALS Selection
Embodied AI: Ushering in the Next Era of Intelligent Systems
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Geodesy 1.pptx...............................................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Lesson 3_Tessellation.pptx finite Mathematics
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
bas. eng. economics group 4 presentation 1.pptx
UNIT 4 Total Quality Management .pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Arduino robotics embedded978-1-4302-3184-4.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPT on Performance Review to get promotions
additive manufacturing of ss316l using mig welding
Sustainable Sites - Green Building Construction

DoS and DDoS mitigations with eBPF, XDP and DPDK

  • 2. Who am I?Who am I? ❖❖ Who am I?Who am I? - Chief System Architect of SiteGround.com- Chief System Architect of SiteGround.com - Sysadmin since 1996- Sysadmin since 1996 - Organizer of OpenFest, BG Perl- Organizer of OpenFest, BG Perl Workshops, LUG-BG, RailsGirls and othersWorkshops, LUG-BG, RailsGirls and others - Teaching Network Security and Linux- Teaching Network Security and Linux System Administration courses in SofiaSystem Administration courses in Sofia University and SoftUniUniversity and SoftUni
  • 3. Why do we need this?Why do we need this? Frequency of DoS/DDoS attacks to ourFrequency of DoS/DDoS attacks to our infrastructureinfrastructure ➢ 4-10 Gbps 6-8 times a month4-10 Gbps 6-8 times a month ➢ 10-40 Gbps maybe 2-3 times a month10-40 Gbps maybe 2-3 times a month ➢ 100+ Gbps around 2 times a month100+ Gbps around 2 times a month
  • 4. More statsMore stats Attacks resulting in service degradation:Attacks resulting in service degradation: ➢ for the past 276 days we had 31 DDoS attacks ➢ some of the months, no attackssome of the months, no attacks ➢ but some months, up to 9but some months, up to 9 ➢ 2019 – 31 attacks2019 – 31 attacks ➢ 2018 – 75 attacks2018 – 75 attacks ➢ 2017 – 69 attacks2017 – 69 attacks ➢ 2016 – 84 attacks2016 – 84 attacks Note: I have manually counted the e-mails. The numbers can be slightly inaccurate.Note: I have manually counted the e-mails. The numbers can be slightly inaccurate.
  • 5. Most attacks are basicMost attacks are basic ➢ 20k pps toward ISC Bind can consume20k pps toward ISC Bind can consume up to 30 CPU coresup to 30 CPU cores ➢ a child can generate that on its laptop, at homea child can generate that on its laptop, at home
  • 6. General solutionsGeneral solutions ➢ Buy additional bandwidthBuy additional bandwidth ➢ Buy a very expensive scrubbing deviceBuy a very expensive scrubbing device OROR ➢ Offload this task to other companies, likeOffload this task to other companies, like CloudFlareCloudFlare
  • 7. Hosted solution issuesHosted solution issues ➢ Not every DataCenter is wiling to invest inNot every DataCenter is wiling to invest in these devicesthese devices ➢ Shared devicesShared devices ➢ Attacks can be larger then the capacity of theAttacks can be larger then the capacity of the devicedevice ➢ Larger attacks almost always result in null routeLarger attacks almost always result in null route ➢ Attacks saturating the uplinks can affect otherAttacks saturating the uplinks can affect other machines in the rack and/or rowmachines in the rack and/or row
  • 8. Cloud solution issuesCloud solution issues ➢ You have to point your DNS to the serviceYou have to point your DNS to the service providerprovider ➢ Controlling your DNS is now only API basedControlling your DNS is now only API based ➢ Large DNS updates become an issueLarge DNS updates become an issue ➢ Not suitable for hosting companiesNot suitable for hosting companies
  • 9. Requirements?Requirements? ➢ Build a VM that can handle 10Gbps withBuild a VM that can handle 10Gbps with ~8Mpps~8Mpps ➢ Why a VM?Why a VM? ➢ scrub UDP DNS and NTP trafficscrub UDP DNS and NTP traffic ➢ scrub TCP traffic by implementing SYN cookiesscrub TCP traffic by implementing SYN cookies ➢ scrub all unrelated trafficscrub all unrelated traffic ➢ cache HTTP responses(wishful thinking) :)cache HTTP responses(wishful thinking) :)
  • 10. Linux Network FlowLinux Network Flow
  • 11. Linux Network FlowLinux Network Flow
  • 12. Linux Network FlowLinux Network Flow
  • 13. Linux Network FlowLinux Network Flowreceived packet XDP eBPF alloc_skb ingress (qdisc) bridge check broute brouting bridge check nat prerouting raw prerouting mangle forward nat prerouting bridging decision filter forward filter input routing decision filter forward mangle prerouting mangle forward filter forward mangle forward nat postrouting mangle postrouting mangle postrouting nat postrouting nat postrouting conntrack nat output filter output nat postrouting bdrige netfilter egress (qdisc) other net
  • 14. 10M packet drop10M packet drop ➢ in 2018 CloudFlare published the article:in 2018 CloudFlare published the article: How to drop 10m packetsHow to drop 10m packets ➢ I confirm their results with a few additions:I confirm their results with a few additions: ➢ iptables can drop at best 2m ppsiptables can drop at best 2m pps Note: with only one entry in the PREROUTING chain of the mangle tableNote: with only one entry in the PREROUTING chain of the mangle table ➢ heaving multiple entries in that chain easilyheaving multiple entries in that chain easily becomes a problembecomes a problem ➢ even if you use ipset with that, you have a bigeven if you use ipset with that, you have a big problem when updating that informationproblem when updating that information
  • 18. So, how I started?So, how I started? ➢ I already knew about XDPI already knew about XDP ➢ But I decided to be “smart ass” and wrote anBut I decided to be “smart ass” and wrote an iptables module...iptables module... ➢ It could handle between 260k and 280k ppsIt could handle between 260k and 280k pps
  • 19. Not good enough... eBPFNot good enough... eBPF ➢ I also knew I can use eBPF for that...I also knew I can use eBPF for that... ➢ from the talk of Daniel Borkmann fromfrom the talk of Daniel Borkmann from FOSDEM 2016FOSDEM 2016 ➢ It was better, but not enough...It was better, but not enough... ➢ 320-350k pps drop rate320-350k pps drop rate ➢ with 2000 domains and UDP packet checkingwith 2000 domains and UDP packet checking ➢ no checksums thouno checksums thou
  • 20. DPDKDPDK ➢ I had previous experience with DPDK ➢ So I ordered one Intel and one SolarFlare NICs ➢ With both I managed to drop anything that was below the 10G limit of the cards ➢ With SolarFlare I even tested uploading code into the NIC it self Data Plane Development Kit
  • 21. Complex DPDKComplex DPDK ➢ Nobody, except me, was interested in supporting DPDK code ➢ Writing and updating DPDK is not trivial ➢ DPDK required specific HW that may not be available in the DataCenter Data Plane Development Kit
  • 22. DPDK and P4DPDK and P4 ➢ A friend(Boyan Krosnov) told me about P4A friend(Boyan Krosnov) told me about P4 ➢ P4 made updating the logic and content of theP4 made updating the logic and content of the filter program a lot simpler for me...filter program a lot simpler for me... Data Plane Development Kit
  • 23. P4 and peopleP4 and people ➢ P what?P what? ➢ If we were to use DPDK with P4, everyone hadIf we were to use DPDK with P4, everyone had to learn the language :(to learn the language :( Data Plane Development Kit
  • 24. And then came XDPAnd then came XDPreceived packet XDP eBPF alloc_skb ingress (qdisc) bridge check broute brouting bridge check nat prerouting raw prerouting mangle forward nat prerouting bridging decision filter forward filter input routing decision filter forward mangle prerouting mangle forward filter forward mangle forward nat postrouting mangle postrouting mangle postrouting nat postrouting nat postrouting conntrack nat output filter output nat postrouting bdrige netfilter egress (qdisc) other net
  • 25. And then came XDPAnd then came XDP ➢ Extremely fast and closest to the NIC, same asExtremely fast and closest to the NIC, same as DPDKDPDK ➢ Supported by many driversSupported by many drivers ➢ Extendable with eBPF functionsExtendable with eBPF functions ➢ Developed by Jasper BrouerDeveloped by Jasper Brouer eXpress Data Path
  • 26. What I ended up, with?What I ended up, with? ➢ A filter similar to what CF did with their DROP example ➢ instead of a comparing a single prefix, I'm extracting the UDP data if the packet is UDP ➢ then the extracted data is compared with a BPF map ➢ I wrote a simple user space tool, that updates the map in the kernel ➢ voila I had a fast scrubber eXpress Data Path
  • 27. the UDP scrubberthe UDP scrubber ➢ if the DNS request is not for a domain that is within the list in the map I drop the packet ➢ ToDo: add caching of responses with TTL eXpress Data Path
  • 28. the TCP scrubberthe TCP scrubber This is where I had to stop :( ➢ compare the packet's dst port and allow it only if it is: ➢ SYN to a port that is allowed ➢ send and receive SYN cookies here ➢ part of already existing connection by examining its own db of tuples and the supplied by the user space(other VMs) eXpress Data Path
  • 29. the TCP scrubberthe TCP scrubber This is where I had to stop :( ➢ It should handle the SYN cookie for the servers behind and replay the initial SYN if correct SYN,ACK is received eXpress Data Path
  • 30. Testing the bastardTesting the bastard I knew I was able to drop packets fast... But I needed a proof ;) ➢ I had a talk with Jasper at Linux Plumbers 2019I had a talk with Jasper at Linux Plumbers 2019 ➢ He pointed me toHe pointed me to his patched version of pktgenhis patched version of pktgen on GitHub :)on GitHub :)
  • 31. Now...Now... How to get from 10GbpsHow to get from 10Gbps to 200Gbps?to 200Gbps?
  • 32. Now...Now... How to get from 10GbpsHow to get from 10Gbps to 200Gbps?to 200Gbps? ➢ Combining multiple VMs with ECMP ➢ I did that directly on the switch :)
  • 33. LinksLinks How to drop 10 million packets per secondHow to drop 10 million packets per second https://blog.cloudflare.com/how-to-drop-10-million-packets/ https://github.com/cloudflare/cloudflare-blog/tree/master/2018-0 7-dropping-packets XDP tutorialXDP tutorial https://github.com/xdp-project/xdp-tutorial More XDP materials:More XDP materials: https://www.iovisor.org/technology/xdp Enhanced pktgen by JasperEnhanced pktgen by Jasper https://github.com/netoptimizer/network-testing
  • 34. LinksLinks Linux tc and eBPFLinux tc and eBPF https://archive.fosdem.org/2016/schedule/event/ebpf/attachments/s lides/1159/export/events/attachments/ebpf/slides/1159/ebpf.pdf man pagesman pages http://man7.org/linux/man-pages/man8/tc-bpf.8.html http://man7.org/linux/man-pages/man2/bpf.2.html SolarFlare AOR firmware development kitSolarFlare AOR firmware development kit https://www.colfaxdirect.com/store/pc/viewPrd.asp?idproduct=1585 Data Plane Development KitData Plane Development Kit https://www.dpdk.org/ P4 Language SpecificationP4 Language Specification https://p4.org/p4-spec/docs/P4-16-v1.0.0-spec.pdf P4 meets DPDKP4 meets DPDK https://www.dpdk.org/wp-content/uploads/sites/35/2017/09/DP DK-Userspace2017-Day2-12-SANDOR_LAKI-T4P4S.pdf