Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
bond_main.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/interrupt.h>
#include <linux/ptrace.h>
#include <linux/ioport.h>
#include <linux/in.h>
#include <net/ip.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/timer.h>
#include <linux/socket.h>
#include <linux/ctype.h>
#include <linux/inet.h>
#include <linux/bitops.h>
#include <linux/io.h>
#include <asm/dma.h>
#include <linux/uaccess.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/igmp.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <linux/rtnetlink.h>
#include <linux/smp.h>
#include <linux/if_ether.h>
#include <net/arp.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
#include <linux/if_bonding.h>
#include <linux/jiffies.h>
#include <linux/preempt.h>
#include <net/route.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>
#include <net/pkt_sched.h>
#include "bonding.h"
#include "bond_3ad.h"
#include "bond_alb.h"

Go to the source code of this file.

Macros

#define pr_fmt(fmt)   KBUILD_MODNAME ": " fmt
 
#define BOND_LINK_MON_INTERV   0
 
#define BOND_LINK_ARP_INTERV   0
 
#define BOND_VLAN_FEATURES
 

Functions

 module_param (max_bonds, int, 0)
 
 MODULE_PARM_DESC (max_bonds,"Max number of bonded devices")
 
 module_param (tx_queues, int, 0)
 
 MODULE_PARM_DESC (tx_queues,"Max number of transmit queues (default = 16)")
 
 module_param_named (num_grat_arp, num_peer_notif, int, 0644)
 
 MODULE_PARM_DESC (num_grat_arp,"Number of peer notifications to send on ""failover event (alias of num_unsol_na)")
 
 module_param_named (num_unsol_na, num_peer_notif, int, 0644)
 
 MODULE_PARM_DESC (num_unsol_na,"Number of peer notifications to send on ""failover event (alias of num_grat_arp)")
 
 module_param (miimon, int, 0)
 
 MODULE_PARM_DESC (miimon,"Link check interval in milliseconds")
 
 module_param (updelay, int, 0)
 
 MODULE_PARM_DESC (updelay,"Delay before considering link up, in milliseconds")
 
 module_param (downdelay, int, 0)
 
 MODULE_PARM_DESC (downdelay,"Delay before considering link down, ""in milliseconds")
 
 module_param (use_carrier, int, 0)
 
 MODULE_PARM_DESC (use_carrier,"Use netif_carrier_ok (vs MII ioctls) in miimon; ""0 for off, 1 for on (default)")
 
 module_param (mode, charp, 0)
 
 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")
 
 module_param (primary, charp, 0)
 
 MODULE_PARM_DESC (primary,"Primary network device to use")
 
 module_param (primary_reselect, charp, 0)
 
 MODULE_PARM_DESC (primary_reselect,"Reselect primary slave ""once it comes up; ""0 for always (default), ""1 for only if speed of primary is ""better, ""2 for only on active slave ""failure")
 
 module_param (lacp_rate, charp, 0)
 
 MODULE_PARM_DESC (lacp_rate,"LACPDU tx rate to request from 802.3ad partner; ""0 for slow, 1 for fast")
 
 module_param (ad_select, charp, 0)
 
 MODULE_PARM_DESC (ad_select,"803.ad aggregation selection logic; ""0 for stable (default), 1 for bandwidth, ""2 for count")
 
 module_param (min_links, int, 0)
 
 MODULE_PARM_DESC (min_links,"Minimum number of available links before turning on carrier")
 
 module_param (xmit_hash_policy, charp, 0)
 
 MODULE_PARM_DESC (xmit_hash_policy,"balance-xor and 802.3ad hashing method; ""0 for layer 2 (default), 1 for layer 3+4, ""2 for layer 2+3")
 
 module_param (arp_interval, int, 0)
 
 MODULE_PARM_DESC (arp_interval,"arp interval in milliseconds")
 
 module_param_array (arp_ip_target, charp, NULL, 0)
 
 MODULE_PARM_DESC (arp_ip_target,"arp targets in n.n.n.n form")
 
 module_param (arp_validate, charp, 0)
 
 MODULE_PARM_DESC (arp_validate,"validate src/dst of ARP probes; ""0 for none (default), 1 for active, ""2 for backup, 3 for all")
 
 module_param (fail_over_mac, charp, 0)
 
 MODULE_PARM_DESC (fail_over_mac,"For active-backup, do not set all slaves to ""the same MAC; 0 for none (default), ""1 for active, 2 for follow")
 
 module_param (all_slaves_active, int, 0)
 
 MODULE_PARM_DESC (all_slaves_active,"Keep all frames received on an interface""by setting active flag for all slaves; ""0 for never (default), 1 for always.")
 
 module_param (resend_igmp, int, 0)
 
 MODULE_PARM_DESC (resend_igmp,"Number of IGMP membership reports to send on ""link failure")
 
