Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Bridge netlink control interface |
| 3 | * |
| 4 | * Authors: |
| 5 | * Stephen Hemminger <shemminger@osdl.org> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version |
| 10 | * 2 of the License, or (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 14 | #include <linux/slab.h> |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 15 | #include <linux/etherdevice.h> |
Thomas Graf | 32fe21c | 2007-03-22 11:59:03 -0700 | [diff] [blame] | 16 | #include <net/rtnetlink.h> |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 17 | #include <net/net_namespace.h> |
Denis V. Lunev | b854272 | 2007-12-01 00:21:31 +1100 | [diff] [blame] | 18 | #include <net/sock.h> |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 19 | |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 20 | #include "br_private.h" |
Vitalii Demianets | b03b6dd | 2011-11-25 00:16:37 +0000 | [diff] [blame] | 21 | #include "br_private_stp.h" |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 22 | |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 23 | static inline size_t br_port_info_size(void) |
| 24 | { |
| 25 | return nla_total_size(1) /* IFLA_BRPORT_STATE */ |
| 26 | + nla_total_size(2) /* IFLA_BRPORT_PRIORITY */ |
| 27 | + nla_total_size(4) /* IFLA_BRPORT_COST */ |
| 28 | + nla_total_size(1) /* IFLA_BRPORT_MODE */ |
stephen hemminger | a2e01a6 | 2012-11-13 07:53:07 +0000 | [diff] [blame] | 29 | + nla_total_size(1) /* IFLA_BRPORT_GUARD */ |
stephen hemminger | 1007dd1 | 2012-11-13 07:53:08 +0000 | [diff] [blame] | 30 | + nla_total_size(1) /* IFLA_BRPORT_PROTECT */ |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 31 | + 0; |
| 32 | } |
| 33 | |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 34 | static inline size_t br_nlmsg_size(void) |
| 35 | { |
| 36 | return NLMSG_ALIGN(sizeof(struct ifinfomsg)) |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 37 | + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */ |
| 38 | + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */ |
| 39 | + nla_total_size(4) /* IFLA_MASTER */ |
| 40 | + nla_total_size(4) /* IFLA_MTU */ |
| 41 | + nla_total_size(4) /* IFLA_LINK */ |
| 42 | + nla_total_size(1) /* IFLA_OPERSTATE */ |
| 43 | + nla_total_size(br_port_info_size()); /* IFLA_PROTINFO */ |
| 44 | } |
| 45 | |
| 46 | static int br_port_fill_attrs(struct sk_buff *skb, |
| 47 | const struct net_bridge_port *p) |
| 48 | { |
| 49 | u8 mode = !!(p->flags & BR_HAIRPIN_MODE); |
| 50 | |
| 51 | if (nla_put_u8(skb, IFLA_BRPORT_STATE, p->state) || |
| 52 | nla_put_u16(skb, IFLA_BRPORT_PRIORITY, p->priority) || |
| 53 | nla_put_u32(skb, IFLA_BRPORT_COST, p->path_cost) || |
stephen hemminger | a2e01a6 | 2012-11-13 07:53:07 +0000 | [diff] [blame] | 54 | nla_put_u8(skb, IFLA_BRPORT_MODE, mode) || |
stephen hemminger | 1007dd1 | 2012-11-13 07:53:08 +0000 | [diff] [blame] | 55 | nla_put_u8(skb, IFLA_BRPORT_GUARD, !!(p->flags & BR_BPDU_GUARD)) || |
David S. Miller | c2d3bab | 2012-12-05 16:24:45 -0500 | [diff] [blame] | 56 | nla_put_u8(skb, IFLA_BRPORT_PROTECT, !!(p->flags & BR_ROOT_BLOCK)) || |
| 57 | nla_put_u8(skb, IFLA_BRPORT_FAST_LEAVE, !!(p->flags & BR_MULTICAST_FAST_LEAVE))) |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 58 | return -EMSGSIZE; |
| 59 | |
| 60 | return 0; |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 61 | } |
| 62 | |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 63 | /* |
| 64 | * Create one netlink message for one interface |
| 65 | * Contains port and master info as well as carrier and bridge state. |
| 66 | */ |
| 67 | static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *port, |
| 68 | u32 pid, u32 seq, int event, unsigned int flags) |
| 69 | { |
| 70 | const struct net_bridge *br = port->br; |
| 71 | const struct net_device *dev = port->dev; |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 72 | struct ifinfomsg *hdr; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 73 | struct nlmsghdr *nlh; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 74 | u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 75 | |
stephen hemminger | 28a16c9 | 2010-05-10 09:31:09 +0000 | [diff] [blame] | 76 | br_debug(br, "br_fill_info event %d port %s master %s\n", |
| 77 | event, dev->name, br->dev->name); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 78 | |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 79 | nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags); |
| 80 | if (nlh == NULL) |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 81 | return -EMSGSIZE; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 82 | |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 83 | hdr = nlmsg_data(nlh); |
| 84 | hdr->ifi_family = AF_BRIDGE; |
| 85 | hdr->__ifi_pad = 0; |
| 86 | hdr->ifi_type = dev->type; |
| 87 | hdr->ifi_index = dev->ifindex; |
| 88 | hdr->ifi_flags = dev_get_flags(dev); |
| 89 | hdr->ifi_change = 0; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 90 | |
David S. Miller | 2eb812e | 2012-04-01 20:49:54 -0400 | [diff] [blame] | 91 | if (nla_put_string(skb, IFLA_IFNAME, dev->name) || |
| 92 | nla_put_u32(skb, IFLA_MASTER, br->dev->ifindex) || |
| 93 | nla_put_u32(skb, IFLA_MTU, dev->mtu) || |
| 94 | nla_put_u8(skb, IFLA_OPERSTATE, operstate) || |
| 95 | (dev->addr_len && |
| 96 | nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || |
| 97 | (dev->ifindex != dev->iflink && |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 98 | nla_put_u32(skb, IFLA_LINK, dev->iflink))) |
David S. Miller | 2eb812e | 2012-04-01 20:49:54 -0400 | [diff] [blame] | 99 | goto nla_put_failure; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 100 | |
| 101 | if (event == RTM_NEWLINK) { |
| 102 | struct nlattr *nest |
| 103 | = nla_nest_start(skb, IFLA_PROTINFO | NLA_F_NESTED); |
| 104 | |
| 105 | if (nest == NULL || br_port_fill_attrs(skb, port) < 0) |
| 106 | goto nla_put_failure; |
| 107 | nla_nest_end(skb, nest); |
| 108 | } |
| 109 | |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 110 | return nlmsg_end(skb, nlh); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 111 | |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 112 | nla_put_failure: |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 113 | nlmsg_cancel(skb, nlh); |
| 114 | return -EMSGSIZE; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | /* |
| 118 | * Notify listeners of a change in port information |
| 119 | */ |
| 120 | void br_ifinfo_notify(int event, struct net_bridge_port *port) |
| 121 | { |
Alexey Dobriyan | 4aa678b | 2008-09-08 16:19:58 -0700 | [diff] [blame] | 122 | struct net *net = dev_net(port->dev); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 123 | struct sk_buff *skb; |
Thomas Graf | 280a306 | 2006-08-15 00:36:28 -0700 | [diff] [blame] | 124 | int err = -ENOBUFS; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 125 | |
stephen hemminger | 28a16c9 | 2010-05-10 09:31:09 +0000 | [diff] [blame] | 126 | br_debug(port->br, "port %u(%s) event %d\n", |
Eric Dumazet | 95c9617 | 2012-04-15 05:58:06 +0000 | [diff] [blame] | 127 | (unsigned int)port->port_no, port->dev->name, event); |
stephen hemminger | 28a16c9 | 2010-05-10 09:31:09 +0000 | [diff] [blame] | 128 | |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 129 | skb = nlmsg_new(br_nlmsg_size(), GFP_ATOMIC); |
Thomas Graf | 280a306 | 2006-08-15 00:36:28 -0700 | [diff] [blame] | 130 | if (skb == NULL) |
| 131 | goto errout; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 132 | |
Thomas Graf | 280a306 | 2006-08-15 00:36:28 -0700 | [diff] [blame] | 133 | err = br_fill_ifinfo(skb, port, 0, 0, event, 0); |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 134 | if (err < 0) { |
| 135 | /* -EMSGSIZE implies BUG in br_nlmsg_size() */ |
| 136 | WARN_ON(err == -EMSGSIZE); |
| 137 | kfree_skb(skb); |
| 138 | goto errout; |
| 139 | } |
Pablo Neira Ayuso | 1ce85fe | 2009-02-24 23:18:28 -0800 | [diff] [blame] | 140 | rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); |
| 141 | return; |
Thomas Graf | 280a306 | 2006-08-15 00:36:28 -0700 | [diff] [blame] | 142 | errout: |
Stephen Hemminger | bea1b42 | 2006-08-03 16:24:02 -0700 | [diff] [blame] | 143 | if (err < 0) |
Alexey Dobriyan | 4aa678b | 2008-09-08 16:19:58 -0700 | [diff] [blame] | 144 | rtnl_set_sk_err(net, RTNLGRP_LINK, err); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /* |
| 148 | * Dump information about all ports, in response to GETLINK |
| 149 | */ |
John Fastabend | e5a55a8 | 2012-10-24 08:12:57 +0000 | [diff] [blame] | 150 | int br_getlink(struct sk_buff *skb, u32 pid, u32 seq, |
| 151 | struct net_device *dev) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 152 | { |
John Fastabend | e5a55a8 | 2012-10-24 08:12:57 +0000 | [diff] [blame] | 153 | int err = 0; |
| 154 | struct net_bridge_port *port = br_port_get_rcu(dev); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 155 | |
John Fastabend | e5a55a8 | 2012-10-24 08:12:57 +0000 | [diff] [blame] | 156 | /* not a bridge port */ |
| 157 | if (!port) |
| 158 | goto out; |
stephen hemminger | b5ed54e | 2010-11-15 06:38:13 +0000 | [diff] [blame] | 159 | |
John Fastabend | e5a55a8 | 2012-10-24 08:12:57 +0000 | [diff] [blame] | 160 | err = br_fill_ifinfo(skb, port, pid, seq, RTM_NEWLINK, NLM_F_MULTI); |
| 161 | out: |
| 162 | return err; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 163 | } |
| 164 | |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 165 | static const struct nla_policy ifla_brport_policy[IFLA_BRPORT_MAX + 1] = { |
| 166 | [IFLA_BRPORT_STATE] = { .type = NLA_U8 }, |
| 167 | [IFLA_BRPORT_COST] = { .type = NLA_U32 }, |
| 168 | [IFLA_BRPORT_PRIORITY] = { .type = NLA_U16 }, |
| 169 | [IFLA_BRPORT_MODE] = { .type = NLA_U8 }, |
stephen hemminger | a2e01a6 | 2012-11-13 07:53:07 +0000 | [diff] [blame] | 170 | [IFLA_BRPORT_GUARD] = { .type = NLA_U8 }, |
stephen hemminger | 1007dd1 | 2012-11-13 07:53:08 +0000 | [diff] [blame] | 171 | [IFLA_BRPORT_PROTECT] = { .type = NLA_U8 }, |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | /* Change the state of the port and notify spanning tree */ |
| 175 | static int br_set_port_state(struct net_bridge_port *p, u8 state) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 176 | { |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 177 | if (state > BR_STATE_BLOCKING) |
stephen hemminger | b5ed54e | 2010-11-15 06:38:13 +0000 | [diff] [blame] | 178 | return -EINVAL; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 179 | |
| 180 | /* if kernel STP is running, don't allow changes */ |
Stephen Hemminger | 9cde070 | 2007-03-21 14:22:44 -0700 | [diff] [blame] | 181 | if (p->br->stp_enabled == BR_KERNEL_STP) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 182 | return -EBUSY; |
| 183 | |
stephen hemminger | 576eb62 | 2012-12-28 18:15:22 +0000 | [diff] [blame^] | 184 | /* if device is not up, change is not allowed |
| 185 | * if link is not present, only allowable state is disabled |
| 186 | */ |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 187 | if (!netif_running(p->dev) || |
stephen hemminger | 576eb62 | 2012-12-28 18:15:22 +0000 | [diff] [blame^] | 188 | (!netif_oper_up(p->dev) && state != BR_STATE_DISABLED)) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 189 | return -ENETDOWN; |
| 190 | |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 191 | p->state = state; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 192 | br_log_state(p); |
Vitalii Demianets | b03b6dd | 2011-11-25 00:16:37 +0000 | [diff] [blame] | 193 | br_port_state_selection(p->br); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 194 | return 0; |
| 195 | } |
| 196 | |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 197 | /* Set/clear or port flags based on attribute */ |
| 198 | static void br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[], |
| 199 | int attrtype, unsigned long mask) |
| 200 | { |
| 201 | if (tb[attrtype]) { |
| 202 | u8 flag = nla_get_u8(tb[attrtype]); |
| 203 | if (flag) |
| 204 | p->flags |= mask; |
| 205 | else |
| 206 | p->flags &= ~mask; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | /* Process bridge protocol info on port */ |
| 211 | static int br_setport(struct net_bridge_port *p, struct nlattr *tb[]) |
| 212 | { |
| 213 | int err; |
| 214 | |
| 215 | br_set_port_flag(p, tb, IFLA_BRPORT_MODE, BR_HAIRPIN_MODE); |
stephen hemminger | a2e01a6 | 2012-11-13 07:53:07 +0000 | [diff] [blame] | 216 | br_set_port_flag(p, tb, IFLA_BRPORT_GUARD, BR_BPDU_GUARD); |
David S. Miller | c2d3bab | 2012-12-05 16:24:45 -0500 | [diff] [blame] | 217 | br_set_port_flag(p, tb, IFLA_BRPORT_FAST_LEAVE, BR_MULTICAST_FAST_LEAVE); |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 218 | |
| 219 | if (tb[IFLA_BRPORT_COST]) { |
| 220 | err = br_stp_set_path_cost(p, nla_get_u32(tb[IFLA_BRPORT_COST])); |
| 221 | if (err) |
| 222 | return err; |
| 223 | } |
| 224 | |
| 225 | if (tb[IFLA_BRPORT_PRIORITY]) { |
| 226 | err = br_stp_set_port_priority(p, nla_get_u16(tb[IFLA_BRPORT_PRIORITY])); |
| 227 | if (err) |
| 228 | return err; |
| 229 | } |
| 230 | |
| 231 | if (tb[IFLA_BRPORT_STATE]) { |
| 232 | err = br_set_port_state(p, nla_get_u8(tb[IFLA_BRPORT_STATE])); |
| 233 | if (err) |
| 234 | return err; |
| 235 | } |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | /* Change state and parameters on port. */ |
| 240 | int br_setlink(struct net_device *dev, struct nlmsghdr *nlh) |
| 241 | { |
| 242 | struct ifinfomsg *ifm; |
| 243 | struct nlattr *protinfo; |
| 244 | struct net_bridge_port *p; |
Dan Carpenter | 2062cc2 | 2012-12-07 01:10:46 +0000 | [diff] [blame] | 245 | struct nlattr *tb[IFLA_BRPORT_MAX + 1]; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 246 | int err; |
| 247 | |
| 248 | ifm = nlmsg_data(nlh); |
| 249 | |
| 250 | protinfo = nlmsg_find_attr(nlh, sizeof(*ifm), IFLA_PROTINFO); |
| 251 | if (!protinfo) |
| 252 | return 0; |
| 253 | |
| 254 | p = br_port_get_rtnl(dev); |
| 255 | if (!p) |
| 256 | return -EINVAL; |
| 257 | |
| 258 | if (protinfo->nla_type & NLA_F_NESTED) { |
| 259 | err = nla_parse_nested(tb, IFLA_BRPORT_MAX, |
| 260 | protinfo, ifla_brport_policy); |
| 261 | if (err) |
| 262 | return err; |
| 263 | |
| 264 | spin_lock_bh(&p->br->lock); |
| 265 | err = br_setport(p, tb); |
| 266 | spin_unlock_bh(&p->br->lock); |
| 267 | } else { |
| 268 | /* Binary compatability with old RSTP */ |
| 269 | if (nla_len(protinfo) < sizeof(u8)) |
| 270 | return -EINVAL; |
| 271 | |
| 272 | spin_lock_bh(&p->br->lock); |
| 273 | err = br_set_port_state(p, nla_get_u8(protinfo)); |
| 274 | spin_unlock_bh(&p->br->lock); |
| 275 | } |
| 276 | |
| 277 | if (err == 0) |
| 278 | br_ifinfo_notify(RTM_NEWLINK, p); |
| 279 | |
| 280 | return err; |
| 281 | } |
| 282 | |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 283 | static int br_validate(struct nlattr *tb[], struct nlattr *data[]) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 284 | { |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 285 | if (tb[IFLA_ADDRESS]) { |
| 286 | if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) |
| 287 | return -EINVAL; |
| 288 | if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) |
| 289 | return -EADDRNOTAVAIL; |
| 290 | } |
Thomas Graf | 32fe21c | 2007-03-22 11:59:03 -0700 | [diff] [blame] | 291 | |
| 292 | return 0; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 293 | } |
| 294 | |
stephen hemminger | 149ddd8 | 2012-06-26 05:48:45 +0000 | [diff] [blame] | 295 | struct rtnl_link_ops br_link_ops __read_mostly = { |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 296 | .kind = "bridge", |
| 297 | .priv_size = sizeof(struct net_bridge), |
| 298 | .setup = br_dev_setup, |
| 299 | .validate = br_validate, |
stephen hemminger | 1ce5cce | 2011-10-06 11:19:41 +0000 | [diff] [blame] | 300 | .dellink = br_dev_delete, |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 301 | }; |
| 302 | |
| 303 | int __init br_netlink_init(void) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 304 | { |
John Fastabend | e5a55a8 | 2012-10-24 08:12:57 +0000 | [diff] [blame] | 305 | return rtnl_link_register(&br_link_ops); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 306 | } |
| 307 | |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 308 | void __exit br_netlink_fini(void) |
| 309 | { |
| 310 | rtnl_link_unregister(&br_link_ops); |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 311 | } |