diff options
Diffstat (limited to 'drivers/net/bonding/bond_netlink.c')
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 54 |
1 files changed, 54 insertions, 0 deletions
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 | |||
23 | static 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 | |||
34 | struct 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 | |||
44 | int __init bond_netlink_init(void) | ||
45 | { | ||
46 | return rtnl_link_register(&bond_link_ops); | ||
47 | } | ||
48 | |||
49 | void __exit bond_netlink_fini(void) | ||
50 | { | ||
51 | rtnl_link_unregister(&bond_link_ops); | ||
52 | } | ||
53 | |||
54 | MODULE_ALIAS_RTNL_LINK("bond"); | ||