const charbond_mode_name (int mode)
 
struct vlan_entrybond_next_vlan (struct bonding *bond, struct vlan_entry *curr)
 
int bond_dev_queue_xmit (struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev)
 
void bond_change_active_slave (struct bonding *bond, struct slave *new_active)
 
void bond_select_active_slave (struct bonding *bond)
 
int bond_enslave (struct net_device *bond_dev, struct net_device *slave_dev)
 
int bond_release (struct net_device *bond_dev, struct net_device *slave_dev)
 
void bond_mii_monitor (struct work_struct *work)
 
void bond_loadbalance_arp_mon (struct work_struct *work)
 
void bond_activebackup_arp_mon (struct work_struct *work)
 
void bond_set_mode_ops (struct bonding *bond, int mode)
 
int bond_parse_parm (const char *buf, const struct bond_parm_tbl *tbl)
 
int bond_create (struct net *net, const char *name)
 
 module_init (bonding_init)
 
 module_exit (bonding_exit)
 
 MODULE_LICENSE ("GPL")
 
 MODULE_VERSION (DRV_VERSION)
 
 MODULE_DESCRIPTION (DRV_DESCRIPTION", v"DRV_VERSION)
 
 MODULE_AUTHOR ("Thomas Davis, [email protected] and many others")
 
 MODULE_ALIAS_RTNL_LINK ("bond")
 

Variables

int bond_net_id __read_mostly
 
struct bond_parm_tbl bond_lacp_tbl []
 
struct bond_parm_tbl bond_mode_tbl []
 
struct bond_parm_tbl xmit_hashtype_tbl []
 
struct bond_parm_tbl arp_validate_tbl []
 
struct bond_parm_tbl fail_over_mac_tbl []
 
struct bond_parm_tbl pri_reselect_tbl []
 
struct bond_parm_tbl ad_select_tbl []
 

Macro Definition Documentation

#define BOND_LINK_ARP_INTERV   0

Definition at line 88 of file bond_main.c.

#define BOND_LINK_MON_INTERV   0

Definition at line 87 of file bond_main.c.

#define BOND_VLAN_FEATURES
Value:
NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \
NETIF_F_HIGHDMA | NETIF_F_LRO)

Definition at line 1372 of file bond_main.c.

#define pr_fmt (   fmt)    KBUILD_MODNAME ": " fmt

Definition at line 34 of file bond_main.c.

Function Documentation

void bond_activebackup_arp_mon ( struct work_struct work)

Definition at line 3171 of file bond_main.c.

void bond_change_active_slave ( struct bonding bond,
struct slave new_active 
)

change_active_interface - change the active slave into the specified one : our bonding struct : the new slave to make the active one

Set the new slave to the bond's settings and unset them on the old curr_active_slave. Setting include flags, mc-list, promiscuity, allmulti, etc.

If 's link state is BOND_LINK_BACK we'll set it to BOND_LINK_UP, because it is apparently the best available slave we have, even though its updelay hasn't timed out yet.

If new_active is not NULL, caller must hold bond->lock for read and curr_slave_lock for write_bh.

Definition at line 1054 of file bond_main.c.

int bond_create ( struct net net,
const char name 
)

Definition at line 4886 of file bond_main.c.

int bond_dev_queue_xmit ( struct bonding bond,
struct sk_buff skb,
struct net_device slave_dev 
)

bond_dev_queue_xmit - Prepare skb for xmit.

: bond device that got this skb for tx. : hw accel VLAN tagged skb to transmit : slave that is supposed to xmit this skbuff

Definition at line 392 of file bond_main.c.

int bond_enslave ( struct net_device bond_dev,
struct net_device slave_dev 
)

Definition at line 1503 of file bond_main.c.

void bond_loadbalance_arp_mon ( struct work_struct work)

