aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c302
1 files changed, 2 insertions, 300 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7b7ca971672f..68a5ce0a649f 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -65,8 +65,6 @@
65#include <linux/skbuff.h> 65#include <linux/skbuff.h>
66#include <net/sock.h> 66#include <net/sock.h>
67#include <linux/rtnetlink.h> 67#include <linux/rtnetlink.h>
68#include <linux/proc_fs.h>
69#include <linux/seq_file.h>
70#include <linux/smp.h> 68#include <linux/smp.h>
71#include <linux/if_ether.h> 69#include <linux/if_ether.h>
72#include <net/arp.h> 70#include <net/arp.h>
@@ -173,9 +171,6 @@ MODULE_PARM_DESC(resend_igmp, "Number of IGMP membership reports to send on link
173atomic_t netpoll_block_tx = ATOMIC_INIT(0); 171atomic_t netpoll_block_tx = ATOMIC_INIT(0);
174#endif 172#endif
175 173
176static const char * const version =
177 DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n";
178
179int bond_net_id __read_mostly; 174int bond_net_id __read_mostly;
180 175
181static __be32 arp_target[BOND_MAX_ARP_TARGETS]; 176static __be32 arp_target[BOND_MAX_ARP_TARGETS];
@@ -245,7 +240,7 @@ static void bond_uninit(struct net_device *bond_dev);
245 240
246/*---------------------------- General routines -----------------------------*/ 241/*---------------------------- General routines -----------------------------*/
247 242
248static const char *bond_mode_name(int mode) 243const char *bond_mode_name(int mode)
249{ 244{
250 static const char *names[] = { 245 static const char *names[] = {
251 [BOND_MODE_ROUNDROBIN] = "load balancing (round-robin)", 246 [BOND_MODE_ROUNDROBIN] = "load balancing (round-robin)",
@@ -3288,299 +3283,6 @@ out:
3288 read_unlock(&bond->lock); 3283 read_unlock(&bond->lock);
3289} 3284}
3290 3285
3291/*------------------------------ proc/seq_file-------------------------------*/
3292
3293#ifdef CONFIG_PROC_FS
3294
3295static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
3296 __acquires(RCU)
3297 __acquires(&bond->lock)
3298{
3299 struct bonding *bond = seq->private;
3300 loff_t off = 0;
3301 struct slave *slave;
3302 int i;
3303
3304 /* make sure the bond won't be taken away */
3305 rcu_read_lock();
3306 read_lock(&bond->lock);
3307
3308 if (*pos == 0)
3309 return SEQ_START_TOKEN;
3310
3311 bond_for_each_slave(bond, slave, i) {
3312 if (++off == *pos)
3313 return slave;
3314 }
3315
3316 return NULL;
3317}
3318
3319static void *bond_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
3320{
3321 struct bonding *bond = seq->private;
3322 struct slave *slave = v;
3323
3324 ++*pos;
3325 if (v == SEQ_START_TOKEN)
3326 return bond->first_slave;
3327
3328 slave = slave->next;
3329
3330 return (slave == bond->first_slave) ? NULL : slave;
3331}
3332
3333static void bond_info_seq_stop(struct seq_file *seq, void *v)
3334 __releases(&bond->lock)
3335 __releases(RCU)
3336{
3337 struct bonding *bond = seq->private;
3338
3339 read_unlock(&bond->lock);
3340 rcu_read_unlock();
3341}
3342
3343static void bond_info_show_master(struct seq_file *seq)
3344{
3345 struct bonding *bond = seq->private;
3346 struct slave *curr;
3347 int i;
3348
3349 read_lock(&bond->curr_slave_lock);
3350 curr = bond->curr_active_slave;
3351 read_unlock(&bond->curr_slave_lock);
3352
3353 seq_printf(seq, "Bonding Mode: %s",
3354 bond_mode_name(bond->params.mode));
3355
3356 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP &&
3357 bond->params.fail_over_mac)
3358 seq_printf(seq, " (fail_over_mac %s)",
3359 fail_over_mac_tbl[bond->params.fail_over_mac].modename);
3360
3361 seq_printf(seq, "\n");
3362
3363 if (bond->params.mode == BOND_MODE_XOR ||
3364 bond->params.mode == BOND_MODE_8023AD) {
3365 seq_printf(seq, "Transmit Hash Policy: %s (%d)\n",
3366 xmit_hashtype_tbl[bond->params.xmit_policy].modename,
3367 bond->params.xmit_policy);
3368 }
3369
3370 if (USES_PRIMARY(bond->params.mode)) {
3371 seq_printf(seq, "Primary Slave: %s",
3372 (bond->primary_slave) ?
3373 bond->primary_slave->dev->name : "None");
3374 if (bond->primary_slave)
3375 seq_printf(seq, " (primary_reselect %s)",
3376 pri_reselect_tbl[bond->params.primary_reselect].modename);
3377
3378 seq_printf(seq, "\nCurrently Active Slave: %s\n",
3379 (curr) ? curr->dev->name : "None");
3380 }
3381
3382 seq_printf(seq, "MII Status: %s\n", netif_carrier_ok(bond->dev) ?
3383 "up" : "down");
3384 seq_printf(seq, "MII Polling Interval (ms): %d\n", bond->params.miimon);
3385 seq_printf(seq, "Up Delay (ms): %d\n",
3386 bond->params.updelay * bond->params.miimon);
3387 seq_printf(seq, "Down Delay (ms): %d\n",
3388 bond->params.downdelay * bond->params.miimon);
3389
3390
3391 /* ARP information */
3392 if (bond->params.arp_interval > 0) {
3393 int printed = 0;
3394 seq_printf(seq, "ARP Polling Interval (ms): %d\n",
3395 bond->params.arp_interval);
3396
3397 seq_printf(seq, "ARP IP target/s (n.n.n.n form):");
3398
3399 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
3400 if (!bond->params.arp_targets[i])
3401 break;
3402 if (printed)
3403 seq_printf(seq, ",");
3404 seq_printf(seq, " %pI4", &bond->params.arp_targets[i]);
3405 printed = 1;
3406 }
3407 seq_printf(seq, "\n");
3408 }
3409
3410 if (bond->params.mode == BOND_MODE_8023AD) {
3411 struct ad_info ad_info;
3412
3413 seq_puts(seq, "\n802.3ad info\n");
3414 seq_printf(seq, "LACP rate: %s\n",
3415 (bond->params.lacp_fast) ? "fast" : "slow");
3416 seq_printf(seq, "Aggregator selection policy (ad_select): %s\n",
3417 ad_select_tbl[bond->params.ad_select].modename);
3418
3419 if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
3420 seq_printf(seq, "bond %s has no active aggregator\n",
3421 bond->dev->name);
3422 } else {
3423 seq_printf(seq, "Active Aggregator Info:\n");
3424
3425 seq_printf(seq, "\tAggregator ID: %d\n",
3426 ad_info.aggregator_id);
3427 seq_printf(seq, "\tNumber of ports: %d\n",
3428 ad_info.ports);
3429 seq_printf(seq, "\tActor Key: %d\n",
3430 ad_info.actor_key);
3431 seq_printf(seq, "\tPartner Key: %d\n",
3432 ad_info.partner_key);
3433 seq_printf(seq, "\tPartner Mac Address: %pM\n",
3434 ad_info.partner_system);
3435 }
3436 }
3437}
3438
3439static void bond_info_show_slave(struct seq_file *seq,
3440 const struct slave *slave)
3441{
3442 struct bonding *bond = seq->private;
3443
3444 seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name);
3445 seq_printf(seq, "MII Status: %s\n",
3446 (slave->link == BOND_LINK_UP) ? "up" : "down");
3447 seq_printf(seq, "Speed: %d Mbps\n", slave->speed);
3448 seq_printf(seq, "Duplex: %s\n", slave->duplex ? "full" : "half");
3449 seq_printf(seq, "Link Failure Count: %u\n",
3450 slave->link_failure_count);
3451
3452 seq_printf(seq, "Permanent HW addr: %pM\n", slave->perm_hwaddr);
3453
3454 if (bond->params.mode == BOND_MODE_8023AD) {
3455 const struct aggregator *agg
3456 = SLAVE_AD_INFO(slave).port.aggregator;
3457
3458 if (agg)
3459 seq_printf(seq, "Aggregator ID: %d\n",
3460 agg->aggregator_identifier);
3461 else
3462 seq_puts(seq, "Aggregator ID: N/A\n");
3463 }
3464 seq_printf(seq, "Slave queue ID: %d\n", slave->queue_id);
3465}
3466
3467static int bond_info_seq_show(struct seq_file *seq, void *v)
3468{
3469 if (v == SEQ_START_TOKEN) {
3470 seq_printf(seq, "%s\n", version);
3471 bond_info_show_master(seq);
3472 } else
3473 bond_info_show_slave(seq, v);
3474
3475 return 0;
3476}
3477
3478static const struct seq_operations bond_info_seq_ops = {
3479 .start = bond_info_seq_start,
3480 .next = bond_info_seq_next,
3481 .stop = bond_info_seq_stop,
3482 .show = bond_info_seq_show,
3483};
3484
3485static int bond_info_open(struct inode *inode, struct file *file)
3486{
3487 struct seq_file *seq;
3488 struct proc_dir_entry *proc;
3489 int res;
3490
3491 res = seq_open(file, &bond_info_seq_ops);
3492 if (!res) {
3493 /* recover the pointer buried in proc_dir_entry data */
3494 seq = file->private_data;
3495 proc = PDE(inode);
3496 seq->private = proc->data;
3497 }
3498
3499 return res;
3500}
3501
3502static const struct file_operations bond_info_fops = {
3503 .owner = THIS_MODULE,
3504 .open = bond_info_open,
3505 .read = seq_read,
3506 .llseek = seq_lseek,
3507 .release = seq_release,
3508};
3509
3510static void bond_create_proc_entry(struct bonding *bond)
3511{
3512 struct net_device *bond_dev = bond->dev;
3513 struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id);
3514
3515 if (bn->proc_dir) {
3516 bond->proc_entry = proc_create_data(bond_dev->name,
3517 S_IRUGO, bn->proc_dir,
3518 &bond_info_fops, bond);
3519 if (bond->proc_entry == NULL)
3520 pr_warning("Warning: Cannot create /proc/net/%s/%s\n",
3521 DRV_NAME, bond_dev->name);
3522 else
3523 memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ);
3524 }
3525}
3526
3527static void bond_remove_proc_entry(struct bonding *bond)
3528{
3529 struct net_device *bond_dev = bond->dev;
3530 struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id);
3531
3532 if (bn->proc_dir && bond->proc_entry) {
3533 remove_proc_entry(bond->proc_file_name, bn->proc_dir);
3534 memset(bond->proc_file_name, 0, IFNAMSIZ);
3535 bond->proc_entry = NULL;
3536 }
3537}
3538
3539/* Create the bonding directory under /proc/net, if doesn't exist yet.
3540 * Caller must hold rtnl_lock.
3541 */
3542static void __net_init bond_create_proc_dir(struct bond_net *bn)
3543{
3544 if (!bn->proc_dir) {
3545 bn->proc_dir = proc_mkdir(DRV_NAME, bn->net->proc_net);
3546 if (!bn->proc_dir)
3547 pr_warning("Warning: cannot create /proc/net/%s\n",
3548 DRV_NAME);
3549 }
3550}
3551
3552/* Destroy the bonding directory under /proc/net, if empty.
3553 * Caller must hold rtnl_lock.
3554 */
3555static void __net_exit bond_destroy_proc_dir(struct bond_net *bn)
3556{
3557 if (bn->proc_dir) {
3558 remove_proc_entry(DRV_NAME, bn->net->proc_net);
3559 bn->proc_dir = NULL;
3560 }
3561}
3562
3563#else /* !CONFIG_PROC_FS */
3564
3565static void bond_create_proc_entry(struct bonding *bond)
3566{
3567}
3568
3569static void bond_remove_proc_entry(struct bonding *bond)
3570{
3571}
3572
3573static inline void bond_create_proc_dir(struct bond_net *bn)
3574{
3575}
3576
3577static inline void bond_destroy_proc_dir(struct bond_net *bn)
3578{
3579}
3580
3581#endif /* CONFIG_PROC_FS */
3582
3583
3584/*-------------------------- netdev event handling --------------------------*/ 3286/*-------------------------- netdev event handling --------------------------*/
3585 3287
3586/* 3288/*
@@ -5384,7 +5086,7 @@ static int __init bonding_init(void)
5384 int i; 5086 int i;
5385 int res; 5087 int res;
5386 5088
5387 pr_info("%s", version); 5089 pr_info("%s", bond_version);
5388 5090
5389 res = bond_check_params(&bonding_defaults); 5091 res = bond_check_params(&bonding_defaults);
5390 if (res) 5092 if (res)