2 * Bridge netlink control interface
5 * Stephen Hemminger <shemminger@osdl.org>
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.
13 #include <linux/kernel.h>
14 #include <linux/slab.h>
15 #include <linux/etherdevice.h>
16 #include <net/rtnetlink.h>
17 #include <net/net_namespace.h>
19 #include <uapi/linux/if_bridge.h>
21 #include "br_private.h"
22 #include "br_private_stp.h"
24 static int __get_num_vlan_infos(struct net_bridge_vlan_group
*vg
,
27 struct net_bridge_vlan
*v
;
28 u16 vid_range_start
= 0, vid_range_end
= 0, vid_range_flags
= 0;
32 if (!(filter_mask
& RTEXT_FILTER_BRVLAN_COMPRESSED
))
35 pvid
= br_get_pvid(vg
);
36 /* Count number of vlan infos */
37 list_for_each_entry_rcu(v
, &vg
->vlan_list
, vlist
) {
39 /* only a context, bridge vlan not activated */
40 if (!br_vlan_should_use(v
))
43 flags
|= BRIDGE_VLAN_INFO_PVID
;
45 if (v
->flags
& BRIDGE_VLAN_INFO_UNTAGGED
)
46 flags
|= BRIDGE_VLAN_INFO_UNTAGGED
;
48 if (vid_range_start
== 0) {
50 } else if ((v
->vid
- vid_range_end
) == 1 &&
51 flags
== vid_range_flags
) {
52 vid_range_end
= v
->vid
;
55 if ((vid_range_end
- vid_range_start
) > 0)
61 vid_range_start
= v
->vid
;
62 vid_range_end
= v
->vid
;
63 vid_range_flags
= flags
;
66 if (vid_range_start
!= 0) {
67 if ((vid_range_end
- vid_range_start
) > 0)
76 static int br_get_num_vlan_infos(struct net_bridge_vlan_group
*vg
,
84 if (filter_mask
& RTEXT_FILTER_BRVLAN
)
88 num_vlans
= __get_num_vlan_infos(vg
, filter_mask
);
94 static size_t br_get_link_af_size_filtered(const struct net_device
*dev
,
97 struct net_bridge_vlan_group
*vg
= NULL
;
98 struct net_bridge_port
*p
;
99 struct net_bridge
*br
;
103 if (br_port_exists(dev
)) {
104 p
= br_port_get_rcu(dev
);
105 vg
= nbp_vlan_group(p
);
106 } else if (dev
->priv_flags
& IFF_EBRIDGE
) {
107 br
= netdev_priv(dev
);
108 vg
= br_vlan_group(br
);
110 num_vlan_infos
= br_get_num_vlan_infos(vg
, filter_mask
);
113 /* Each VLAN is returned in bridge_vlan_info along with flags */
114 return num_vlan_infos
* nla_total_size(sizeof(struct bridge_vlan_info
));
117 static inline size_t br_port_info_size(void)
119 return nla_total_size(1) /* IFLA_BRPORT_STATE */
120 + nla_total_size(2) /* IFLA_BRPORT_PRIORITY */
121 + nla_total_size(4) /* IFLA_BRPORT_COST */
122 + nla_total_size(1) /* IFLA_BRPORT_MODE */
123 + nla_total_size(1) /* IFLA_BRPORT_GUARD */
124 + nla_total_size(1) /* IFLA_BRPORT_PROTECT */
125 + nla_total_size(1) /* IFLA_BRPORT_FAST_LEAVE */
126 + nla_total_size(1) /* IFLA_BRPORT_LEARNING */
127 + nla_total_size(1) /* IFLA_BRPORT_UNICAST_FLOOD */
128 + nla_total_size(1) /* IFLA_BRPORT_PROXYARP */
129 + nla_total_size(1) /* IFLA_BRPORT_PROXYARP_WIFI */
133 static inline size_t br_nlmsg_size(struct net_device
*dev
, u32 filter_mask
)
135 return NLMSG_ALIGN(sizeof(struct ifinfomsg
))
136 + nla_total_size(IFNAMSIZ
) /* IFLA_IFNAME */
137 + nla_total_size(MAX_ADDR_LEN
) /* IFLA_ADDRESS */
138 + nla_total_size(4) /* IFLA_MASTER */
139 + nla_total_size(4) /* IFLA_MTU */
140 + nla_total_size(4) /* IFLA_LINK */
141 + nla_total_size(1) /* IFLA_OPERSTATE */
142 + nla_total_size(br_port_info_size()) /* IFLA_PROTINFO */
143 + nla_total_size(br_get_link_af_size_filtered(dev
,
144 filter_mask
)); /* IFLA_AF_SPEC */
147 static int br_port_fill_attrs(struct sk_buff
*skb
,
148 const struct net_bridge_port
*p
)
150 u8 mode
= !!(p
->flags
& BR_HAIRPIN_MODE
);
152 if (nla_put_u8(skb
, IFLA_BRPORT_STATE
, p
->state
) ||
153 nla_put_u16(skb
, IFLA_BRPORT_PRIORITY
, p
->priority
) ||
154 nla_put_u32(skb
, IFLA_BRPORT_COST
, p
->path_cost
) ||
155 nla_put_u8(skb
, IFLA_BRPORT_MODE
, mode
) ||
156 nla_put_u8(skb
, IFLA_BRPORT_GUARD
, !!(p
->flags
& BR_BPDU_GUARD
)) ||
157 nla_put_u8(skb
, IFLA_BRPORT_PROTECT
, !!(p
->flags
& BR_ROOT_BLOCK
)) ||
158 nla_put_u8(skb
, IFLA_BRPORT_FAST_LEAVE
, !!(p
->flags
& BR_MULTICAST_FAST_LEAVE
)) ||
159 nla_put_u8(skb
, IFLA_BRPORT_LEARNING
, !!(p
->flags
& BR_LEARNING
)) ||
160 nla_put_u8(skb
, IFLA_BRPORT_UNICAST_FLOOD
, !!(p
->flags
& BR_FLOOD
)) ||
161 nla_put_u8(skb
, IFLA_BRPORT_PROXYARP
, !!(p
->flags
& BR_PROXYARP
)) ||
162 nla_put_u8(skb
, IFLA_BRPORT_PROXYARP_WIFI
,
163 !!(p
->flags
& BR_PROXYARP_WIFI
)))
169 static int br_fill_ifvlaninfo_range(struct sk_buff
*skb
, u16 vid_start
,
170 u16 vid_end
, u16 flags
)
172 struct bridge_vlan_info vinfo
;
174 if ((vid_end
- vid_start
) > 0) {
175 /* add range to skb */
176 vinfo
.vid
= vid_start
;
177 vinfo
.flags
= flags
| BRIDGE_VLAN_INFO_RANGE_BEGIN
;
178 if (nla_put(skb
, IFLA_BRIDGE_VLAN_INFO
,
179 sizeof(vinfo
), &vinfo
))
180 goto nla_put_failure
;
183 vinfo
.flags
= flags
| BRIDGE_VLAN_INFO_RANGE_END
;
184 if (nla_put(skb
, IFLA_BRIDGE_VLAN_INFO
,
185 sizeof(vinfo
), &vinfo
))
186 goto nla_put_failure
;
188 vinfo
.vid
= vid_start
;
190 if (nla_put(skb
, IFLA_BRIDGE_VLAN_INFO
,
191 sizeof(vinfo
), &vinfo
))
192 goto nla_put_failure
;
201 static int br_fill_ifvlaninfo_compressed(struct sk_buff
*skb
,
202 struct net_bridge_vlan_group
*vg
)
204 struct net_bridge_vlan
*v
;
205 u16 vid_range_start
= 0, vid_range_end
= 0, vid_range_flags
= 0;
209 /* Pack IFLA_BRIDGE_VLAN_INFO's for every vlan
210 * and mark vlan info with begin and end flags
211 * if vlaninfo represents a range
213 pvid
= br_get_pvid(vg
);
214 list_for_each_entry(v
, &vg
->vlan_list
, vlist
) {
216 if (!br_vlan_should_use(v
))
219 flags
|= BRIDGE_VLAN_INFO_PVID
;
221 if (v
->flags
& BRIDGE_VLAN_INFO_UNTAGGED
)
222 flags
|= BRIDGE_VLAN_INFO_UNTAGGED
;
224 if (vid_range_start
== 0) {
226 } else if ((v
->vid
- vid_range_end
) == 1 &&
227 flags
== vid_range_flags
) {
228 vid_range_end
= v
->vid
;
231 err
= br_fill_ifvlaninfo_range(skb
, vid_range_start
,
239 vid_range_start
= v
->vid
;
240 vid_range_end
= v
->vid
;
241 vid_range_flags
= flags
;
244 if (vid_range_start
!= 0) {
245 /* Call it once more to send any left over vlans */
246 err
= br_fill_ifvlaninfo_range(skb
, vid_range_start
,
256 static int br_fill_ifvlaninfo(struct sk_buff
*skb
,
257 struct net_bridge_vlan_group
*vg
)
259 struct bridge_vlan_info vinfo
;
260 struct net_bridge_vlan
*v
;
263 pvid
= br_get_pvid(vg
);
264 list_for_each_entry(v
, &vg
->vlan_list
, vlist
) {
265 if (!br_vlan_should_use(v
))
271 vinfo
.flags
|= BRIDGE_VLAN_INFO_PVID
;
273 if (v
->flags
& BRIDGE_VLAN_INFO_UNTAGGED
)
274 vinfo
.flags
|= BRIDGE_VLAN_INFO_UNTAGGED
;
276 if (nla_put(skb
, IFLA_BRIDGE_VLAN_INFO
,
277 sizeof(vinfo
), &vinfo
))
278 goto nla_put_failure
;
288 * Create one netlink message for one interface
289 * Contains port and master info as well as carrier and bridge state.
291 static int br_fill_ifinfo(struct sk_buff
*skb
,
292 struct net_bridge_port
*port
,
293 u32 pid
, u32 seq
, int event
, unsigned int flags
,
294 u32 filter_mask
, const struct net_device
*dev
)
296 struct net_bridge
*br
;
297 struct ifinfomsg
*hdr
;
298 struct nlmsghdr
*nlh
;
299 u8 operstate
= netif_running(dev
) ? dev
->operstate
: IF_OPER_DOWN
;
304 br
= netdev_priv(dev
);
306 br_debug(br
, "br_fill_info event %d port %s master %s\n",
307 event
, dev
->name
, br
->dev
->name
);
309 nlh
= nlmsg_put(skb
, pid
, seq
, event
, sizeof(*hdr
), flags
);
313 hdr
= nlmsg_data(nlh
);
314 hdr
->ifi_family
= AF_BRIDGE
;
316 hdr
->ifi_type
= dev
->type
;
317 hdr
->ifi_index
= dev
->ifindex
;
318 hdr
->ifi_flags
= dev_get_flags(dev
);
321 if (nla_put_string(skb
, IFLA_IFNAME
, dev
->name
) ||
322 nla_put_u32(skb
, IFLA_MASTER
, br
->dev
->ifindex
) ||
323 nla_put_u32(skb
, IFLA_MTU
, dev
->mtu
) ||
324 nla_put_u8(skb
, IFLA_OPERSTATE
, operstate
) ||
326 nla_put(skb
, IFLA_ADDRESS
, dev
->addr_len
, dev
->dev_addr
)) ||
327 (dev
->ifindex
!= dev_get_iflink(dev
) &&
328 nla_put_u32(skb
, IFLA_LINK
, dev_get_iflink(dev
))))
329 goto nla_put_failure
;
331 if (event
== RTM_NEWLINK
&& port
) {
333 = nla_nest_start(skb
, IFLA_PROTINFO
| NLA_F_NESTED
);
335 if (nest
== NULL
|| br_port_fill_attrs(skb
, port
) < 0)
336 goto nla_put_failure
;
337 nla_nest_end(skb
, nest
);
340 /* Check if the VID information is requested */
341 if ((filter_mask
& RTEXT_FILTER_BRVLAN
) ||
342 (filter_mask
& RTEXT_FILTER_BRVLAN_COMPRESSED
)) {
343 struct net_bridge_vlan_group
*vg
;
348 vg
= nbp_vlan_group(port
);
350 vg
= br_vlan_group(br
);
352 if (!vg
|| !vg
->num_vlans
)
355 af
= nla_nest_start(skb
, IFLA_AF_SPEC
);
357 goto nla_put_failure
;
359 if (filter_mask
& RTEXT_FILTER_BRVLAN_COMPRESSED
)
360 err
= br_fill_ifvlaninfo_compressed(skb
, vg
);
362 err
= br_fill_ifvlaninfo(skb
, vg
);
364 goto nla_put_failure
;
365 nla_nest_end(skb
, af
);
373 nlmsg_cancel(skb
, nlh
);
378 * Notify listeners of a change in port information
380 void br_ifinfo_notify(int event
, struct net_bridge_port
*port
)
385 u32 filter
= RTEXT_FILTER_BRVLAN_COMPRESSED
;
390 net
= dev_net(port
->dev
);
391 br_debug(port
->br
, "port %u(%s) event %d\n",
392 (unsigned int)port
->port_no
, port
->dev
->name
, event
);
394 skb
= nlmsg_new(br_nlmsg_size(port
->dev
, filter
), GFP_ATOMIC
);
398 err
= br_fill_ifinfo(skb
, port
, 0, 0, event
, 0, filter
, port
->dev
);
400 /* -EMSGSIZE implies BUG in br_nlmsg_size() */
401 WARN_ON(err
== -EMSGSIZE
);
405 rtnl_notify(skb
, net
, 0, RTNLGRP_LINK
, NULL
, GFP_ATOMIC
);
408 rtnl_set_sk_err(net
, RTNLGRP_LINK
, err
);
413 * Dump information about all ports, in response to GETLINK
415 int br_getlink(struct sk_buff
*skb
, u32 pid
, u32 seq
,
416 struct net_device
*dev
, u32 filter_mask
, int nlflags
)
418 struct net_bridge_port
*port
= br_port_get_rtnl(dev
);
420 if (!port
&& !(filter_mask
& RTEXT_FILTER_BRVLAN
) &&
421 !(filter_mask
& RTEXT_FILTER_BRVLAN_COMPRESSED
))
424 return br_fill_ifinfo(skb
, port
, pid
, seq
, RTM_NEWLINK
, nlflags
,
428 static int br_vlan_info(struct net_bridge
*br
, struct net_bridge_port
*p
,
429 int cmd
, struct bridge_vlan_info
*vinfo
)
436 /* if the MASTER flag is set this will act on the global
437 * per-VLAN entry as well
439 err
= nbp_vlan_add(p
, vinfo
->vid
, vinfo
->flags
);
443 vinfo
->flags
|= BRIDGE_VLAN_INFO_BRENTRY
;
444 err
= br_vlan_add(br
, vinfo
->vid
, vinfo
->flags
);
450 nbp_vlan_delete(p
, vinfo
->vid
);
451 if (vinfo
->flags
& BRIDGE_VLAN_INFO_MASTER
)
452 br_vlan_delete(p
->br
, vinfo
->vid
);
454 br_vlan_delete(br
, vinfo
->vid
);
462 static int br_afspec(struct net_bridge
*br
,
463 struct net_bridge_port
*p
,
464 struct nlattr
*af_spec
,
467 struct bridge_vlan_info
*vinfo_start
= NULL
;
468 struct bridge_vlan_info
*vinfo
= NULL
;
473 nla_for_each_nested(attr
, af_spec
, rem
) {
474 if (nla_type(attr
) != IFLA_BRIDGE_VLAN_INFO
)
476 if (nla_len(attr
) != sizeof(struct bridge_vlan_info
))
478 vinfo
= nla_data(attr
);
479 if (!vinfo
->vid
|| vinfo
->vid
>= VLAN_VID_MASK
)
481 if (vinfo
->flags
& BRIDGE_VLAN_INFO_RANGE_BEGIN
) {
489 struct bridge_vlan_info tmp_vinfo
;
492 if (!(vinfo
->flags
& BRIDGE_VLAN_INFO_RANGE_END
))
495 if (vinfo
->vid
<= vinfo_start
->vid
)
498 memcpy(&tmp_vinfo
, vinfo_start
,
499 sizeof(struct bridge_vlan_info
));
501 for (v
= vinfo_start
->vid
; v
<= vinfo
->vid
; v
++) {
503 err
= br_vlan_info(br
, p
, cmd
, &tmp_vinfo
);
509 err
= br_vlan_info(br
, p
, cmd
, vinfo
);
518 static const struct nla_policy br_port_policy
[IFLA_BRPORT_MAX
+ 1] = {
519 [IFLA_BRPORT_STATE
] = { .type
= NLA_U8
},
520 [IFLA_BRPORT_COST
] = { .type
= NLA_U32
},
521 [IFLA_BRPORT_PRIORITY
] = { .type
= NLA_U16
},
522 [IFLA_BRPORT_MODE
] = { .type
= NLA_U8
},
523 [IFLA_BRPORT_GUARD
] = { .type
= NLA_U8
},
524 [IFLA_BRPORT_PROTECT
] = { .type
= NLA_U8
},
525 [IFLA_BRPORT_FAST_LEAVE
]= { .type
= NLA_U8
},
526 [IFLA_BRPORT_LEARNING
] = { .type
= NLA_U8
},
527 [IFLA_BRPORT_UNICAST_FLOOD
] = { .type
= NLA_U8
},
528 [IFLA_BRPORT_PROXYARP
] = { .type
= NLA_U8
},
529 [IFLA_BRPORT_PROXYARP_WIFI
] = { .type
= NLA_U8
},
532 /* Change the state of the port and notify spanning tree */
533 static int br_set_port_state(struct net_bridge_port
*p
, u8 state
)
535 if (state
> BR_STATE_BLOCKING
)
538 /* if kernel STP is running, don't allow changes */
539 if (p
->br
->stp_enabled
== BR_KERNEL_STP
)
542 /* if device is not up, change is not allowed
543 * if link is not present, only allowable state is disabled
545 if (!netif_running(p
->dev
) ||
546 (!netif_oper_up(p
->dev
) && state
!= BR_STATE_DISABLED
))
549 br_set_state(p
, state
);
551 br_port_state_selection(p
->br
);
555 /* Set/clear or port flags based on attribute */
556 static void br_set_port_flag(struct net_bridge_port
*p
, struct nlattr
*tb
[],
557 int attrtype
, unsigned long mask
)
560 u8 flag
= nla_get_u8(tb
[attrtype
]);
568 /* Process bridge protocol info on port */
569 static int br_setport(struct net_bridge_port
*p
, struct nlattr
*tb
[])
572 unsigned long old_flags
= p
->flags
;
574 br_set_port_flag(p
, tb
, IFLA_BRPORT_MODE
, BR_HAIRPIN_MODE
);
575 br_set_port_flag(p
, tb
, IFLA_BRPORT_GUARD
, BR_BPDU_GUARD
);
576 br_set_port_flag(p
, tb
, IFLA_BRPORT_FAST_LEAVE
, BR_MULTICAST_FAST_LEAVE
);
577 br_set_port_flag(p
, tb
, IFLA_BRPORT_PROTECT
, BR_ROOT_BLOCK
);
578 br_set_port_flag(p
, tb
, IFLA_BRPORT_LEARNING
, BR_LEARNING
);
579 br_set_port_flag(p
, tb
, IFLA_BRPORT_UNICAST_FLOOD
, BR_FLOOD
);
580 br_set_port_flag(p
, tb
, IFLA_BRPORT_PROXYARP
, BR_PROXYARP
);
581 br_set_port_flag(p
, tb
, IFLA_BRPORT_PROXYARP_WIFI
, BR_PROXYARP_WIFI
);
583 if (tb
[IFLA_BRPORT_COST
]) {
584 err
= br_stp_set_path_cost(p
, nla_get_u32(tb
[IFLA_BRPORT_COST
]));
589 if (tb
[IFLA_BRPORT_PRIORITY
]) {
590 err
= br_stp_set_port_priority(p
, nla_get_u16(tb
[IFLA_BRPORT_PRIORITY
]));
595 if (tb
[IFLA_BRPORT_STATE
]) {
596 err
= br_set_port_state(p
, nla_get_u8(tb
[IFLA_BRPORT_STATE
]));
601 br_port_flags_change(p
, old_flags
^ p
->flags
);
605 /* Change state and parameters on port. */
606 int br_setlink(struct net_device
*dev
, struct nlmsghdr
*nlh
, u16 flags
)
608 struct nlattr
*protinfo
;
609 struct nlattr
*afspec
;
610 struct net_bridge_port
*p
;
611 struct nlattr
*tb
[IFLA_BRPORT_MAX
+ 1];
614 protinfo
= nlmsg_find_attr(nlh
, sizeof(struct ifinfomsg
), IFLA_PROTINFO
);
615 afspec
= nlmsg_find_attr(nlh
, sizeof(struct ifinfomsg
), IFLA_AF_SPEC
);
616 if (!protinfo
&& !afspec
)
619 p
= br_port_get_rtnl(dev
);
620 /* We want to accept dev as bridge itself if the AF_SPEC
621 * is set to see if someone is setting vlan info on the bridge
627 if (protinfo
->nla_type
& NLA_F_NESTED
) {
628 err
= nla_parse_nested(tb
, IFLA_BRPORT_MAX
,
629 protinfo
, br_port_policy
);
633 spin_lock_bh(&p
->br
->lock
);
634 err
= br_setport(p
, tb
);
635 spin_unlock_bh(&p
->br
->lock
);
637 /* Binary compatibility with old RSTP */
638 if (nla_len(protinfo
) < sizeof(u8
))
641 spin_lock_bh(&p
->br
->lock
);
642 err
= br_set_port_state(p
, nla_get_u8(protinfo
));
643 spin_unlock_bh(&p
->br
->lock
);
650 err
= br_afspec((struct net_bridge
*)netdev_priv(dev
), p
,
651 afspec
, RTM_SETLINK
);
655 br_ifinfo_notify(RTM_NEWLINK
, p
);
660 /* Delete port information */
661 int br_dellink(struct net_device
*dev
, struct nlmsghdr
*nlh
, u16 flags
)
663 struct nlattr
*afspec
;
664 struct net_bridge_port
*p
;
667 afspec
= nlmsg_find_attr(nlh
, sizeof(struct ifinfomsg
), IFLA_AF_SPEC
);
671 p
= br_port_get_rtnl(dev
);
672 /* We want to accept dev as bridge itself as well */
673 if (!p
&& !(dev
->priv_flags
& IFF_EBRIDGE
))
676 err
= br_afspec((struct net_bridge
*)netdev_priv(dev
), p
,
677 afspec
, RTM_DELLINK
);
679 /* Send RTM_NEWLINK because userspace
680 * expects RTM_NEWLINK for vlan dels
682 br_ifinfo_notify(RTM_NEWLINK
, p
);
686 static int br_validate(struct nlattr
*tb
[], struct nlattr
*data
[])
688 if (tb
[IFLA_ADDRESS
]) {
689 if (nla_len(tb
[IFLA_ADDRESS
]) != ETH_ALEN
)
691 if (!is_valid_ether_addr(nla_data(tb
[IFLA_ADDRESS
])))
692 return -EADDRNOTAVAIL
;
698 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
699 if (data
[IFLA_BR_VLAN_PROTOCOL
]) {
700 switch (nla_get_be16(data
[IFLA_BR_VLAN_PROTOCOL
])) {
701 case htons(ETH_P_8021Q
):
702 case htons(ETH_P_8021AD
):
705 return -EPROTONOSUPPORT
;
713 static int br_dev_newlink(struct net
*src_net
, struct net_device
*dev
,
714 struct nlattr
*tb
[], struct nlattr
*data
[])
716 struct net_bridge
*br
= netdev_priv(dev
);
718 if (tb
[IFLA_ADDRESS
]) {
719 spin_lock_bh(&br
->lock
);
720 br_stp_change_bridge_id(br
, nla_data(tb
[IFLA_ADDRESS
]));
721 spin_unlock_bh(&br
->lock
);
724 return register_netdevice(dev
);
727 static int br_port_slave_changelink(struct net_device
*brdev
,
728 struct net_device
*dev
,
730 struct nlattr
*data
[])
732 struct net_bridge
*br
= netdev_priv(brdev
);
738 spin_lock_bh(&br
->lock
);
739 ret
= br_setport(br_port_get_rtnl(dev
), data
);
740 spin_unlock_bh(&br
->lock
);
745 static int br_port_fill_slave_info(struct sk_buff
*skb
,
746 const struct net_device
*brdev
,
747 const struct net_device
*dev
)
749 return br_port_fill_attrs(skb
, br_port_get_rtnl(dev
));
752 static size_t br_port_get_slave_size(const struct net_device
*brdev
,
753 const struct net_device
*dev
)
755 return br_port_info_size();
758 static const struct nla_policy br_policy
[IFLA_BR_MAX
+ 1] = {
759 [IFLA_BR_FORWARD_DELAY
] = { .type
= NLA_U32
},
760 [IFLA_BR_HELLO_TIME
] = { .type
= NLA_U32
},
761 [IFLA_BR_MAX_AGE
] = { .type
= NLA_U32
},
762 [IFLA_BR_AGEING_TIME
] = { .type
= NLA_U32
},
763 [IFLA_BR_STP_STATE
] = { .type
= NLA_U32
},
764 [IFLA_BR_PRIORITY
] = { .type
= NLA_U16
},
765 [IFLA_BR_VLAN_FILTERING
] = { .type
= NLA_U8
},
766 [IFLA_BR_VLAN_PROTOCOL
] = { .type
= NLA_U16
},
767 [IFLA_BR_GROUP_FWD_MASK
] = { .type
= NLA_U16
},
768 [IFLA_BR_GROUP_ADDR
] = { .type
= NLA_BINARY
,
770 [IFLA_BR_MCAST_ROUTER
] = { .type
= NLA_U8
},
771 [IFLA_BR_MCAST_SNOOPING
] = { .type
= NLA_U8
},
772 [IFLA_BR_MCAST_QUERY_USE_IFADDR
] = { .type
= NLA_U8
},
773 [IFLA_BR_MCAST_QUERIER
] = { .type
= NLA_U8
},
774 [IFLA_BR_MCAST_HASH_ELASTICITY
] = { .type
= NLA_U32
},
775 [IFLA_BR_MCAST_HASH_MAX
] = { .type
= NLA_U32
},
776 [IFLA_BR_MCAST_LAST_MEMBER_CNT
] = { .type
= NLA_U32
},
777 [IFLA_BR_MCAST_STARTUP_QUERY_CNT
] = { .type
= NLA_U32
},
778 [IFLA_BR_MCAST_LAST_MEMBER_INTVL
] = { .type
= NLA_U64
},
779 [IFLA_BR_MCAST_MEMBERSHIP_INTVL
] = { .type
= NLA_U64
},
780 [IFLA_BR_MCAST_QUERIER_INTVL
] = { .type
= NLA_U64
},
781 [IFLA_BR_MCAST_QUERY_INTVL
] = { .type
= NLA_U64
},
782 [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
] = { .type
= NLA_U64
},
783 [IFLA_BR_MCAST_STARTUP_QUERY_INTVL
] = { .type
= NLA_U64
},
784 [IFLA_BR_NF_CALL_IPTABLES
] = { .type
= NLA_U8
},
785 [IFLA_BR_NF_CALL_IP6TABLES
] = { .type
= NLA_U8
},
786 [IFLA_BR_NF_CALL_ARPTABLES
] = { .type
= NLA_U8
},
787 [IFLA_BR_VLAN_DEFAULT_PVID
] = { .type
= NLA_U16
},
790 static int br_changelink(struct net_device
*brdev
, struct nlattr
*tb
[],
791 struct nlattr
*data
[])
793 struct net_bridge
*br
= netdev_priv(brdev
);
799 if (data
[IFLA_BR_FORWARD_DELAY
]) {
800 err
= br_set_forward_delay(br
, nla_get_u32(data
[IFLA_BR_FORWARD_DELAY
]));
805 if (data
[IFLA_BR_HELLO_TIME
]) {
806 err
= br_set_hello_time(br
, nla_get_u32(data
[IFLA_BR_HELLO_TIME
]));
811 if (data
[IFLA_BR_MAX_AGE
]) {
812 err
= br_set_max_age(br
, nla_get_u32(data
[IFLA_BR_MAX_AGE
]));
817 if (data
[IFLA_BR_AGEING_TIME
]) {
818 u32 ageing_time
= nla_get_u32(data
[IFLA_BR_AGEING_TIME
]);
820 br
->ageing_time
= clock_t_to_jiffies(ageing_time
);
823 if (data
[IFLA_BR_STP_STATE
]) {
824 u32 stp_enabled
= nla_get_u32(data
[IFLA_BR_STP_STATE
]);
826 br_stp_set_enabled(br
, stp_enabled
);
829 if (data
[IFLA_BR_PRIORITY
]) {
830 u32 priority
= nla_get_u16(data
[IFLA_BR_PRIORITY
]);
832 br_stp_set_bridge_priority(br
, priority
);
835 if (data
[IFLA_BR_VLAN_FILTERING
]) {
836 u8 vlan_filter
= nla_get_u8(data
[IFLA_BR_VLAN_FILTERING
]);
838 err
= __br_vlan_filter_toggle(br
, vlan_filter
);
843 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
844 if (data
[IFLA_BR_VLAN_PROTOCOL
]) {
845 __be16 vlan_proto
= nla_get_be16(data
[IFLA_BR_VLAN_PROTOCOL
]);
847 err
= __br_vlan_set_proto(br
, vlan_proto
);
852 if (data
[IFLA_BR_VLAN_DEFAULT_PVID
]) {
853 __u16 defpvid
= nla_get_u16(data
[IFLA_BR_VLAN_DEFAULT_PVID
]);
855 err
= __br_vlan_set_default_pvid(br
, defpvid
);
861 if (data
[IFLA_BR_GROUP_FWD_MASK
]) {
862 u16 fwd_mask
= nla_get_u16(data
[IFLA_BR_GROUP_FWD_MASK
]);
864 if (fwd_mask
& BR_GROUPFWD_RESTRICTED
)
866 br
->group_fwd_mask
= fwd_mask
;
869 if (data
[IFLA_BR_GROUP_ADDR
]) {
870 u8 new_addr
[ETH_ALEN
];
872 if (nla_len(data
[IFLA_BR_GROUP_ADDR
]) != ETH_ALEN
)
874 memcpy(new_addr
, nla_data(data
[IFLA_BR_GROUP_ADDR
]), ETH_ALEN
);
875 if (!is_link_local_ether_addr(new_addr
))
877 if (new_addr
[5] == 1 || /* 802.3x Pause address */
878 new_addr
[5] == 2 || /* 802.3ad Slow protocols */
879 new_addr
[5] == 3) /* 802.1X PAE address */
881 spin_lock_bh(&br
->lock
);
882 memcpy(br
->group_addr
, new_addr
, sizeof(br
->group_addr
));
883 spin_unlock_bh(&br
->lock
);
884 br
->group_addr_set
= true;
885 br_recalculate_fwd_mask(br
);
888 if (data
[IFLA_BR_FDB_FLUSH
])
891 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
892 if (data
[IFLA_BR_MCAST_ROUTER
]) {
893 u8 multicast_router
= nla_get_u8(data
[IFLA_BR_MCAST_ROUTER
]);
895 err
= br_multicast_set_router(br
, multicast_router
);
900 if (data
[IFLA_BR_MCAST_SNOOPING
]) {
901 u8 mcast_snooping
= nla_get_u8(data
[IFLA_BR_MCAST_SNOOPING
]);
903 err
= br_multicast_toggle(br
, mcast_snooping
);
908 if (data
[IFLA_BR_MCAST_QUERY_USE_IFADDR
]) {
911 val
= nla_get_u8(data
[IFLA_BR_MCAST_QUERY_USE_IFADDR
]);
912 br
->multicast_query_use_ifaddr
= !!val
;
915 if (data
[IFLA_BR_MCAST_QUERIER
]) {
916 u8 mcast_querier
= nla_get_u8(data
[IFLA_BR_MCAST_QUERIER
]);
918 err
= br_multicast_set_querier(br
, mcast_querier
);
923 if (data
[IFLA_BR_MCAST_HASH_ELASTICITY
]) {
924 u32 val
= nla_get_u32(data
[IFLA_BR_MCAST_HASH_ELASTICITY
]);
926 br
->hash_elasticity
= val
;
929 if (data
[IFLA_BR_MCAST_HASH_MAX
]) {
930 u32 hash_max
= nla_get_u32(data
[IFLA_BR_MCAST_HASH_MAX
]);
932 err
= br_multicast_set_hash_max(br
, hash_max
);
937 if (data
[IFLA_BR_MCAST_LAST_MEMBER_CNT
]) {
938 u32 val
= nla_get_u32(data
[IFLA_BR_MCAST_LAST_MEMBER_CNT
]);
940 br
->multicast_last_member_count
= val
;
943 if (data
[IFLA_BR_MCAST_STARTUP_QUERY_CNT
]) {
944 u32 val
= nla_get_u32(data
[IFLA_BR_MCAST_STARTUP_QUERY_CNT
]);
946 br
->multicast_startup_query_count
= val
;
949 if (data
[IFLA_BR_MCAST_LAST_MEMBER_INTVL
]) {
950 u64 val
= nla_get_u64(data
[IFLA_BR_MCAST_LAST_MEMBER_INTVL
]);
952 br
->multicast_last_member_interval
= clock_t_to_jiffies(val
);
955 if (data
[IFLA_BR_MCAST_MEMBERSHIP_INTVL
]) {
956 u64 val
= nla_get_u64(data
[IFLA_BR_MCAST_MEMBERSHIP_INTVL
]);
958 br
->multicast_membership_interval
= clock_t_to_jiffies(val
);
961 if (data
[IFLA_BR_MCAST_QUERIER_INTVL
]) {
962 u64 val
= nla_get_u64(data
[IFLA_BR_MCAST_QUERIER_INTVL
]);
964 br
->multicast_querier_interval
= clock_t_to_jiffies(val
);
967 if (data
[IFLA_BR_MCAST_QUERY_INTVL
]) {
968 u64 val
= nla_get_u64(data
[IFLA_BR_MCAST_QUERY_INTVL
]);
970 br
->multicast_query_interval
= clock_t_to_jiffies(val
);
973 if (data
[IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
]) {
974 u64 val
= nla_get_u64(data
[IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
]);
976 br
->multicast_query_response_interval
= clock_t_to_jiffies(val
);
979 if (data
[IFLA_BR_MCAST_STARTUP_QUERY_INTVL
]) {
980 u64 val
= nla_get_u64(data
[IFLA_BR_MCAST_STARTUP_QUERY_INTVL
]);
982 br
->multicast_startup_query_interval
= clock_t_to_jiffies(val
);
985 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
986 if (data
[IFLA_BR_NF_CALL_IPTABLES
]) {
987 u8 val
= nla_get_u8(data
[IFLA_BR_NF_CALL_IPTABLES
]);
989 br
->nf_call_iptables
= val
? true : false;
992 if (data
[IFLA_BR_NF_CALL_IP6TABLES
]) {
993 u8 val
= nla_get_u8(data
[IFLA_BR_NF_CALL_IP6TABLES
]);
995 br
->nf_call_ip6tables
= val
? true : false;
998 if (data
[IFLA_BR_NF_CALL_ARPTABLES
]) {
999 u8 val
= nla_get_u8(data
[IFLA_BR_NF_CALL_ARPTABLES
]);
1001 br
->nf_call_arptables
= val
? true : false;
1008 static size_t br_get_size(const struct net_device
*brdev
)
1010 return nla_total_size(sizeof(u32
)) + /* IFLA_BR_FORWARD_DELAY */
1011 nla_total_size(sizeof(u32
)) + /* IFLA_BR_HELLO_TIME */
1012 nla_total_size(sizeof(u32
)) + /* IFLA_BR_MAX_AGE */
1013 nla_total_size(sizeof(u32
)) + /* IFLA_BR_AGEING_TIME */
1014 nla_total_size(sizeof(u32
)) + /* IFLA_BR_STP_STATE */
1015 nla_total_size(sizeof(u16
)) + /* IFLA_BR_PRIORITY */
1016 nla_total_size(sizeof(u8
)) + /* IFLA_BR_VLAN_FILTERING */
1017 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
1018 nla_total_size(sizeof(__be16
)) + /* IFLA_BR_VLAN_PROTOCOL */
1019 nla_total_size(sizeof(u16
)) + /* IFLA_BR_VLAN_DEFAULT_PVID */
1021 nla_total_size(sizeof(u16
)) + /* IFLA_BR_GROUP_FWD_MASK */
1022 nla_total_size(sizeof(struct ifla_bridge_id
)) + /* IFLA_BR_ROOT_ID */
1023 nla_total_size(sizeof(struct ifla_bridge_id
)) + /* IFLA_BR_BRIDGE_ID */
1024 nla_total_size(sizeof(u16
)) + /* IFLA_BR_ROOT_PORT */
1025 nla_total_size(sizeof(u32
)) + /* IFLA_BR_ROOT_PATH_COST */
1026 nla_total_size(sizeof(u8
)) + /* IFLA_BR_TOPOLOGY_CHANGE */
1027 nla_total_size(sizeof(u8
)) + /* IFLA_BR_TOPOLOGY_CHANGE_DETECTED */
1028 nla_total_size(sizeof(u64
)) + /* IFLA_BR_HELLO_TIMER */
1029 nla_total_size(sizeof(u64
)) + /* IFLA_BR_TCN_TIMER */
1030 nla_total_size(sizeof(u64
)) + /* IFLA_BR_TOPOLOGY_CHANGE_TIMER */
1031 nla_total_size(sizeof(u64
)) + /* IFLA_BR_GC_TIMER */
1032 nla_total_size(ETH_ALEN
) + /* IFLA_BR_GROUP_ADDR */
1033 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
1034 nla_total_size(sizeof(u8
)) + /* IFLA_BR_MCAST_ROUTER */
1035 nla_total_size(sizeof(u8
)) + /* IFLA_BR_MCAST_SNOOPING */
1036 nla_total_size(sizeof(u8
)) + /* IFLA_BR_MCAST_QUERY_USE_IFADDR */
1037 nla_total_size(sizeof(u8
)) + /* IFLA_BR_MCAST_QUERIER */
1038 nla_total_size(sizeof(u32
)) + /* IFLA_BR_MCAST_HASH_ELASTICITY */
1039 nla_total_size(sizeof(u32
)) + /* IFLA_BR_MCAST_HASH_MAX */
1040 nla_total_size(sizeof(u32
)) + /* IFLA_BR_MCAST_LAST_MEMBER_CNT */
1041 nla_total_size(sizeof(u32
)) + /* IFLA_BR_MCAST_STARTUP_QUERY_CNT */
1042 nla_total_size(sizeof(u64
)) + /* IFLA_BR_MCAST_LAST_MEMBER_INTVL */
1043 nla_total_size(sizeof(u64
)) + /* IFLA_BR_MCAST_MEMBERSHIP_INTVL */
1044 nla_total_size(sizeof(u64
)) + /* IFLA_BR_MCAST_QUERIER_INTVL */
1045 nla_total_size(sizeof(u64
)) + /* IFLA_BR_MCAST_QUERY_INTVL */
1046 nla_total_size(sizeof(u64
)) + /* IFLA_BR_MCAST_QUERY_RESPONSE_INTVL */
1047 nla_total_size(sizeof(u64
)) + /* IFLA_BR_MCAST_STARTUP_QUERY_INTVL */
1049 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
1050 nla_total_size(sizeof(u8
)) + /* IFLA_BR_NF_CALL_IPTABLES */
1051 nla_total_size(sizeof(u8
)) + /* IFLA_BR_NF_CALL_IP6TABLES */
1052 nla_total_size(sizeof(u8
)) + /* IFLA_BR_NF_CALL_ARPTABLES */
1057 static int br_fill_info(struct sk_buff
*skb
, const struct net_device
*brdev
)
1059 struct net_bridge
*br
= netdev_priv(brdev
);
1060 u64 hello_timer
, tcn_timer
, topology_change_timer
, gc_timer
, clockval
;
1061 u32 forward_delay
= jiffies_to_clock_t(br
->forward_delay
);
1062 u32 hello_time
= jiffies_to_clock_t(br
->hello_time
);
1063 u32 age_time
= jiffies_to_clock_t(br
->max_age
);
1064 u32 ageing_time
= jiffies_to_clock_t(br
->ageing_time
);
1065 u32 stp_enabled
= br
->stp_enabled
;
1066 u16 priority
= (br
->bridge_id
.prio
[0] << 8) | br
->bridge_id
.prio
[1];
1067 u16 group_fwd_mask
= br
->group_fwd_mask
;
1068 u8 vlan_enabled
= br_vlan_enabled(br
);
1069 struct ifla_bridge_id root_id
, bridge_id
;
1071 memset(&bridge_id
, 0, sizeof(bridge_id
));
1072 memset(&root_id
, 0, sizeof(root_id
));
1073 memcpy(root_id
.prio
, br
->designated_root
.prio
, sizeof(root_id
.prio
));
1074 memcpy(root_id
.addr
, br
->designated_root
.addr
, sizeof(root_id
.addr
));
1075 memcpy(bridge_id
.prio
, br
->bridge_id
.prio
, sizeof(bridge_id
.prio
));
1076 memcpy(bridge_id
.addr
, br
->bridge_id
.addr
, sizeof(bridge_id
.addr
));
1077 hello_timer
= br_timer_value(&br
->hello_timer
);
1078 tcn_timer
= br_timer_value(&br
->tcn_timer
);
1079 topology_change_timer
= br_timer_value(&br
->topology_change_timer
);
1080 gc_timer
= br_timer_value(&br
->gc_timer
);
1083 if (nla_put_u32(skb
, IFLA_BR_FORWARD_DELAY
, forward_delay
) ||
1084 nla_put_u32(skb
, IFLA_BR_HELLO_TIME
, hello_time
) ||
1085 nla_put_u32(skb
, IFLA_BR_MAX_AGE
, age_time
) ||
1086 nla_put_u32(skb
, IFLA_BR_AGEING_TIME
, ageing_time
) ||
1087 nla_put_u32(skb
, IFLA_BR_STP_STATE
, stp_enabled
) ||
1088 nla_put_u16(skb
, IFLA_BR_PRIORITY
, priority
) ||
1089 nla_put_u8(skb
, IFLA_BR_VLAN_FILTERING
, vlan_enabled
) ||
1090 nla_put_u16(skb
, IFLA_BR_GROUP_FWD_MASK
, group_fwd_mask
) ||
1091 nla_put(skb
, IFLA_BR_ROOT_ID
, sizeof(root_id
), &root_id
) ||
1092 nla_put(skb
, IFLA_BR_BRIDGE_ID
, sizeof(bridge_id
), &bridge_id
) ||
1093 nla_put_u16(skb
, IFLA_BR_ROOT_PORT
, br
->root_port
) ||
1094 nla_put_u32(skb
, IFLA_BR_ROOT_PATH_COST
, br
->root_path_cost
) ||
1095 nla_put_u8(skb
, IFLA_BR_TOPOLOGY_CHANGE
, br
->topology_change
) ||
1096 nla_put_u8(skb
, IFLA_BR_TOPOLOGY_CHANGE_DETECTED
,
1097 br
->topology_change_detected
) ||
1098 nla_put_u64(skb
, IFLA_BR_HELLO_TIMER
, hello_timer
) ||
1099 nla_put_u64(skb
, IFLA_BR_TCN_TIMER
, tcn_timer
) ||
1100 nla_put_u64(skb
, IFLA_BR_TOPOLOGY_CHANGE_TIMER
,
1101 topology_change_timer
) ||
1102 nla_put_u64(skb
, IFLA_BR_GC_TIMER
, gc_timer
) ||
1103 nla_put(skb
, IFLA_BR_GROUP_ADDR
, ETH_ALEN
, br
->group_addr
))
1106 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
1107 if (nla_put_be16(skb
, IFLA_BR_VLAN_PROTOCOL
, br
->vlan_proto
) ||
1108 nla_put_u16(skb
, IFLA_BR_VLAN_DEFAULT_PVID
, br
->default_pvid
))
1111 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
1112 if (nla_put_u8(skb
, IFLA_BR_MCAST_ROUTER
, br
->multicast_router
) ||
1113 nla_put_u8(skb
, IFLA_BR_MCAST_SNOOPING
, !br
->multicast_disabled
) ||
1114 nla_put_u8(skb
, IFLA_BR_MCAST_QUERY_USE_IFADDR
,
1115 br
->multicast_query_use_ifaddr
) ||
1116 nla_put_u8(skb
, IFLA_BR_MCAST_QUERIER
, br
->multicast_querier
) ||
1117 nla_put_u32(skb
, IFLA_BR_MCAST_HASH_ELASTICITY
,
1118 br
->hash_elasticity
) ||
1119 nla_put_u32(skb
, IFLA_BR_MCAST_HASH_MAX
, br
->hash_max
) ||
1120 nla_put_u32(skb
, IFLA_BR_MCAST_LAST_MEMBER_CNT
,
1121 br
->multicast_last_member_count
) ||
1122 nla_put_u32(skb
, IFLA_BR_MCAST_STARTUP_QUERY_CNT
,
1123 br
->multicast_startup_query_count
))
1126 clockval
= jiffies_to_clock_t(br
->multicast_last_member_interval
);
1127 if (nla_put_u64(skb
, IFLA_BR_MCAST_LAST_MEMBER_INTVL
, clockval
))
1129 clockval
= jiffies_to_clock_t(br
->multicast_membership_interval
);
1130 if (nla_put_u64(skb
, IFLA_BR_MCAST_MEMBERSHIP_INTVL
, clockval
))
1132 clockval
= jiffies_to_clock_t(br
->multicast_querier_interval
);
1133 if (nla_put_u64(skb
, IFLA_BR_MCAST_QUERIER_INTVL
, clockval
))
1135 clockval
= jiffies_to_clock_t(br
->multicast_query_interval
);
1136 if (nla_put_u64(skb
, IFLA_BR_MCAST_QUERY_INTVL
, clockval
))
1138 clockval
= jiffies_to_clock_t(br
->multicast_query_response_interval
);
1139 if (nla_put_u64(skb
, IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
, clockval
))
1141 clockval
= jiffies_to_clock_t(br
->multicast_startup_query_interval
);
1142 if (nla_put_u64(skb
, IFLA_BR_MCAST_STARTUP_QUERY_INTVL
, clockval
))
1145 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
1146 if (nla_put_u8(skb
, IFLA_BR_NF_CALL_IPTABLES
,
1147 br
->nf_call_iptables
? 1 : 0) ||
1148 nla_put_u8(skb
, IFLA_BR_NF_CALL_IP6TABLES
,
1149 br
->nf_call_ip6tables
? 1 : 0) ||
1150 nla_put_u8(skb
, IFLA_BR_NF_CALL_ARPTABLES
,
1151 br
->nf_call_arptables
? 1 : 0))
1158 static size_t br_get_link_af_size(const struct net_device
*dev
)
1160 struct net_bridge_port
*p
;
1161 struct net_bridge
*br
;
1164 if (br_port_exists(dev
)) {
1165 p
= br_port_get_rtnl(dev
);
1166 num_vlans
= br_get_num_vlan_infos(nbp_vlan_group(p
),
1167 RTEXT_FILTER_BRVLAN
);
1168 } else if (dev
->priv_flags
& IFF_EBRIDGE
) {
1169 br
= netdev_priv(dev
);
1170 num_vlans
= br_get_num_vlan_infos(br_vlan_group(br
),
1171 RTEXT_FILTER_BRVLAN
);
1174 /* Each VLAN is returned in bridge_vlan_info along with flags */
1175 return num_vlans
* nla_total_size(sizeof(struct bridge_vlan_info
));
1178 static struct rtnl_af_ops br_af_ops __read_mostly
= {
1179 .family
= AF_BRIDGE
,
1180 .get_link_af_size
= br_get_link_af_size
,
1183 struct rtnl_link_ops br_link_ops __read_mostly
= {
1185 .priv_size
= sizeof(struct net_bridge
),
1186 .setup
= br_dev_setup
,
1187 .maxtype
= IFLA_BR_MAX
,
1188 .policy
= br_policy
,
1189 .validate
= br_validate
,
1190 .newlink
= br_dev_newlink
,
1191 .changelink
= br_changelink
,
1192 .dellink
= br_dev_delete
,
1193 .get_size
= br_get_size
,
1194 .fill_info
= br_fill_info
,
1196 .slave_maxtype
= IFLA_BRPORT_MAX
,
1197 .slave_policy
= br_port_policy
,
1198 .slave_changelink
= br_port_slave_changelink
,
1199 .get_slave_size
= br_port_get_slave_size
,
1200 .fill_slave_info
= br_port_fill_slave_info
,
1203 int __init
br_netlink_init(void)
1208 rtnl_af_register(&br_af_ops
);
1210 err
= rtnl_link_register(&br_link_ops
);
1217 rtnl_af_unregister(&br_af_ops
);
1222 void br_netlink_fini(void)
1225 rtnl_af_unregister(&br_af_ops
);
1226 rtnl_link_unregister(&br_link_ops
);