Definition at line 2815 of file bond_main.c.

void bond_mii_monitor ( struct work_struct work)

Definition at line 2545 of file bond_main.c.

const char* bond_mode_name ( int  mode)

Definition at line 255 of file bond_main.c.

struct vlan_entry* bond_next_vlan ( struct bonding bond,
struct vlan_entry curr 
)
read

bond_next_vlan - safely skip to the next item in the vlans list. : the bond we're working on : item we're advancing from

Returns NULL if list is empty, bond->next_vlan if is NULL, or ->next otherwise (even if it is itself again).

Caller must hold bond->lock

Definition at line 360 of file bond_main.c.

int bond_parse_parm ( const char buf,
const struct bond_parm_tbl tbl 
)

Definition at line 4459 of file bond_main.c.

int bond_release ( struct net_device bond_dev,
struct net_device slave_dev 
)

Definition at line 1935 of file bond_main.c.

void bond_select_active_slave ( struct bonding bond)

bond_select_active_slave - select a new active slave, if needed : our bonding struct

This functions should be called when one of the following occurs:

  • The old curr_active_slave has been released or lost its link.
  • The primary_slave has got its link back.
  • A slave has got its link back and there's no old curr_active_slave.

Caller must hold bond->lock for read and curr_slave_lock for write_bh.

Definition at line 1156 of file bond_main.c.

void bond_set_mode_ops ( struct bonding bond,
int  mode 
)

Definition at line 4292 of file bond_main.c.

MODULE_ALIAS_RTNL_LINK ( "bond"  )
MODULE_AUTHOR ( "Thomas  Davis,
tadavis @lbl.gov and many others"   
)
MODULE_DESCRIPTION ( DRV_DESCRIPTION ,
v DRV_VERSION 
)
module_exit ( bonding_exit  )
module_init ( bonding_init  )
MODULE_LICENSE ( "GPL"  )
module_param ( max_bonds  ,
int  ,
 
)
module_param ( tx_queues  ,
int  ,
 
)
module_param ( miimon  ,
int  ,
 
)
module_param ( updelay  ,
int  ,
 
)
module_param ( downdelay  ,
int  ,
 
)
module_param ( use_carrier  ,
int  ,
 
)
module_param ( mode  ,
charp  ,
 
)
module_param ( primary  ,
charp  ,
 
)
module_param ( primary_reselect  ,
charp  ,
 
)
module_param ( lacp_rate  ,
charp  ,
 
)
module_param ( ad_select  ,
charp  ,
 
)
module_param ( min_links  ,
int  ,
 
)
module_param ( xmit_hash_policy  ,
charp  ,
 
)
module_param ( arp_interval  ,
int  ,
 
)
module_param ( arp_validate  ,
charp  ,
 
)
module_param ( fail_over_mac  ,
charp  ,
 
)
module_param ( all_slaves_active  ,
int  ,
 
)
module_param ( resend_igmp  ,
int  ,
 
)
module_param_array ( arp_ip_target  ,
charp  ,
NULL  ,
 
)
module_param_named ( num_grat_arp  ,
num_peer_notif  ,
int  ,
0644   
)
module_param_named ( num_unsol_na  ,
num_peer_notif  ,
int  ,
0644   
)
MODULE_PARM_DESC ( max_bonds  ,
"Max number of bonded devices  
)
MODULE_PARM_DESC ( tx_queues  ,
"Max number of transmit queues (default = 16)"   
)
MODULE_PARM_DESC ( num_grat_arp  ,
"Number of peer notifications to send on ""failover event (alias of num_unsol_na)"   
)
MODULE_PARM_DESC ( num_unsol_na  ,
"Number of peer notifications to send on ""failover event (alias of num_grat_arp)"   
)
MODULE_PARM_DESC ( miimon  ,
"Link check interval in milliseconds"   
)
MODULE_PARM_DESC ( updelay  ,
"Delay before considering link  up,
in milliseconds"   
)
MODULE_PARM_DESC ( downdelay  ,
"Delay before considering link  down,
""in milliseconds"   
)
MODULE_PARM_DESC ( use_carrier  ,
"Use netif_carrier_ok (vs MII ioctls) in miimon; ""0 for  off,
1 for on(default)"   
)
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"   
)
MODULE_PARM_DESC ( primary  ,
"Primary network device to use"   
)
MODULE_PARM_DESC ( primary_reselect  ,
"Reselect primary slave ""once it comes up; ""0 for always   default,
""1 for only if speed of primary is""  better,
""2 for only on active slave""failure"   
)
MODULE_PARM_DESC ( lacp_rate  ,
"LACPDU tx rate to request from 802.3ad partner; ""0 for  slow,
1 for fast  
)
MODULE_PARM_DESC ( ad_select  ,
"803.ad aggregation selection logic; ""0 for stable   default,
1 for  bandwidth,
""2 for count  
)
MODULE_PARM_DESC ( min_links  ,
"Minimum number of available links before turning on carrier"   
)
MODULE_PARM_DESC ( xmit_hash_policy  ,
"balance-xor and 802.3ad hashing method; ""0 for layer 2   default,
1 for layer 3+  4,
""2 for layer 2+3"   
)
MODULE_PARM_DESC ( arp_interval  ,
"arp interval in milliseconds"   
)
MODULE_PARM_DESC ( arp_ip_target  ,
"arp targets in n.n.n.n form  
)
MODULE_PARM_DESC ( arp_validate  ,
"validate src/dst of ARP probes; ""0 for none   default,
1 for  active,
""2 for  backup,
3 for all"   
)
MODULE_PARM_DESC ( fail_over_mac  ,
"For active backup,
do not set all slaves to""the same MAC;0 for   nonedefault,
""1 for  active,
2 for follow"   
)
MODULE_PARM_DESC ( all_slaves_active  ,
"Keep all frames received on an interface""by setting active flag for all slaves; ""0 for never   default,
1 for always."   
)
MODULE_PARM_DESC ( resend_igmp  ,
"Number of IGMP membership reports to send on ""link failure"   
)
MODULE_VERSION ( DRV_VERSION  )

