SlideShare a Scribd company logo
1 of 29
Download to read offline
Introduction of eBPF
時下最夯的Linux Technology
梁維恩
Jace Liang
SW / Infra. engineer at ITRI
Facebook: jace.liang
github: mJace
TOC Votes to Move Falco into CNCF Incubator
By Jessie January 8, 2020 in Blog
Today, the Cloud Native Computing Foundation (CNCF) Technical Oversight Committee (TOC) voted to accept
Falco as an incubation-level hosted project.
Falco, which entered the CNCF Sandbox in October 2018, is an open source Kubernetes runtime security
project. It provides intrusion and abnormality detection for cloud native platforms such as Kubernetes,
Mesosphere, and Cloud Foundry.
BPF security capabilities
• Which processes are being
executed? By which processes?
• What network connections are
being made? By which processes?
• What permission denied errors
are happening on the system?
• Is this kernel/user function being
executed with these arguments?
Take away
• What’s eBPF
• Use eBPF based tools to debug
• New design idea
You don't need to know how to operate an X-ray machine,
but you do need to know that if you swallow a penny, an X-ray is an option!
www.bredangregg.com
What’s BPF?
• BPF全名為Berkeley Packet Filter, Introduced by Lawrence Berkeley
National Laboratory, 1992.
• 當時推出的目的是為了提高 BSD-based Kernel過濾封包的效率。
原理是將封包的過濾程式編譯後由Kernel中類似虛擬機的環境執
行。
• 和原先在Userspace過濾封包相比有更好的效能。
且透過編譯以及在核心內沙盒中執行的特性,能夠避免使用者把
Kernel搞壞掉。
Example of BPF – Tcpdump
Example of BPF – Tcpdump cont.
#檢查是否為IPV6,如果不是(jf),則視為IPV4 (GOTO Line:006)
#檢查是否為TCP
#檢查dst port是否為7070(0x1b9e),if so (jt) L014
#檢查是否為 ipv4封包
#檢查是否為 tcp封包
#檢查是否為 ip fragment packet
#找到tcp封包中 dest port 的所在位置
#檢查dst port是否為7070,若為真(jt) GOT L014
#Packet Match!
#Packet Mis-match!
How about eBPF (enhanced BPF)?
• 原先Kernel內bpf虛擬機的設計過時,不支援新硬體CPU架構
• eBPF相對bpf有更佳的硬體相容性,支援更大的register
• eBPF相對bpf有更快的編譯速度,在過濾網路封包時的效能也更好
• eBPF於2014年的版本後,便可直接從userspace操作
“Super powers have finally come to Linux“ – Brendan Gregg, Linux Conf. 2017
eBPF Architecture.
What can you do with eBPF?
• Filter traffic, at the lowest entry of linux network stack.
• Programs can be attached to tracepoints, kprobes, system calls, perf events,
etc.
Velocity 2017: Performance Analysis Superpowers with Linux eBPF - Brendan Gregg
https://www.youtube.com/watch?v=bj3qdEDbCD4
Use case of eBPF – Userspace tracing
https://github.com/iovisor/kubectl-trace
relationship between userspace threads
fnc
tid/pid/arg/ret
fnc
tid/pid/arg/ret
pkt
pkt
pkt
pkt
enqueue
tid/pid/arg/ret
dequeue
tid/pid/arg/ret
Get relationship by en/dequeue args and retval
https://github.com/mJace/ebpfKit/blob/master/Examples/cpp/README.md
eBPF related projects – XDP (express data path)
• Since Kernel v4.8
• Based on eBPF
• DDOS Protection
• Network security
• Network accelerate
eBPF related projects – sysdig
• Embed Security, Compliance and Performance Into Your DevOps Workflows
eBPF related projects – Falco
• Cloud-Native Runtime Security
Falco efficiently leverages Extended Berkeley Packet Filter (eBPF), a secure
mechanism, to capture system calls and gain deep visibility. By adding
Kubernetes application context and Kubernetes API audit events, teams can
understand who did what.
Other eBPF related implementations…
• Cilium – XDP based CNI
• Weavescope – ebpf based monitor tool
• Iptables – Bpfilter implementations to optimize ingress/outgress security
rules
• Calicio – Just release a alpha version that lavages ebpf
• Systemtap – Support eBPF now.
eBPF related projects – BCC
• BPF Compiler Collection (BCC)
BCC is a toolkit for creating efficient kernel tracing and manipulation programs, and includes several useful
tools and examples
https://github.com/iovisor/bcc
BCC tools example – tcpconlat (tcp latency)
BCC tools example – execsnoop ( trace syscall- exec)
bpftrace tool example – cpuwalk.
Demo 1 – containerized ebpf tool
• Bcc tools inside a container, and trace other container’s processes.
Target
container
ebpf
container
Host Machine
Kernel
ebpf
program
ebpf
map
https://github.com/mJace/ebpfKit/blob/master/Examples/bcc-demo/demo-01.md
Demo 2.
• Namespace-based tracing.
ebpf
container
Target Container
P3
P2
P1 How to trace all processes?????
Even process just created?
https://github.com/mJace/ebpfKit/blob/master/Examples/bcc-demo/demo-02.md
Software stack for ebpf related project
bpf,ebpf – main framework
XDP – Express data plane powered by ebpf
Bcc lib – library for higher app to communicate with bpf
go-bpf – golang lib for bpf
Bcc tools – userspace tool like tcptracer to trace all tcp status
bpftrace – high level userspace bpf based trace tool.
bpfebpf
Bcc lib
Kernel Space
User Space
Bcc tools
go-bpf
bpftrace tools
XDP
The future of eBPF
Kernel operations structures in BPF
what has been merged for 5.6 is not just a mechanism for hooking in TCP congestion-control algorithms……
this new infrastructure can be used to allow a BPF program to replace any "operations structure“ (in kernel)
https://lwn.net/Articles/811631/?fbclid=IwAR3otEAmjW4GS5i3hcWHzsy6hfmTIJwb_nUGHcT-
sS2aCOX1xcn9DuTfcwA
➢Update kernel without building kernel, even rebooting
➢Dynamic driver? Runtime configurable kernel driver, without re-bulding
➢Kernel layer cloud native application?
Q n’ A / Take away
• What’s eBPF
• 一種Linux內的技術,能讓人動態的觀察系統內的行為
• Use eBPF based tools to debug
• ebpf tool產生的overhead,遠低於傳統userspace monitor tool
• 可觀測幾乎所有系統內行為,從kernel到userspace
• New design idea
• eBPF打破以往kernel layer application可攜性極低的問題
You don't need to know how to operate an X-ray machine,
but you do need to know that if you swallow a penny, an X-ray is an option!
www.bredangregg.com
Reference.
• http://www.brendangregg.com/blog/2019-01-01/learn-ebpf-tracing.html
• https://hackmd.io/@sysprog/SJTuuG9a7?type=view
• https://github.com/iovisor/bpftrace
• https://github.com/iovisor/bcc
• https://github.com/iovisor/kubectl-trace

