forked from Minki/linux
55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
|
/*
|
||
|
* 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");
|