Variable Documentation

struct rtnl_link_ops bond_link_ops __read_mostly
Initial value:
= {
.kind = "bond",
.priv_size = sizeof(struct bonding),
.setup = bond_setup,
.validate = bond_validate,
.get_num_tx_queues = bond_get_num_tx_queues,
.get_num_rx_queues = bond_get_num_tx_queues,
}

Definition at line 187 of file bond_main.c.

struct bond_parm_tbl ad_select_tbl[]
Initial value:
= {
{ "stable", BOND_AD_STABLE},
{ "bandwidth", BOND_AD_BANDWIDTH},
{ "count", BOND_AD_COUNT},
{ NULL, -1},
}

Definition at line 241 of file bond_main.c.

struct bond_parm_tbl arp_validate_tbl[]
Initial value:
= {
{ NULL, -1},
}

Definition at line 219 of file bond_main.c.

struct bond_parm_tbl bond_lacp_tbl[]
Initial value:
= {
{ "slow", AD_LACP_SLOW},
{ "fast", AD_LACP_FAST},
{ NULL, -1},
}

Definition at line 195 of file bond_main.c.

struct bond_parm_tbl bond_mode_tbl[]
Initial value:
= {
{ "balance-rr", BOND_MODE_ROUNDROBIN},
{ "active-backup", BOND_MODE_ACTIVEBACKUP},
{ "balance-xor", BOND_MODE_XOR},
{ "broadcast", BOND_MODE_BROADCAST},
{ "802.3ad", BOND_MODE_8023AD},
{ "balance-tlb", BOND_MODE_TLB},
{ "balance-alb", BOND_MODE_ALB},
{ NULL, -1},
}

Definition at line 201 of file bond_main.c.

struct bond_parm_tbl fail_over_mac_tbl[]
Initial value:
= {
{ "none", BOND_FOM_NONE},
{ "active", BOND_FOM_ACTIVE},
{ "follow", BOND_FOM_FOLLOW},
{ NULL, -1},
}

Definition at line 227 of file bond_main.c.

struct bond_parm_tbl pri_reselect_tbl[]
Initial value:
= {
{ NULL, -1},
}

Definition at line 234 of file bond_main.c.

struct bond_parm_tbl xmit_hashtype_tbl[]
Initial value:
= {
{ "layer3+4", BOND_XMIT_POLICY_LAYER34},
{ "layer2+3", BOND_XMIT_POLICY_LAYER23},
{ NULL, -1},
}

Definition at line 212 of file bond_main.c.