Che-Wei Lin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Cilium Notes ## 目的 討論 Cilium eBPF 共享同步知識 ## 議題 1. eBPF 2. Cilium 3. Service Mesh 4. eBPF 有人質疑圖靈不完備 ## 入門相關資料 - [XDP ACM Paper 中譯](https://arthurchiao.art/blog/xdp-paper-acm-2018-zh/) - XDP技術分析 bottom up - [eBPF + Kubernetes](http://arthurchiao.art/blog/ebpf-and-k8s-zh/) - Cilium eBPF 特性及概覽 - [Cilium Datapath 封包旅程](https://arthurchiao.art/blog/understanding-ebpf-datapath-in-cilium-zh/) ## eBPF ### 討論重點 - Cilium eBPF 實作細節 - cgroup eBPF - tc eBPF - sock_ops eBPF - gXDP eBPF ### cgroup eBPF - [cgroup 實作(2016, 非常早期)](https://github.com/torvalds/linux/commit/ca89fa77b4488ecf2e3f72096386e8f3a58fe2fc#) - [用 cgroup ebpf 來實作防火牆](https://nfil.dev/coding/security/ebpf-firewall-with-cgroups/) - 本篇作者想要用ebpf實現防火牆, 內文開頭有提到做這件 packets dropping 有2個hook points 可以做包含 - XDP(但目前僅能支援 ingress traffic) - 透過Linux traffic control subsystem's hook points(但不能支援作者的CentOS環境) - cgroup hooks - 分別寫下 ingress/egress eBPF 程式透過LLVM編譯成.o檔案。透過 `__section` 可以看到這兩段控制 ingress/egress 的code被注入到 cgroup skb ```c= #include <stdbool.h> #include <linux/bpf.h> #include <netinet/ip.h> #include "bpf_helpers.h" #define __section(NAME) \ __attribute__((section(NAME), used)) /* Ingress hook - handle incoming packets */ __section("cgroup_skb/ingress") int ingress(struct __sk_buff *skb) { return false; } /* Egress hook - handle outgoing packets */ __section("cgroup_skb/egress") int egress(struct __sk_buff *skb) { return false; } char __license[] __section("license") = "GPL"; ``` - 最後必須要透過cilium的函式庫 將這兩段注入至 kernel 流程大概是 - 到ebpf map 註冊(pin), 因為go程序離開之後必須還要能操作這2段ebpf程式 - 獲得root cgroup 的file handle - 將兩段ebpf code attach 到root group ### tc eBPF - Linux Kernel 4.1開始支援 eBPF 程式在 tc 的 classifier 及 action 附著(attach)這兩個 hooks > Extends the "classic" BPF programmable tc classifier by extending its scope also to native eBPF code, thus allowing userspace to implement own custom, 'safe' C like classifiers that can then be compiled with the LLVM eBPF backend to an eBPF elf file and loaded into the kernel via iproute2's tc, and be JITed in the kernel [來源](https://kernelnewbies.org/Linux_4.1) - tc ebpf direct-action - tc ebpf classifier with direct-action - 本來行為是返回0/1/classID 因為透過ebpf改成返回action - classID 可以從其他地方看到 `tc_classid` - tc ebpf action direct-classifier? 不行 - actions 必須接在classifer之後 - 但可以做邏輯處理透過hook點滿足條件drop ### 觀點或討論內容 ### 相關參考資料 - https://blog.yadutaf.fr/2021/08/22/ebpf-cgroup-per-cpu-storage-low-overhead-accounting/ - [理解tc ebpf的 direct-action](https://arthurchiao.art/blog/understanding-tc-da-mode-zh/) ## Cilium ### 討論重點 - 透過 eBPF 達到 Linux networking stack shortcut ### 觀點或討論內容 xxx ## Service Mesh ### 討論重點 - Sidecar based service mesh - 因為 sidecar based 將架構及路由變得更複雜,在這個框架之下是否有價值 - eBPF based service mesh ### 觀點或討論內容 xxx ### 相關參考資料 - [社群討論](https://twitter.com/louiscryan/status/1522661442138238976?s=21&t=SAPgpU07Uo2TiZzv76Ok9A) - isovalent 提出 [eBPF based service mesh] (https://isovalent.com/blog/post/2021-12-08-ebpf-servicemesh) proxyless - 反對 eBPF based service mesh 並支持 [sidecar based service mesh](https://www.infoq.com/news/2022/01/ebpf-wasm-service-mesh/)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully