Kawakami Kento
    • 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
    --- lang: ja breaks: false --- <style> .ui-infobar, #doc.markdown-body { max-width: 1100px; } </style> # 2020-09-16 kernel network stack reading - vrf transfer - - 参加者: hayakawa, kawakami, taguchi - kernel: - ドライバー: taguchi - 今回のテーマ - VRF乗り換え - LinuxではVRFをout deviceに指定してルーティングすることによってVRF乗り換えをすることができる。そのデータパスを探索する。 ## tinet環境 ![](https://i.imgur.com/3pwRgWG.png) ```yaml --- nodes: - name: R1 image: slankdev/frr interfaces: - { name: net1, type: direct, args: N1#net0 } - { name: net2, type: direct, args: N2#net0 } - name: N1 image: slankdev/frr interfaces: - { name: net0, type: direct, args: R1#net1 } - name: N2 image: slankdev/frr interfaces: - { name: net0, type: direct, args: R1#net2 } node_configs: - name: R1 cmds: - cmd: ip link add vrf10 type vrf table 10 - cmd: ip link add vrf20 type vrf table 20 - cmd: ip link set vrf10 up - cmd: ip link set vrf20 up - cmd: ip addr add 10.1.0.2/24 dev net1 - cmd: ip addr add 10.2.0.2/24 dev net2 - cmd: ip link set net1 vrf vrf10 - cmd: ip link set net2 vrf vrf20 - cmd: ip route add 10.1.0.1 dev vrf10 vrf vrf20 - cmd: ip route add 10.2.0.1 dev vrf20 vrf vrf10 - name: N1 cmds: - cmd: ip addr add 10.1.0.1/24 dev net0 - cmd: ip route add default via 10.1.0.2 - name: N2 cmds: - cmd: ip addr add 10.2.0.1/24 dev net0 - cmd: ip route add default via 10.2.0.2 ``` ## iptables ``` iptables -t raw -A PREROUTING -i net1 -j MARK --set-mark 0xdeadbeef ``` ## N1からN2にPing ``` ping 10.2.0.1 -c 1 ``` ## Trace結果 ``` === 536089144619 000 ip_rcv_finish 536089174957 000 vrf_l3_rcv 536089184803 000 nf_hook_slow 536089191883 000 iptable_raw_hook 536089202558 000 ip_route_input_noref 536089212338 000 ip_route_input_slow 536089230157 000 fib_validate_source 536089243655 000 __fib_validate_source 536089256874 000 ip_forward 536089262887 000 nf_hook_slow 536089274880 000 selinux_ipv4_forward 536089280597 000 selinux_ip_forward 536089288404 000 ip_forward_finish 536089293446 000 ip_output 536089297830 000 nf_hook_slow 536089308358 000 selinux_ipv4_postroute 536089314537 000 selinux_ip_postroute 536089320384 000 ip_finish_output 536089326866 000 __ip_finish_output 536089333321 000 ip_finish_output2 536089342498 000 dev_queue_xmit <= vrf20に入る 536089347440 000 __dev_queue_xmit 536089355142 000 netdev_core_pick_tx 536089364345 000 validate_xmit_skb 536089373074 000 netif_skb_features 536089380225 000 skb_network_protocol 536089385774 000 validate_xmit_xfrm 536089392276 000 dev_hard_start_xmit 536089400047 000 vrf_xmit 536089408306 000 vrf_process_v4_outbound <= この中で再度lookup 536089419794 000 nf_hook_slow 536089425830 000 iptable_raw_hook 536089431510 000 selinux_ipv4_output 536089436375 000 ip_output 536089441084 000 nf_hook_slow 536089446385 000 selinux_ipv4_postroute 536089451714 000 selinux_ip_postroute 536089456636 000 ip_finish_output 536089461476 000 __ip_finish_output 536089465935 000 ip_finish_output2 536089474542 000 neigh_resolve_output 536089483837 000 __neigh_event_send 536089492662 000 eth_header 536089504288 000 skb_push 536089509074 000 dev_queue_xmit 536089514700 000 __dev_queue_xmit 536089520043 000 netdev_core_pick_tx 536089525739 000 validate_xmit_skb 536089531315 000 netif_skb_features 536089538028 000 passthru_features_check 536089543066 000 skb_network_protocol 536089548024 000 validate_xmit_xfrm 536089553026 000 dev_hard_start_xmit 536089558604 000 veth_xmit 536089568345 000 skb_clone_tx_timestamp 536089574100 000 __dev_forward_skb 536089580003 000 skb_scrub_packet ``` ## メモ VRFのソース: http://elixir-referencer.dev.linecorp.com/linux/latest/source/drivers/net/vrf.c - LinuxのVRF乗り換え == l3mdevへのパケットフォワーディング - vrf_xmit => vrf_process_v4_outboundで再度ルーティング - ちなみにip_forwardが挟まるのでttlが1減る ## 参考文献 VRFのドキュメント: https://www.kernel.org/doc/Documentation/networking/vrf.txt

    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