Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Bridge netlink control interface |
| 4 | * |
| 5 | * Authors: |
| 6 | * Stephen Hemminger <shemminger@osdl.org> |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 10 | #include <linux/slab.h> |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 11 | #include <linux/etherdevice.h> |
Thomas Graf | 32fe21c | 2007-03-22 11:59:03 -0700 | [diff] [blame] | 12 | #include <net/rtnetlink.h> |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 13 | #include <net/net_namespace.h> |
Denis V. Lunev | b854272 | 2007-12-01 00:21:31 +1100 | [diff] [blame] | 14 | #include <net/sock.h> |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 15 | #include <uapi/linux/if_bridge.h> |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 16 | |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 17 | #include "br_private.h" |
Vitalii Demianets | b03b6dd | 2011-11-25 00:16:37 +0000 | [diff] [blame] | 18 | #include "br_private_stp.h" |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 19 | #include "br_private_tunnel.h" |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 20 | |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 21 | static int __get_num_vlan_infos(struct net_bridge_vlan_group *vg, |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 22 | u32 filter_mask) |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 23 | { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 24 | struct net_bridge_vlan *v; |
| 25 | u16 vid_range_start = 0, vid_range_end = 0, vid_range_flags = 0; |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 26 | u16 flags, pvid; |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 27 | int num_vlans = 0; |
| 28 | |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 29 | if (!(filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED)) |
| 30 | return 0; |
| 31 | |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 32 | pvid = br_get_pvid(vg); |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 33 | /* Count number of vlan infos */ |
Nikolay Aleksandrov | 586c2b5 | 2015-10-02 15:05:10 +0200 | [diff] [blame] | 34 | list_for_each_entry_rcu(v, &vg->vlan_list, vlist) { |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 35 | flags = 0; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 36 | /* only a context, bridge vlan not activated */ |
| 37 | if (!br_vlan_should_use(v)) |
| 38 | continue; |
| 39 | if (v->vid == pvid) |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 40 | flags |= BRIDGE_VLAN_INFO_PVID; |
| 41 | |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 42 | if (v->flags & BRIDGE_VLAN_INFO_UNTAGGED) |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 43 | flags |= BRIDGE_VLAN_INFO_UNTAGGED; |
| 44 | |
| 45 | if (vid_range_start == 0) { |
| 46 | goto initvars; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 47 | } else if ((v->vid - vid_range_end) == 1 && |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 48 | flags == vid_range_flags) { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 49 | vid_range_end = v->vid; |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 50 | continue; |
| 51 | } else { |
| 52 | if ((vid_range_end - vid_range_start) > 0) |
| 53 | num_vlans += 2; |
| 54 | else |
| 55 | num_vlans += 1; |
| 56 | } |
| 57 | initvars: |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 58 | vid_range_start = v->vid; |
| 59 | vid_range_end = v->vid; |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 60 | vid_range_flags = flags; |
| 61 | } |
| 62 | |
| 63 | if (vid_range_start != 0) { |
| 64 | if ((vid_range_end - vid_range_start) > 0) |
| 65 | num_vlans += 2; |
| 66 | else |
| 67 | num_vlans += 1; |
| 68 | } |
| 69 | |
| 70 | return num_vlans; |
| 71 | } |
| 72 | |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 73 | static int br_get_num_vlan_infos(struct net_bridge_vlan_group *vg, |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 74 | u32 filter_mask) |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 75 | { |
Nikolay Aleksandrov | 586c2b5 | 2015-10-02 15:05:10 +0200 | [diff] [blame] | 76 | int num_vlans; |
| 77 | |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 78 | if (!vg) |
| 79 | return 0; |
| 80 | |
| 81 | if (filter_mask & RTEXT_FILTER_BRVLAN) |
| 82 | return vg->num_vlans; |
| 83 | |
Nikolay Aleksandrov | 586c2b5 | 2015-10-02 15:05:10 +0200 | [diff] [blame] | 84 | rcu_read_lock(); |
| 85 | num_vlans = __get_num_vlan_infos(vg, filter_mask); |
| 86 | rcu_read_unlock(); |
| 87 | |
| 88 | return num_vlans; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 89 | } |
| 90 | |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 91 | static size_t br_get_link_af_size_filtered(const struct net_device *dev, |
| 92 | u32 filter_mask) |
Roopa Prabhu | b7853d7 | 2015-02-21 20:21:51 -0800 | [diff] [blame] | 93 | { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 94 | struct net_bridge_vlan_group *vg = NULL; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 95 | struct net_bridge_port *p = NULL; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 96 | struct net_bridge *br; |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 97 | int num_vlan_infos; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 98 | size_t vinfo_sz = 0; |
Roopa Prabhu | b7853d7 | 2015-02-21 20:21:51 -0800 | [diff] [blame] | 99 | |
Johannes Berg | 2f56f6b | 2015-03-03 16:02:16 +0100 | [diff] [blame] | 100 | rcu_read_lock(); |
Julian Wiedmann | 35f861e | 2019-03-29 14:38:19 +0100 | [diff] [blame] | 101 | if (netif_is_bridge_port(dev)) { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 102 | p = br_port_get_rcu(dev); |
Nikolay Aleksandrov | 907b1e6 | 2015-10-12 21:47:02 +0200 | [diff] [blame] | 103 | vg = nbp_vlan_group_rcu(p); |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 104 | } else if (dev->priv_flags & IFF_EBRIDGE) { |
| 105 | br = netdev_priv(dev); |
Nikolay Aleksandrov | 907b1e6 | 2015-10-12 21:47:02 +0200 | [diff] [blame] | 106 | vg = br_vlan_group_rcu(br); |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 107 | } |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 108 | num_vlan_infos = br_get_num_vlan_infos(vg, filter_mask); |
Johannes Berg | 2f56f6b | 2015-03-03 16:02:16 +0100 | [diff] [blame] | 109 | rcu_read_unlock(); |
Roopa Prabhu | b7853d7 | 2015-02-21 20:21:51 -0800 | [diff] [blame] | 110 | |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 111 | if (p && (p->flags & BR_VLAN_TUNNEL)) |
| 112 | vinfo_sz += br_get_vlan_tunnel_info_size(vg); |
| 113 | |
Roopa Prabhu | b7853d7 | 2015-02-21 20:21:51 -0800 | [diff] [blame] | 114 | /* Each VLAN is returned in bridge_vlan_info along with flags */ |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 115 | vinfo_sz += num_vlan_infos * nla_total_size(sizeof(struct bridge_vlan_info)); |
| 116 | |
| 117 | return vinfo_sz; |
Roopa Prabhu | b7853d7 | 2015-02-21 20:21:51 -0800 | [diff] [blame] | 118 | } |
| 119 | |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 120 | static inline size_t br_port_info_size(void) |
| 121 | { |
| 122 | return nla_total_size(1) /* IFLA_BRPORT_STATE */ |
| 123 | + nla_total_size(2) /* IFLA_BRPORT_PRIORITY */ |
| 124 | + nla_total_size(4) /* IFLA_BRPORT_COST */ |
| 125 | + nla_total_size(1) /* IFLA_BRPORT_MODE */ |
stephen hemminger | a2e01a6 | 2012-11-13 07:53:07 +0000 | [diff] [blame] | 126 | + nla_total_size(1) /* IFLA_BRPORT_GUARD */ |
stephen hemminger | 1007dd1 | 2012-11-13 07:53:08 +0000 | [diff] [blame] | 127 | + nla_total_size(1) /* IFLA_BRPORT_PROTECT */ |
stephen hemminger | 3da889b | 2013-03-11 13:52:17 +0000 | [diff] [blame] | 128 | + nla_total_size(1) /* IFLA_BRPORT_FAST_LEAVE */ |
Felix Fietkau | 6db6f0e | 2017-01-21 21:01:32 +0100 | [diff] [blame] | 129 | + nla_total_size(1) /* IFLA_BRPORT_MCAST_TO_UCAST */ |
Vlad Yasevich | 9ba1889 | 2013-06-05 10:08:00 -0400 | [diff] [blame] | 130 | + nla_total_size(1) /* IFLA_BRPORT_LEARNING */ |
Vlad Yasevich | 867a594 | 2013-06-05 10:08:01 -0400 | [diff] [blame] | 131 | + nla_total_size(1) /* IFLA_BRPORT_UNICAST_FLOOD */ |
Tobias Klauser | 9051247 | 2017-05-05 16:36:53 +0200 | [diff] [blame] | 132 | + nla_total_size(1) /* IFLA_BRPORT_MCAST_FLOOD */ |
| 133 | + nla_total_size(1) /* IFLA_BRPORT_BCAST_FLOOD */ |
Nikolay Aleksandrov | 355b9f9 | 2015-08-04 19:06:32 +0200 | [diff] [blame] | 134 | + nla_total_size(1) /* IFLA_BRPORT_PROXYARP */ |
Nikolay Aleksandrov | 786c207 | 2015-08-04 19:06:33 +0200 | [diff] [blame] | 135 | + nla_total_size(1) /* IFLA_BRPORT_PROXYARP_WIFI */ |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 136 | + nla_total_size(1) /* IFLA_BRPORT_VLAN_TUNNEL */ |
Roopa Prabhu | 821f1b2 | 2017-10-06 22:12:37 -0700 | [diff] [blame] | 137 | + nla_total_size(1) /* IFLA_BRPORT_NEIGH_SUPPRESS */ |
Nikolay Aleksandrov | 7d850ab | 2018-05-24 11:56:48 +0300 | [diff] [blame] | 138 | + nla_total_size(1) /* IFLA_BRPORT_ISOLATED */ |
Nikolay Aleksandrov | 4ebc766 | 2015-10-06 14:11:55 +0200 | [diff] [blame] | 139 | + nla_total_size(sizeof(struct ifla_bridge_id)) /* IFLA_BRPORT_ROOT_ID */ |
Nikolay Aleksandrov | 80df9a2 | 2015-10-06 14:11:56 +0200 | [diff] [blame] | 140 | + nla_total_size(sizeof(struct ifla_bridge_id)) /* IFLA_BRPORT_BRIDGE_ID */ |
Nikolay Aleksandrov | 96f94e7 | 2015-10-06 14:11:57 +0200 | [diff] [blame] | 141 | + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_DESIGNATED_PORT */ |
| 142 | + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_DESIGNATED_COST */ |
Nikolay Aleksandrov | 42d452c | 2015-10-06 14:11:58 +0200 | [diff] [blame] | 143 | + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_ID */ |
| 144 | + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_NO */ |
Nikolay Aleksandrov | e08e838 | 2015-10-06 14:11:59 +0200 | [diff] [blame] | 145 | + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_TOPOLOGY_CHANGE_ACK */ |
| 146 | + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_CONFIG_PENDING */ |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 147 | + nla_total_size_64bit(sizeof(u64)) /* IFLA_BRPORT_MESSAGE_AGE_TIMER */ |
| 148 | + nla_total_size_64bit(sizeof(u64)) /* IFLA_BRPORT_FORWARD_DELAY_TIMER */ |
| 149 | + nla_total_size_64bit(sizeof(u64)) /* IFLA_BRPORT_HOLD_TIMER */ |
Nikolay Aleksandrov | 5d6ae47 | 2015-10-06 14:12:02 +0200 | [diff] [blame] | 150 | #ifdef CONFIG_BRIDGE_IGMP_SNOOPING |
| 151 | + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MULTICAST_ROUTER */ |
| 152 | #endif |
Nikolay Aleksandrov | 5af48b5 | 2017-09-27 16:12:44 +0300 | [diff] [blame] | 153 | + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_GROUP_FWD_MASK */ |
Horatiu Vultur | 3e54442 | 2020-04-26 15:22:01 +0200 | [diff] [blame] | 154 | + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MRP_RING_OPEN */ |
Horatiu Vultur | ffb3adb | 2020-07-14 09:34:58 +0200 | [diff] [blame] | 155 | + nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MRP_IN_OPEN */ |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 156 | + 0; |
| 157 | } |
| 158 | |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 159 | static inline size_t br_nlmsg_size(struct net_device *dev, u32 filter_mask) |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 160 | { |
| 161 | return NLMSG_ALIGN(sizeof(struct ifinfomsg)) |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 162 | + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */ |
| 163 | + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */ |
| 164 | + nla_total_size(4) /* IFLA_MASTER */ |
| 165 | + nla_total_size(4) /* IFLA_MTU */ |
| 166 | + nla_total_size(4) /* IFLA_LINK */ |
| 167 | + nla_total_size(1) /* IFLA_OPERSTATE */ |
Roopa Prabhu | b7853d7 | 2015-02-21 20:21:51 -0800 | [diff] [blame] | 168 | + nla_total_size(br_port_info_size()) /* IFLA_PROTINFO */ |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 169 | + nla_total_size(br_get_link_af_size_filtered(dev, |
Nikolay Aleksandrov | 2756f68 | 2018-07-23 11:16:59 +0300 | [diff] [blame] | 170 | filter_mask)) /* IFLA_AF_SPEC */ |
| 171 | + nla_total_size(4); /* IFLA_BRPORT_BACKUP_PORT */ |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | static int br_port_fill_attrs(struct sk_buff *skb, |
| 175 | const struct net_bridge_port *p) |
| 176 | { |
| 177 | u8 mode = !!(p->flags & BR_HAIRPIN_MODE); |
Nikolay Aleksandrov | 2756f68 | 2018-07-23 11:16:59 +0300 | [diff] [blame] | 178 | struct net_bridge_port *backup_p; |
Nikolay Aleksandrov | 61c0a9a | 2015-10-06 14:12:00 +0200 | [diff] [blame] | 179 | u64 timerval; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 180 | |
| 181 | if (nla_put_u8(skb, IFLA_BRPORT_STATE, p->state) || |
| 182 | nla_put_u16(skb, IFLA_BRPORT_PRIORITY, p->priority) || |
| 183 | nla_put_u32(skb, IFLA_BRPORT_COST, p->path_cost) || |
stephen hemminger | a2e01a6 | 2012-11-13 07:53:07 +0000 | [diff] [blame] | 184 | nla_put_u8(skb, IFLA_BRPORT_MODE, mode) || |
stephen hemminger | 1007dd1 | 2012-11-13 07:53:08 +0000 | [diff] [blame] | 185 | nla_put_u8(skb, IFLA_BRPORT_GUARD, !!(p->flags & BR_BPDU_GUARD)) || |
Nikolay Aleksandrov | b6cb5ac | 2016-08-31 15:36:52 +0200 | [diff] [blame] | 186 | nla_put_u8(skb, IFLA_BRPORT_PROTECT, |
| 187 | !!(p->flags & BR_ROOT_BLOCK)) || |
| 188 | nla_put_u8(skb, IFLA_BRPORT_FAST_LEAVE, |
| 189 | !!(p->flags & BR_MULTICAST_FAST_LEAVE)) || |
Felix Fietkau | 6db6f0e | 2017-01-21 21:01:32 +0100 | [diff] [blame] | 190 | nla_put_u8(skb, IFLA_BRPORT_MCAST_TO_UCAST, |
| 191 | !!(p->flags & BR_MULTICAST_TO_UNICAST)) || |
Vlad Yasevich | 867a594 | 2013-06-05 10:08:01 -0400 | [diff] [blame] | 192 | nla_put_u8(skb, IFLA_BRPORT_LEARNING, !!(p->flags & BR_LEARNING)) || |
Nikolay Aleksandrov | b6cb5ac | 2016-08-31 15:36:52 +0200 | [diff] [blame] | 193 | nla_put_u8(skb, IFLA_BRPORT_UNICAST_FLOOD, |
| 194 | !!(p->flags & BR_FLOOD)) || |
| 195 | nla_put_u8(skb, IFLA_BRPORT_MCAST_FLOOD, |
| 196 | !!(p->flags & BR_MCAST_FLOOD)) || |
Mike Manning | 99f906e | 2017-04-26 14:48:09 +0100 | [diff] [blame] | 197 | nla_put_u8(skb, IFLA_BRPORT_BCAST_FLOOD, |
| 198 | !!(p->flags & BR_BCAST_FLOOD)) || |
Jouni Malinen | 842a9ae | 2015-03-04 12:54:21 +0200 | [diff] [blame] | 199 | nla_put_u8(skb, IFLA_BRPORT_PROXYARP, !!(p->flags & BR_PROXYARP)) || |
| 200 | nla_put_u8(skb, IFLA_BRPORT_PROXYARP_WIFI, |
Nikolay Aleksandrov | 4ebc766 | 2015-10-06 14:11:55 +0200 | [diff] [blame] | 201 | !!(p->flags & BR_PROXYARP_WIFI)) || |
| 202 | nla_put(skb, IFLA_BRPORT_ROOT_ID, sizeof(struct ifla_bridge_id), |
Nikolay Aleksandrov | 80df9a2 | 2015-10-06 14:11:56 +0200 | [diff] [blame] | 203 | &p->designated_root) || |
| 204 | nla_put(skb, IFLA_BRPORT_BRIDGE_ID, sizeof(struct ifla_bridge_id), |
Nikolay Aleksandrov | 96f94e7 | 2015-10-06 14:11:57 +0200 | [diff] [blame] | 205 | &p->designated_bridge) || |
| 206 | nla_put_u16(skb, IFLA_BRPORT_DESIGNATED_PORT, p->designated_port) || |
Nikolay Aleksandrov | 42d452c | 2015-10-06 14:11:58 +0200 | [diff] [blame] | 207 | nla_put_u16(skb, IFLA_BRPORT_DESIGNATED_COST, p->designated_cost) || |
| 208 | nla_put_u16(skb, IFLA_BRPORT_ID, p->port_id) || |
Nikolay Aleksandrov | e08e838 | 2015-10-06 14:11:59 +0200 | [diff] [blame] | 209 | nla_put_u16(skb, IFLA_BRPORT_NO, p->port_no) || |
| 210 | nla_put_u8(skb, IFLA_BRPORT_TOPOLOGY_CHANGE_ACK, |
| 211 | p->topology_change_ack) || |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 212 | nla_put_u8(skb, IFLA_BRPORT_CONFIG_PENDING, p->config_pending) || |
| 213 | nla_put_u8(skb, IFLA_BRPORT_VLAN_TUNNEL, !!(p->flags & |
Nikolay Aleksandrov | 5af48b5 | 2017-09-27 16:12:44 +0300 | [diff] [blame] | 214 | BR_VLAN_TUNNEL)) || |
Roopa Prabhu | 821f1b2 | 2017-10-06 22:12:37 -0700 | [diff] [blame] | 215 | nla_put_u16(skb, IFLA_BRPORT_GROUP_FWD_MASK, p->group_fwd_mask) || |
| 216 | nla_put_u8(skb, IFLA_BRPORT_NEIGH_SUPPRESS, |
Nikolay Aleksandrov | 7d850ab | 2018-05-24 11:56:48 +0300 | [diff] [blame] | 217 | !!(p->flags & BR_NEIGH_SUPPRESS)) || |
Horatiu Vultur | 3e54442 | 2020-04-26 15:22:01 +0200 | [diff] [blame] | 218 | nla_put_u8(skb, IFLA_BRPORT_MRP_RING_OPEN, !!(p->flags & |
| 219 | BR_MRP_LOST_CONT)) || |
Horatiu Vultur | ffb3adb | 2020-07-14 09:34:58 +0200 | [diff] [blame] | 220 | nla_put_u8(skb, IFLA_BRPORT_MRP_IN_OPEN, |
| 221 | !!(p->flags & BR_MRP_LOST_IN_CONT)) || |
Nikolay Aleksandrov | 7d850ab | 2018-05-24 11:56:48 +0300 | [diff] [blame] | 222 | nla_put_u8(skb, IFLA_BRPORT_ISOLATED, !!(p->flags & BR_ISOLATED))) |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 223 | return -EMSGSIZE; |
| 224 | |
Nikolay Aleksandrov | 61c0a9a | 2015-10-06 14:12:00 +0200 | [diff] [blame] | 225 | timerval = br_timer_value(&p->message_age_timer); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 226 | if (nla_put_u64_64bit(skb, IFLA_BRPORT_MESSAGE_AGE_TIMER, timerval, |
| 227 | IFLA_BRPORT_PAD)) |
Nikolay Aleksandrov | 61c0a9a | 2015-10-06 14:12:00 +0200 | [diff] [blame] | 228 | return -EMSGSIZE; |
| 229 | timerval = br_timer_value(&p->forward_delay_timer); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 230 | if (nla_put_u64_64bit(skb, IFLA_BRPORT_FORWARD_DELAY_TIMER, timerval, |
| 231 | IFLA_BRPORT_PAD)) |
Nikolay Aleksandrov | 61c0a9a | 2015-10-06 14:12:00 +0200 | [diff] [blame] | 232 | return -EMSGSIZE; |
| 233 | timerval = br_timer_value(&p->hold_timer); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 234 | if (nla_put_u64_64bit(skb, IFLA_BRPORT_HOLD_TIMER, timerval, |
| 235 | IFLA_BRPORT_PAD)) |
Nikolay Aleksandrov | 61c0a9a | 2015-10-06 14:12:00 +0200 | [diff] [blame] | 236 | return -EMSGSIZE; |
| 237 | |
Nikolay Aleksandrov | 5d6ae47 | 2015-10-06 14:12:02 +0200 | [diff] [blame] | 238 | #ifdef CONFIG_BRIDGE_IGMP_SNOOPING |
| 239 | if (nla_put_u8(skb, IFLA_BRPORT_MULTICAST_ROUTER, |
| 240 | p->multicast_router)) |
| 241 | return -EMSGSIZE; |
| 242 | #endif |
| 243 | |
Nikolay Aleksandrov | 2756f68 | 2018-07-23 11:16:59 +0300 | [diff] [blame] | 244 | /* we might be called only with br->lock */ |
| 245 | rcu_read_lock(); |
| 246 | backup_p = rcu_dereference(p->backup_port); |
| 247 | if (backup_p) |
| 248 | nla_put_u32(skb, IFLA_BRPORT_BACKUP_PORT, |
| 249 | backup_p->dev->ifindex); |
| 250 | rcu_read_unlock(); |
| 251 | |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 252 | return 0; |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 253 | } |
| 254 | |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 255 | static int br_fill_ifvlaninfo_range(struct sk_buff *skb, u16 vid_start, |
| 256 | u16 vid_end, u16 flags) |
| 257 | { |
| 258 | struct bridge_vlan_info vinfo; |
| 259 | |
| 260 | if ((vid_end - vid_start) > 0) { |
| 261 | /* add range to skb */ |
| 262 | vinfo.vid = vid_start; |
| 263 | vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_BEGIN; |
| 264 | if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO, |
| 265 | sizeof(vinfo), &vinfo)) |
| 266 | goto nla_put_failure; |
| 267 | |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 268 | vinfo.vid = vid_end; |
| 269 | vinfo.flags = flags | BRIDGE_VLAN_INFO_RANGE_END; |
| 270 | if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO, |
| 271 | sizeof(vinfo), &vinfo)) |
| 272 | goto nla_put_failure; |
| 273 | } else { |
| 274 | vinfo.vid = vid_start; |
| 275 | vinfo.flags = flags; |
| 276 | if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO, |
| 277 | sizeof(vinfo), &vinfo)) |
| 278 | goto nla_put_failure; |
| 279 | } |
| 280 | |
| 281 | return 0; |
| 282 | |
| 283 | nla_put_failure: |
| 284 | return -EMSGSIZE; |
| 285 | } |
| 286 | |
| 287 | static int br_fill_ifvlaninfo_compressed(struct sk_buff *skb, |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 288 | struct net_bridge_vlan_group *vg) |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 289 | { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 290 | struct net_bridge_vlan *v; |
| 291 | u16 vid_range_start = 0, vid_range_end = 0, vid_range_flags = 0; |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 292 | u16 flags, pvid; |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 293 | int err = 0; |
| 294 | |
| 295 | /* Pack IFLA_BRIDGE_VLAN_INFO's for every vlan |
| 296 | * and mark vlan info with begin and end flags |
| 297 | * if vlaninfo represents a range |
| 298 | */ |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 299 | pvid = br_get_pvid(vg); |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 300 | list_for_each_entry_rcu(v, &vg->vlan_list, vlist) { |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 301 | flags = 0; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 302 | if (!br_vlan_should_use(v)) |
| 303 | continue; |
| 304 | if (v->vid == pvid) |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 305 | flags |= BRIDGE_VLAN_INFO_PVID; |
| 306 | |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 307 | if (v->flags & BRIDGE_VLAN_INFO_UNTAGGED) |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 308 | flags |= BRIDGE_VLAN_INFO_UNTAGGED; |
| 309 | |
| 310 | if (vid_range_start == 0) { |
| 311 | goto initvars; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 312 | } else if ((v->vid - vid_range_end) == 1 && |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 313 | flags == vid_range_flags) { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 314 | vid_range_end = v->vid; |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 315 | continue; |
| 316 | } else { |
| 317 | err = br_fill_ifvlaninfo_range(skb, vid_range_start, |
| 318 | vid_range_end, |
| 319 | vid_range_flags); |
| 320 | if (err) |
| 321 | return err; |
| 322 | } |
| 323 | |
| 324 | initvars: |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 325 | vid_range_start = v->vid; |
| 326 | vid_range_end = v->vid; |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 327 | vid_range_flags = flags; |
| 328 | } |
| 329 | |
Roopa Prabhu | 0fe6de4 | 2015-01-12 16:25:28 -0800 | [diff] [blame] | 330 | if (vid_range_start != 0) { |
| 331 | /* Call it once more to send any left over vlans */ |
| 332 | err = br_fill_ifvlaninfo_range(skb, vid_range_start, |
| 333 | vid_range_end, |
| 334 | vid_range_flags); |
| 335 | if (err) |
| 336 | return err; |
| 337 | } |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 338 | |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | static int br_fill_ifvlaninfo(struct sk_buff *skb, |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 343 | struct net_bridge_vlan_group *vg) |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 344 | { |
| 345 | struct bridge_vlan_info vinfo; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 346 | struct net_bridge_vlan *v; |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 347 | u16 pvid; |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 348 | |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 349 | pvid = br_get_pvid(vg); |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 350 | list_for_each_entry_rcu(v, &vg->vlan_list, vlist) { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 351 | if (!br_vlan_should_use(v)) |
| 352 | continue; |
| 353 | |
| 354 | vinfo.vid = v->vid; |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 355 | vinfo.flags = 0; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 356 | if (v->vid == pvid) |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 357 | vinfo.flags |= BRIDGE_VLAN_INFO_PVID; |
| 358 | |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 359 | if (v->flags & BRIDGE_VLAN_INFO_UNTAGGED) |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 360 | vinfo.flags |= BRIDGE_VLAN_INFO_UNTAGGED; |
| 361 | |
| 362 | if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO, |
| 363 | sizeof(vinfo), &vinfo)) |
| 364 | goto nla_put_failure; |
| 365 | } |
| 366 | |
| 367 | return 0; |
| 368 | |
| 369 | nla_put_failure: |
| 370 | return -EMSGSIZE; |
| 371 | } |
| 372 | |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 373 | /* |
| 374 | * Create one netlink message for one interface |
| 375 | * Contains port and master info as well as carrier and bridge state. |
| 376 | */ |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 377 | static int br_fill_ifinfo(struct sk_buff *skb, |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 378 | const struct net_bridge_port *port, |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 379 | u32 pid, u32 seq, int event, unsigned int flags, |
| 380 | u32 filter_mask, const struct net_device *dev) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 381 | { |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 382 | u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN; |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 383 | struct net_bridge *br; |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 384 | struct ifinfomsg *hdr; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 385 | struct nlmsghdr *nlh; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 386 | |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 387 | if (port) |
| 388 | br = port->br; |
| 389 | else |
| 390 | br = netdev_priv(dev); |
| 391 | |
stephen hemminger | 28a16c9 | 2010-05-10 09:31:09 +0000 | [diff] [blame] | 392 | br_debug(br, "br_fill_info event %d port %s master %s\n", |
| 393 | event, dev->name, br->dev->name); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 394 | |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 395 | nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags); |
| 396 | if (nlh == NULL) |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 397 | return -EMSGSIZE; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 398 | |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 399 | hdr = nlmsg_data(nlh); |
| 400 | hdr->ifi_family = AF_BRIDGE; |
| 401 | hdr->__ifi_pad = 0; |
| 402 | hdr->ifi_type = dev->type; |
| 403 | hdr->ifi_index = dev->ifindex; |
| 404 | hdr->ifi_flags = dev_get_flags(dev); |
| 405 | hdr->ifi_change = 0; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 406 | |
David S. Miller | 2eb812e | 2012-04-01 20:49:54 -0400 | [diff] [blame] | 407 | if (nla_put_string(skb, IFLA_IFNAME, dev->name) || |
| 408 | nla_put_u32(skb, IFLA_MASTER, br->dev->ifindex) || |
| 409 | nla_put_u32(skb, IFLA_MTU, dev->mtu) || |
| 410 | nla_put_u8(skb, IFLA_OPERSTATE, operstate) || |
| 411 | (dev->addr_len && |
| 412 | nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || |
Nicolas Dichtel | a54acb3 | 2015-04-02 17:07:00 +0200 | [diff] [blame] | 413 | (dev->ifindex != dev_get_iflink(dev) && |
| 414 | nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev)))) |
David S. Miller | 2eb812e | 2012-04-01 20:49:54 -0400 | [diff] [blame] | 415 | goto nla_put_failure; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 416 | |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 417 | if (event == RTM_NEWLINK && port) { |
Michal Kubecek | f78c603 | 2019-04-26 11:13:12 +0200 | [diff] [blame] | 418 | struct nlattr *nest; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 419 | |
Michal Kubecek | f78c603 | 2019-04-26 11:13:12 +0200 | [diff] [blame] | 420 | nest = nla_nest_start(skb, IFLA_PROTINFO); |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 421 | if (nest == NULL || br_port_fill_attrs(skb, port) < 0) |
| 422 | goto nla_put_failure; |
| 423 | nla_nest_end(skb, nest); |
| 424 | } |
| 425 | |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 426 | /* Check if the VID information is requested */ |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 427 | if ((filter_mask & RTEXT_FILTER_BRVLAN) || |
| 428 | (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED)) { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 429 | struct net_bridge_vlan_group *vg; |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 430 | struct nlattr *af; |
| 431 | int err; |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 432 | |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 433 | /* RCU needed because of the VLAN locking rules (rcu || rtnl) */ |
| 434 | rcu_read_lock(); |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 435 | if (port) |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 436 | vg = nbp_vlan_group_rcu(port); |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 437 | else |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 438 | vg = br_vlan_group_rcu(br); |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 439 | |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 440 | if (!vg || !vg->num_vlans) { |
| 441 | rcu_read_unlock(); |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 442 | goto done; |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 443 | } |
Michal Kubecek | ae0be8d | 2019-04-26 11:13:06 +0200 | [diff] [blame] | 444 | af = nla_nest_start_noflag(skb, IFLA_AF_SPEC); |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 445 | if (!af) { |
| 446 | rcu_read_unlock(); |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 447 | goto nla_put_failure; |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 448 | } |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 449 | if (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED) |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 450 | err = br_fill_ifvlaninfo_compressed(skb, vg); |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 451 | else |
Nikolay Aleksandrov | 77751ee | 2015-09-30 20:16:53 +0200 | [diff] [blame] | 452 | err = br_fill_ifvlaninfo(skb, vg); |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 453 | |
| 454 | if (port && (port->flags & BR_VLAN_TUNNEL)) |
| 455 | err = br_fill_vlan_tunnel_info(skb, vg); |
Nikolay Aleksandrov | e9c953e | 2015-10-12 21:47:03 +0200 | [diff] [blame] | 456 | rcu_read_unlock(); |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 457 | if (err) |
| 458 | goto nla_put_failure; |
Horatiu Vultur | 36a8e8e | 2020-07-02 10:13:07 +0200 | [diff] [blame] | 459 | |
| 460 | nla_nest_end(skb, af); |
| 461 | } |
| 462 | |
| 463 | if (filter_mask & RTEXT_FILTER_MRP) { |
| 464 | struct nlattr *af; |
| 465 | int err; |
| 466 | |
| 467 | if (!br_mrp_enabled(br) || port) |
| 468 | goto done; |
| 469 | |
| 470 | af = nla_nest_start_noflag(skb, IFLA_AF_SPEC); |
| 471 | if (!af) |
| 472 | goto nla_put_failure; |
| 473 | |
| 474 | rcu_read_lock(); |
| 475 | err = br_mrp_fill_info(skb, br); |
| 476 | rcu_read_unlock(); |
| 477 | |
| 478 | if (err) |
| 479 | goto nla_put_failure; |
| 480 | |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 481 | nla_nest_end(skb, af); |
| 482 | } |
| 483 | |
| 484 | done: |
Johannes Berg | 053c095 | 2015-01-16 22:09:00 +0100 | [diff] [blame] | 485 | nlmsg_end(skb, nlh); |
| 486 | return 0; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 487 | |
Thomas Graf | 7468596 | 2006-11-20 16:20:22 -0800 | [diff] [blame] | 488 | nla_put_failure: |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 489 | nlmsg_cancel(skb, nlh); |
| 490 | return -EMSGSIZE; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 491 | } |
| 492 | |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 493 | /* Notify listeners of a change in bridge or port information */ |
| 494 | void br_ifinfo_notify(int event, const struct net_bridge *br, |
| 495 | const struct net_bridge_port *port) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 496 | { |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 497 | u32 filter = RTEXT_FILTER_BRVLAN_COMPRESSED; |
| 498 | struct net_device *dev; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 499 | struct sk_buff *skb; |
Thomas Graf | 280a306 | 2006-08-15 00:36:28 -0700 | [diff] [blame] | 500 | int err = -ENOBUFS; |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 501 | struct net *net; |
| 502 | u16 port_no = 0; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 503 | |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 504 | if (WARN_ON(!port && !br)) |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 505 | return; |
| 506 | |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 507 | if (port) { |
| 508 | dev = port->dev; |
| 509 | br = port->br; |
| 510 | port_no = port->port_no; |
| 511 | } else { |
| 512 | dev = br->dev; |
| 513 | } |
stephen hemminger | 28a16c9 | 2010-05-10 09:31:09 +0000 | [diff] [blame] | 514 | |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 515 | net = dev_net(dev); |
| 516 | br_debug(br, "port %u(%s) event %d\n", port_no, dev->name, event); |
| 517 | |
| 518 | skb = nlmsg_new(br_nlmsg_size(dev, filter), GFP_ATOMIC); |
Thomas Graf | 280a306 | 2006-08-15 00:36:28 -0700 | [diff] [blame] | 519 | if (skb == NULL) |
| 520 | goto errout; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 521 | |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 522 | err = br_fill_ifinfo(skb, port, 0, 0, event, 0, filter, dev); |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 523 | if (err < 0) { |
| 524 | /* -EMSGSIZE implies BUG in br_nlmsg_size() */ |
| 525 | WARN_ON(err == -EMSGSIZE); |
| 526 | kfree_skb(skb); |
| 527 | goto errout; |
| 528 | } |
Pablo Neira Ayuso | 1ce85fe | 2009-02-24 23:18:28 -0800 | [diff] [blame] | 529 | rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); |
| 530 | return; |
Thomas Graf | 280a306 | 2006-08-15 00:36:28 -0700 | [diff] [blame] | 531 | errout: |
tanxiaojun | 87e823b | 2013-12-19 13:28:10 +0800 | [diff] [blame] | 532 | rtnl_set_sk_err(net, RTNLGRP_LINK, err); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | /* |
| 536 | * Dump information about all ports, in response to GETLINK |
| 537 | */ |
John Fastabend | e5a55a8 | 2012-10-24 08:12:57 +0000 | [diff] [blame] | 538 | int br_getlink(struct sk_buff *skb, u32 pid, u32 seq, |
Nicolas Dichtel | 46c264d | 2015-04-28 18:33:49 +0200 | [diff] [blame] | 539 | struct net_device *dev, u32 filter_mask, int nlflags) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 540 | { |
Hong Zhiguo | 1fb1754 | 2013-09-14 22:42:27 +0800 | [diff] [blame] | 541 | struct net_bridge_port *port = br_port_get_rtnl(dev); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 542 | |
Roopa Prabhu | 36cd0ff | 2015-01-10 07:31:14 -0800 | [diff] [blame] | 543 | if (!port && !(filter_mask & RTEXT_FILTER_BRVLAN) && |
Horatiu Vultur | 36a8e8e | 2020-07-02 10:13:07 +0200 | [diff] [blame] | 544 | !(filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED) && |
| 545 | !(filter_mask & RTEXT_FILTER_MRP)) |
Dan Carpenter | 1b846f9 | 2015-01-21 12:22:35 +0300 | [diff] [blame] | 546 | return 0; |
stephen hemminger | b5ed54e | 2010-11-15 06:38:13 +0000 | [diff] [blame] | 547 | |
Nicolas Dichtel | 46c264d | 2015-04-28 18:33:49 +0200 | [diff] [blame] | 548 | return br_fill_ifinfo(skb, port, pid, seq, RTM_NEWLINK, nlflags, |
Dan Carpenter | 1b846f9 | 2015-01-21 12:22:35 +0300 | [diff] [blame] | 549 | filter_mask, dev); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 550 | } |
| 551 | |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 552 | static int br_vlan_info(struct net_bridge *br, struct net_bridge_port *p, |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 553 | int cmd, struct bridge_vlan_info *vinfo, bool *changed, |
| 554 | struct netlink_ext_ack *extack) |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 555 | { |
Nikolay Aleksandrov | f418af6 | 2017-10-27 13:19:37 +0300 | [diff] [blame] | 556 | bool curr_change; |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 557 | int err = 0; |
| 558 | |
| 559 | switch (cmd) { |
| 560 | case RTM_SETLINK: |
| 561 | if (p) { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 562 | /* if the MASTER flag is set this will act on the global |
| 563 | * per-VLAN entry as well |
| 564 | */ |
Nikolay Aleksandrov | f418af6 | 2017-10-27 13:19:37 +0300 | [diff] [blame] | 565 | err = nbp_vlan_add(p, vinfo->vid, vinfo->flags, |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 566 | &curr_change, extack); |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 567 | } else { |
Nikolay Aleksandrov | 2594e906 | 2015-09-25 19:00:11 +0200 | [diff] [blame] | 568 | vinfo->flags |= BRIDGE_VLAN_INFO_BRENTRY; |
Nikolay Aleksandrov | f418af6 | 2017-10-27 13:19:37 +0300 | [diff] [blame] | 569 | err = br_vlan_add(br, vinfo->vid, vinfo->flags, |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 570 | &curr_change, extack); |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 571 | } |
Nikolay Aleksandrov | f418af6 | 2017-10-27 13:19:37 +0300 | [diff] [blame] | 572 | if (curr_change) |
Nikolay Aleksandrov | e19b42a | 2017-10-27 13:19:36 +0300 | [diff] [blame] | 573 | *changed = true; |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 574 | break; |
| 575 | |
| 576 | case RTM_DELLINK: |
| 577 | if (p) { |
Nikolay Aleksandrov | e19b42a | 2017-10-27 13:19:36 +0300 | [diff] [blame] | 578 | if (!nbp_vlan_delete(p, vinfo->vid)) |
| 579 | *changed = true; |
| 580 | |
| 581 | if ((vinfo->flags & BRIDGE_VLAN_INFO_MASTER) && |
| 582 | !br_vlan_delete(p->br, vinfo->vid)) |
| 583 | *changed = true; |
| 584 | } else if (!br_vlan_delete(br, vinfo->vid)) { |
| 585 | *changed = true; |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 586 | } |
| 587 | break; |
| 588 | } |
| 589 | |
| 590 | return err; |
| 591 | } |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 592 | |
Nikolay Aleksandrov | f26b296 | 2020-01-14 19:56:10 +0200 | [diff] [blame] | 593 | int br_process_vlan_info(struct net_bridge *br, |
| 594 | struct net_bridge_port *p, int cmd, |
| 595 | struct bridge_vlan_info *vinfo_curr, |
| 596 | struct bridge_vlan_info **vinfo_last, |
| 597 | bool *changed, |
| 598 | struct netlink_ext_ack *extack) |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 599 | { |
Nikolay Aleksandrov | f545923 | 2020-01-14 19:56:14 +0200 | [diff] [blame] | 600 | int err, rtm_cmd; |
| 601 | |
Nikolay Aleksandrov | 8f4cc94 | 2020-01-14 19:56:08 +0200 | [diff] [blame] | 602 | if (!br_vlan_valid_id(vinfo_curr->vid, extack)) |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 603 | return -EINVAL; |
| 604 | |
Nikolay Aleksandrov | f545923 | 2020-01-14 19:56:14 +0200 | [diff] [blame] | 605 | /* needed for vlan-only NEWVLAN/DELVLAN notifications */ |
| 606 | rtm_cmd = br_afspec_cmd_to_rtm(cmd); |
| 607 | |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 608 | if (vinfo_curr->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { |
Nikolay Aleksandrov | 8f4cc94 | 2020-01-14 19:56:08 +0200 | [diff] [blame] | 609 | if (!br_vlan_valid_range(vinfo_curr, *vinfo_last, extack)) |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 610 | return -EINVAL; |
| 611 | *vinfo_last = vinfo_curr; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 612 | return 0; |
| 613 | } |
| 614 | |
| 615 | if (*vinfo_last) { |
| 616 | struct bridge_vlan_info tmp_vinfo; |
Nikolay Aleksandrov | f545923 | 2020-01-14 19:56:14 +0200 | [diff] [blame] | 617 | int v, v_change_start = 0; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 618 | |
Nikolay Aleksandrov | 8f4cc94 | 2020-01-14 19:56:08 +0200 | [diff] [blame] | 619 | if (!br_vlan_valid_range(vinfo_curr, *vinfo_last, extack)) |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 620 | return -EINVAL; |
| 621 | |
| 622 | memcpy(&tmp_vinfo, *vinfo_last, |
| 623 | sizeof(struct bridge_vlan_info)); |
| 624 | for (v = (*vinfo_last)->vid; v <= vinfo_curr->vid; v++) { |
Nikolay Aleksandrov | f545923 | 2020-01-14 19:56:14 +0200 | [diff] [blame] | 625 | bool curr_change = false; |
| 626 | |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 627 | tmp_vinfo.vid = v; |
Nikolay Aleksandrov | f545923 | 2020-01-14 19:56:14 +0200 | [diff] [blame] | 628 | err = br_vlan_info(br, p, cmd, &tmp_vinfo, &curr_change, |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 629 | extack); |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 630 | if (err) |
| 631 | break; |
Nikolay Aleksandrov | f545923 | 2020-01-14 19:56:14 +0200 | [diff] [blame] | 632 | if (curr_change) { |
| 633 | *changed = curr_change; |
| 634 | if (!v_change_start) |
| 635 | v_change_start = v; |
| 636 | } else { |
| 637 | /* nothing to notify yet */ |
| 638 | if (!v_change_start) |
| 639 | continue; |
| 640 | br_vlan_notify(br, p, v_change_start, |
| 641 | v - 1, rtm_cmd); |
| 642 | v_change_start = 0; |
| 643 | } |
Ido Schimmel | 7979457 | 2020-04-30 22:38:45 +0300 | [diff] [blame] | 644 | cond_resched(); |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 645 | } |
Nikolay Aleksandrov | f545923 | 2020-01-14 19:56:14 +0200 | [diff] [blame] | 646 | /* v_change_start is set only if the last/whole range changed */ |
| 647 | if (v_change_start) |
| 648 | br_vlan_notify(br, p, v_change_start, |
| 649 | v - 1, rtm_cmd); |
| 650 | |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 651 | *vinfo_last = NULL; |
| 652 | |
Nikolay Aleksandrov | 66c5451 | 2017-10-19 20:17:32 +0300 | [diff] [blame] | 653 | return err; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 654 | } |
| 655 | |
Nikolay Aleksandrov | f545923 | 2020-01-14 19:56:14 +0200 | [diff] [blame] | 656 | err = br_vlan_info(br, p, cmd, vinfo_curr, changed, extack); |
| 657 | if (*changed) |
| 658 | br_vlan_notify(br, p, vinfo_curr->vid, 0, rtm_cmd); |
| 659 | |
| 660 | return err; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 661 | } |
| 662 | |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 663 | static int br_afspec(struct net_bridge *br, |
| 664 | struct net_bridge_port *p, |
| 665 | struct nlattr *af_spec, |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 666 | int cmd, bool *changed, |
| 667 | struct netlink_ext_ack *extack) |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 668 | { |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 669 | struct bridge_vlan_info *vinfo_curr = NULL; |
| 670 | struct bridge_vlan_info *vinfo_last = NULL; |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 671 | struct nlattr *attr; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 672 | struct vtunnel_info tinfo_last = {}; |
| 673 | struct vtunnel_info tinfo_curr = {}; |
| 674 | int err = 0, rem; |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 675 | |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 676 | nla_for_each_nested(attr, af_spec, rem) { |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 677 | err = 0; |
| 678 | switch (nla_type(attr)) { |
| 679 | case IFLA_BRIDGE_VLAN_TUNNEL_INFO: |
Nikolay Aleksandrov | 1020ce3 | 2017-06-06 01:26:24 +0300 | [diff] [blame] | 680 | if (!p || !(p->flags & BR_VLAN_TUNNEL)) |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 681 | return -EINVAL; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 682 | err = br_parse_vlan_tunnel_info(attr, &tinfo_curr); |
| 683 | if (err) |
| 684 | return err; |
| 685 | err = br_process_vlan_tunnel_info(br, p, cmd, |
| 686 | &tinfo_curr, |
Nikolay Aleksandrov | e19b42a | 2017-10-27 13:19:36 +0300 | [diff] [blame] | 687 | &tinfo_last, |
| 688 | changed); |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 689 | if (err) |
| 690 | return err; |
Roopa Prabhu | bdced7e | 2015-01-10 07:31:12 -0800 | [diff] [blame] | 691 | break; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 692 | case IFLA_BRIDGE_VLAN_INFO: |
| 693 | if (nla_len(attr) != sizeof(struct bridge_vlan_info)) |
| 694 | return -EINVAL; |
| 695 | vinfo_curr = nla_data(attr); |
| 696 | err = br_process_vlan_info(br, p, cmd, vinfo_curr, |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 697 | &vinfo_last, changed, |
| 698 | extack); |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 699 | if (err) |
| 700 | return err; |
| 701 | break; |
Horatiu Vultur | 6536993 | 2020-04-26 15:22:07 +0200 | [diff] [blame] | 702 | case IFLA_BRIDGE_MRP: |
| 703 | err = br_mrp_parse(br, p, attr, cmd, extack); |
| 704 | if (err) |
| 705 | return err; |
| 706 | break; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 707 | } |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | return err; |
| 711 | } |
| 712 | |
Jiri Pirko | 3ac636b | 2014-09-05 15:51:30 +0200 | [diff] [blame] | 713 | static const struct nla_policy br_port_policy[IFLA_BRPORT_MAX + 1] = { |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 714 | [IFLA_BRPORT_STATE] = { .type = NLA_U8 }, |
| 715 | [IFLA_BRPORT_COST] = { .type = NLA_U32 }, |
| 716 | [IFLA_BRPORT_PRIORITY] = { .type = NLA_U16 }, |
| 717 | [IFLA_BRPORT_MODE] = { .type = NLA_U8 }, |
stephen hemminger | a2e01a6 | 2012-11-13 07:53:07 +0000 | [diff] [blame] | 718 | [IFLA_BRPORT_GUARD] = { .type = NLA_U8 }, |
stephen hemminger | 1007dd1 | 2012-11-13 07:53:08 +0000 | [diff] [blame] | 719 | [IFLA_BRPORT_PROTECT] = { .type = NLA_U8 }, |
Thomas Graf | 6f705d8 | 2014-11-26 13:42:19 +0100 | [diff] [blame] | 720 | [IFLA_BRPORT_FAST_LEAVE]= { .type = NLA_U8 }, |
Vlad Yasevich | 9ba1889 | 2013-06-05 10:08:00 -0400 | [diff] [blame] | 721 | [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 }, |
Vlad Yasevich | 867a594 | 2013-06-05 10:08:01 -0400 | [diff] [blame] | 722 | [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 355b9f9 | 2015-08-04 19:06:32 +0200 | [diff] [blame] | 723 | [IFLA_BRPORT_PROXYARP] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 786c207 | 2015-08-04 19:06:33 +0200 | [diff] [blame] | 724 | [IFLA_BRPORT_PROXYARP_WIFI] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 5d6ae47 | 2015-10-06 14:12:02 +0200 | [diff] [blame] | 725 | [IFLA_BRPORT_MULTICAST_ROUTER] = { .type = NLA_U8 }, |
Felix Fietkau | 6db6f0e | 2017-01-21 21:01:32 +0100 | [diff] [blame] | 726 | [IFLA_BRPORT_MCAST_TO_UCAST] = { .type = NLA_U8 }, |
Tobias Klauser | 9051247 | 2017-05-05 16:36:53 +0200 | [diff] [blame] | 727 | [IFLA_BRPORT_MCAST_FLOOD] = { .type = NLA_U8 }, |
| 728 | [IFLA_BRPORT_BCAST_FLOOD] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | fbec443 | 2017-11-13 18:30:55 +0200 | [diff] [blame] | 729 | [IFLA_BRPORT_VLAN_TUNNEL] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 5af48b5 | 2017-09-27 16:12:44 +0300 | [diff] [blame] | 730 | [IFLA_BRPORT_GROUP_FWD_MASK] = { .type = NLA_U16 }, |
Nikolay Aleksandrov | 1a3fbd3 | 2017-10-30 12:56:33 +0200 | [diff] [blame] | 731 | [IFLA_BRPORT_NEIGH_SUPPRESS] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 7d850ab | 2018-05-24 11:56:48 +0300 | [diff] [blame] | 732 | [IFLA_BRPORT_ISOLATED] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 2756f68 | 2018-07-23 11:16:59 +0300 | [diff] [blame] | 733 | [IFLA_BRPORT_BACKUP_PORT] = { .type = NLA_U32 }, |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 734 | }; |
| 735 | |
| 736 | /* Change the state of the port and notify spanning tree */ |
| 737 | 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] | 738 | { |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 739 | if (state > BR_STATE_BLOCKING) |
stephen hemminger | b5ed54e | 2010-11-15 06:38:13 +0000 | [diff] [blame] | 740 | return -EINVAL; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 741 | |
| 742 | /* if kernel STP is running, don't allow changes */ |
Stephen Hemminger | 9cde070 | 2007-03-21 14:22:44 -0700 | [diff] [blame] | 743 | if (p->br->stp_enabled == BR_KERNEL_STP) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 744 | return -EBUSY; |
| 745 | |
stephen hemminger | 576eb62 | 2012-12-28 18:15:22 +0000 | [diff] [blame] | 746 | /* if device is not up, change is not allowed |
| 747 | * if link is not present, only allowable state is disabled |
| 748 | */ |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 749 | if (!netif_running(p->dev) || |
stephen hemminger | 576eb62 | 2012-12-28 18:15:22 +0000 | [diff] [blame] | 750 | (!netif_oper_up(p->dev) && state != BR_STATE_DISABLED)) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 751 | return -ENETDOWN; |
| 752 | |
Florian Fainelli | 775dd69 | 2014-09-30 16:13:19 -0700 | [diff] [blame] | 753 | br_set_state(p, state); |
Vitalii Demianets | b03b6dd | 2011-11-25 00:16:37 +0000 | [diff] [blame] | 754 | br_port_state_selection(p->br); |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 755 | return 0; |
| 756 | } |
| 757 | |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 758 | /* Set/clear or port flags based on attribute */ |
Arkadi Sharshevsky | 3922285 | 2017-06-08 08:44:11 +0200 | [diff] [blame] | 759 | static int br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[], |
| 760 | int attrtype, unsigned long mask) |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 761 | { |
Arkadi Sharshevsky | 3922285 | 2017-06-08 08:44:11 +0200 | [diff] [blame] | 762 | unsigned long flags; |
| 763 | int err; |
| 764 | |
| 765 | if (!tb[attrtype]) |
| 766 | return 0; |
| 767 | |
| 768 | if (nla_get_u8(tb[attrtype])) |
| 769 | flags = p->flags | mask; |
| 770 | else |
| 771 | flags = p->flags & ~mask; |
| 772 | |
| 773 | err = br_switchdev_set_port_flag(p, flags, mask); |
| 774 | if (err) |
| 775 | return err; |
| 776 | |
| 777 | p->flags = flags; |
| 778 | return 0; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | /* Process bridge protocol info on port */ |
| 782 | static int br_setport(struct net_bridge_port *p, struct nlattr *tb[]) |
| 783 | { |
Vlad Yasevich | e028e4b | 2014-05-16 09:59:16 -0400 | [diff] [blame] | 784 | unsigned long old_flags = p->flags; |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 785 | bool br_vlan_tunnel_old = false; |
| 786 | int err; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 787 | |
Arkadi Sharshevsky | 3922285 | 2017-06-08 08:44:11 +0200 | [diff] [blame] | 788 | err = br_set_port_flag(p, tb, IFLA_BRPORT_MODE, BR_HAIRPIN_MODE); |
| 789 | if (err) |
| 790 | return err; |
| 791 | |
| 792 | err = br_set_port_flag(p, tb, IFLA_BRPORT_GUARD, BR_BPDU_GUARD); |
| 793 | if (err) |
| 794 | return err; |
| 795 | |
| 796 | err = br_set_port_flag(p, tb, IFLA_BRPORT_FAST_LEAVE, BR_MULTICAST_FAST_LEAVE); |
| 797 | if (err) |
| 798 | return err; |
| 799 | |
| 800 | err = br_set_port_flag(p, tb, IFLA_BRPORT_PROTECT, BR_ROOT_BLOCK); |
| 801 | if (err) |
| 802 | return err; |
| 803 | |
| 804 | err = br_set_port_flag(p, tb, IFLA_BRPORT_LEARNING, BR_LEARNING); |
| 805 | if (err) |
| 806 | return err; |
| 807 | |
| 808 | err = br_set_port_flag(p, tb, IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD); |
| 809 | if (err) |
| 810 | return err; |
| 811 | |
| 812 | err = br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD); |
| 813 | if (err) |
| 814 | return err; |
| 815 | |
| 816 | err = br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_TO_UCAST, BR_MULTICAST_TO_UNICAST); |
| 817 | if (err) |
| 818 | return err; |
| 819 | |
| 820 | err = br_set_port_flag(p, tb, IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD); |
| 821 | if (err) |
| 822 | return err; |
| 823 | |
| 824 | err = br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP, BR_PROXYARP); |
| 825 | if (err) |
| 826 | return err; |
| 827 | |
| 828 | err = br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP_WIFI, BR_PROXYARP_WIFI); |
| 829 | if (err) |
| 830 | return err; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 831 | |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 832 | br_vlan_tunnel_old = (p->flags & BR_VLAN_TUNNEL) ? true : false; |
Arkadi Sharshevsky | 3922285 | 2017-06-08 08:44:11 +0200 | [diff] [blame] | 833 | err = br_set_port_flag(p, tb, IFLA_BRPORT_VLAN_TUNNEL, BR_VLAN_TUNNEL); |
| 834 | if (err) |
| 835 | return err; |
| 836 | |
Roopa Prabhu | efa5356 | 2017-01-31 22:59:54 -0800 | [diff] [blame] | 837 | if (br_vlan_tunnel_old && !(p->flags & BR_VLAN_TUNNEL)) |
| 838 | nbp_vlan_tunnel_info_flush(p); |
| 839 | |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 840 | if (tb[IFLA_BRPORT_COST]) { |
| 841 | err = br_stp_set_path_cost(p, nla_get_u32(tb[IFLA_BRPORT_COST])); |
| 842 | if (err) |
| 843 | return err; |
| 844 | } |
| 845 | |
| 846 | if (tb[IFLA_BRPORT_PRIORITY]) { |
| 847 | err = br_stp_set_port_priority(p, nla_get_u16(tb[IFLA_BRPORT_PRIORITY])); |
| 848 | if (err) |
| 849 | return err; |
| 850 | } |
| 851 | |
| 852 | if (tb[IFLA_BRPORT_STATE]) { |
| 853 | err = br_set_port_state(p, nla_get_u8(tb[IFLA_BRPORT_STATE])); |
| 854 | if (err) |
| 855 | return err; |
| 856 | } |
Vlad Yasevich | e028e4b | 2014-05-16 09:59:16 -0400 | [diff] [blame] | 857 | |
Nikolay Aleksandrov | 9b0c6e4 | 2015-10-06 14:12:01 +0200 | [diff] [blame] | 858 | if (tb[IFLA_BRPORT_FLUSH]) |
| 859 | br_fdb_delete_by_port(p->br, p, 0, 0); |
| 860 | |
Nikolay Aleksandrov | 5d6ae47 | 2015-10-06 14:12:02 +0200 | [diff] [blame] | 861 | #ifdef CONFIG_BRIDGE_IGMP_SNOOPING |
| 862 | if (tb[IFLA_BRPORT_MULTICAST_ROUTER]) { |
| 863 | u8 mcast_router = nla_get_u8(tb[IFLA_BRPORT_MULTICAST_ROUTER]); |
| 864 | |
| 865 | err = br_multicast_set_port_router(p, mcast_router); |
| 866 | if (err) |
| 867 | return err; |
| 868 | } |
| 869 | #endif |
Nikolay Aleksandrov | 5af48b5 | 2017-09-27 16:12:44 +0300 | [diff] [blame] | 870 | |
| 871 | if (tb[IFLA_BRPORT_GROUP_FWD_MASK]) { |
| 872 | u16 fwd_mask = nla_get_u16(tb[IFLA_BRPORT_GROUP_FWD_MASK]); |
| 873 | |
| 874 | if (fwd_mask & BR_GROUPFWD_MACPAUSE) |
| 875 | return -EINVAL; |
| 876 | p->group_fwd_mask = fwd_mask; |
| 877 | } |
| 878 | |
Roopa Prabhu | 821f1b2 | 2017-10-06 22:12:37 -0700 | [diff] [blame] | 879 | err = br_set_port_flag(p, tb, IFLA_BRPORT_NEIGH_SUPPRESS, |
| 880 | BR_NEIGH_SUPPRESS); |
| 881 | if (err) |
| 882 | return err; |
| 883 | |
Nikolay Aleksandrov | 7d850ab | 2018-05-24 11:56:48 +0300 | [diff] [blame] | 884 | err = br_set_port_flag(p, tb, IFLA_BRPORT_ISOLATED, BR_ISOLATED); |
| 885 | if (err) |
| 886 | return err; |
| 887 | |
Nikolay Aleksandrov | 2756f68 | 2018-07-23 11:16:59 +0300 | [diff] [blame] | 888 | if (tb[IFLA_BRPORT_BACKUP_PORT]) { |
| 889 | struct net_device *backup_dev = NULL; |
| 890 | u32 backup_ifindex; |
| 891 | |
| 892 | backup_ifindex = nla_get_u32(tb[IFLA_BRPORT_BACKUP_PORT]); |
| 893 | if (backup_ifindex) { |
| 894 | backup_dev = __dev_get_by_index(dev_net(p->dev), |
| 895 | backup_ifindex); |
| 896 | if (!backup_dev) |
| 897 | return -ENOENT; |
| 898 | } |
| 899 | |
| 900 | err = nbp_backup_change(p, backup_dev); |
| 901 | if (err) |
| 902 | return err; |
| 903 | } |
| 904 | |
Vlad Yasevich | e028e4b | 2014-05-16 09:59:16 -0400 | [diff] [blame] | 905 | br_port_flags_change(p, old_flags ^ p->flags); |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 906 | return 0; |
| 907 | } |
| 908 | |
| 909 | /* Change state and parameters on port. */ |
Petr Machata | 2fd527b | 2018-12-12 17:02:48 +0000 | [diff] [blame] | 910 | int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags, |
| 911 | struct netlink_ext_ack *extack) |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 912 | { |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 913 | struct net_bridge *br = (struct net_bridge *)netdev_priv(dev); |
| 914 | struct nlattr *tb[IFLA_BRPORT_MAX + 1]; |
| 915 | struct net_bridge_port *p; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 916 | struct nlattr *protinfo; |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 917 | struct nlattr *afspec; |
Nikolay Aleksandrov | e19b42a | 2017-10-27 13:19:36 +0300 | [diff] [blame] | 918 | bool changed = false; |
Scott Feldman | 41c498b | 2015-05-10 09:47:59 -0700 | [diff] [blame] | 919 | int err = 0; |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 920 | |
Hong zhi guo | c60ee67 | 2013-03-28 06:21:22 +0000 | [diff] [blame] | 921 | protinfo = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_PROTINFO); |
| 922 | afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 923 | if (!protinfo && !afspec) |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 924 | return 0; |
| 925 | |
| 926 | p = br_port_get_rtnl(dev); |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 927 | /* We want to accept dev as bridge itself if the AF_SPEC |
stephen hemminger | 8e3bff9 | 2013-12-08 12:15:44 -0800 | [diff] [blame] | 928 | * is set to see if someone is setting vlan info on the bridge |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 929 | */ |
Hong zhi guo | 7b99a99 | 2013-03-24 03:26:47 +0000 | [diff] [blame] | 930 | if (!p && !afspec) |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 931 | return -EINVAL; |
| 932 | |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 933 | if (p && protinfo) { |
| 934 | if (protinfo->nla_type & NLA_F_NESTED) { |
Johannes Berg | 8cb0817 | 2019-04-26 14:07:28 +0200 | [diff] [blame] | 935 | err = nla_parse_nested_deprecated(tb, IFLA_BRPORT_MAX, |
| 936 | protinfo, |
| 937 | br_port_policy, |
| 938 | NULL); |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 939 | if (err) |
| 940 | return err; |
| 941 | |
| 942 | spin_lock_bh(&p->br->lock); |
| 943 | err = br_setport(p, tb); |
| 944 | spin_unlock_bh(&p->br->lock); |
| 945 | } else { |
stephen hemminger | 8e3bff9 | 2013-12-08 12:15:44 -0800 | [diff] [blame] | 946 | /* Binary compatibility with old RSTP */ |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 947 | if (nla_len(protinfo) < sizeof(u8)) |
| 948 | return -EINVAL; |
| 949 | |
| 950 | spin_lock_bh(&p->br->lock); |
| 951 | err = br_set_port_state(p, nla_get_u8(protinfo)); |
| 952 | spin_unlock_bh(&p->br->lock); |
| 953 | } |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 954 | if (err) |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 955 | goto out; |
Nikolay Aleksandrov | e19b42a | 2017-10-27 13:19:36 +0300 | [diff] [blame] | 956 | changed = true; |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 957 | } |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 958 | |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 959 | if (afspec) |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 960 | err = br_afspec(br, p, afspec, RTM_SETLINK, &changed, extack); |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 961 | |
Nikolay Aleksandrov | e19b42a | 2017-10-27 13:19:36 +0300 | [diff] [blame] | 962 | if (changed) |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 963 | br_ifinfo_notify(RTM_NEWLINK, br, p); |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 964 | out: |
stephen hemminger | 25c71c7 | 2012-11-13 07:53:05 +0000 | [diff] [blame] | 965 | return err; |
| 966 | } |
| 967 | |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 968 | /* Delete port information */ |
Roopa Prabhu | add511b | 2015-01-29 22:40:12 -0800 | [diff] [blame] | 969 | int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 970 | { |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 971 | struct net_bridge *br = (struct net_bridge *)netdev_priv(dev); |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 972 | struct net_bridge_port *p; |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 973 | struct nlattr *afspec; |
Nikolay Aleksandrov | e19b42a | 2017-10-27 13:19:36 +0300 | [diff] [blame] | 974 | bool changed = false; |
Scott Feldman | 8508025 | 2015-05-10 09:48:03 -0700 | [diff] [blame] | 975 | int err = 0; |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 976 | |
Hong zhi guo | c60ee67 | 2013-03-28 06:21:22 +0000 | [diff] [blame] | 977 | afspec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 978 | if (!afspec) |
| 979 | return 0; |
| 980 | |
| 981 | p = br_port_get_rtnl(dev); |
| 982 | /* We want to accept dev as bridge itself as well */ |
| 983 | if (!p && !(dev->priv_flags & IFF_EBRIDGE)) |
| 984 | return -EINVAL; |
| 985 | |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 986 | err = br_afspec(br, p, afspec, RTM_DELLINK, &changed, NULL); |
Nikolay Aleksandrov | e19b42a | 2017-10-27 13:19:36 +0300 | [diff] [blame] | 987 | if (changed) |
Roopa Prabhu | 02dba43 | 2015-01-14 20:02:25 -0800 | [diff] [blame] | 988 | /* Send RTM_NEWLINK because userspace |
| 989 | * expects RTM_NEWLINK for vlan dels |
| 990 | */ |
Nikolay Aleksandrov | 9289906 | 2017-11-01 12:18:13 +0200 | [diff] [blame] | 991 | br_ifinfo_notify(RTM_NEWLINK, br, p); |
Vlad Yasevich | 407af32 | 2013-02-13 12:00:12 +0000 | [diff] [blame] | 992 | |
| 993 | return err; |
| 994 | } |
Matthias Schiffer | a8b8a889 | 2017-06-25 23:56:01 +0200 | [diff] [blame] | 995 | |
| 996 | static int br_validate(struct nlattr *tb[], struct nlattr *data[], |
| 997 | struct netlink_ext_ack *extack) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 998 | { |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 999 | if (tb[IFLA_ADDRESS]) { |
| 1000 | if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) |
| 1001 | return -EINVAL; |
| 1002 | if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) |
| 1003 | return -EADDRNOTAVAIL; |
| 1004 | } |
Thomas Graf | 32fe21c | 2007-03-22 11:59:03 -0700 | [diff] [blame] | 1005 | |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1006 | if (!data) |
| 1007 | return 0; |
| 1008 | |
| 1009 | #ifdef CONFIG_BRIDGE_VLAN_FILTERING |
| 1010 | if (data[IFLA_BR_VLAN_PROTOCOL]) { |
| 1011 | switch (nla_get_be16(data[IFLA_BR_VLAN_PROTOCOL])) { |
| 1012 | case htons(ETH_P_8021Q): |
| 1013 | case htons(ETH_P_8021AD): |
| 1014 | break; |
| 1015 | default: |
| 1016 | return -EPROTONOSUPPORT; |
| 1017 | } |
| 1018 | } |
Tobias Jungel | a285860 | 2017-05-17 09:29:12 +0200 | [diff] [blame] | 1019 | |
| 1020 | if (data[IFLA_BR_VLAN_DEFAULT_PVID]) { |
| 1021 | __u16 defpvid = nla_get_u16(data[IFLA_BR_VLAN_DEFAULT_PVID]); |
| 1022 | |
| 1023 | if (defpvid >= VLAN_VID_MASK) |
| 1024 | return -EINVAL; |
| 1025 | } |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1026 | #endif |
| 1027 | |
Thomas Graf | 32fe21c | 2007-03-22 11:59:03 -0700 | [diff] [blame] | 1028 | return 0; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 1029 | } |
| 1030 | |
Jiri Pirko | 3ac636b | 2014-09-05 15:51:30 +0200 | [diff] [blame] | 1031 | static int br_port_slave_changelink(struct net_device *brdev, |
| 1032 | struct net_device *dev, |
| 1033 | struct nlattr *tb[], |
Matthias Schiffer | 17dd0ec | 2017-06-25 23:56:02 +0200 | [diff] [blame] | 1034 | struct nlattr *data[], |
| 1035 | struct netlink_ext_ack *extack) |
Jiri Pirko | 3ac636b | 2014-09-05 15:51:30 +0200 | [diff] [blame] | 1036 | { |
Nikolay Aleksandrov | 963ad94 | 2015-07-22 13:03:40 +0200 | [diff] [blame] | 1037 | struct net_bridge *br = netdev_priv(brdev); |
| 1038 | int ret; |
| 1039 | |
Jiri Pirko | 3ac636b | 2014-09-05 15:51:30 +0200 | [diff] [blame] | 1040 | if (!data) |
| 1041 | return 0; |
Nikolay Aleksandrov | 963ad94 | 2015-07-22 13:03:40 +0200 | [diff] [blame] | 1042 | |
| 1043 | spin_lock_bh(&br->lock); |
| 1044 | ret = br_setport(br_port_get_rtnl(dev), data); |
| 1045 | spin_unlock_bh(&br->lock); |
| 1046 | |
| 1047 | return ret; |
Jiri Pirko | 3ac636b | 2014-09-05 15:51:30 +0200 | [diff] [blame] | 1048 | } |
| 1049 | |
Jiri Pirko | ced8283 | 2014-09-05 15:51:29 +0200 | [diff] [blame] | 1050 | static int br_port_fill_slave_info(struct sk_buff *skb, |
| 1051 | const struct net_device *brdev, |
| 1052 | const struct net_device *dev) |
| 1053 | { |
| 1054 | return br_port_fill_attrs(skb, br_port_get_rtnl(dev)); |
| 1055 | } |
| 1056 | |
| 1057 | static size_t br_port_get_slave_size(const struct net_device *brdev, |
| 1058 | const struct net_device *dev) |
| 1059 | { |
| 1060 | return br_port_info_size(); |
| 1061 | } |
| 1062 | |
Jiri Pirko | 1332351 | 2014-09-05 15:51:32 +0200 | [diff] [blame] | 1063 | static const struct nla_policy br_policy[IFLA_BR_MAX + 1] = { |
| 1064 | [IFLA_BR_FORWARD_DELAY] = { .type = NLA_U32 }, |
| 1065 | [IFLA_BR_HELLO_TIME] = { .type = NLA_U32 }, |
| 1066 | [IFLA_BR_MAX_AGE] = { .type = NLA_U32 }, |
Jörg Thalheim | af61576 | 2015-03-18 10:06:58 +0100 | [diff] [blame] | 1067 | [IFLA_BR_AGEING_TIME] = { .type = NLA_U32 }, |
| 1068 | [IFLA_BR_STP_STATE] = { .type = NLA_U32 }, |
| 1069 | [IFLA_BR_PRIORITY] = { .type = NLA_U16 }, |
Nikolay Aleksandrov | a785403 | 2015-08-07 19:40:45 +0300 | [diff] [blame] | 1070 | [IFLA_BR_VLAN_FILTERING] = { .type = NLA_U8 }, |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1071 | [IFLA_BR_VLAN_PROTOCOL] = { .type = NLA_U16 }, |
Nikolay Aleksandrov | 7910228 | 2015-10-04 14:23:28 +0200 | [diff] [blame] | 1072 | [IFLA_BR_GROUP_FWD_MASK] = { .type = NLA_U16 }, |
Nikolay Aleksandrov | 111189a | 2015-10-04 14:23:35 +0200 | [diff] [blame] | 1073 | [IFLA_BR_GROUP_ADDR] = { .type = NLA_BINARY, |
| 1074 | .len = ETH_ALEN }, |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1075 | [IFLA_BR_MCAST_ROUTER] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 8912632 | 2015-10-04 14:23:38 +0200 | [diff] [blame] | 1076 | [IFLA_BR_MCAST_SNOOPING] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 295141d | 2015-10-04 14:23:39 +0200 | [diff] [blame] | 1077 | [IFLA_BR_MCAST_QUERY_USE_IFADDR] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | ba062d7c | 2015-10-04 14:23:40 +0200 | [diff] [blame] | 1078 | [IFLA_BR_MCAST_QUERIER] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 431db3c | 2015-10-04 14:23:41 +0200 | [diff] [blame] | 1079 | [IFLA_BR_MCAST_HASH_ELASTICITY] = { .type = NLA_U32 }, |
Nikolay Aleksandrov | 858079f | 2015-10-04 14:23:42 +0200 | [diff] [blame] | 1080 | [IFLA_BR_MCAST_HASH_MAX] = { .type = NLA_U32 }, |
Nikolay Aleksandrov | 79b859f | 2015-10-04 14:23:43 +0200 | [diff] [blame] | 1081 | [IFLA_BR_MCAST_LAST_MEMBER_CNT] = { .type = NLA_U32 }, |
Nikolay Aleksandrov | b89e6ba | 2015-10-04 14:23:44 +0200 | [diff] [blame] | 1082 | [IFLA_BR_MCAST_STARTUP_QUERY_CNT] = { .type = NLA_U32 }, |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1083 | [IFLA_BR_MCAST_LAST_MEMBER_INTVL] = { .type = NLA_U64 }, |
| 1084 | [IFLA_BR_MCAST_MEMBERSHIP_INTVL] = { .type = NLA_U64 }, |
| 1085 | [IFLA_BR_MCAST_QUERIER_INTVL] = { .type = NLA_U64 }, |
| 1086 | [IFLA_BR_MCAST_QUERY_INTVL] = { .type = NLA_U64 }, |
| 1087 | [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL] = { .type = NLA_U64 }, |
| 1088 | [IFLA_BR_MCAST_STARTUP_QUERY_INTVL] = { .type = NLA_U64 }, |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1089 | [IFLA_BR_NF_CALL_IPTABLES] = { .type = NLA_U8 }, |
| 1090 | [IFLA_BR_NF_CALL_IP6TABLES] = { .type = NLA_U8 }, |
| 1091 | [IFLA_BR_NF_CALL_ARPTABLES] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 0f963b7 | 2015-10-04 14:23:47 +0200 | [diff] [blame] | 1092 | [IFLA_BR_VLAN_DEFAULT_PVID] = { .type = NLA_U16 }, |
Nikolay Aleksandrov | 6dada9b | 2016-04-30 10:25:28 +0200 | [diff] [blame] | 1093 | [IFLA_BR_VLAN_STATS_ENABLED] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1094 | [IFLA_BR_MCAST_STATS_ENABLED] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 5e92358 | 2016-11-21 13:03:24 +0100 | [diff] [blame] | 1095 | [IFLA_BR_MCAST_IGMP_VERSION] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | aa2ae3e | 2016-11-21 13:03:25 +0100 | [diff] [blame] | 1096 | [IFLA_BR_MCAST_MLD_VERSION] = { .type = NLA_U8 }, |
Nikolay Aleksandrov | 9163a0f | 2018-10-12 13:41:16 +0300 | [diff] [blame] | 1097 | [IFLA_BR_VLAN_STATS_PER_PORT] = { .type = NLA_U8 }, |
Johannes Berg | 8140860 | 2020-08-18 10:17:31 +0200 | [diff] [blame^] | 1098 | [IFLA_BR_MULTI_BOOLOPT] = |
| 1099 | NLA_POLICY_EXACT_LEN(sizeof(struct br_boolopt_multi)), |
Jiri Pirko | 1332351 | 2014-09-05 15:51:32 +0200 | [diff] [blame] | 1100 | }; |
| 1101 | |
| 1102 | static int br_changelink(struct net_device *brdev, struct nlattr *tb[], |
Matthias Schiffer | ad744b2 | 2017-06-25 23:56:00 +0200 | [diff] [blame] | 1103 | struct nlattr *data[], |
| 1104 | struct netlink_ext_ack *extack) |
Jiri Pirko | 1332351 | 2014-09-05 15:51:32 +0200 | [diff] [blame] | 1105 | { |
| 1106 | struct net_bridge *br = netdev_priv(brdev); |
| 1107 | int err; |
| 1108 | |
| 1109 | if (!data) |
| 1110 | return 0; |
| 1111 | |
| 1112 | if (data[IFLA_BR_FORWARD_DELAY]) { |
| 1113 | err = br_set_forward_delay(br, nla_get_u32(data[IFLA_BR_FORWARD_DELAY])); |
| 1114 | if (err) |
| 1115 | return err; |
| 1116 | } |
| 1117 | |
| 1118 | if (data[IFLA_BR_HELLO_TIME]) { |
| 1119 | err = br_set_hello_time(br, nla_get_u32(data[IFLA_BR_HELLO_TIME])); |
| 1120 | if (err) |
| 1121 | return err; |
| 1122 | } |
| 1123 | |
| 1124 | if (data[IFLA_BR_MAX_AGE]) { |
| 1125 | err = br_set_max_age(br, nla_get_u32(data[IFLA_BR_MAX_AGE])); |
| 1126 | if (err) |
| 1127 | return err; |
| 1128 | } |
| 1129 | |
Jörg Thalheim | af61576 | 2015-03-18 10:06:58 +0100 | [diff] [blame] | 1130 | if (data[IFLA_BR_AGEING_TIME]) { |
Scott Feldman | c62987b | 2015-10-08 19:23:19 -0700 | [diff] [blame] | 1131 | err = br_set_ageing_time(br, nla_get_u32(data[IFLA_BR_AGEING_TIME])); |
| 1132 | if (err) |
| 1133 | return err; |
Jörg Thalheim | af61576 | 2015-03-18 10:06:58 +0100 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | if (data[IFLA_BR_STP_STATE]) { |
| 1137 | u32 stp_enabled = nla_get_u32(data[IFLA_BR_STP_STATE]); |
| 1138 | |
Horatiu Vultur | 419dba8a | 2020-04-26 15:22:08 +0200 | [diff] [blame] | 1139 | err = br_stp_set_enabled(br, stp_enabled, extack); |
| 1140 | if (err) |
| 1141 | return err; |
Jörg Thalheim | af61576 | 2015-03-18 10:06:58 +0100 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | if (data[IFLA_BR_PRIORITY]) { |
| 1145 | u32 priority = nla_get_u16(data[IFLA_BR_PRIORITY]); |
| 1146 | |
| 1147 | br_stp_set_bridge_priority(br, priority); |
| 1148 | } |
| 1149 | |
Nikolay Aleksandrov | a785403 | 2015-08-07 19:40:45 +0300 | [diff] [blame] | 1150 | if (data[IFLA_BR_VLAN_FILTERING]) { |
| 1151 | u8 vlan_filter = nla_get_u8(data[IFLA_BR_VLAN_FILTERING]); |
| 1152 | |
| 1153 | err = __br_vlan_filter_toggle(br, vlan_filter); |
| 1154 | if (err) |
| 1155 | return err; |
| 1156 | } |
| 1157 | |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1158 | #ifdef CONFIG_BRIDGE_VLAN_FILTERING |
| 1159 | if (data[IFLA_BR_VLAN_PROTOCOL]) { |
| 1160 | __be16 vlan_proto = nla_get_be16(data[IFLA_BR_VLAN_PROTOCOL]); |
| 1161 | |
| 1162 | err = __br_vlan_set_proto(br, vlan_proto); |
| 1163 | if (err) |
| 1164 | return err; |
| 1165 | } |
Nikolay Aleksandrov | 0f963b7 | 2015-10-04 14:23:47 +0200 | [diff] [blame] | 1166 | |
| 1167 | if (data[IFLA_BR_VLAN_DEFAULT_PVID]) { |
| 1168 | __u16 defpvid = nla_get_u16(data[IFLA_BR_VLAN_DEFAULT_PVID]); |
| 1169 | |
Petr Machata | 169327d | 2018-12-12 17:02:50 +0000 | [diff] [blame] | 1170 | err = __br_vlan_set_default_pvid(br, defpvid, extack); |
Nikolay Aleksandrov | 0f963b7 | 2015-10-04 14:23:47 +0200 | [diff] [blame] | 1171 | if (err) |
| 1172 | return err; |
| 1173 | } |
Nikolay Aleksandrov | 6dada9b | 2016-04-30 10:25:28 +0200 | [diff] [blame] | 1174 | |
| 1175 | if (data[IFLA_BR_VLAN_STATS_ENABLED]) { |
| 1176 | __u8 vlan_stats = nla_get_u8(data[IFLA_BR_VLAN_STATS_ENABLED]); |
| 1177 | |
| 1178 | err = br_vlan_set_stats(br, vlan_stats); |
| 1179 | if (err) |
| 1180 | return err; |
| 1181 | } |
Nikolay Aleksandrov | 9163a0f | 2018-10-12 13:41:16 +0300 | [diff] [blame] | 1182 | |
| 1183 | if (data[IFLA_BR_VLAN_STATS_PER_PORT]) { |
| 1184 | __u8 per_port = nla_get_u8(data[IFLA_BR_VLAN_STATS_PER_PORT]); |
| 1185 | |
| 1186 | err = br_vlan_set_stats_per_port(br, per_port); |
| 1187 | if (err) |
| 1188 | return err; |
| 1189 | } |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1190 | #endif |
| 1191 | |
Nikolay Aleksandrov | 7910228 | 2015-10-04 14:23:28 +0200 | [diff] [blame] | 1192 | if (data[IFLA_BR_GROUP_FWD_MASK]) { |
| 1193 | u16 fwd_mask = nla_get_u16(data[IFLA_BR_GROUP_FWD_MASK]); |
| 1194 | |
| 1195 | if (fwd_mask & BR_GROUPFWD_RESTRICTED) |
| 1196 | return -EINVAL; |
| 1197 | br->group_fwd_mask = fwd_mask; |
| 1198 | } |
| 1199 | |
Nikolay Aleksandrov | 111189a | 2015-10-04 14:23:35 +0200 | [diff] [blame] | 1200 | if (data[IFLA_BR_GROUP_ADDR]) { |
| 1201 | u8 new_addr[ETH_ALEN]; |
| 1202 | |
| 1203 | if (nla_len(data[IFLA_BR_GROUP_ADDR]) != ETH_ALEN) |
| 1204 | return -EINVAL; |
| 1205 | memcpy(new_addr, nla_data(data[IFLA_BR_GROUP_ADDR]), ETH_ALEN); |
| 1206 | if (!is_link_local_ether_addr(new_addr)) |
| 1207 | return -EINVAL; |
| 1208 | if (new_addr[5] == 1 || /* 802.3x Pause address */ |
| 1209 | new_addr[5] == 2 || /* 802.3ad Slow protocols */ |
| 1210 | new_addr[5] == 3) /* 802.1X PAE address */ |
| 1211 | return -EINVAL; |
| 1212 | spin_lock_bh(&br->lock); |
| 1213 | memcpy(br->group_addr, new_addr, sizeof(br->group_addr)); |
| 1214 | spin_unlock_bh(&br->lock); |
Nikolay Aleksandrov | be3664a | 2018-09-26 17:01:02 +0300 | [diff] [blame] | 1215 | br_opt_toggle(br, BROPT_GROUP_ADDR_SET, true); |
Nikolay Aleksandrov | 111189a | 2015-10-04 14:23:35 +0200 | [diff] [blame] | 1216 | br_recalculate_fwd_mask(br); |
| 1217 | } |
| 1218 | |
Nikolay Aleksandrov | 150217c | 2015-10-04 14:23:36 +0200 | [diff] [blame] | 1219 | if (data[IFLA_BR_FDB_FLUSH]) |
| 1220 | br_fdb_flush(br); |
| 1221 | |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1222 | #ifdef CONFIG_BRIDGE_IGMP_SNOOPING |
| 1223 | if (data[IFLA_BR_MCAST_ROUTER]) { |
| 1224 | u8 multicast_router = nla_get_u8(data[IFLA_BR_MCAST_ROUTER]); |
| 1225 | |
| 1226 | err = br_multicast_set_router(br, multicast_router); |
| 1227 | if (err) |
| 1228 | return err; |
| 1229 | } |
Nikolay Aleksandrov | 8912632 | 2015-10-04 14:23:38 +0200 | [diff] [blame] | 1230 | |
| 1231 | if (data[IFLA_BR_MCAST_SNOOPING]) { |
| 1232 | u8 mcast_snooping = nla_get_u8(data[IFLA_BR_MCAST_SNOOPING]); |
| 1233 | |
YueHaibing | a26d94b | 2018-12-17 17:46:23 +0800 | [diff] [blame] | 1234 | br_multicast_toggle(br, mcast_snooping); |
Nikolay Aleksandrov | 8912632 | 2015-10-04 14:23:38 +0200 | [diff] [blame] | 1235 | } |
Nikolay Aleksandrov | 295141d | 2015-10-04 14:23:39 +0200 | [diff] [blame] | 1236 | |
| 1237 | if (data[IFLA_BR_MCAST_QUERY_USE_IFADDR]) { |
| 1238 | u8 val; |
| 1239 | |
| 1240 | val = nla_get_u8(data[IFLA_BR_MCAST_QUERY_USE_IFADDR]); |
Nikolay Aleksandrov | 675779a | 2018-09-26 17:01:04 +0300 | [diff] [blame] | 1241 | br_opt_toggle(br, BROPT_MULTICAST_QUERY_USE_IFADDR, !!val); |
Nikolay Aleksandrov | 295141d | 2015-10-04 14:23:39 +0200 | [diff] [blame] | 1242 | } |
Nikolay Aleksandrov | ba062d7c | 2015-10-04 14:23:40 +0200 | [diff] [blame] | 1243 | |
| 1244 | if (data[IFLA_BR_MCAST_QUERIER]) { |
| 1245 | u8 mcast_querier = nla_get_u8(data[IFLA_BR_MCAST_QUERIER]); |
| 1246 | |
| 1247 | err = br_multicast_set_querier(br, mcast_querier); |
| 1248 | if (err) |
| 1249 | return err; |
| 1250 | } |
Nikolay Aleksandrov | 431db3c | 2015-10-04 14:23:41 +0200 | [diff] [blame] | 1251 | |
Nikolay Aleksandrov | cf332bca | 2018-12-05 15:14:26 +0200 | [diff] [blame] | 1252 | if (data[IFLA_BR_MCAST_HASH_ELASTICITY]) |
| 1253 | br_warn(br, "the hash_elasticity option has been deprecated and is always %u\n", |
| 1254 | RHT_ELASTICITY); |
Nikolay Aleksandrov | 858079f | 2015-10-04 14:23:42 +0200 | [diff] [blame] | 1255 | |
Nikolay Aleksandrov | 19e3a9c | 2018-12-05 15:14:24 +0200 | [diff] [blame] | 1256 | if (data[IFLA_BR_MCAST_HASH_MAX]) |
| 1257 | br->hash_max = nla_get_u32(data[IFLA_BR_MCAST_HASH_MAX]); |
Nikolay Aleksandrov | 79b859f | 2015-10-04 14:23:43 +0200 | [diff] [blame] | 1258 | |
| 1259 | if (data[IFLA_BR_MCAST_LAST_MEMBER_CNT]) { |
| 1260 | u32 val = nla_get_u32(data[IFLA_BR_MCAST_LAST_MEMBER_CNT]); |
| 1261 | |
| 1262 | br->multicast_last_member_count = val; |
| 1263 | } |
Nikolay Aleksandrov | b89e6ba | 2015-10-04 14:23:44 +0200 | [diff] [blame] | 1264 | |
| 1265 | if (data[IFLA_BR_MCAST_STARTUP_QUERY_CNT]) { |
| 1266 | u32 val = nla_get_u32(data[IFLA_BR_MCAST_STARTUP_QUERY_CNT]); |
| 1267 | |
| 1268 | br->multicast_startup_query_count = val; |
| 1269 | } |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1270 | |
| 1271 | if (data[IFLA_BR_MCAST_LAST_MEMBER_INTVL]) { |
| 1272 | u64 val = nla_get_u64(data[IFLA_BR_MCAST_LAST_MEMBER_INTVL]); |
| 1273 | |
| 1274 | br->multicast_last_member_interval = clock_t_to_jiffies(val); |
| 1275 | } |
| 1276 | |
| 1277 | if (data[IFLA_BR_MCAST_MEMBERSHIP_INTVL]) { |
| 1278 | u64 val = nla_get_u64(data[IFLA_BR_MCAST_MEMBERSHIP_INTVL]); |
| 1279 | |
| 1280 | br->multicast_membership_interval = clock_t_to_jiffies(val); |
| 1281 | } |
| 1282 | |
| 1283 | if (data[IFLA_BR_MCAST_QUERIER_INTVL]) { |
| 1284 | u64 val = nla_get_u64(data[IFLA_BR_MCAST_QUERIER_INTVL]); |
| 1285 | |
| 1286 | br->multicast_querier_interval = clock_t_to_jiffies(val); |
| 1287 | } |
| 1288 | |
| 1289 | if (data[IFLA_BR_MCAST_QUERY_INTVL]) { |
| 1290 | u64 val = nla_get_u64(data[IFLA_BR_MCAST_QUERY_INTVL]); |
| 1291 | |
| 1292 | br->multicast_query_interval = clock_t_to_jiffies(val); |
| 1293 | } |
| 1294 | |
| 1295 | if (data[IFLA_BR_MCAST_QUERY_RESPONSE_INTVL]) { |
| 1296 | u64 val = nla_get_u64(data[IFLA_BR_MCAST_QUERY_RESPONSE_INTVL]); |
| 1297 | |
| 1298 | br->multicast_query_response_interval = clock_t_to_jiffies(val); |
| 1299 | } |
| 1300 | |
| 1301 | if (data[IFLA_BR_MCAST_STARTUP_QUERY_INTVL]) { |
| 1302 | u64 val = nla_get_u64(data[IFLA_BR_MCAST_STARTUP_QUERY_INTVL]); |
| 1303 | |
| 1304 | br->multicast_startup_query_interval = clock_t_to_jiffies(val); |
| 1305 | } |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1306 | |
| 1307 | if (data[IFLA_BR_MCAST_STATS_ENABLED]) { |
| 1308 | __u8 mcast_stats; |
| 1309 | |
| 1310 | mcast_stats = nla_get_u8(data[IFLA_BR_MCAST_STATS_ENABLED]); |
Nikolay Aleksandrov | 675779a | 2018-09-26 17:01:04 +0300 | [diff] [blame] | 1311 | br_opt_toggle(br, BROPT_MULTICAST_STATS_ENABLED, !!mcast_stats); |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1312 | } |
Nikolay Aleksandrov | 5e92358 | 2016-11-21 13:03:24 +0100 | [diff] [blame] | 1313 | |
| 1314 | if (data[IFLA_BR_MCAST_IGMP_VERSION]) { |
| 1315 | __u8 igmp_version; |
| 1316 | |
| 1317 | igmp_version = nla_get_u8(data[IFLA_BR_MCAST_IGMP_VERSION]); |
| 1318 | err = br_multicast_set_igmp_version(br, igmp_version); |
| 1319 | if (err) |
| 1320 | return err; |
| 1321 | } |
Nikolay Aleksandrov | aa2ae3e | 2016-11-21 13:03:25 +0100 | [diff] [blame] | 1322 | |
| 1323 | #if IS_ENABLED(CONFIG_IPV6) |
| 1324 | if (data[IFLA_BR_MCAST_MLD_VERSION]) { |
| 1325 | __u8 mld_version; |
| 1326 | |
| 1327 | mld_version = nla_get_u8(data[IFLA_BR_MCAST_MLD_VERSION]); |
| 1328 | err = br_multicast_set_mld_version(br, mld_version); |
| 1329 | if (err) |
| 1330 | return err; |
| 1331 | } |
| 1332 | #endif |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1333 | #endif |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1334 | #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) |
| 1335 | if (data[IFLA_BR_NF_CALL_IPTABLES]) { |
| 1336 | u8 val = nla_get_u8(data[IFLA_BR_NF_CALL_IPTABLES]); |
| 1337 | |
Nikolay Aleksandrov | 8df3510 | 2018-09-26 17:01:01 +0300 | [diff] [blame] | 1338 | br_opt_toggle(br, BROPT_NF_CALL_IPTABLES, !!val); |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1339 | } |
| 1340 | |
| 1341 | if (data[IFLA_BR_NF_CALL_IP6TABLES]) { |
| 1342 | u8 val = nla_get_u8(data[IFLA_BR_NF_CALL_IP6TABLES]); |
| 1343 | |
Nikolay Aleksandrov | 8df3510 | 2018-09-26 17:01:01 +0300 | [diff] [blame] | 1344 | br_opt_toggle(br, BROPT_NF_CALL_IP6TABLES, !!val); |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1345 | } |
| 1346 | |
| 1347 | if (data[IFLA_BR_NF_CALL_ARPTABLES]) { |
| 1348 | u8 val = nla_get_u8(data[IFLA_BR_NF_CALL_ARPTABLES]); |
| 1349 | |
Nikolay Aleksandrov | 8df3510 | 2018-09-26 17:01:01 +0300 | [diff] [blame] | 1350 | br_opt_toggle(br, BROPT_NF_CALL_ARPTABLES, !!val); |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1351 | } |
| 1352 | #endif |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1353 | |
Nikolay Aleksandrov | a428afe | 2018-11-24 04:34:20 +0200 | [diff] [blame] | 1354 | if (data[IFLA_BR_MULTI_BOOLOPT]) { |
| 1355 | struct br_boolopt_multi *bm; |
| 1356 | |
| 1357 | bm = nla_data(data[IFLA_BR_MULTI_BOOLOPT]); |
| 1358 | err = br_boolopt_multi_toggle(br, bm, extack); |
| 1359 | if (err) |
| 1360 | return err; |
| 1361 | } |
| 1362 | |
Jiri Pirko | 1332351 | 2014-09-05 15:51:32 +0200 | [diff] [blame] | 1363 | return 0; |
| 1364 | } |
| 1365 | |
Ivan Vecera | b667744 | 2017-01-20 18:12:17 +0100 | [diff] [blame] | 1366 | static int br_dev_newlink(struct net *src_net, struct net_device *dev, |
Matthias Schiffer | 7a3f4a1 | 2017-06-25 23:55:59 +0200 | [diff] [blame] | 1367 | struct nlattr *tb[], struct nlattr *data[], |
| 1368 | struct netlink_ext_ack *extack) |
Ivan Vecera | b667744 | 2017-01-20 18:12:17 +0100 | [diff] [blame] | 1369 | { |
| 1370 | struct net_bridge *br = netdev_priv(dev); |
| 1371 | int err; |
| 1372 | |
Nikolay Aleksandrov | 84aeb43 | 2017-12-18 17:35:09 +0200 | [diff] [blame] | 1373 | err = register_netdevice(dev); |
| 1374 | if (err) |
| 1375 | return err; |
| 1376 | |
Ivan Vecera | b667744 | 2017-01-20 18:12:17 +0100 | [diff] [blame] | 1377 | if (tb[IFLA_ADDRESS]) { |
| 1378 | spin_lock_bh(&br->lock); |
| 1379 | br_stp_change_bridge_id(br, nla_data(tb[IFLA_ADDRESS])); |
| 1380 | spin_unlock_bh(&br->lock); |
| 1381 | } |
| 1382 | |
Matthias Schiffer | ad744b2 | 2017-06-25 23:56:00 +0200 | [diff] [blame] | 1383 | err = br_changelink(dev, tb, data, extack); |
Ido Schimmel | 5b8d542 | 2017-04-10 14:59:28 +0300 | [diff] [blame] | 1384 | if (err) |
Nikolay Aleksandrov | 84aeb43 | 2017-12-18 17:35:09 +0200 | [diff] [blame] | 1385 | br_dev_delete(dev, NULL); |
| 1386 | |
Ido Schimmel | 5b8d542 | 2017-04-10 14:59:28 +0300 | [diff] [blame] | 1387 | return err; |
Ivan Vecera | b667744 | 2017-01-20 18:12:17 +0100 | [diff] [blame] | 1388 | } |
| 1389 | |
Jiri Pirko | e5c3ea5 | 2014-09-05 15:51:31 +0200 | [diff] [blame] | 1390 | static size_t br_get_size(const struct net_device *brdev) |
| 1391 | { |
| 1392 | return nla_total_size(sizeof(u32)) + /* IFLA_BR_FORWARD_DELAY */ |
| 1393 | nla_total_size(sizeof(u32)) + /* IFLA_BR_HELLO_TIME */ |
| 1394 | nla_total_size(sizeof(u32)) + /* IFLA_BR_MAX_AGE */ |
Jörg Thalheim | af61576 | 2015-03-18 10:06:58 +0100 | [diff] [blame] | 1395 | nla_total_size(sizeof(u32)) + /* IFLA_BR_AGEING_TIME */ |
| 1396 | nla_total_size(sizeof(u32)) + /* IFLA_BR_STP_STATE */ |
| 1397 | nla_total_size(sizeof(u16)) + /* IFLA_BR_PRIORITY */ |
Nikolay Aleksandrov | a785403 | 2015-08-07 19:40:45 +0300 | [diff] [blame] | 1398 | nla_total_size(sizeof(u8)) + /* IFLA_BR_VLAN_FILTERING */ |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1399 | #ifdef CONFIG_BRIDGE_VLAN_FILTERING |
| 1400 | nla_total_size(sizeof(__be16)) + /* IFLA_BR_VLAN_PROTOCOL */ |
Nikolay Aleksandrov | 0f963b7 | 2015-10-04 14:23:47 +0200 | [diff] [blame] | 1401 | nla_total_size(sizeof(u16)) + /* IFLA_BR_VLAN_DEFAULT_PVID */ |
Nikolay Aleksandrov | 6dada9b | 2016-04-30 10:25:28 +0200 | [diff] [blame] | 1402 | nla_total_size(sizeof(u8)) + /* IFLA_BR_VLAN_STATS_ENABLED */ |
Nikolay Aleksandrov | 9163a0f | 2018-10-12 13:41:16 +0300 | [diff] [blame] | 1403 | nla_total_size(sizeof(u8)) + /* IFLA_BR_VLAN_STATS_PER_PORT */ |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1404 | #endif |
Nikolay Aleksandrov | 7910228 | 2015-10-04 14:23:28 +0200 | [diff] [blame] | 1405 | nla_total_size(sizeof(u16)) + /* IFLA_BR_GROUP_FWD_MASK */ |
Nikolay Aleksandrov | 5127c81 | 2015-10-04 14:23:29 +0200 | [diff] [blame] | 1406 | nla_total_size(sizeof(struct ifla_bridge_id)) + /* IFLA_BR_ROOT_ID */ |
Nikolay Aleksandrov | 7599a22 | 2015-10-04 14:23:30 +0200 | [diff] [blame] | 1407 | nla_total_size(sizeof(struct ifla_bridge_id)) + /* IFLA_BR_BRIDGE_ID */ |
Nikolay Aleksandrov | 8762ba6 | 2015-10-04 14:23:31 +0200 | [diff] [blame] | 1408 | nla_total_size(sizeof(u16)) + /* IFLA_BR_ROOT_PORT */ |
Nikolay Aleksandrov | 684dd24 | 2015-10-04 14:23:32 +0200 | [diff] [blame] | 1409 | nla_total_size(sizeof(u32)) + /* IFLA_BR_ROOT_PATH_COST */ |
Nikolay Aleksandrov | b89e6ba | 2015-10-04 14:23:44 +0200 | [diff] [blame] | 1410 | nla_total_size(sizeof(u8)) + /* IFLA_BR_TOPOLOGY_CHANGE */ |
| 1411 | nla_total_size(sizeof(u8)) + /* IFLA_BR_TOPOLOGY_CHANGE_DETECTED */ |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1412 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_HELLO_TIMER */ |
| 1413 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_TCN_TIMER */ |
| 1414 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_TOPOLOGY_CHANGE_TIMER */ |
| 1415 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_GC_TIMER */ |
Nikolay Aleksandrov | 111189a | 2015-10-04 14:23:35 +0200 | [diff] [blame] | 1416 | nla_total_size(ETH_ALEN) + /* IFLA_BR_GROUP_ADDR */ |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1417 | #ifdef CONFIG_BRIDGE_IGMP_SNOOPING |
| 1418 | nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_ROUTER */ |
Nikolay Aleksandrov | 8912632 | 2015-10-04 14:23:38 +0200 | [diff] [blame] | 1419 | nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_SNOOPING */ |
Nikolay Aleksandrov | 295141d | 2015-10-04 14:23:39 +0200 | [diff] [blame] | 1420 | nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_QUERY_USE_IFADDR */ |
Nikolay Aleksandrov | ba062d7c | 2015-10-04 14:23:40 +0200 | [diff] [blame] | 1421 | nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_QUERIER */ |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1422 | nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_STATS_ENABLED */ |
Nikolay Aleksandrov | b89e6ba | 2015-10-04 14:23:44 +0200 | [diff] [blame] | 1423 | nla_total_size(sizeof(u32)) + /* IFLA_BR_MCAST_HASH_ELASTICITY */ |
| 1424 | nla_total_size(sizeof(u32)) + /* IFLA_BR_MCAST_HASH_MAX */ |
| 1425 | nla_total_size(sizeof(u32)) + /* IFLA_BR_MCAST_LAST_MEMBER_CNT */ |
| 1426 | nla_total_size(sizeof(u32)) + /* IFLA_BR_MCAST_STARTUP_QUERY_CNT */ |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1427 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_MCAST_LAST_MEMBER_INTVL */ |
| 1428 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_MCAST_MEMBERSHIP_INTVL */ |
| 1429 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_MCAST_QUERIER_INTVL */ |
| 1430 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_MCAST_QUERY_INTVL */ |
| 1431 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_MCAST_QUERY_RESPONSE_INTVL */ |
| 1432 | nla_total_size_64bit(sizeof(u64)) + /* IFLA_BR_MCAST_STARTUP_QUERY_INTVL */ |
Nikolay Aleksandrov | 5e92358 | 2016-11-21 13:03:24 +0100 | [diff] [blame] | 1433 | nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_IGMP_VERSION */ |
Nikolay Aleksandrov | aa2ae3e | 2016-11-21 13:03:25 +0100 | [diff] [blame] | 1434 | nla_total_size(sizeof(u8)) + /* IFLA_BR_MCAST_MLD_VERSION */ |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1435 | #endif |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1436 | #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) |
| 1437 | nla_total_size(sizeof(u8)) + /* IFLA_BR_NF_CALL_IPTABLES */ |
| 1438 | nla_total_size(sizeof(u8)) + /* IFLA_BR_NF_CALL_IP6TABLES */ |
| 1439 | nla_total_size(sizeof(u8)) + /* IFLA_BR_NF_CALL_ARPTABLES */ |
| 1440 | #endif |
Nikolay Aleksandrov | a428afe | 2018-11-24 04:34:20 +0200 | [diff] [blame] | 1441 | nla_total_size(sizeof(struct br_boolopt_multi)) + /* IFLA_BR_MULTI_BOOLOPT */ |
Jiri Pirko | e5c3ea5 | 2014-09-05 15:51:31 +0200 | [diff] [blame] | 1442 | 0; |
| 1443 | } |
| 1444 | |
| 1445 | static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev) |
| 1446 | { |
| 1447 | struct net_bridge *br = netdev_priv(brdev); |
| 1448 | u32 forward_delay = jiffies_to_clock_t(br->forward_delay); |
| 1449 | u32 hello_time = jiffies_to_clock_t(br->hello_time); |
| 1450 | u32 age_time = jiffies_to_clock_t(br->max_age); |
Jörg Thalheim | af61576 | 2015-03-18 10:06:58 +0100 | [diff] [blame] | 1451 | u32 ageing_time = jiffies_to_clock_t(br->ageing_time); |
| 1452 | u32 stp_enabled = br->stp_enabled; |
| 1453 | u16 priority = (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]; |
Ido Schimmel | 1f51445 | 2017-05-26 08:37:23 +0200 | [diff] [blame] | 1454 | u8 vlan_enabled = br_vlan_enabled(br->dev); |
Nikolay Aleksandrov | a428afe | 2018-11-24 04:34:20 +0200 | [diff] [blame] | 1455 | struct br_boolopt_multi bm; |
Nikolay Aleksandrov | 4917a15 | 2015-10-05 12:11:21 +0200 | [diff] [blame] | 1456 | u64 clockval; |
Nikolay Aleksandrov | 5127c81 | 2015-10-04 14:23:29 +0200 | [diff] [blame] | 1457 | |
Nikolay Aleksandrov | 4917a15 | 2015-10-05 12:11:21 +0200 | [diff] [blame] | 1458 | clockval = br_timer_value(&br->hello_timer); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1459 | if (nla_put_u64_64bit(skb, IFLA_BR_HELLO_TIMER, clockval, IFLA_BR_PAD)) |
Nikolay Aleksandrov | 4917a15 | 2015-10-05 12:11:21 +0200 | [diff] [blame] | 1460 | return -EMSGSIZE; |
| 1461 | clockval = br_timer_value(&br->tcn_timer); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1462 | if (nla_put_u64_64bit(skb, IFLA_BR_TCN_TIMER, clockval, IFLA_BR_PAD)) |
Nikolay Aleksandrov | 4917a15 | 2015-10-05 12:11:21 +0200 | [diff] [blame] | 1463 | return -EMSGSIZE; |
| 1464 | clockval = br_timer_value(&br->topology_change_timer); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1465 | if (nla_put_u64_64bit(skb, IFLA_BR_TOPOLOGY_CHANGE_TIMER, clockval, |
| 1466 | IFLA_BR_PAD)) |
Nikolay Aleksandrov | 4917a15 | 2015-10-05 12:11:21 +0200 | [diff] [blame] | 1467 | return -EMSGSIZE; |
Nikolay Aleksandrov | f7cdee8 | 2017-02-04 18:05:07 +0100 | [diff] [blame] | 1468 | clockval = br_timer_value(&br->gc_work.timer); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1469 | if (nla_put_u64_64bit(skb, IFLA_BR_GC_TIMER, clockval, IFLA_BR_PAD)) |
Nikolay Aleksandrov | 4917a15 | 2015-10-05 12:11:21 +0200 | [diff] [blame] | 1470 | return -EMSGSIZE; |
Jiri Pirko | e5c3ea5 | 2014-09-05 15:51:31 +0200 | [diff] [blame] | 1471 | |
Nikolay Aleksandrov | a428afe | 2018-11-24 04:34:20 +0200 | [diff] [blame] | 1472 | br_boolopt_multi_get(br, &bm); |
Jiri Pirko | e5c3ea5 | 2014-09-05 15:51:31 +0200 | [diff] [blame] | 1473 | if (nla_put_u32(skb, IFLA_BR_FORWARD_DELAY, forward_delay) || |
| 1474 | nla_put_u32(skb, IFLA_BR_HELLO_TIME, hello_time) || |
Jörg Thalheim | af61576 | 2015-03-18 10:06:58 +0100 | [diff] [blame] | 1475 | nla_put_u32(skb, IFLA_BR_MAX_AGE, age_time) || |
| 1476 | nla_put_u32(skb, IFLA_BR_AGEING_TIME, ageing_time) || |
| 1477 | nla_put_u32(skb, IFLA_BR_STP_STATE, stp_enabled) || |
Nikolay Aleksandrov | a785403 | 2015-08-07 19:40:45 +0300 | [diff] [blame] | 1478 | nla_put_u16(skb, IFLA_BR_PRIORITY, priority) || |
Nikolay Aleksandrov | 7910228 | 2015-10-04 14:23:28 +0200 | [diff] [blame] | 1479 | nla_put_u8(skb, IFLA_BR_VLAN_FILTERING, vlan_enabled) || |
Nikolay Aleksandrov | 4917a15 | 2015-10-05 12:11:21 +0200 | [diff] [blame] | 1480 | nla_put_u16(skb, IFLA_BR_GROUP_FWD_MASK, br->group_fwd_mask) || |
| 1481 | nla_put(skb, IFLA_BR_BRIDGE_ID, sizeof(struct ifla_bridge_id), |
| 1482 | &br->bridge_id) || |
| 1483 | nla_put(skb, IFLA_BR_ROOT_ID, sizeof(struct ifla_bridge_id), |
| 1484 | &br->designated_root) || |
Nikolay Aleksandrov | 684dd24 | 2015-10-04 14:23:32 +0200 | [diff] [blame] | 1485 | nla_put_u16(skb, IFLA_BR_ROOT_PORT, br->root_port) || |
Nikolay Aleksandrov | ed41630 | 2015-10-04 14:23:33 +0200 | [diff] [blame] | 1486 | nla_put_u32(skb, IFLA_BR_ROOT_PATH_COST, br->root_path_cost) || |
| 1487 | nla_put_u8(skb, IFLA_BR_TOPOLOGY_CHANGE, br->topology_change) || |
| 1488 | nla_put_u8(skb, IFLA_BR_TOPOLOGY_CHANGE_DETECTED, |
Nikolay Aleksandrov | d76bd14 | 2015-10-04 14:23:34 +0200 | [diff] [blame] | 1489 | br->topology_change_detected) || |
Nikolay Aleksandrov | a428afe | 2018-11-24 04:34:20 +0200 | [diff] [blame] | 1490 | nla_put(skb, IFLA_BR_GROUP_ADDR, ETH_ALEN, br->group_addr) || |
| 1491 | nla_put(skb, IFLA_BR_MULTI_BOOLOPT, sizeof(bm), &bm)) |
Jiri Pirko | e5c3ea5 | 2014-09-05 15:51:31 +0200 | [diff] [blame] | 1492 | return -EMSGSIZE; |
| 1493 | |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1494 | #ifdef CONFIG_BRIDGE_VLAN_FILTERING |
Nikolay Aleksandrov | 0f963b7 | 2015-10-04 14:23:47 +0200 | [diff] [blame] | 1495 | if (nla_put_be16(skb, IFLA_BR_VLAN_PROTOCOL, br->vlan_proto) || |
Nikolay Aleksandrov | 6dada9b | 2016-04-30 10:25:28 +0200 | [diff] [blame] | 1496 | nla_put_u16(skb, IFLA_BR_VLAN_DEFAULT_PVID, br->default_pvid) || |
Nikolay Aleksandrov | ae75767 | 2018-09-26 17:01:00 +0300 | [diff] [blame] | 1497 | nla_put_u8(skb, IFLA_BR_VLAN_STATS_ENABLED, |
Nikolay Aleksandrov | 9163a0f | 2018-10-12 13:41:16 +0300 | [diff] [blame] | 1498 | br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) || |
| 1499 | nla_put_u8(skb, IFLA_BR_VLAN_STATS_PER_PORT, |
Nikolay Aleksandrov | 600bea7 | 2019-04-16 16:15:56 +0300 | [diff] [blame] | 1500 | br_opt_get(br, BROPT_VLAN_STATS_PER_PORT))) |
Toshiaki Makita | d2d427b | 2015-08-27 15:32:26 +0900 | [diff] [blame] | 1501 | return -EMSGSIZE; |
| 1502 | #endif |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1503 | #ifdef CONFIG_BRIDGE_IGMP_SNOOPING |
Nikolay Aleksandrov | 8912632 | 2015-10-04 14:23:38 +0200 | [diff] [blame] | 1504 | if (nla_put_u8(skb, IFLA_BR_MCAST_ROUTER, br->multicast_router) || |
Nikolay Aleksandrov | 13cefad | 2018-09-26 17:01:03 +0300 | [diff] [blame] | 1505 | nla_put_u8(skb, IFLA_BR_MCAST_SNOOPING, |
| 1506 | br_opt_get(br, BROPT_MULTICAST_ENABLED)) || |
Nikolay Aleksandrov | 295141d | 2015-10-04 14:23:39 +0200 | [diff] [blame] | 1507 | nla_put_u8(skb, IFLA_BR_MCAST_QUERY_USE_IFADDR, |
Nikolay Aleksandrov | 675779a | 2018-09-26 17:01:04 +0300 | [diff] [blame] | 1508 | br_opt_get(br, BROPT_MULTICAST_QUERY_USE_IFADDR)) || |
| 1509 | nla_put_u8(skb, IFLA_BR_MCAST_QUERIER, |
| 1510 | br_opt_get(br, BROPT_MULTICAST_QUERIER)) || |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1511 | nla_put_u8(skb, IFLA_BR_MCAST_STATS_ENABLED, |
Nikolay Aleksandrov | 675779a | 2018-09-26 17:01:04 +0300 | [diff] [blame] | 1512 | br_opt_get(br, BROPT_MULTICAST_STATS_ENABLED)) || |
Nikolay Aleksandrov | cf332bca | 2018-12-05 15:14:26 +0200 | [diff] [blame] | 1513 | nla_put_u32(skb, IFLA_BR_MCAST_HASH_ELASTICITY, RHT_ELASTICITY) || |
Nikolay Aleksandrov | 79b859f | 2015-10-04 14:23:43 +0200 | [diff] [blame] | 1514 | nla_put_u32(skb, IFLA_BR_MCAST_HASH_MAX, br->hash_max) || |
| 1515 | nla_put_u32(skb, IFLA_BR_MCAST_LAST_MEMBER_CNT, |
Nikolay Aleksandrov | b89e6ba | 2015-10-04 14:23:44 +0200 | [diff] [blame] | 1516 | br->multicast_last_member_count) || |
| 1517 | nla_put_u32(skb, IFLA_BR_MCAST_STARTUP_QUERY_CNT, |
Nikolay Aleksandrov | 5e92358 | 2016-11-21 13:03:24 +0100 | [diff] [blame] | 1518 | br->multicast_startup_query_count) || |
| 1519 | nla_put_u8(skb, IFLA_BR_MCAST_IGMP_VERSION, |
| 1520 | br->multicast_igmp_version)) |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1521 | return -EMSGSIZE; |
Nikolay Aleksandrov | aa2ae3e | 2016-11-21 13:03:25 +0100 | [diff] [blame] | 1522 | #if IS_ENABLED(CONFIG_IPV6) |
| 1523 | if (nla_put_u8(skb, IFLA_BR_MCAST_MLD_VERSION, |
| 1524 | br->multicast_mld_version)) |
| 1525 | return -EMSGSIZE; |
| 1526 | #endif |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1527 | clockval = jiffies_to_clock_t(br->multicast_last_member_interval); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1528 | if (nla_put_u64_64bit(skb, IFLA_BR_MCAST_LAST_MEMBER_INTVL, clockval, |
| 1529 | IFLA_BR_PAD)) |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1530 | return -EMSGSIZE; |
| 1531 | clockval = jiffies_to_clock_t(br->multicast_membership_interval); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1532 | if (nla_put_u64_64bit(skb, IFLA_BR_MCAST_MEMBERSHIP_INTVL, clockval, |
| 1533 | IFLA_BR_PAD)) |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1534 | return -EMSGSIZE; |
| 1535 | clockval = jiffies_to_clock_t(br->multicast_querier_interval); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1536 | if (nla_put_u64_64bit(skb, IFLA_BR_MCAST_QUERIER_INTVL, clockval, |
| 1537 | IFLA_BR_PAD)) |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1538 | return -EMSGSIZE; |
| 1539 | clockval = jiffies_to_clock_t(br->multicast_query_interval); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1540 | if (nla_put_u64_64bit(skb, IFLA_BR_MCAST_QUERY_INTVL, clockval, |
| 1541 | IFLA_BR_PAD)) |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1542 | return -EMSGSIZE; |
| 1543 | clockval = jiffies_to_clock_t(br->multicast_query_response_interval); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1544 | if (nla_put_u64_64bit(skb, IFLA_BR_MCAST_QUERY_RESPONSE_INTVL, clockval, |
| 1545 | IFLA_BR_PAD)) |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1546 | return -EMSGSIZE; |
| 1547 | clockval = jiffies_to_clock_t(br->multicast_startup_query_interval); |
Nicolas Dichtel | 12a0faa | 2016-04-25 10:25:18 +0200 | [diff] [blame] | 1548 | if (nla_put_u64_64bit(skb, IFLA_BR_MCAST_STARTUP_QUERY_INTVL, clockval, |
| 1549 | IFLA_BR_PAD)) |
Nikolay Aleksandrov | 7e4df51 | 2015-10-04 14:23:45 +0200 | [diff] [blame] | 1550 | return -EMSGSIZE; |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1551 | #endif |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1552 | #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) |
| 1553 | if (nla_put_u8(skb, IFLA_BR_NF_CALL_IPTABLES, |
Nikolay Aleksandrov | 8df3510 | 2018-09-26 17:01:01 +0300 | [diff] [blame] | 1554 | br_opt_get(br, BROPT_NF_CALL_IPTABLES) ? 1 : 0) || |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1555 | nla_put_u8(skb, IFLA_BR_NF_CALL_IP6TABLES, |
Nikolay Aleksandrov | 8df3510 | 2018-09-26 17:01:01 +0300 | [diff] [blame] | 1556 | br_opt_get(br, BROPT_NF_CALL_IP6TABLES) ? 1 : 0) || |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1557 | nla_put_u8(skb, IFLA_BR_NF_CALL_ARPTABLES, |
Nikolay Aleksandrov | 8df3510 | 2018-09-26 17:01:01 +0300 | [diff] [blame] | 1558 | br_opt_get(br, BROPT_NF_CALL_ARPTABLES) ? 1 : 0)) |
Nikolay Aleksandrov | 93870cc | 2015-10-04 14:23:46 +0200 | [diff] [blame] | 1559 | return -EMSGSIZE; |
| 1560 | #endif |
Nikolay Aleksandrov | a9a6bc7 | 2015-10-04 14:23:37 +0200 | [diff] [blame] | 1561 | |
Jiri Pirko | e5c3ea5 | 2014-09-05 15:51:31 +0200 | [diff] [blame] | 1562 | return 0; |
| 1563 | } |
| 1564 | |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1565 | static size_t br_get_linkxstats_size(const struct net_device *dev, int attr) |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1566 | { |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1567 | struct net_bridge_port *p = NULL; |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1568 | struct net_bridge_vlan_group *vg; |
| 1569 | struct net_bridge_vlan *v; |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1570 | struct net_bridge *br; |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1571 | int numvls = 0; |
| 1572 | |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1573 | switch (attr) { |
| 1574 | case IFLA_STATS_LINK_XSTATS: |
| 1575 | br = netdev_priv(dev); |
| 1576 | vg = br_vlan_group(br); |
| 1577 | break; |
| 1578 | case IFLA_STATS_LINK_XSTATS_SLAVE: |
| 1579 | p = br_port_get_rtnl(dev); |
| 1580 | if (!p) |
| 1581 | return 0; |
| 1582 | br = p->br; |
| 1583 | vg = nbp_vlan_group(p); |
| 1584 | break; |
| 1585 | default: |
| 1586 | return 0; |
| 1587 | } |
| 1588 | |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1589 | if (vg) { |
| 1590 | /* we need to count all, even placeholder entries */ |
| 1591 | list_for_each_entry(v, &vg->vlan_list, vlist) |
| 1592 | numvls++; |
| 1593 | } |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1594 | |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1595 | return numvls * nla_total_size(sizeof(struct bridge_vlan_xstats)) + |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1596 | nla_total_size(sizeof(struct br_mcast_stats)) + |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1597 | nla_total_size(0); |
| 1598 | } |
| 1599 | |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1600 | static int br_fill_linkxstats(struct sk_buff *skb, |
| 1601 | const struct net_device *dev, |
| 1602 | int *prividx, int attr) |
Nikolay Aleksandrov | 80e73cc | 2016-06-28 16:57:05 +0200 | [diff] [blame] | 1603 | { |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1604 | struct nlattr *nla __maybe_unused; |
| 1605 | struct net_bridge_port *p = NULL; |
| 1606 | struct net_bridge_vlan_group *vg; |
| 1607 | struct net_bridge_vlan *v; |
| 1608 | struct net_bridge *br; |
| 1609 | struct nlattr *nest; |
| 1610 | int vl_idx = 0; |
Nikolay Aleksandrov | 80e73cc | 2016-06-28 16:57:05 +0200 | [diff] [blame] | 1611 | |
| 1612 | switch (attr) { |
| 1613 | case IFLA_STATS_LINK_XSTATS: |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1614 | br = netdev_priv(dev); |
| 1615 | vg = br_vlan_group(br); |
Nikolay Aleksandrov | 80e73cc | 2016-06-28 16:57:05 +0200 | [diff] [blame] | 1616 | break; |
| 1617 | case IFLA_STATS_LINK_XSTATS_SLAVE: |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1618 | p = br_port_get_rtnl(dev); |
| 1619 | if (!p) |
| 1620 | return 0; |
| 1621 | br = p->br; |
| 1622 | vg = nbp_vlan_group(p); |
Nikolay Aleksandrov | 80e73cc | 2016-06-28 16:57:05 +0200 | [diff] [blame] | 1623 | break; |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1624 | default: |
| 1625 | return -EINVAL; |
Nikolay Aleksandrov | 80e73cc | 2016-06-28 16:57:05 +0200 | [diff] [blame] | 1626 | } |
| 1627 | |
Michal Kubecek | ae0be8d | 2019-04-26 11:13:06 +0200 | [diff] [blame] | 1628 | nest = nla_nest_start_noflag(skb, LINK_XSTATS_TYPE_BRIDGE); |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1629 | if (!nest) |
| 1630 | return -EMSGSIZE; |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1631 | |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1632 | if (vg) { |
Nikolay Aleksandrov | 72f4af4 | 2016-08-25 14:27:51 +0200 | [diff] [blame] | 1633 | u16 pvid; |
| 1634 | |
| 1635 | pvid = br_get_pvid(vg); |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1636 | list_for_each_entry(v, &vg->vlan_list, vlist) { |
| 1637 | struct bridge_vlan_xstats vxi; |
| 1638 | struct br_vlan_stats stats; |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1639 | |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1640 | if (++vl_idx < *prividx) |
| 1641 | continue; |
| 1642 | memset(&vxi, 0, sizeof(vxi)); |
| 1643 | vxi.vid = v->vid; |
Nikolay Aleksandrov | 61ba1a2 | 2016-08-17 12:53:10 +0200 | [diff] [blame] | 1644 | vxi.flags = v->flags; |
Nikolay Aleksandrov | 72f4af4 | 2016-08-25 14:27:51 +0200 | [diff] [blame] | 1645 | if (v->vid == pvid) |
| 1646 | vxi.flags |= BRIDGE_VLAN_INFO_PVID; |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1647 | br_vlan_get_stats(v, &stats); |
| 1648 | vxi.rx_bytes = stats.rx_bytes; |
| 1649 | vxi.rx_packets = stats.rx_packets; |
| 1650 | vxi.tx_bytes = stats.tx_bytes; |
| 1651 | vxi.tx_packets = stats.tx_packets; |
| 1652 | |
| 1653 | if (nla_put(skb, BRIDGE_XSTATS_VLAN, sizeof(vxi), &vxi)) |
| 1654 | goto nla_put_failure; |
| 1655 | } |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1656 | } |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1657 | |
| 1658 | #ifdef CONFIG_BRIDGE_IGMP_SNOOPING |
| 1659 | if (++vl_idx >= *prividx) { |
| 1660 | nla = nla_reserve_64bit(skb, BRIDGE_XSTATS_MCAST, |
| 1661 | sizeof(struct br_mcast_stats), |
| 1662 | BRIDGE_XSTATS_PAD); |
| 1663 | if (!nla) |
| 1664 | goto nla_put_failure; |
Nikolay Aleksandrov | d5ff8c4 | 2016-08-17 12:53:09 +0200 | [diff] [blame] | 1665 | br_multicast_get_stats(br, p, nla_data(nla)); |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1666 | } |
| 1667 | #endif |
Vivien Didelot | de17996 | 2019-12-11 20:07:10 -0500 | [diff] [blame] | 1668 | |
| 1669 | if (p) { |
| 1670 | nla = nla_reserve_64bit(skb, BRIDGE_XSTATS_STP, |
| 1671 | sizeof(p->stp_xstats), |
| 1672 | BRIDGE_XSTATS_PAD); |
| 1673 | if (!nla) |
| 1674 | goto nla_put_failure; |
| 1675 | |
| 1676 | spin_lock_bh(&br->lock); |
| 1677 | memcpy(nla_data(nla), &p->stp_xstats, sizeof(p->stp_xstats)); |
| 1678 | spin_unlock_bh(&br->lock); |
| 1679 | } |
| 1680 | |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1681 | nla_nest_end(skb, nest); |
| 1682 | *prividx = 0; |
Nikolay Aleksandrov | 1080ab9 | 2016-06-28 16:57:06 +0200 | [diff] [blame] | 1683 | |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1684 | return 0; |
| 1685 | |
| 1686 | nla_put_failure: |
| 1687 | nla_nest_end(skb, nest); |
| 1688 | *prividx = vl_idx; |
| 1689 | |
| 1690 | return -EMSGSIZE; |
| 1691 | } |
Roopa Prabhu | fed0a15 | 2015-02-25 23:55:40 -0800 | [diff] [blame] | 1692 | |
Daniel Borkmann | 207895fd3 | 2015-01-29 12:15:03 +0100 | [diff] [blame] | 1693 | static struct rtnl_af_ops br_af_ops __read_mostly = { |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 1694 | .family = AF_BRIDGE, |
Arad, Ronen | b1974ed | 2015-10-19 09:23:28 -0700 | [diff] [blame] | 1695 | .get_link_af_size = br_get_link_af_size_filtered, |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 1696 | }; |
| 1697 | |
stephen hemminger | 149ddd8 | 2012-06-26 05:48:45 +0000 | [diff] [blame] | 1698 | struct rtnl_link_ops br_link_ops __read_mostly = { |
Jiri Pirko | ced8283 | 2014-09-05 15:51:29 +0200 | [diff] [blame] | 1699 | .kind = "bridge", |
| 1700 | .priv_size = sizeof(struct net_bridge), |
| 1701 | .setup = br_dev_setup, |
Scott Feldman | eb4cb85 | 2015-08-19 11:29:35 -0700 | [diff] [blame] | 1702 | .maxtype = IFLA_BR_MAX, |
Jiri Pirko | 1332351 | 2014-09-05 15:51:32 +0200 | [diff] [blame] | 1703 | .policy = br_policy, |
Jiri Pirko | ced8283 | 2014-09-05 15:51:29 +0200 | [diff] [blame] | 1704 | .validate = br_validate, |
| 1705 | .newlink = br_dev_newlink, |
Jiri Pirko | 1332351 | 2014-09-05 15:51:32 +0200 | [diff] [blame] | 1706 | .changelink = br_changelink, |
Jiri Pirko | ced8283 | 2014-09-05 15:51:29 +0200 | [diff] [blame] | 1707 | .dellink = br_dev_delete, |
Jiri Pirko | e5c3ea5 | 2014-09-05 15:51:31 +0200 | [diff] [blame] | 1708 | .get_size = br_get_size, |
| 1709 | .fill_info = br_fill_info, |
Nikolay Aleksandrov | a60c090 | 2016-04-30 10:25:29 +0200 | [diff] [blame] | 1710 | .fill_linkxstats = br_fill_linkxstats, |
| 1711 | .get_linkxstats_size = br_get_linkxstats_size, |
Jiri Pirko | 3ac636b | 2014-09-05 15:51:30 +0200 | [diff] [blame] | 1712 | |
| 1713 | .slave_maxtype = IFLA_BRPORT_MAX, |
| 1714 | .slave_policy = br_port_policy, |
| 1715 | .slave_changelink = br_port_slave_changelink, |
Jiri Pirko | ced8283 | 2014-09-05 15:51:29 +0200 | [diff] [blame] | 1716 | .get_slave_size = br_port_get_slave_size, |
| 1717 | .fill_slave_info = br_port_fill_slave_info, |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 1718 | }; |
| 1719 | |
| 1720 | int __init br_netlink_init(void) |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 1721 | { |
Vlad Yasevich | 3ec8e9f | 2013-01-02 09:41:25 +0000 | [diff] [blame] | 1722 | int err; |
| 1723 | |
| 1724 | br_mdb_init(); |
Nikolay Aleksandrov | 8dcea18 | 2020-01-14 19:56:09 +0200 | [diff] [blame] | 1725 | br_vlan_rtnl_init(); |
stephen hemminger | 3678a9d | 2013-12-30 10:41:32 -0800 | [diff] [blame] | 1726 | rtnl_af_register(&br_af_ops); |
Vlad Yasevich | 3ec8e9f | 2013-01-02 09:41:25 +0000 | [diff] [blame] | 1727 | |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 1728 | err = rtnl_link_register(&br_link_ops); |
| 1729 | if (err) |
| 1730 | goto out_af; |
| 1731 | |
Vlad Yasevich | 3ec8e9f | 2013-01-02 09:41:25 +0000 | [diff] [blame] | 1732 | return 0; |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 1733 | |
| 1734 | out_af: |
| 1735 | rtnl_af_unregister(&br_af_ops); |
Vlad Yasevich | 3ec8e9f | 2013-01-02 09:41:25 +0000 | [diff] [blame] | 1736 | br_mdb_uninit(); |
| 1737 | return err; |
Stephen Hemminger | 11dc1f3 | 2006-05-25 16:00:12 -0700 | [diff] [blame] | 1738 | } |
| 1739 | |
Pablo Neira Ayuso | 34666d4 | 2014-09-18 11:29:03 +0200 | [diff] [blame] | 1740 | void br_netlink_fini(void) |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 1741 | { |
Vlad Yasevich | 3ec8e9f | 2013-01-02 09:41:25 +0000 | [diff] [blame] | 1742 | br_mdb_uninit(); |
Nikolay Aleksandrov | 8dcea18 | 2020-01-14 19:56:09 +0200 | [diff] [blame] | 1743 | br_vlan_rtnl_uninit(); |
Vlad Yasevich | 6cbdcee | 2013-02-13 12:00:13 +0000 | [diff] [blame] | 1744 | rtnl_af_unregister(&br_af_ops); |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 1745 | rtnl_link_unregister(&br_link_ops); |
stephen hemminger | bb900b2 | 2011-04-04 14:03:32 +0000 | [diff] [blame] | 1746 | } |