More Related Content

What's hot

Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
Kernel TLV
 

What's hot (20)

Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
 
BPF - in-kernel virtual machine
BPF - in-kernel virtual machineBPF - in-kernel virtual machine
BPF - in-kernel virtual machine
 
Introduction to eBPF and XDP
Introduction to eBPF and XDPIntroduction to eBPF and XDP
Introduction to eBPF and XDP
 
eBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux KerneleBPF - Rethinking the Linux Kernel
eBPF - Rethinking the Linux Kernel
 
Understanding DPDK algorithmics
Understanding DPDK algorithmicsUnderstanding DPDK algorithmics
Understanding DPDK algorithmics
 
Container Runtime Security with Falco
Container Runtime Security with FalcoContainer Runtime Security with Falco
Container Runtime Security with Falco
 
Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)
 
Using eBPF to Measure the k8s Cluster Health
Using eBPF to Measure the k8s Cluster HealthUsing eBPF to Measure the k8s Cluster Health
Using eBPF to Measure the k8s Cluster Health
 
Dpdk performance
Dpdk performanceDpdk performance
Dpdk performance
 
Linux BPF Superpowers
Linux BPF SuperpowersLinux BPF Superpowers
Linux BPF Superpowers
 
Project ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementationProject ACRN: SR-IOV implementation
Project ACRN: SR-IOV implementation
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
 
