aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2013-10-18 11:43:33 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-19 18:58:45 -0400
commit0a2a78c4a95240e658272bd7cd7422a529e4eb4a (patch)
tree6b03014f30e7f45ffd222753eae1afce8a63b4aa
parentb1eda2ac3fa6bf23b27c7c70eda6885124c79ed3 (diff)
bonding: push Netlink bits into separate file
Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bonding/Makefile2
-rw-r--r--drivers/net/bonding/bond_main.c32
-rw-r--r--drivers/net/bonding/bond_netlink.c54
-rw-r--r--drivers/net/bonding/bonding.h7
4 files changed, 67 insertions, 28 deletions
diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile
index 4c21bf6b8b2f..09e8b2c83afe 100644
--- a/drivers/net/bonding/Makefile
+++ b/drivers/net/bonding/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-$(CONFIG_BONDING) += bonding.o 5obj-$(CONFIG_BONDING) += bonding.o
6 6
7bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o bond_debugfs.o 7bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o bond_debugfs.o bond_netlink.o
8 8
9proc-$(CONFIG_PROC_FS) += bond_procfs.o 9proc-$(CONFIG_PROC_FS) += bond_procfs.o
10bonding-objs += $(proc-y) 10bonding-objs += $(proc-y)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index dfb4f6dd5de0..a113e4212486 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3951,7 +3951,7 @@ static void bond_destructor(struct net_device *bond_dev)
3951 free_netdev(bond_dev); 3951 free_netdev(bond_dev);
3952} 3952}
3953 3953
3954static void bond_setup(struct net_device *bond_dev) 3954void bond_setup(struct net_device *bond_dev)
3955{ 3955{
3956 struct bonding *bond = netdev_priv(bond_dev); 3956 struct bonding *bond = netdev_priv(bond_dev);
3957 3957
@@ -4451,32 +4451,11 @@ static int bond_init(struct net_device *bond_dev)
4451 return 0; 4451 return 0;
4452} 4452}
4453 4453
4454static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) 4454unsigned int bond_get_num_tx_queues(void)
4455{
4456 if (tb[IFLA_ADDRESS]) {
4457 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
4458 return -EINVAL;
4459 if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
4460 return -EADDRNOTAVAIL;
4461 }
4462 return 0;
4463}
4464
4465static unsigned int bond_get_num_tx_queues(void)
4466{ 4455{
4467 return tx_queues; 4456 return tx_queues;
4468} 4457}
4469 4458
4470static struct rtnl_link_ops bond_link_ops __read_mostly = {
4471 .kind = "bond",
4472 .priv_size = sizeof(struct bonding),
4473 .setup = bond_setup,
4474 .validate = bond_validate,
4475 .get_num_tx_queues = bond_get_num_tx_queues,
4476 .get_num_rx_queues = bond_get_num_tx_queues, /* Use the same number
4477 as for TX queues */
4478};
4479
4480/* Create a new bond based on the specified name and bonding parameters. 4459/* Create a new bond based on the specified name and bonding parameters.
4481 * If name is NULL, obtain a suitable "bond%d" name for us. 4460 * If name is NULL, obtain a suitable "bond%d" name for us.
4482 * Caller must NOT hold rtnl_lock; we need to release it here before we 4461 * Caller must NOT hold rtnl_lock; we need to release it here before we
@@ -4563,7 +4542,7 @@ static int __init bonding_init(void)
4563 if (res) 4542 if (res)
4564 goto out; 4543 goto out;
4565 4544
4566 res = rtnl_link_register(&bond_link_ops); 4545 res = bond_netlink_init();
4567 if (res) 4546 if (res)
4568 goto err_link; 4547 goto err_link;
4569 4548
@@ -4579,7 +4558,7 @@ static int __init bonding_init(void)
4579out: 4558out:
4580 return res; 4559 return res;
4581err: 4560err:
4582 rtnl_link_unregister(&bond_link_ops); 4561 bond_netlink_fini();
4583err_link: 4562err_link:
4584 unregister_pernet_subsys(&bond_net_ops); 4563 unregister_pernet_subsys(&bond_net_ops);
4585 goto out; 4564 goto out;
@@ -4592,7 +4571,7 @@ static void __exit bonding_exit(void)
4592 4571
4593 bond_destroy_debugfs(); 4572 bond_destroy_debugfs();
4594 4573
4595 rtnl_link_unregister(&bond_link_ops); 4574 bond_netlink_fini();
4596 unregister_pernet_subsys(&bond_net_ops); 4575 unregister_pernet_subsys(&bond_net_ops);
4597 4576
4598#ifdef CONFIG_NET_POLL_CONTROLLER 4577#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -4609,4 +4588,3 @@ MODULE_LICENSE("GPL");
4609MODULE_VERSION(DRV_VERSION); 4588MODULE_VERSION(DRV_VERSION);
4610MODULE_DESCRIPTION(DRV_DESCRIPTION ", v" DRV_VERSION); 4589MODULE_DESCRIPTION(DRV_DESCRIPTION ", v" DRV_VERSION);
4611MODULE_AUTHOR("Thomas Davis, tadavis@lbl.gov and many others"); 4590MODULE_AUTHOR("Thomas Davis, tadavis@lbl.gov and many others");
4612MODULE_ALIAS_RTNL_LINK("bond");
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
new file mode 100644
index 000000000000..3e5c5f80c320
--- /dev/null
+++ b/drivers/net/bonding/bond_netlink.c
@@ -0,0 +1,54 @@
1/*
2 * drivers/net/bond/bond_netlink.c - Netlink interface for bonding
3 * Copyright (c) 2013 Jiri Pirko <jiri@resnulli.us>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12
13#include <linux/module.h>
14#include <linux/errno.h>
15#include <linux/netdevice.h>
16#include <linux/etherdevice.h>
17#include <linux/if_link.h>
18#include <linux/if_ether.h>
19#include <net/netlink.h>
20#include <net/rtnetlink.h>
21#include "bonding.h"
22
23static int bond_validate(struct nlattr *tb[], struct nlattr *data[])
24{
25 if (tb[IFLA_ADDRESS]) {
26 if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
27 return -EINVAL;
28 if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
29 return -EADDRNOTAVAIL;
30 }
31 return 0;
32}
33
34struct rtnl_link_ops bond_link_ops __read_mostly = {
35 .kind = "bond",
36 .priv_size = sizeof(struct bonding),
37 .setup = bond_setup,
38 .validate = bond_validate,
39 .get_num_tx_queues = bond_get_num_tx_queues,
40 .get_num_rx_queues = bond_get_num_tx_queues, /* Use the same number
41 as for TX queues */
42};
43
44int __init bond_netlink_init(void)
45{
46 return rtnl_link_register(&bond_link_ops);
47}
48
49void __exit bond_netlink_fini(void)
50{
51 rtnl_link_unregister(&bond_link_ops);
52}
53
54MODULE_ALIAS_RTNL_LINK("bond");
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index bb5c731e2560..a2a353bf9ea6 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -418,6 +418,10 @@ void bond_debug_register(struct bonding *bond);
418void bond_debug_unregister(struct bonding *bond); 418void bond_debug_unregister(struct bonding *bond);
419void bond_debug_reregister(struct bonding *bond); 419void bond_debug_reregister(struct bonding *bond);
420const char *bond_mode_name(int mode); 420const char *bond_mode_name(int mode);
421void bond_setup(struct net_device *bond_dev);
422unsigned int bond_get_num_tx_queues(void);
423int bond_netlink_init(void);
424void bond_netlink_fini(void);
421 425
422struct bond_net { 426struct bond_net {
423 struct net * net; /* Associated network namespace */ 427 struct net * net; /* Associated network namespace */
@@ -505,4 +509,7 @@ extern const struct bond_parm_tbl fail_over_mac_tbl[];
505extern const struct bond_parm_tbl pri_reselect_tbl[]; 509extern const struct bond_parm_tbl pri_reselect_tbl[];
506extern struct bond_parm_tbl ad_select_tbl[]; 510extern struct bond_parm_tbl ad_select_tbl[];
507 511
512/* exported from bond_netlink.c */
513extern struct rtnl_link_ops bond_link_ops;
514
508#endif /* _LINUX_BONDING_H */ 515#endif /* _LINUX_BONDING_H */