diff options
author | Jiri Pirko <jiri@resnulli.us> | 2013-10-18 17:43:33 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-19 18:58:45 -0400 |
commit | 0a2a78c4a95240e658272bd7cd7422a529e4eb4a (patch) | |
tree | 6b03014f30e7f45ffd222753eae1afce8a63b4aa /drivers/net/bonding/bond_netlink.c | |
parent | b1eda2ac3fa6bf23b27c7c70eda6885124c79ed3 (diff) | |
download | lwn-0a2a78c4a95240e658272bd7cd7422a529e4eb4a.tar.gz lwn-0a2a78c4a95240e658272bd7cd7422a529e4eb4a.zip |
bonding: push Netlink bits into separate file
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
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 @@ +/* + * drivers/net/bond/bond_netlink.c - Netlink interface for bonding + * Copyright (c) 2013 Jiri Pirko <jiri@resnulli.us> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/if_link.h> +#include <linux/if_ether.h> +#include <net/netlink.h> +#include <net/rtnetlink.h> +#include "bonding.h" + +static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) +{ + if (tb[IFLA_ADDRESS]) { + if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) + return -EINVAL; + if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) + return -EADDRNOTAVAIL; + } + return 0; +} + +struct rtnl_link_ops bond_link_ops __read_mostly = { + .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, /* Use the same number + as for TX queues */ +}; + +int __init bond_netlink_init(void) +{ + return rtnl_link_register(&bond_link_ops); +} + +void __exit bond_netlink_fini(void) +{ + rtnl_link_unregister(&bond_link_ops); +} + +MODULE_ALIAS_RTNL_LINK("bond"); |