BPF Hardware Offload Deep Dive
BPF Hardware Offload Deep DiveBPF Hardware Offload Deep Dive
BPF Hardware Offload Deep Dive
 
Systems@Scale 2021 BPF Performance Getting Started
Systems@Scale 2021 BPF Performance Getting StartedSystems@Scale 2021 BPF Performance Getting Started
Systems@Scale 2021 BPF Performance Getting Started
 
re:Invent 2019 BPF Performance Analysis at Netflix
re:Invent 2019 BPF Performance Analysis at Netflixre:Invent 2019 BPF Performance Analysis at Netflix
re:Invent 2019 BPF Performance Analysis at Netflix
 
BPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabBPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLab
 
Intel DPDK Step by Step instructions
Intel DPDK Step by Step instructionsIntel DPDK Step by Step instructions
Intel DPDK Step by Step instructions
 
Meet cute-between-ebpf-and-tracing
Meet cute-between-ebpf-and-tracingMeet cute-between-ebpf-and-tracing
Meet cute-between-ebpf-and-tracing
 
eBPF/XDP
eBPF/XDP eBPF/XDP
eBPF/XDP
 
Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!Understanding eBPF in a Hurry!
Understanding eBPF in a Hurry!
 

Similar to Introduction of eBPF - 時下最夯的Linux Technology

"APIs for Accelerating Vision and Inferencing: Options and Trade-offs," a Pre...
"APIs for Accelerating Vision and Inferencing: Options and Trade-offs," a Pre..."APIs for Accelerating Vision and Inferencing: Options and Trade-offs," a Pre...
"APIs for Accelerating Vision and Inferencing: Options and Trade-offs," a Pre...
Edge AI and Vision Alliance
 
Os Grossupdated
Os GrossupdatedOs Grossupdated
Os Grossupdated
oscon2007
 

Similar to Introduction of eBPF - 時下最夯的Linux Technology (20)

eBPF — Divulging The Hidden Super Power.pdf
eBPF — Divulging The Hidden Super Power.pdfeBPF — Divulging The Hidden Super Power.pdf
eBPF — Divulging The Hidden Super Power.pdf
 
Dataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsDataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and tools
 
story_of_bpf-1.pdf
story_of_bpf-1.pdfstory_of_bpf-1.pdf
story_of_bpf-1.pdf
 
eBPF — Divulging The Hidden Super Power.pdf
eBPF — Divulging The Hidden Super Power.pdfeBPF — Divulging The Hidden Super Power.pdf
eBPF — Divulging The Hidden Super Power.pdf
 
ebpf and IO Visor: The What, how, and what next!
ebpf and IO Visor: The What, how, and what next!ebpf and IO Visor: The What, how, and what next!
ebpf and IO Visor: The What, how, and what next!
 
Kernel bug hunting
Kernel bug huntingKernel bug hunting
Kernel bug hunting
 
When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?
 
Calico-eBPF-Dataplane-CNCF-Webinar-Slides.pdf
Calico-eBPF-Dataplane-CNCF-Webinar-Slides.pdfCalico-eBPF-Dataplane-CNCF-Webinar-Slides.pdf
Calico-eBPF-Dataplane-CNCF-Webinar-Slides.pdf
 
"APIs for Accelerating Vision and Inferencing: Options and Trade-offs," a Pre...
"APIs for Accelerating Vision and Inferencing: Options and Trade-offs," a Pre..."APIs for Accelerating Vision and Inferencing: Options and Trade-offs," a Pre...
"APIs for Accelerating Vision and Inferencing: Options and Trade-offs," a Pre...
 
給 RD 的 Kubernetes 初體驗
給 RD 的 Kubernetes 初體驗給 RD 的 Kubernetes 初體驗
給 RD 的 Kubernetes 初體驗
 
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
DISTRIBUTED PERFORMANCE ANALYSIS USING INFLUXDB AND THE LINUX EBPF VIRTUAL MA...
 
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
 
