use bonding driver with ethernet

Download Use bonding driver with ethernet

If you can't read please download the document

Upload: suselab

Post on 23-Feb-2017

356 views

Category:

Software


3 download

TRANSCRIPT

Thank you.

Corporate HeadquartersMaxfeldstrasse 590409 NurembergGermany

+49 911 740 53 0 (Worldwide)www.suse.com

Join us on:www.opensuse.org

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 DisclaimerThis 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.

Use bonding driver with ethernet
SUSE Labs Taipei technology sharing day

AL ChoSUSE Labs [email protected]

Agenda

Bonding

Yast

active-backup mode

Code review

Q&A

Bonding

Bonding / Introduce Bonding

Bonding

Networking Introduction

PC/Server

ip address

WWWroutereth0

Networking Introduction

Question:How to speed up ?

How to do backup ?

PC

Networking Introduction
How to speed up? How to do backup?

ip address 1

ip address 2

WWWroutereth0eth1

PC / Server

bond0

Bonding

bond0eth1eth0routerWWWip address

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

(1) (2) (fault tolerance) Linux bonding Linux bonding From http://linux.vbird.org/linux_enterprise/0110network.php

Networking Introduction

Question:How to speed up ?

How to backup ?

Networking Introduction
How to speed up?

ip address

WWWswitchPC/Server

bond0eth1eth0

Networking Introduction
How to do backup?

ip address

WWWswitchPC/Server

bond0eth0eth1X

(broken)

(enable for backup)

Bonding

Bonding Introduction

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");

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)

In the basic balance modes (balance-rr and balance-xor), itworks with any system that supports etherchannel (also calledtrunking). Most managed switches currently available have suchsupport, and many unmanaged switches as well.

The advanced balance modes (balance-tlb and balance-alb) donot have special switch requirements, but do need device drivers thatsupport specific features (described in the appropriate section undermodule parameters, above).

In 802.3ad mode, it works with systems that support IEEE802.3ad Dynamic Link Aggregation. Most managed and many unmanagedswitches currently available support 802.3ad.

The active-backup mode should work with any Layer-II switch.


How to configure it

/ ConfigurationYast

( Documentation/networking/bonding.txt )

/ Live Demo

Linux Kernel

*_ops

register_netdevice_notifier / call_netdevice_notifier

netlink

rtnetlink_*

Code

Code - module_init(bonding_init)

Drivers/net/bonding/bond_main.cstatic 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;

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);

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;}

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

Init module point 1

Use register_pernet_subsys - register a network namespace subsystem

What is network namespace?

/** * 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. */

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

Init module point 2

Use rtnl_link_register - Register rtnl_link_ops with rtnetlink

What is rtnetlink ?

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.

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

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.

Init module point 4

Use register_netdevice_notifier - register a network notifier block

What is network notifier block ?

Kernelnotifiers/notifier chainspublish-and-subscribejoinnotifier chainchainproviderpublishjoinchainkernelnotifierrebootregister_reboot_notifier()unregister_reboot_notifier()notifiernotifier/proc/brook_notifierpublishbrook_notifier_listscbscriber

Linux Kernel8- Notificationnotifierpublish-and-subscribe patterncallback functionlistlistcallback functionnotifierpublish-and-subscribe patterncallback functionlistlistcallback function

Init module point 4

Use register_netdevice_notifier - register a network notifier block

Why use raw_notifier_call_chain ?

Init module point 4

Use register_netdevice_notifier - register a network notifier block

Why use raw_notifier_call_chain ?commit f07d5b946510a54937a75a3654941e855ffdc4c2Author: Alan Stern Date: Tue May 9 15:23:03 2006 -0700

[NET]: Make netdev_chain a raw notifier. From: Alan Stern 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.

Question ?

Reference

http://nano-chicken.blogspot.com/2010/01/linux-modules8-notification.html

http://nano-chicken.blogspot.com/2011/02/linux-kernel81-notifier.html

https://www.kernel.org/doc/Documentation/networking/bonding.txt

http://linux.vbird.org/linux_enterprise/0110network.php#server_bonding

http://www.xuebuyuan.com/1788250.html