Jiri Pirko | 0a2a78c | 2013-10-18 17:43:33 +0200 | [diff] [blame] | 1 | /* |
| 2 | * drivers/net/bond/bond_netlink.c - Netlink interface for bonding |
| 3 | * Copyright (c) 2013 Jiri Pirko <jiri@resnulli.us> |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 4 | * Copyright (c) 2013 Scott Feldman <sfeldma@cumulusnetworks.com> |
Jiri Pirko | 0a2a78c | 2013-10-18 17:43:33 +0200 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/errno.h> |
| 16 | #include <linux/netdevice.h> |
| 17 | #include <linux/etherdevice.h> |
| 18 | #include <linux/if_link.h> |
| 19 | #include <linux/if_ether.h> |
| 20 | #include <net/netlink.h> |
| 21 | #include <net/rtnetlink.h> |
| 22 | #include "bonding.h" |
| 23 | |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 24 | static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { |
| 25 | [IFLA_BOND_MODE] = { .type = NLA_U8 }, |
Jiri Pirko | ec76aa4 | 2013-10-18 17:43:39 +0200 | [diff] [blame] | 26 | [IFLA_BOND_ACTIVE_SLAVE] = { .type = NLA_U32 }, |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 27 | [IFLA_BOND_MIIMON] = { .type = NLA_U32 }, |
sfeldma@cumulusnetworks.com | 25852e2 | 2013-12-12 14:10:02 -0800 | [diff] [blame] | 28 | [IFLA_BOND_UPDELAY] = { .type = NLA_U32 }, |
sfeldma@cumulusnetworks.com | c7461f9 | 2013-12-12 14:10:09 -0800 | [diff] [blame] | 29 | [IFLA_BOND_DOWNDELAY] = { .type = NLA_U32 }, |
sfeldma@cumulusnetworks.com | 9f53e14 | 2013-12-12 14:10:16 -0800 | [diff] [blame] | 30 | [IFLA_BOND_USE_CARRIER] = { .type = NLA_U8 }, |
sfeldma@cumulusnetworks.com | 06151db | 2013-12-12 14:10:24 -0800 | [diff] [blame] | 31 | [IFLA_BOND_ARP_INTERVAL] = { .type = NLA_U32 }, |
sfeldma@cumulusnetworks.com | 7f28fa1 | 2013-12-12 14:10:31 -0800 | [diff] [blame] | 32 | [IFLA_BOND_ARP_IP_TARGET] = { .type = NLA_NESTED }, |
sfeldma@cumulusnetworks.com | 29c4948 | 2013-12-12 14:10:38 -0800 | [diff] [blame] | 33 | [IFLA_BOND_ARP_VALIDATE] = { .type = NLA_U32 }, |
sfeldma@cumulusnetworks.com | d5c8425 | 2013-12-12 14:10:45 -0800 | [diff] [blame] | 34 | [IFLA_BOND_ARP_ALL_TARGETS] = { .type = NLA_U32 }, |
sfeldma@cumulusnetworks.com | 0a98a0d | 2013-12-15 16:41:51 -0800 | [diff] [blame] | 35 | [IFLA_BOND_PRIMARY] = { .type = NLA_U32 }, |
sfeldma@cumulusnetworks.com | 8a41ae4 | 2013-12-15 16:41:58 -0800 | [diff] [blame] | 36 | [IFLA_BOND_PRIMARY_RESELECT] = { .type = NLA_U8 }, |
sfeldma@cumulusnetworks.com | 8990197 | 2013-12-15 16:42:05 -0800 | [diff] [blame] | 37 | [IFLA_BOND_FAIL_OVER_MAC] = { .type = NLA_U8 }, |
sfeldma@cumulusnetworks.com | f70161c | 2013-12-15 16:42:12 -0800 | [diff] [blame^] | 38 | [IFLA_BOND_XMIT_HASH_POLICY] = { .type = NLA_U8 }, |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 39 | }; |
| 40 | |
Jiri Pirko | 0a2a78c | 2013-10-18 17:43:33 +0200 | [diff] [blame] | 41 | static int bond_validate(struct nlattr *tb[], struct nlattr *data[]) |
| 42 | { |
| 43 | if (tb[IFLA_ADDRESS]) { |
| 44 | if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) |
| 45 | return -EINVAL; |
| 46 | if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) |
| 47 | return -EADDRNOTAVAIL; |
| 48 | } |
| 49 | return 0; |
| 50 | } |
| 51 | |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 52 | static int bond_changelink(struct net_device *bond_dev, |
| 53 | struct nlattr *tb[], struct nlattr *data[]) |
| 54 | { |
| 55 | struct bonding *bond = netdev_priv(bond_dev); |
sfeldma@cumulusnetworks.com | 06151db | 2013-12-12 14:10:24 -0800 | [diff] [blame] | 56 | int miimon = 0; |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 57 | int err; |
| 58 | |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 59 | if (!data) |
| 60 | return 0; |
| 61 | |
| 62 | if (data[IFLA_BOND_MODE]) { |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 63 | int mode = nla_get_u8(data[IFLA_BOND_MODE]); |
| 64 | |
| 65 | err = bond_option_mode_set(bond, mode); |
| 66 | if (err) |
| 67 | return err; |
| 68 | } |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 69 | if (data[IFLA_BOND_ACTIVE_SLAVE]) { |
Jiri Pirko | ec76aa4 | 2013-10-18 17:43:39 +0200 | [diff] [blame] | 70 | int ifindex = nla_get_u32(data[IFLA_BOND_ACTIVE_SLAVE]); |
| 71 | struct net_device *slave_dev; |
| 72 | |
| 73 | if (ifindex == 0) { |
| 74 | slave_dev = NULL; |
| 75 | } else { |
| 76 | slave_dev = __dev_get_by_index(dev_net(bond_dev), |
| 77 | ifindex); |
| 78 | if (!slave_dev) |
| 79 | return -ENODEV; |
| 80 | } |
| 81 | err = bond_option_active_slave_set(bond, slave_dev); |
| 82 | if (err) |
| 83 | return err; |
| 84 | } |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 85 | if (data[IFLA_BOND_MIIMON]) { |
sfeldma@cumulusnetworks.com | 06151db | 2013-12-12 14:10:24 -0800 | [diff] [blame] | 86 | miimon = nla_get_u32(data[IFLA_BOND_MIIMON]); |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 87 | |
| 88 | err = bond_option_miimon_set(bond, miimon); |
| 89 | if (err) |
| 90 | return err; |
| 91 | } |
sfeldma@cumulusnetworks.com | 25852e2 | 2013-12-12 14:10:02 -0800 | [diff] [blame] | 92 | if (data[IFLA_BOND_UPDELAY]) { |
| 93 | int updelay = nla_get_u32(data[IFLA_BOND_UPDELAY]); |
| 94 | |
| 95 | err = bond_option_updelay_set(bond, updelay); |
| 96 | if (err) |
| 97 | return err; |
| 98 | } |
sfeldma@cumulusnetworks.com | c7461f9 | 2013-12-12 14:10:09 -0800 | [diff] [blame] | 99 | if (data[IFLA_BOND_DOWNDELAY]) { |
| 100 | int downdelay = nla_get_u32(data[IFLA_BOND_DOWNDELAY]); |
| 101 | |
| 102 | err = bond_option_downdelay_set(bond, downdelay); |
| 103 | if (err) |
| 104 | return err; |
| 105 | } |
sfeldma@cumulusnetworks.com | 9f53e14 | 2013-12-12 14:10:16 -0800 | [diff] [blame] | 106 | if (data[IFLA_BOND_USE_CARRIER]) { |
| 107 | int use_carrier = nla_get_u8(data[IFLA_BOND_USE_CARRIER]); |
| 108 | |
| 109 | err = bond_option_use_carrier_set(bond, use_carrier); |
| 110 | if (err) |
| 111 | return err; |
| 112 | } |
sfeldma@cumulusnetworks.com | 06151db | 2013-12-12 14:10:24 -0800 | [diff] [blame] | 113 | if (data[IFLA_BOND_ARP_INTERVAL]) { |
| 114 | int arp_interval = nla_get_u32(data[IFLA_BOND_ARP_INTERVAL]); |
| 115 | |
| 116 | if (arp_interval && miimon) { |
| 117 | pr_err("%s: ARP monitoring cannot be used with MII monitoring.\n", |
| 118 | bond->dev->name); |
| 119 | return -EINVAL; |
| 120 | } |
| 121 | |
| 122 | err = bond_option_arp_interval_set(bond, arp_interval); |
| 123 | if (err) |
| 124 | return err; |
| 125 | } |
sfeldma@cumulusnetworks.com | 7f28fa1 | 2013-12-12 14:10:31 -0800 | [diff] [blame] | 126 | if (data[IFLA_BOND_ARP_IP_TARGET]) { |
| 127 | __be32 targets[BOND_MAX_ARP_TARGETS] = { 0, }; |
| 128 | struct nlattr *attr; |
| 129 | int i = 0, rem; |
| 130 | |
| 131 | nla_for_each_nested(attr, data[IFLA_BOND_ARP_IP_TARGET], rem) { |
Jiri Pirko | e7ef941 | 2013-12-14 12:32:10 +0100 | [diff] [blame] | 132 | __be32 target = nla_get_be32(attr); |
sfeldma@cumulusnetworks.com | 7f28fa1 | 2013-12-12 14:10:31 -0800 | [diff] [blame] | 133 | targets[i++] = target; |
| 134 | } |
| 135 | |
| 136 | err = bond_option_arp_ip_targets_set(bond, targets, i); |
| 137 | if (err) |
| 138 | return err; |
| 139 | } |
sfeldma@cumulusnetworks.com | 29c4948 | 2013-12-12 14:10:38 -0800 | [diff] [blame] | 140 | if (data[IFLA_BOND_ARP_VALIDATE]) { |
| 141 | int arp_validate = nla_get_u32(data[IFLA_BOND_ARP_VALIDATE]); |
| 142 | |
| 143 | if (arp_validate && miimon) { |
| 144 | pr_err("%s: ARP validating cannot be used with MII monitoring.\n", |
| 145 | bond->dev->name); |
| 146 | return -EINVAL; |
| 147 | } |
| 148 | |
| 149 | err = bond_option_arp_validate_set(bond, arp_validate); |
| 150 | if (err) |
| 151 | return err; |
| 152 | } |
sfeldma@cumulusnetworks.com | d5c8425 | 2013-12-12 14:10:45 -0800 | [diff] [blame] | 153 | if (data[IFLA_BOND_ARP_ALL_TARGETS]) { |
| 154 | int arp_all_targets = |
| 155 | nla_get_u32(data[IFLA_BOND_ARP_ALL_TARGETS]); |
| 156 | |
| 157 | err = bond_option_arp_all_targets_set(bond, arp_all_targets); |
| 158 | if (err) |
| 159 | return err; |
| 160 | } |
sfeldma@cumulusnetworks.com | 0a98a0d | 2013-12-15 16:41:51 -0800 | [diff] [blame] | 161 | if (data[IFLA_BOND_PRIMARY]) { |
| 162 | int ifindex = nla_get_u32(data[IFLA_BOND_PRIMARY]); |
| 163 | struct net_device *dev; |
| 164 | char *primary = ""; |
| 165 | |
| 166 | dev = __dev_get_by_index(dev_net(bond_dev), ifindex); |
| 167 | if (dev) |
| 168 | primary = dev->name; |
| 169 | |
| 170 | err = bond_option_primary_set(bond, primary); |
| 171 | if (err) |
| 172 | return err; |
| 173 | } |
sfeldma@cumulusnetworks.com | 8a41ae4 | 2013-12-15 16:41:58 -0800 | [diff] [blame] | 174 | if (data[IFLA_BOND_PRIMARY_RESELECT]) { |
| 175 | int primary_reselect = |
| 176 | nla_get_u8(data[IFLA_BOND_PRIMARY_RESELECT]); |
| 177 | |
| 178 | err = bond_option_primary_reselect_set(bond, primary_reselect); |
| 179 | if (err) |
| 180 | return err; |
| 181 | } |
sfeldma@cumulusnetworks.com | 8990197 | 2013-12-15 16:42:05 -0800 | [diff] [blame] | 182 | if (data[IFLA_BOND_FAIL_OVER_MAC]) { |
| 183 | int fail_over_mac = |
| 184 | nla_get_u8(data[IFLA_BOND_FAIL_OVER_MAC]); |
| 185 | |
| 186 | err = bond_option_fail_over_mac_set(bond, fail_over_mac); |
| 187 | if (err) |
| 188 | return err; |
| 189 | } |
sfeldma@cumulusnetworks.com | f70161c | 2013-12-15 16:42:12 -0800 | [diff] [blame^] | 190 | if (data[IFLA_BOND_XMIT_HASH_POLICY]) { |
| 191 | int xmit_hash_policy = |
| 192 | nla_get_u8(data[IFLA_BOND_XMIT_HASH_POLICY]); |
| 193 | |
| 194 | err = bond_option_xmit_hash_policy_set(bond, xmit_hash_policy); |
| 195 | if (err) |
| 196 | return err; |
| 197 | } |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 198 | return 0; |
| 199 | } |
| 200 | |
| 201 | static int bond_newlink(struct net *src_net, struct net_device *bond_dev, |
| 202 | struct nlattr *tb[], struct nlattr *data[]) |
| 203 | { |
| 204 | int err; |
| 205 | |
| 206 | err = bond_changelink(bond_dev, tb, data); |
| 207 | if (err < 0) |
| 208 | return err; |
| 209 | |
| 210 | return register_netdevice(bond_dev); |
| 211 | } |
| 212 | |
| 213 | static size_t bond_get_size(const struct net_device *bond_dev) |
| 214 | { |
Dan Carpenter | e139862 | 2013-11-01 13:18:44 +0300 | [diff] [blame] | 215 | return nla_total_size(sizeof(u8)) + /* IFLA_BOND_MODE */ |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 216 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_ACTIVE_SLAVE */ |
| 217 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_MIIMON */ |
sfeldma@cumulusnetworks.com | 25852e2 | 2013-12-12 14:10:02 -0800 | [diff] [blame] | 218 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_UPDELAY */ |
sfeldma@cumulusnetworks.com | c7461f9 | 2013-12-12 14:10:09 -0800 | [diff] [blame] | 219 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_DOWNDELAY */ |
sfeldma@cumulusnetworks.com | 9f53e14 | 2013-12-12 14:10:16 -0800 | [diff] [blame] | 220 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_USE_CARRIER */ |
sfeldma@cumulusnetworks.com | 06151db | 2013-12-12 14:10:24 -0800 | [diff] [blame] | 221 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_INTERVAL */ |
sfeldma@cumulusnetworks.com | 7f28fa1 | 2013-12-12 14:10:31 -0800 | [diff] [blame] | 222 | /* IFLA_BOND_ARP_IP_TARGET */ |
| 223 | nla_total_size(sizeof(u32)) * BOND_MAX_ARP_TARGETS + |
sfeldma@cumulusnetworks.com | 29c4948 | 2013-12-12 14:10:38 -0800 | [diff] [blame] | 224 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_VALIDATE */ |
sfeldma@cumulusnetworks.com | d5c8425 | 2013-12-12 14:10:45 -0800 | [diff] [blame] | 225 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_ARP_ALL_TARGETS */ |
sfeldma@cumulusnetworks.com | 0a98a0d | 2013-12-15 16:41:51 -0800 | [diff] [blame] | 226 | nla_total_size(sizeof(u32)) + /* IFLA_BOND_PRIMARY */ |
sfeldma@cumulusnetworks.com | 8a41ae4 | 2013-12-15 16:41:58 -0800 | [diff] [blame] | 227 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_PRIMARY_RESELECT */ |
sfeldma@cumulusnetworks.com | 8990197 | 2013-12-15 16:42:05 -0800 | [diff] [blame] | 228 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_FAIL_OVER_MAC */ |
sfeldma@cumulusnetworks.com | f70161c | 2013-12-15 16:42:12 -0800 | [diff] [blame^] | 229 | nla_total_size(sizeof(u8)) + /* IFLA_BOND_XMIT_HASH_POLICY */ |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 230 | 0; |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | static int bond_fill_info(struct sk_buff *skb, |
| 234 | const struct net_device *bond_dev) |
| 235 | { |
| 236 | struct bonding *bond = netdev_priv(bond_dev); |
Jiri Pirko | ec76aa4 | 2013-10-18 17:43:39 +0200 | [diff] [blame] | 237 | struct net_device *slave_dev = bond_option_active_slave_get(bond); |
sfeldma@cumulusnetworks.com | 7f28fa1 | 2013-12-12 14:10:31 -0800 | [diff] [blame] | 238 | struct nlattr *targets; |
| 239 | int i, targets_added; |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 240 | |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 241 | if (nla_put_u8(skb, IFLA_BOND_MODE, bond->params.mode)) |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 242 | goto nla_put_failure; |
sfeldma@cumulusnetworks.com | eecdaa6 | 2013-12-12 14:09:55 -0800 | [diff] [blame] | 243 | |
| 244 | if (slave_dev && |
| 245 | nla_put_u32(skb, IFLA_BOND_ACTIVE_SLAVE, slave_dev->ifindex)) |
| 246 | goto nla_put_failure; |
| 247 | |
| 248 | if (nla_put_u32(skb, IFLA_BOND_MIIMON, bond->params.miimon)) |
| 249 | goto nla_put_failure; |
| 250 | |
sfeldma@cumulusnetworks.com | 25852e2 | 2013-12-12 14:10:02 -0800 | [diff] [blame] | 251 | if (nla_put_u32(skb, IFLA_BOND_UPDELAY, |
| 252 | bond->params.updelay * bond->params.miimon)) |
| 253 | goto nla_put_failure; |
| 254 | |
sfeldma@cumulusnetworks.com | c7461f9 | 2013-12-12 14:10:09 -0800 | [diff] [blame] | 255 | if (nla_put_u32(skb, IFLA_BOND_DOWNDELAY, |
| 256 | bond->params.downdelay * bond->params.miimon)) |
| 257 | goto nla_put_failure; |
| 258 | |
sfeldma@cumulusnetworks.com | 9f53e14 | 2013-12-12 14:10:16 -0800 | [diff] [blame] | 259 | if (nla_put_u8(skb, IFLA_BOND_USE_CARRIER, bond->params.use_carrier)) |
| 260 | goto nla_put_failure; |
| 261 | |
sfeldma@cumulusnetworks.com | 06151db | 2013-12-12 14:10:24 -0800 | [diff] [blame] | 262 | if (nla_put_u32(skb, IFLA_BOND_ARP_INTERVAL, bond->params.arp_interval)) |
| 263 | goto nla_put_failure; |
| 264 | |
sfeldma@cumulusnetworks.com | 7f28fa1 | 2013-12-12 14:10:31 -0800 | [diff] [blame] | 265 | targets = nla_nest_start(skb, IFLA_BOND_ARP_IP_TARGET); |
| 266 | if (!targets) |
| 267 | goto nla_put_failure; |
| 268 | |
| 269 | targets_added = 0; |
| 270 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { |
| 271 | if (bond->params.arp_targets[i]) { |
Jiri Pirko | e7ef941 | 2013-12-14 12:32:10 +0100 | [diff] [blame] | 272 | nla_put_be32(skb, i, bond->params.arp_targets[i]); |
sfeldma@cumulusnetworks.com | 7f28fa1 | 2013-12-12 14:10:31 -0800 | [diff] [blame] | 273 | targets_added = 1; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | if (targets_added) |
| 278 | nla_nest_end(skb, targets); |
| 279 | else |
| 280 | nla_nest_cancel(skb, targets); |
| 281 | |
sfeldma@cumulusnetworks.com | 29c4948 | 2013-12-12 14:10:38 -0800 | [diff] [blame] | 282 | if (nla_put_u32(skb, IFLA_BOND_ARP_VALIDATE, bond->params.arp_validate)) |
| 283 | goto nla_put_failure; |
| 284 | |
sfeldma@cumulusnetworks.com | d5c8425 | 2013-12-12 14:10:45 -0800 | [diff] [blame] | 285 | if (nla_put_u32(skb, IFLA_BOND_ARP_ALL_TARGETS, |
| 286 | bond->params.arp_all_targets)) |
| 287 | goto nla_put_failure; |
| 288 | |
sfeldma@cumulusnetworks.com | 0a98a0d | 2013-12-15 16:41:51 -0800 | [diff] [blame] | 289 | if (bond->primary_slave && |
| 290 | nla_put_u32(skb, IFLA_BOND_PRIMARY, |
| 291 | bond->primary_slave->dev->ifindex)) |
| 292 | goto nla_put_failure; |
| 293 | |
sfeldma@cumulusnetworks.com | 8a41ae4 | 2013-12-15 16:41:58 -0800 | [diff] [blame] | 294 | if (nla_put_u8(skb, IFLA_BOND_PRIMARY_RESELECT, |
| 295 | bond->params.primary_reselect)) |
| 296 | goto nla_put_failure; |
| 297 | |
sfeldma@cumulusnetworks.com | 8990197 | 2013-12-15 16:42:05 -0800 | [diff] [blame] | 298 | if (nla_put_u8(skb, IFLA_BOND_FAIL_OVER_MAC, |
| 299 | bond->params.fail_over_mac)) |
| 300 | goto nla_put_failure; |
| 301 | |
sfeldma@cumulusnetworks.com | f70161c | 2013-12-15 16:42:12 -0800 | [diff] [blame^] | 302 | if (nla_put_u8(skb, IFLA_BOND_XMIT_HASH_POLICY, |
| 303 | bond->params.xmit_policy)) |
| 304 | goto nla_put_failure; |
| 305 | |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 306 | return 0; |
| 307 | |
| 308 | nla_put_failure: |
| 309 | return -EMSGSIZE; |
| 310 | } |
| 311 | |
Jiri Pirko | 0a2a78c | 2013-10-18 17:43:33 +0200 | [diff] [blame] | 312 | struct rtnl_link_ops bond_link_ops __read_mostly = { |
| 313 | .kind = "bond", |
| 314 | .priv_size = sizeof(struct bonding), |
| 315 | .setup = bond_setup, |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 316 | .maxtype = IFLA_BOND_MAX, |
| 317 | .policy = bond_policy, |
Jiri Pirko | 0a2a78c | 2013-10-18 17:43:33 +0200 | [diff] [blame] | 318 | .validate = bond_validate, |
Jiri Pirko | 90af231 | 2013-10-18 17:43:38 +0200 | [diff] [blame] | 319 | .newlink = bond_newlink, |
| 320 | .changelink = bond_changelink, |
| 321 | .get_size = bond_get_size, |
| 322 | .fill_info = bond_fill_info, |
Jiri Pirko | 0a2a78c | 2013-10-18 17:43:33 +0200 | [diff] [blame] | 323 | .get_num_tx_queues = bond_get_num_tx_queues, |
| 324 | .get_num_rx_queues = bond_get_num_tx_queues, /* Use the same number |
| 325 | as for TX queues */ |
| 326 | }; |
| 327 | |
| 328 | int __init bond_netlink_init(void) |
| 329 | { |
| 330 | return rtnl_link_register(&bond_link_ops); |
| 331 | } |
| 332 | |
David S. Miller | a729e83 | 2013-10-19 19:09:18 -0400 | [diff] [blame] | 333 | void bond_netlink_fini(void) |
Jiri Pirko | 0a2a78c | 2013-10-18 17:43:33 +0200 | [diff] [blame] | 334 | { |
| 335 | rtnl_link_unregister(&bond_link_ops); |
| 336 | } |
| 337 | |
| 338 | MODULE_ALIAS_RTNL_LINK("bond"); |