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
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
介紹 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
基礎設置
How to configure it
• 設定 / Configuration
‒ 使用 Yast
‒ 手動 ( Documentation/networking/bonding.txt )
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);
27. 27
Init module – point 2
• Use “ rtnl_link_register” - Register rtnl_link_ops with
rtnetlink
• What is rtnetlink ?
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.
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
Init module – point 4
• Use “register_netdevice_notifier” - register a network
notifier block
• What is network notifier block ?
32. 32
Init module – point 4
• Use “register_netdevice_notifier” - register a network
notifier block
• Why use raw_notifier_call_chain ?
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.
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.
Editor's Notes
早期由於乙太網路卡的速度還不夠快,那如果妳的伺服器需要比較大的頻寬使用時,就得要購買更昂貴的設備才行。 那為什麼不能將幾張網卡合併成為一張來擴大頻寬呢?此外,對於重要的服務來說,網路是不能中斷的!所以,能不能使用兩條以上的線路連接到我的伺服器呢? 因此,(1)合併網路卡的頻寬與 (2)讓網路具有容錯能力 (fault tolerance) 就成了 Linux bonding 最主要的考量了!目前 Linux bonding 功能已經加入核心,所以只要啟動它即可!不需要額外安裝其他軟體呦!
From 鳥哥
http://linux.vbird.org/linux_enterprise/0110network.php
In the basic balance modes (balance-rr and balance-xor), it
works with any system that supports etherchannel (also called
trunking). Most managed switches currently available have such
support, and many unmanaged switches as well.
The advanced balance modes (balance-tlb and balance-alb) do
not have special switch requirements, but do need device drivers that
support specific features (described in the appropriate section under
module parameters, above).
In 802.3ad mode, it works with systems that support IEEE
802.3ad Dynamic Link Aggregation. Most managed and many unmanaged
switches currently available support 802.3ad.
The active-backup mode should work with any Layer-II switch.
/**
* register_pernet_subsys - register a network namespace subsystem
* @ops: pernet operations structure for the subsystem
*
* Register a subsystem which has init and exit functions
* that are called when network namespaces are created and
* destroyed respectively.
*
* When registered all network namespace init functions are
* called for every existing network namespace. Allowing kernel
* modules to have a race free view of the set of network namespaces.
*
* When a new network namespace is created all of the init
* methods are called in the order in which they were registered.
*
* When a network namespace is destroyed all of the exit methods
* are called in the reverse of the order with which they were
* registered.
*/