blob: 1138e6ee759929900456c3f178e1479470b18050 [file] [log] [blame]
Jiri Pirko28d84b42014-09-28 16:33:29 -07001/*
2 * iplink_bridge.c Bridge device support
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * Authors: Jiri Pirko <jiri@resnulli.us>
10 */
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <string.h>
15#include <linux/if_link.h>
Nikolay Aleksandrov70dfb0b2016-02-09 00:14:19 +010016#include <netinet/ether.h>
Jiri Pirko28d84b42014-09-28 16:33:29 -070017
Toshiaki Makita1eea5c42015-08-31 18:48:46 +090018#include "rt_names.h"
Jiri Pirko28d84b42014-09-28 16:33:29 -070019#include "utils.h"
20#include "ip_common.h"
21
Zhang Shengju43367ef2015-08-12 06:03:23 +000022static void print_explain(FILE *f)
Jiri Pirko28d84b42014-09-28 16:33:29 -070023{
Zhang Shengju43367ef2015-08-12 06:03:23 +000024 fprintf(f,
Jiri Pirko28d84b42014-09-28 16:33:29 -070025 "Usage: ... bridge [ forward_delay FORWARD_DELAY ]\n"
26 " [ hello_time HELLO_TIME ]\n"
27 " [ max_age MAX_AGE ]\n"
Nikolay Aleksandrov6c99fb62015-06-16 13:38:47 +030028 " [ ageing_time AGEING_TIME ]\n"
Nikolay Aleksandrovdab04962015-06-16 13:38:48 +030029 " [ stp_state STP_STATE ]\n"
Nikolay Aleksandrovb0197a02015-06-16 13:38:49 +030030 " [ priority PRIORITY ]\n"
Nikolay Aleksandrov8caaf332016-02-09 00:14:22 +010031 " [ group_fwd_mask MASK ]\n"
Nikolay Aleksandrov0a61aa32016-02-09 00:14:23 +010032 " [ group_address ADDRESS ]\n"
Nikolay Aleksandrove4d456f2015-08-12 09:19:06 -070033 " [ vlan_filtering VLAN_FILTERING ]\n"
Toshiaki Makita1eea5c42015-08-31 18:48:46 +090034 " [ vlan_protocol VLAN_PROTOCOL ]\n"
Nikolay Aleksandrov719832a2016-02-09 00:14:24 +010035 " [ vlan_default_pvid VLAN_DEFAULT_PVID ]\n"
Nikolay Aleksandrov7ddd2d92016-02-09 00:14:26 +010036 " [ mcast_snooping MULTICAST_SNOOPING ]\n"
Nikolay Aleksandrov963d1372016-02-09 00:14:25 +010037 " [ mcast_router MULTICAST_ROUTER ]\n"
Nikolay Aleksandrov449843d2016-02-09 00:14:27 +010038 " [ mcast_query_use_ifaddr MCAST_QUERY_USE_IFADDR ]\n"
Nikolay Aleksandrov0778b742016-02-09 00:14:28 +010039 " [ mcast_querier MULTICAST_QUERIER ]\n"
Nikolay Aleksandrov92c0ef72016-02-09 00:14:29 +010040 " [ mcast_hash_elasticity HASH_ELASTICITY ]\n"
Nikolay Aleksandrov8b9eb7c2016-02-09 00:14:30 +010041 " [ mcast_hash_max HASH_MAX ]\n"
Nikolay Aleksandrovfb44cad2016-02-09 00:14:31 +010042 " [ mcast_last_member_count LAST_MEMBER_COUNT ]\n"
Nikolay Aleksandrovceb64862016-02-09 00:14:32 +010043 " [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n"
Nikolay Aleksandrov10082a22016-02-09 00:14:33 +010044 " [ mcast_last_member_interval LAST_MEMBER_INTERVAL ]\n"
Nikolay Aleksandrov7f3d5592016-02-09 00:14:34 +010045 " [ mcast_membership_interval MEMBERSHIP_INTERVAL ]\n"
Nikolay Aleksandrov1f2244b2016-02-09 00:14:35 +010046 " [ mcast_querier_interval QUERIER_INTERVAL ]\n"
Toshiaki Makita1eea5c42015-08-31 18:48:46 +090047 "\n"
48 "Where: VLAN_PROTOCOL := { 802.1Q | 802.1ad }\n"
Jiri Pirko28d84b42014-09-28 16:33:29 -070049 );
50}
51
Zhang Shengju43367ef2015-08-12 06:03:23 +000052static void explain(void)
53{
54 print_explain(stderr);
55}
56
Nikolay Aleksandrov70dfb0b2016-02-09 00:14:19 +010057static void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf,
58 size_t len)
59{
60 char eaddr[32];
61
62 ether_ntoa_r((const struct ether_addr *)id->addr, eaddr);
63 snprintf(buf, len, "%.2x%.2x.%s", id->prio[0], id->prio[1], eaddr);
64}
65
Jiri Pirko28d84b42014-09-28 16:33:29 -070066static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,
67 struct nlmsghdr *n)
68{
69 __u32 val;
70
71 while (argc > 0) {
72 if (matches(*argv, "forward_delay") == 0) {
73 NEXT_ARG();
Zhang Shengju6a9ce302015-08-13 07:48:15 +000074 if (get_u32(&val, *argv, 0))
Jiri Pirko28d84b42014-09-28 16:33:29 -070075 invarg("invalid forward_delay", *argv);
Zhang Shengju6a9ce302015-08-13 07:48:15 +000076
Jiri Pirko28d84b42014-09-28 16:33:29 -070077 addattr32(n, 1024, IFLA_BR_FORWARD_DELAY, val);
78 } else if (matches(*argv, "hello_time") == 0) {
79 NEXT_ARG();
Zhang Shengju6a9ce302015-08-13 07:48:15 +000080 if (get_u32(&val, *argv, 0))
Jiri Pirko28d84b42014-09-28 16:33:29 -070081 invarg("invalid hello_time", *argv);
Zhang Shengju6a9ce302015-08-13 07:48:15 +000082
Jiri Pirko28d84b42014-09-28 16:33:29 -070083 addattr32(n, 1024, IFLA_BR_HELLO_TIME, val);
84 } else if (matches(*argv, "max_age") == 0) {
85 NEXT_ARG();
Zhang Shengju6a9ce302015-08-13 07:48:15 +000086 if (get_u32(&val, *argv, 0))
Jiri Pirko28d84b42014-09-28 16:33:29 -070087 invarg("invalid max_age", *argv);
Zhang Shengju6a9ce302015-08-13 07:48:15 +000088
Jiri Pirko28d84b42014-09-28 16:33:29 -070089 addattr32(n, 1024, IFLA_BR_MAX_AGE, val);
Nikolay Aleksandrov6c99fb62015-06-16 13:38:47 +030090 } else if (matches(*argv, "ageing_time") == 0) {
91 NEXT_ARG();
Zhang Shengju6a9ce302015-08-13 07:48:15 +000092 if (get_u32(&val, *argv, 0))
Nikolay Aleksandrov6c99fb62015-06-16 13:38:47 +030093 invarg("invalid ageing_time", *argv);
Zhang Shengju6a9ce302015-08-13 07:48:15 +000094
Nikolay Aleksandrov6c99fb62015-06-16 13:38:47 +030095 addattr32(n, 1024, IFLA_BR_AGEING_TIME, val);
Nikolay Aleksandrovdab04962015-06-16 13:38:48 +030096 } else if (matches(*argv, "stp_state") == 0) {
97 NEXT_ARG();
Zhang Shengju6a9ce302015-08-13 07:48:15 +000098 if (get_u32(&val, *argv, 0))
Nikolay Aleksandrovdab04962015-06-16 13:38:48 +030099 invarg("invalid stp_state", *argv);
Zhang Shengju6a9ce302015-08-13 07:48:15 +0000100
Nikolay Aleksandrovdab04962015-06-16 13:38:48 +0300101 addattr32(n, 1024, IFLA_BR_STP_STATE, val);
Nikolay Aleksandrovb0197a02015-06-16 13:38:49 +0300102 } else if (matches(*argv, "priority") == 0) {
103 __u16 prio;
104
105 NEXT_ARG();
Zhang Shengju6a9ce302015-08-13 07:48:15 +0000106 if (get_u16(&prio, *argv, 0))
Nikolay Aleksandrovb0197a02015-06-16 13:38:49 +0300107 invarg("invalid priority", *argv);
Zhang Shengju6a9ce302015-08-13 07:48:15 +0000108
Nikolay Aleksandrovb0197a02015-06-16 13:38:49 +0300109 addattr16(n, 1024, IFLA_BR_PRIORITY, prio);
Nikolay Aleksandrove4d456f2015-08-12 09:19:06 -0700110 } else if (matches(*argv, "vlan_filtering") == 0) {
111 __u8 vlan_filter;
112
113 NEXT_ARG();
114 if (get_u8(&vlan_filter, *argv, 0)) {
115 invarg("invalid vlan_filtering", *argv);
116 return -1;
117 }
118 addattr8(n, 1024, IFLA_BR_VLAN_FILTERING, vlan_filter);
Toshiaki Makita1eea5c42015-08-31 18:48:46 +0900119 } else if (matches(*argv, "vlan_protocol") == 0) {
120 __u16 vlan_proto;
121
122 NEXT_ARG();
123 if (ll_proto_a2n(&vlan_proto, *argv)) {
124 invarg("invalid vlan_protocol", *argv);
125 return -1;
126 }
127 addattr16(n, 1024, IFLA_BR_VLAN_PROTOCOL, vlan_proto);
Nikolay Aleksandrov8caaf332016-02-09 00:14:22 +0100128 } else if (matches(*argv, "group_fwd_mask") == 0) {
129 __u16 fwd_mask;
130
131 NEXT_ARG();
132 if (get_u16(&fwd_mask, *argv, 0))
133 invarg("invalid group_fwd_mask", *argv);
134
135 addattr16(n, 1024, IFLA_BR_GROUP_FWD_MASK, fwd_mask);
Nikolay Aleksandrov0a61aa32016-02-09 00:14:23 +0100136 } else if (matches(*argv, "group_address") == 0) {
137 char llabuf[32];
138 int len;
139
140 NEXT_ARG();
141 len = ll_addr_a2n(llabuf, sizeof(llabuf), *argv);
142 if (len < 0)
143 return -1;
144 addattr_l(n, 1024, IFLA_BR_GROUP_ADDR, llabuf, len);
Nikolay Aleksandrov719832a2016-02-09 00:14:24 +0100145 } else if (matches(*argv, "vlan_default_pvid") == 0) {
146 __u16 default_pvid;
147
148 NEXT_ARG();
149 if (get_u16(&default_pvid, *argv, 0))
150 invarg("invalid vlan_default_pvid", *argv);
151
152 addattr16(n, 1024, IFLA_BR_VLAN_DEFAULT_PVID,
153 default_pvid);
Nikolay Aleksandrov963d1372016-02-09 00:14:25 +0100154 } else if (matches(*argv, "mcast_router") == 0) {
155 __u8 mcast_router;
156
157 NEXT_ARG();
158 if (get_u8(&mcast_router, *argv, 0))
159 invarg("invalid mcast_router", *argv);
160
161 addattr8(n, 1024, IFLA_BR_MCAST_ROUTER, mcast_router);
Nikolay Aleksandrov7ddd2d92016-02-09 00:14:26 +0100162 } else if (matches(*argv, "mcast_snooping") == 0) {
163 __u8 mcast_snoop;
164
165 NEXT_ARG();
166 if (get_u8(&mcast_snoop, *argv, 0))
167 invarg("invalid mcast_snooping", *argv);
168
169 addattr8(n, 1024, IFLA_BR_MCAST_SNOOPING, mcast_snoop);
Nikolay Aleksandrov449843d2016-02-09 00:14:27 +0100170 } else if (matches(*argv, "mcast_query_use_ifaddr") == 0) {
171 __u8 mcast_qui;
172
173 NEXT_ARG();
174 if (get_u8(&mcast_qui, *argv, 0))
175 invarg("invalid mcast_query_use_ifaddr",
176 *argv);
177
178 addattr8(n, 1024, IFLA_BR_MCAST_QUERY_USE_IFADDR,
179 mcast_qui);
Nikolay Aleksandrov0778b742016-02-09 00:14:28 +0100180 } else if (matches(*argv, "mcast_querier") == 0) {
181 __u8 mcast_querier;
182
183 NEXT_ARG();
184 if (get_u8(&mcast_querier, *argv, 0))
185 invarg("invalid mcast_querier", *argv);
186
187 addattr8(n, 1024, IFLA_BR_MCAST_QUERIER, mcast_querier);
Nikolay Aleksandrov92c0ef72016-02-09 00:14:29 +0100188 } else if (matches(*argv, "mcast_hash_elasticity") == 0) {
189 __u32 mcast_hash_el;
190
191 NEXT_ARG();
192 if (get_u32(&mcast_hash_el, *argv, 0))
193 invarg("invalid mcast_hash_elasticity",
194 *argv);
195
196 addattr32(n, 1024, IFLA_BR_MCAST_HASH_ELASTICITY,
197 mcast_hash_el);
Nikolay Aleksandrov8b9eb7c2016-02-09 00:14:30 +0100198 } else if (matches(*argv, "mcast_hash_max") == 0) {
199 __u32 mcast_hash_max;
200
201 NEXT_ARG();
202 if (get_u32(&mcast_hash_max, *argv, 0))
203 invarg("invalid mcast_hash_max", *argv);
204
205 addattr32(n, 1024, IFLA_BR_MCAST_HASH_MAX,
206 mcast_hash_max);
Nikolay Aleksandrovfb44cad2016-02-09 00:14:31 +0100207 } else if (matches(*argv, "mcast_last_member_count") == 0) {
208 __u32 mcast_lmc;
209
210 NEXT_ARG();
211 if (get_u32(&mcast_lmc, *argv, 0))
212 invarg("invalid mcast_last_member_count",
213 *argv);
214
215 addattr32(n, 1024, IFLA_BR_MCAST_LAST_MEMBER_CNT,
216 mcast_lmc);
Nikolay Aleksandrovceb64862016-02-09 00:14:32 +0100217 } else if (matches(*argv, "mcast_startup_query_count") == 0) {
218 __u32 mcast_sqc;
219
220 NEXT_ARG();
221 if (get_u32(&mcast_sqc, *argv, 0))
222 invarg("invalid mcast_startup_query_count",
223 *argv);
224
225 addattr32(n, 1024, IFLA_BR_MCAST_STARTUP_QUERY_CNT,
226 mcast_sqc);
Nikolay Aleksandrov10082a22016-02-09 00:14:33 +0100227 } else if (matches(*argv, "mcast_last_member_interval") == 0) {
228 __u64 mcast_last_member_intvl;
229
230 NEXT_ARG();
231 if (get_u64(&mcast_last_member_intvl, *argv, 0))
232 invarg("invalid mcast_last_member_interval",
233 *argv);
234
235 addattr64(n, 1024, IFLA_BR_MCAST_LAST_MEMBER_INTVL,
236 mcast_last_member_intvl);
Nikolay Aleksandrov7f3d5592016-02-09 00:14:34 +0100237 } else if (matches(*argv, "mcast_membership_interval") == 0) {
238 __u64 mcast_membership_intvl;
239
240 NEXT_ARG();
241 if (get_u64(&mcast_membership_intvl, *argv, 0)) {
242 invarg("invalid mcast_membership_interval",
243 *argv);
244 return -1;
245 }
246 addattr64(n, 1024, IFLA_BR_MCAST_MEMBERSHIP_INTVL,
247 mcast_membership_intvl);
Nikolay Aleksandrov1f2244b2016-02-09 00:14:35 +0100248 } else if (matches(*argv, "mcast_querier_interval") == 0) {
249 __u64 mcast_querier_intvl;
250
251 NEXT_ARG();
252 if (get_u64(&mcast_querier_intvl, *argv, 0)) {
253 invarg("invalid mcast_querier_interval",
254 *argv);
255 return -1;
256 }
257 addattr64(n, 1024, IFLA_BR_MCAST_QUERIER_INTVL,
258 mcast_querier_intvl);
Jiri Pirko28d84b42014-09-28 16:33:29 -0700259 } else if (matches(*argv, "help") == 0) {
260 explain();
261 return -1;
262 } else {
263 fprintf(stderr, "bridge: unknown command \"%s\"?\n", *argv);
264 explain();
265 return -1;
266 }
267 argc--, argv++;
268 }
269
270 return 0;
271}
272
273static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
274{
275 if (!tb)
276 return;
277
278 if (tb[IFLA_BR_FORWARD_DELAY])
279 fprintf(f, "forward_delay %u ",
280 rta_getattr_u32(tb[IFLA_BR_FORWARD_DELAY]));
281
282 if (tb[IFLA_BR_HELLO_TIME])
283 fprintf(f, "hello_time %u ",
284 rta_getattr_u32(tb[IFLA_BR_HELLO_TIME]));
285
286 if (tb[IFLA_BR_MAX_AGE])
287 fprintf(f, "max_age %u ",
288 rta_getattr_u32(tb[IFLA_BR_MAX_AGE]));
Nikolay Aleksandrovfdba0512015-08-12 09:11:30 -0700289
290 if (tb[IFLA_BR_AGEING_TIME])
291 fprintf(f, "ageing_time %u ",
292 rta_getattr_u32(tb[IFLA_BR_AGEING_TIME]));
293
294 if (tb[IFLA_BR_STP_STATE])
295 fprintf(f, "stp_state %u ",
296 rta_getattr_u32(tb[IFLA_BR_STP_STATE]));
297
298 if (tb[IFLA_BR_PRIORITY])
299 fprintf(f, "priority %u ",
300 rta_getattr_u16(tb[IFLA_BR_PRIORITY]));
Nikolay Aleksandrove4d456f2015-08-12 09:19:06 -0700301
302 if (tb[IFLA_BR_VLAN_FILTERING])
303 fprintf(f, "vlan_filtering %u ",
304 rta_getattr_u8(tb[IFLA_BR_VLAN_FILTERING]));
Toshiaki Makita1eea5c42015-08-31 18:48:46 +0900305
306 if (tb[IFLA_BR_VLAN_PROTOCOL]) {
307 SPRINT_BUF(b1);
308
309 fprintf(f, "vlan_protocol %s ",
310 ll_proto_n2a(rta_getattr_u16(tb[IFLA_BR_VLAN_PROTOCOL]),
311 b1, sizeof(b1)));
312 }
Nikolay Aleksandrov70dfb0b2016-02-09 00:14:19 +0100313
314 if (tb[IFLA_BR_BRIDGE_ID]) {
315 char bridge_id[32];
316
317 br_dump_bridge_id(RTA_DATA(tb[IFLA_BR_BRIDGE_ID]), bridge_id,
318 sizeof(bridge_id));
319 fprintf(f, "bridge_id %s ", bridge_id);
320 }
321
322 if (tb[IFLA_BR_ROOT_ID]) {
323 char root_id[32];
324
325 br_dump_bridge_id(RTA_DATA(tb[IFLA_BR_BRIDGE_ID]), root_id,
326 sizeof(root_id));
327 fprintf(f, "designated_root %s ", root_id);
328 }
Nikolay Aleksandrov4e3bbc62016-02-09 00:14:20 +0100329
330 if (tb[IFLA_BR_ROOT_PORT])
331 fprintf(f, "root_port %u ",
332 rta_getattr_u16(tb[IFLA_BR_ROOT_PORT]));
333
334 if (tb[IFLA_BR_ROOT_PATH_COST])
335 fprintf(f, "root_path_cost %u ",
336 rta_getattr_u32(tb[IFLA_BR_ROOT_PATH_COST]));
337
338 if (tb[IFLA_BR_TOPOLOGY_CHANGE])
339 fprintf(f, "topology_change %u ",
340 rta_getattr_u8(tb[IFLA_BR_TOPOLOGY_CHANGE]));
341
342 if (tb[IFLA_BR_TOPOLOGY_CHANGE_DETECTED])
343 fprintf(f, "topology_change_detected %u ",
344 rta_getattr_u8(tb[IFLA_BR_TOPOLOGY_CHANGE_DETECTED]));
Nikolay Aleksandrov8c0f7a12016-02-09 00:14:21 +0100345
346 if (tb[IFLA_BR_HELLO_TIMER]) {
347 struct timeval tv;
348
349 __jiffies_to_tv(&tv, rta_getattr_u64(tb[IFLA_BR_HELLO_TIMER]));
350 fprintf(f, "hello_timer %4i.%.2i ", (int)tv.tv_sec,
351 (int)tv.tv_usec/10000);
352 }
353
354 if (tb[IFLA_BR_TCN_TIMER]) {
355 struct timeval tv;
356
357 __jiffies_to_tv(&tv, rta_getattr_u64(tb[IFLA_BR_TCN_TIMER]));
358 fprintf(f, "tcn_timer %4i.%.2i ", (int)tv.tv_sec,
359 (int)tv.tv_usec/10000);
360 }
361
362 if (tb[IFLA_BR_TOPOLOGY_CHANGE_TIMER]) {
363 unsigned long jiffies;
364 struct timeval tv;
365
366 jiffies = rta_getattr_u64(tb[IFLA_BR_TOPOLOGY_CHANGE_TIMER]);
367 __jiffies_to_tv(&tv, jiffies);
368 fprintf(f, "topology_change_timer %4i.%.2i ", (int)tv.tv_sec,
369 (int)tv.tv_usec/10000);
370 }
371
372 if (tb[IFLA_BR_GC_TIMER]) {
373 struct timeval tv;
374
375 __jiffies_to_tv(&tv, rta_getattr_u64(tb[IFLA_BR_GC_TIMER]));
376 fprintf(f, "gc_timer %4i.%.2i ", (int)tv.tv_sec,
377 (int)tv.tv_usec/10000);
378 }
Nikolay Aleksandrov8caaf332016-02-09 00:14:22 +0100379
Nikolay Aleksandrov719832a2016-02-09 00:14:24 +0100380 if (tb[IFLA_BR_VLAN_DEFAULT_PVID])
381 fprintf(f, "vlan_default_pvid %u ",
382 rta_getattr_u16(tb[IFLA_BR_VLAN_DEFAULT_PVID]));
383
Nikolay Aleksandrov8caaf332016-02-09 00:14:22 +0100384 if (tb[IFLA_BR_GROUP_FWD_MASK])
385 fprintf(f, "group_fwd_mask %#x ",
386 rta_getattr_u16(tb[IFLA_BR_GROUP_FWD_MASK]));
Nikolay Aleksandrov0a61aa32016-02-09 00:14:23 +0100387
388 if (tb[IFLA_BR_GROUP_ADDR]) {
389 SPRINT_BUF(mac);
390
391 fprintf(f, "group_address %s ",
392 ll_addr_n2a(RTA_DATA(tb[IFLA_BR_GROUP_ADDR]),
393 RTA_PAYLOAD(tb[IFLA_BR_GROUP_ADDR]),
394 1 /*ARPHDR_ETHER*/, mac, sizeof(mac)));
395 }
Nikolay Aleksandrov963d1372016-02-09 00:14:25 +0100396
Nikolay Aleksandrov7ddd2d92016-02-09 00:14:26 +0100397 if (tb[IFLA_BR_MCAST_SNOOPING])
398 fprintf(f, "mcast_snooping %u ",
399 rta_getattr_u8(tb[IFLA_BR_MCAST_SNOOPING]));
400
Nikolay Aleksandrov963d1372016-02-09 00:14:25 +0100401 if (tb[IFLA_BR_MCAST_ROUTER])
402 fprintf(f, "mcast_router %u ",
403 rta_getattr_u8(tb[IFLA_BR_MCAST_ROUTER]));
Nikolay Aleksandrov449843d2016-02-09 00:14:27 +0100404
405 if (tb[IFLA_BR_MCAST_QUERY_USE_IFADDR])
406 fprintf(f, "mcast_query_use_ifaddr %u ",
407 rta_getattr_u8(tb[IFLA_BR_MCAST_QUERY_USE_IFADDR]));
Nikolay Aleksandrov0778b742016-02-09 00:14:28 +0100408
409 if (tb[IFLA_BR_MCAST_QUERIER])
410 fprintf(f, "mcast_querier %u ",
411 rta_getattr_u8(tb[IFLA_BR_MCAST_QUERIER]));
Nikolay Aleksandrov92c0ef72016-02-09 00:14:29 +0100412
413 if (tb[IFLA_BR_MCAST_HASH_ELASTICITY])
414 fprintf(f, "mcast_hash_elasticity %u ",
415 rta_getattr_u32(tb[IFLA_BR_MCAST_HASH_ELASTICITY]));
Nikolay Aleksandrov8b9eb7c2016-02-09 00:14:30 +0100416
417 if (tb[IFLA_BR_MCAST_HASH_MAX])
418 fprintf(f, "mcast_hash_max %u ",
419 rta_getattr_u32(tb[IFLA_BR_MCAST_HASH_MAX]));
Nikolay Aleksandrovfb44cad2016-02-09 00:14:31 +0100420
421 if (tb[IFLA_BR_MCAST_LAST_MEMBER_CNT])
422 fprintf(f, "mcast_last_member_count %u ",
423 rta_getattr_u32(tb[IFLA_BR_MCAST_LAST_MEMBER_CNT]));
Nikolay Aleksandrovceb64862016-02-09 00:14:32 +0100424
425 if (tb[IFLA_BR_MCAST_STARTUP_QUERY_CNT])
426 fprintf(f, "mcast_startup_query_count %u ",
427 rta_getattr_u32(tb[IFLA_BR_MCAST_STARTUP_QUERY_CNT]));
Nikolay Aleksandrov10082a22016-02-09 00:14:33 +0100428
429 if (tb[IFLA_BR_MCAST_LAST_MEMBER_INTVL])
430 fprintf(f, "mcast_last_member_interval %llu ",
431 rta_getattr_u64(tb[IFLA_BR_MCAST_LAST_MEMBER_INTVL]));
Nikolay Aleksandrov7f3d5592016-02-09 00:14:34 +0100432
433 if (tb[IFLA_BR_MCAST_MEMBERSHIP_INTVL])
434 fprintf(f, "mcast_membership_interval %llu ",
435 rta_getattr_u64(tb[IFLA_BR_MCAST_MEMBERSHIP_INTVL]));
Nikolay Aleksandrov1f2244b2016-02-09 00:14:35 +0100436
437 if (tb[IFLA_BR_MCAST_QUERIER_INTVL])
438 fprintf(f, "mcast_querier_interval %llu ",
439 rta_getattr_u64(tb[IFLA_BR_MCAST_QUERIER_INTVL]));
Jiri Pirko28d84b42014-09-28 16:33:29 -0700440}
441
Zhang Shengju43367ef2015-08-12 06:03:23 +0000442static void bridge_print_help(struct link_util *lu, int argc, char **argv,
443 FILE *f)
444{
445 print_explain(f);
446}
447
Jiri Pirko28d84b42014-09-28 16:33:29 -0700448struct link_util bridge_link_util = {
449 .id = "bridge",
450 .maxattr = IFLA_BR_MAX,
451 .parse_opt = bridge_parse_opt,
452 .print_opt = bridge_print_opt,
Zhang Shengju43367ef2015-08-12 06:03:23 +0000453 .print_help = bridge_print_help,
Jiri Pirko28d84b42014-09-28 16:33:29 -0700454};