Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Use bonding driver with ethernet

1,065 views

Published on

SUSE Labs Taipei Technology Sharing Day 2016

Published in: Software
  • Be the first to comment

  • Be the first to like this

Use bonding driver with ethernet

  1. 1. Use bonding driver with ethernet SUSE Labs Taipei technology sharing day AL Cho SUSE Labs Taipei acho@suse.com
  2. 2. 2 Agenda • 介紹 Bonding • 基礎設置 ‒ 使用 Yast ‒ 手動 • 講解範圍 ‒ active-backup mode • Code review • 實際操作
  3. 3. Bonding
  4. 4. 4 介紹 Bonding / Introduce Bonding • Bonding 是什麼?
  5. 5. 5 Networking Introduction PC / Server ip address WWWroutereth0
  6. 6. 6 Networking Introduction • Question: ‒ How to speed up ? ‒ How to do backup ?
  7. 7. 7 PC Networking Introduction How to speed up? How to do backup? ip address 1 ip address 2 WWWrouter eth0 eth1
  8. 8. 8 PC / Server bond0 介紹 Bonding bond0 eth1 eth0 router WWW ip address
  9. 9. 9 介紹 Bonding • Bonding 是什麼? ‒ Reference: ‒ NIC bonding (sometimes called NIC teaming) combines multiple discreet physical NICs into a single logical interface with all of the NICs sharing IP address, MAC address, etc. This allows for redundant failover and can sometimes provide improved transfer times for larger files over a LAN. ‒ https://en.opensuse.org/SDB:Bonding
  10. 10. 10 Networking Introduction • Question: ‒ How to speed up ? ‒ How to backup ?
  11. 11. 11 Networking Introduction How to speed up? ip address WWWswitch PC / Server bond0 eth1 eth0
  12. 12. 12 Networking Introduction How to do backup? ip address WWWswitch PC / Server bond0 eth0 eth1 X (broken) (enable for backup)
  13. 13. 13 介紹 Bonding • Bonding 是什麼? ‒ Introduction
  14. 14. 14 介紹 Bonding • Bonding 模式 ‒ MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, " "1 for active-backup, 2 for balance-xor, " "3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, " "6 for balance-alb");
  15. 15. 15 介紹 Bonding • Bonding 模式 ‒ 0 for balance-rr (Round-robin) ‒ 1 for active-backup ‒ 2 for balance-xor ‒ 3 for broadcast ‒ 4 for 802.3ad (Dynamic link aggregation) ‒ 5 for balance-tlb (Adaptive transmit load balancing ) ‒ 6 for balance-alb (Adaptive load balancing)
  16. 16. 16 基礎設置 How to configure it • 設定 / Configuration ‒ 使用 Yast ‒ 手動 ( Documentation/networking/bonding.txt )
  17. 17. 實際操作 / Live Demo
  18. 18. Linux Kernel 重要機制
  19. 19. 19 重要機制 • *_ops • register_netdevice_notifier / call_netdevice_notifier • netlink • rtnetlink_*
  20. 20. Code
  21. 21. 21 Code - module_init(bonding_init) Drivers/net/bonding/bond_main.c static int __init bonding_init(void) { int i; int res; pr_info("%s", bond_version); res = bond_check_params(&bonding_defaults); if (res) goto out; res = register_pernet_subsys(&bond_net_ops); if (res) goto out;
  22. 22. 22 Code - module_init(bonding_init) res = bond_netlink_init(); if (res) goto err_link; bond_create_debugfs(); for (i = 0; i < max_bonds; i++) { res = bond_create(&init_net, NULL); if (res) goto err; } register_netdevice_notifier(&bond_netdev_notifier);
  23. 23. 23 Code - module_init(bonding_init) out: return res; err: bond_destroy_debugfs(); bond_netlink_fini(); err_link: unregister_pernet_subsys(&bond_net_ops); goto out; }
  24. 24. 24 Bonding.ko module_init(bonding_init) (bond_main.c) (net/core/net_namespace.c) int register_pernet_subsys(struct pernet_operations *ops) register_pernet_subsys(&bond_net_ops) Kernel
  25. 25. 25 Init module – point 1 • Use “register_pernet_subsys” - register a network namespace subsystem • What is network namespace?
  26. 26. 26 Bonding.ko module_init(bonding_init) (bond_main.c) bond_netlink_init( ) (net/core/rtnetlink.c) int rtnl_link_register(struct rtnl_link_ops *ops) rtnl_link_register(&bond_link_ops) Kernel
  27. 27. 27 Init module – point 2 • Use “ rtnl_link_register” - Register rtnl_link_ops with rtnetlink • What is rtnetlink ?
  28. 28. 28 Init module – point 3 • Use “bond_create” • Create a new bond based on the specified name and bonding parameters. • If name is NULL, obtain a suitable "bond%d" name for us. Caller must NOT hold rtnl_lock; we need to release it here before we set up our sysfs entries.
  29. 29. 29 Bonding.ko module_init(bonding_init) (bond_main.c) (net/core/dev.c) int register_netdevice_notifier(struct notifier_block *nb) register_netdevice_notifier(&bond_netdev_notifier) Kernel
  30. 30. 30 Init module – point 4 • Use “register_netdevice_notifier” - register a network notifier block • Register a notifier to be called when network device events occur. • The notifier passed is linked into the kernel structures and must not be reused until it has been unregistered. A negative errno code is returned on a failure. When registered all registration and up events are replayed to the new notifier to allow device to have a race free view of the network device list.
  31. 31. 31 Init module – point 4 • Use “register_netdevice_notifier” - register a network notifier block • What is network notifier block ?
  32. 32. 32 Init module – point 4 • Use “register_netdevice_notifier” - register a network notifier block • Why use raw_notifier_call_chain ?
  33. 33. 33 Init module – point 4 • Use “register_netdevice_notifier” - register a network notifier block • Why use raw_notifier_call_chain ? commit f07d5b946510a54937a75a3654941e855ffdc4c2 Author: Alan Stern <stern@rowland.harvard.edu> Date: Tue May 9 15:23:03 2006 -0700 [NET]: Make netdev_chain a raw notifier. From: Alan Stern <stern@rowland.harvard.edu> This chain does it's own locking via the RTNL semaphore, and can also run recursively so adding a new mutex here was causing deadlocks.
  34. 34. Thank you. 34 Question ?
  35. 35. 35 Reference • http://nano-chicken.blogspot.com/2010/01/linux-modules8-no • http://nano-chicken.blogspot.com/2011/02/linux-kernel81-noti • https://www.kernel.org/doc/Documentation/networking/bondin • http://linux.vbird.org/linux_enterprise/0110network.php#serve • http://www.xuebuyuan.com/1788250.html
  36. 36. 36
  37. 37. Corporate Headquarters Maxfeldstrasse 5 90409 Nuremberg Germany +49 911 740 53 0 (Worldwide) www.suse.com Join us on: www.opensuse.org 37
  38. 38. Unpublished Work of SUSE LLC. All Rights Reserved. This work is an unpublished work and contains confidential, proprietary and trade secret information of SUSE LLC. Access to this work is restricted to SUSE employees who have a need to know to perform tasks within the scope of their assignments. No part of this work may be practiced, performed, copied, distributed, revised, modified, translated, abridged, condensed, expanded, collected, or adapted without the prior written consent of SUSE. Any use or exploitation of this work without authorization could subject the perpetrator to criminal and civil liability. General Disclaimer This document is not to be construed as a promise by any participating company to develop, deliver, or market a product. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. SUSE makes no representations or warranties with respect to the contents of this document, and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose. The development, release, and timing of features or functionality described for SUSE products remains at the sole discretion of SUSE. Further, SUSE reserves the right to revise this document and to make changes to its content, at any time, without obligation to notify any person or entity of such revisions or changes. All SUSE marks referenced in this presentation are trademarks or registered trademarks of Novell, Inc. in the United States and other countries. All third-party trademarks are the property of their respective owners.

×