Os Grossupdated
Os GrossupdatedOs Grossupdated
Os Grossupdated
 
What's New in Docker - February 2017
What's New in Docker - February 2017What's New in Docker - February 2017
What's New in Docker - February 2017
 
eBPF - Observability In Deep
eBPF - Observability In DeepeBPF - Observability In Deep
eBPF - Observability In Deep
 
Moby Open Source Summit North America 2017
Moby Open Source Summit North America 2017Moby Open Source Summit North America 2017
Moby Open Source Summit North America 2017
 
How to Contribute to Cloud Native Computing Foundation
How to Contribute to Cloud Native Computing FoundationHow to Contribute to Cloud Native Computing Foundation
How to Contribute to Cloud Native Computing Foundation
 
How to contribute to cloud native computing foundation (CNCF)
How to contribute to cloud native computing foundation (CNCF)How to contribute to cloud native computing foundation (CNCF)
How to contribute to cloud native computing foundation (CNCF)
 
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
 
DEEP: a user success story
DEEP: a user success storyDEEP: a user success story
DEEP: a user success story
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Recently uploaded (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Introduction of eBPF - 時下最夯的Linux Technology

  • 2. 梁維恩 Jace Liang SW / Infra. engineer at ITRI Facebook: jace.liang github: mJace
  • 3. TOC Votes to Move Falco into CNCF Incubator By Jessie January 8, 2020 in Blog Today, the Cloud Native Computing Foundation (CNCF) Technical Oversight Committee (TOC) voted to accept Falco as an incubation-level hosted project. Falco, which entered the CNCF Sandbox in October 2018, is an open source Kubernetes runtime security project. It provides intrusion and abnormality detection for cloud native platforms such as Kubernetes, Mesosphere, and Cloud Foundry.
  • 4. BPF security capabilities • Which processes are being executed? By which processes? • What network connections are being made? By which processes? • What permission denied errors are happening on the system? • Is this kernel/user function being executed with these arguments?
  • 5. Take away • What’s eBPF • Use eBPF based tools to debug • New design idea You don't need to know how to operate an X-ray machine, but you do need to know that if you swallow a penny, an X-ray is an option! www.bredangregg.com
  • 6. What’s BPF? • BPF全名為Berkeley Packet Filter, Introduced by Lawrence Berkeley National Laboratory, 1992. • 當時推出的目的是為了提高 BSD-based Kernel過濾封包的效率。 原理是將封包的過濾程式編譯後由Kernel中類似虛擬機的環境執 行。 • 和原先在Userspace過濾封包相比有更好的效能。 且透過編譯以及在核心內沙盒中執行的特性,能夠避免使用者把 Kernel搞壞掉。
  • 7. Example of BPF – Tcpdump
  • 8. Example of BPF – Tcpdump cont. #檢查是否為IPV6,如果不是(jf),則視為IPV4 (GOTO Line:006) #檢查是否為TCP #檢查dst port是否為7070(0x1b9e),if so (jt) L014 #檢查是否為 ipv4封包 #檢查是否為 tcp封包 #檢查是否為 ip fragment packet #找到tcp封包中 dest port 的所在位置 #檢查dst port是否為7070,若為真(jt) GOT L014 #Packet Match! #Packet Mis-match!
  • 9. How about eBPF (enhanced BPF)? • 原先Kernel內bpf虛擬機的設計過時,不支援新硬體CPU架構 • eBPF相對bpf有更佳的硬體相容性,支援更大的register • eBPF相對bpf有更快的編譯速度,在過濾網路封包時的效能也更好 • eBPF於2014年的版本後,便可直接從userspace操作 “Super powers have finally come to Linux“ – Brendan Gregg, Linux Conf. 2017
  • 11. What can you do with eBPF? • Filter traffic, at the lowest entry of linux network stack. • Programs can be attached to tracepoints, kprobes, system calls, perf events, etc.
  • 12. Velocity 2017: Performance Analysis Superpowers with Linux eBPF - Brendan Gregg https://www.youtube.com/watch?v=bj3qdEDbCD4
  • 13. Use case of eBPF – Userspace tracing https://github.com/iovisor/kubectl-trace
  • 14. relationship between userspace threads fnc tid/pid/arg/ret fnc tid/pid/arg/ret pkt pkt pkt pkt enqueue tid/pid/arg/ret dequeue tid/pid/arg/ret Get relationship by en/dequeue args and retval https://github.com/mJace/ebpfKit/blob/master/Examples/cpp/README.md
  • 15.
  • 16. eBPF related projects – XDP (express data path) • Since Kernel v4.8 • Based on eBPF • DDOS Protection • Network security • Network accelerate
  • 17. eBPF related projects – sysdig • Embed Security, Compliance and Performance Into Your DevOps Workflows
  • 18. eBPF related projects – Falco • Cloud-Native Runtime Security Falco efficiently leverages Extended Berkeley Packet Filter (eBPF), a secure mechanism, to capture system calls and gain deep visibility. By adding Kubernetes application context and Kubernetes API audit events, teams can understand who did what.
  • 19. Other eBPF related implementations… • Cilium – XDP based CNI • Weavescope – ebpf based monitor tool • Iptables – Bpfilter implementations to optimize ingress/outgress security rules • Calicio – Just release a alpha version that lavages ebpf • Systemtap – Support eBPF now.
  • 20. eBPF related projects – BCC • BPF Compiler Collection (BCC) BCC is a toolkit for creating efficient kernel tracing and manipulation programs, and includes several useful tools and examples https://github.com/iovisor/bcc
  • 21. BCC tools example – tcpconlat (tcp latency)
  • 22. BCC tools example – execsnoop ( trace syscall- exec)
  • 23. bpftrace tool example – cpuwalk.
  • 24. Demo 1 – containerized ebpf tool • Bcc tools inside a container, and trace other container’s processes. Target container ebpf container Host Machine Kernel ebpf program ebpf map https://github.com/mJace/ebpfKit/blob/master/Examples/bcc-demo/demo-01.md
  • 25. Demo 2. • Namespace-based tracing. ebpf container Target Container P3 P2 P1 How to trace all processes????? Even process just created? https://github.com/mJace/ebpfKit/blob/master/Examples/bcc-demo/demo-02.md
  • 26. Software stack for ebpf related project bpf,ebpf – main framework XDP – Express data plane powered by ebpf Bcc lib – library for higher app to communicate with bpf go-bpf – golang lib for bpf Bcc tools – userspace tool like tcptracer to trace all tcp status bpftrace – high level userspace bpf based trace tool. bpfebpf Bcc lib Kernel Space User Space Bcc tools go-bpf bpftrace tools XDP
  • 27. The future of eBPF Kernel operations structures in BPF what has been merged for 5.6 is not just a mechanism for hooking in TCP congestion-control algorithms…… this new infrastructure can be used to allow a BPF program to replace any "operations structure“ (in kernel) https://lwn.net/Articles/811631/?fbclid=IwAR3otEAmjW4GS5i3hcWHzsy6hfmTIJwb_nUGHcT- sS2aCOX1xcn9DuTfcwA ➢Update kernel without building kernel, even rebooting ➢Dynamic driver? Runtime configurable kernel driver, without re-bulding ➢Kernel layer cloud native application?
  • 28. Q n’ A / Take away • What’s eBPF • 一種Linux內的技術,能讓人動態的觀察系統內的行為 • Use eBPF based tools to debug • ebpf tool產生的overhead,遠低於傳統userspace monitor tool • 可觀測幾乎所有系統內行為,從kernel到userspace • New design idea • eBPF打破以往kernel layer application可攜性極低的問題 You don't need to know how to operate an X-ray machine, but you do need to know that if you swallow a penny, an X-ray is an option! www.bredangregg.com
  • 29. Reference. • http://www.brendangregg.com/blog/2019-01-01/learn-ebpf-tracing.html • https://hackmd.io/@sysprog/SJTuuG9a7?type=view • https://github.com/iovisor/bpftrace • https://github.com/iovisor/bcc • https://github.com/iovisor/kubectl-trace