remove obsolete /opt/local prefix on Mac OS X
[project/netifd.git] / bridge.c
1 /*
2  * netifd - network interface daemon
3  * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14 #include <string.h>
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include <assert.h>
18 #include <errno.h>
19
20 #include "netifd.h"
21 #include "device.h"
22 #include "interface.h"
23 #include "system.h"
24
25 enum {
26         BRIDGE_ATTR_IFNAME,
27         BRIDGE_ATTR_STP,
28         BRIDGE_ATTR_FORWARD_DELAY,
29         BRIDGE_ATTR_PRIORITY,
30         BRIDGE_ATTR_IGMP_SNOOP,
31         BRIDGE_ATTR_AGEING_TIME,
32         BRIDGE_ATTR_HELLO_TIME,
33         BRIDGE_ATTR_MAX_AGE,
34         BRIDGE_ATTR_BRIDGE_EMPTY,
35         BRIDGE_ATTR_MULTICAST_QUERIER,
36         BRIDGE_ATTR_HASH_MAX,
37         BRIDGE_ATTR_ROBUSTNESS,
38         BRIDGE_ATTR_QUERY_INTERVAL,
39         BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL,
40         BRIDGE_ATTR_LAST_MEMBER_INTERVAL,
41         __BRIDGE_ATTR_MAX
42 };
43
44 static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = {
45         [BRIDGE_ATTR_IFNAME] = { "ifname", BLOBMSG_TYPE_ARRAY },
46         [BRIDGE_ATTR_STP] = { "stp", BLOBMSG_TYPE_BOOL },
47         [BRIDGE_ATTR_FORWARD_DELAY] = { "forward_delay", BLOBMSG_TYPE_INT32 },
48         [BRIDGE_ATTR_PRIORITY] = { "priority", BLOBMSG_TYPE_INT32 },
49         [BRIDGE_ATTR_AGEING_TIME] = { "ageing_time", BLOBMSG_TYPE_INT32 },
50         [BRIDGE_ATTR_HELLO_TIME] = { "hello_time", BLOBMSG_TYPE_INT32 },
51         [BRIDGE_ATTR_MAX_AGE] = { "max_age", BLOBMSG_TYPE_INT32 },
52         [BRIDGE_ATTR_IGMP_SNOOP] = { "igmp_snooping", BLOBMSG_TYPE_BOOL },
53         [BRIDGE_ATTR_BRIDGE_EMPTY] = { "bridge_empty", BLOBMSG_TYPE_BOOL },
54         [BRIDGE_ATTR_MULTICAST_QUERIER] = { "multicast_querier", BLOBMSG_TYPE_BOOL },
55         [BRIDGE_ATTR_HASH_MAX] = { "hash_max", BLOBMSG_TYPE_INT32 },
56         [BRIDGE_ATTR_ROBUSTNESS] = { "robustness", BLOBMSG_TYPE_INT32 },
57         [BRIDGE_ATTR_QUERY_INTERVAL] = { "query_interval", BLOBMSG_TYPE_INT32 },
58         [BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL] = { "query_response_interval", BLOBMSG_TYPE_INT32 },
59         [BRIDGE_ATTR_LAST_MEMBER_INTERVAL] = { "last_member_interval", BLOBMSG_TYPE_INT32 },
60 };
61
62 static const struct uci_blob_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = {
63         [BRIDGE_ATTR_IFNAME] = { .type = BLOBMSG_TYPE_STRING },
64 };
65
66 static const struct uci_blob_param_list bridge_attr_list = {
67         .n_params = __BRIDGE_ATTR_MAX,
68         .params = bridge_attrs,
69         .info = bridge_attr_info,
70
71         .n_next = 1,
72         .next = { &device_attr_list },
73 };
74
75 static struct device *bridge_create(const char *name, struct device_type *devtype,
76         struct blob_attr *attr);
77 static void bridge_config_init(struct device *dev);
78 static void bridge_free(struct device *dev);
79 static void bridge_dump_info(struct device *dev, struct blob_buf *b);
80 enum dev_change_type
81 bridge_reload(struct device *dev, struct blob_attr *attr);
82
83 static struct device_type bridge_device_type = {
84         .name = "bridge",
85         .config_params = &bridge_attr_list,
86
87         .bridge_capability = true,
88         .name_prefix = "br",
89
90         .create = bridge_create,
91         .config_init = bridge_config_init,
92         .reload = bridge_reload,
93         .free = bridge_free,
94         .dump_info = bridge_dump_info,
95 };
96
97 struct bridge_state {
98         struct device dev;
99         device_state_cb set_state;
100
101         struct blob_attr *config_data;
102         struct bridge_config config;
103         struct blob_attr *ifnames;
104         bool active;
105         bool force_active;
106
107         struct uloop_timeout retry;
108         struct bridge_member *primary_port;
109         struct vlist_tree members;
110         int n_present;
111         int n_failed;
112 };
113
114 struct bridge_member {
115         struct vlist_node node;
116         struct bridge_state *bst;
117         struct device_user dev;
118         bool present;
119         char name[];
120 };
121
122 static void
123 bridge_reset_primary(struct bridge_state *bst)
124 {
125         struct bridge_member *bm;
126
127         if (!bst->primary_port &&
128             (bst->dev.settings.flags & DEV_OPT_MACADDR))
129                 return;
130
131         bst->primary_port = NULL;
132         bst->dev.settings.flags &= ~DEV_OPT_MACADDR;
133         vlist_for_each_element(&bst->members, bm, node) {
134                 uint8_t *macaddr;
135
136                 if (!bm->present)
137                         continue;
138
139                 bst->primary_port = bm;
140                 if (bm->dev.dev->settings.flags & DEV_OPT_MACADDR)
141                         macaddr = bm->dev.dev->settings.macaddr;
142                 else
143                         macaddr = bm->dev.dev->orig_settings.macaddr;
144                 memcpy(bst->dev.settings.macaddr, macaddr, 6);
145                 bst->dev.settings.flags |= DEV_OPT_MACADDR;
146                 return;
147         }
148 }
149
150 static int
151 bridge_disable_member(struct bridge_member *bm)
152 {
153         struct bridge_state *bst = bm->bst;
154
155         if (!bm->present)
156                 return 0;
157
158         system_bridge_delif(&bst->dev, bm->dev.dev);
159         device_release(&bm->dev);
160
161         device_broadcast_event(&bst->dev, DEV_EVENT_TOPO_CHANGE);
162
163         return 0;
164 }
165
166 static int
167 bridge_enable_interface(struct bridge_state *bst)
168 {
169         int ret;
170
171         if (bst->active)
172                 return 0;
173
174         ret = system_bridge_addbr(&bst->dev, &bst->config);
175         if (ret < 0)
176                 return ret;
177
178         bst->active = true;
179         return 0;
180 }
181
182 static void
183 bridge_disable_interface(struct bridge_state *bst)
184 {
185         if (!bst->active)
186                 return;
187
188         system_bridge_delbr(&bst->dev);
189         bst->active = false;
190 }
191
192 static int
193 bridge_enable_member(struct bridge_member *bm)
194 {
195         struct bridge_state *bst = bm->bst;
196         int ret;
197
198         if (!bm->present)
199                 return 0;
200
201         ret = bridge_enable_interface(bst);
202         if (ret)
203                 goto error;
204
205         /* Disable IPv6 for bridge members */
206         if (!(bm->dev.dev->settings.flags & DEV_OPT_IPV6)) {
207                 bm->dev.dev->settings.ipv6 = 0;
208                 bm->dev.dev->settings.flags |= DEV_OPT_IPV6;
209         }
210
211         ret = device_claim(&bm->dev);
212         if (ret < 0)
213                 goto error;
214
215         ret = system_bridge_addif(&bst->dev, bm->dev.dev);
216         if (ret < 0) {
217                 D(DEVICE, "Bridge device %s could not be added\n", bm->dev.dev->ifname);
218                 goto error;
219         }
220
221         device_set_present(&bst->dev, true);
222         device_broadcast_event(&bst->dev, DEV_EVENT_TOPO_CHANGE);
223
224         return 0;
225
226 error:
227         bst->n_failed++;
228         bm->present = false;
229         bst->n_present--;
230         device_release(&bm->dev);
231
232         return ret;
233 }
234
235 static void
236 bridge_remove_member(struct bridge_member *bm)
237 {
238         struct bridge_state *bst = bm->bst;
239
240         if (!bm->present)
241                 return;
242
243         if (bm == bst->primary_port)
244                 bridge_reset_primary(bst);
245
246         if (bst->dev.active)
247                 bridge_disable_member(bm);
248
249         bm->present = false;
250         bm->bst->n_present--;
251
252         if (bst->config.bridge_empty)
253                 return;
254
255         bst->force_active = false;
256         if (bst->n_present == 0)
257                 device_set_present(&bst->dev, false);
258 }
259
260 static void
261 bridge_free_member(struct bridge_member *bm)
262 {
263         struct device *dev = bm->dev.dev;
264
265         bridge_remove_member(bm);
266         device_remove_user(&bm->dev);
267
268         /*
269          * When reloading the config and moving a device from one bridge to
270          * another, the other bridge may have tried to claim this device
271          * before it was removed here.
272          * Ensure that claiming the device is retried by toggling its present
273          * state
274          */
275         if (dev->present) {
276                 device_set_present(dev, false);
277                 device_set_present(dev, true);
278         }
279
280         free(bm);
281 }
282
283 static void
284 bridge_check_retry(struct bridge_state *bst)
285 {
286         if (!bst->n_failed)
287                 return;
288
289         uloop_timeout_set(&bst->retry, 100);
290 }
291
292 static void
293 bridge_member_cb(struct device_user *dev, enum device_event ev)
294 {
295         struct bridge_member *bm = container_of(dev, struct bridge_member, dev);
296         struct bridge_state *bst = bm->bst;
297
298         switch (ev) {
299         case DEV_EVENT_ADD:
300                 assert(!bm->present);
301
302                 bm->present = true;
303                 bst->n_present++;
304
305                 if (bst->n_present == 1)
306                         device_set_present(&bst->dev, true);
307                 if (bst->dev.active && !bridge_enable_member(bm)) {
308                         /*
309                          * Adding a bridge member can overwrite the bridge mtu
310                          * in the kernel, apply the bridge settings in case the
311                          * bridge mtu is set
312                          */
313                         system_if_apply_settings(&bst->dev, &bst->dev.settings,
314                                                  DEV_OPT_MTU | DEV_OPT_MTU6);
315                 }
316
317                 break;
318         case DEV_EVENT_REMOVE:
319                 if (dev->hotplug) {
320                         vlist_delete(&bst->members, &bm->node);
321                         return;
322                 }
323
324                 if (bm->present)
325                         bridge_remove_member(bm);
326
327                 break;
328         default:
329                 return;
330         }
331 }
332
333 static int
334 bridge_set_down(struct bridge_state *bst)
335 {
336         struct bridge_member *bm;
337
338         bst->set_state(&bst->dev, false);
339
340         vlist_for_each_element(&bst->members, bm, node)
341                 bridge_disable_member(bm);
342
343         bridge_disable_interface(bst);
344
345         return 0;
346 }
347
348 static int
349 bridge_set_up(struct bridge_state *bst)
350 {
351         struct bridge_member *bm;
352         int ret;
353
354         if (!bst->n_present) {
355                 if (!bst->force_active)
356                         return -ENOENT;
357
358                 ret = bridge_enable_interface(bst);
359                 if (ret)
360                         return ret;
361         }
362
363         bst->n_failed = 0;
364         vlist_for_each_element(&bst->members, bm, node)
365                 bridge_enable_member(bm);
366         bridge_check_retry(bst);
367
368         if (!bst->force_active && !bst->n_present) {
369                 /* initialization of all member interfaces failed */
370                 bridge_disable_interface(bst);
371                 device_set_present(&bst->dev, false);
372                 return -ENOENT;
373         }
374
375         bridge_reset_primary(bst);
376         ret = bst->set_state(&bst->dev, true);
377         if (ret < 0)
378                 bridge_set_down(bst);
379
380         return ret;
381 }
382
383 static int
384 bridge_set_state(struct device *dev, bool up)
385 {
386         struct bridge_state *bst;
387
388         bst = container_of(dev, struct bridge_state, dev);
389
390         if (up)
391                 return bridge_set_up(bst);
392         else
393                 return bridge_set_down(bst);
394 }
395
396 static struct bridge_member *
397 bridge_create_member(struct bridge_state *bst, const char *name,
398                      struct device *dev, bool hotplug)
399 {
400         struct bridge_member *bm;
401
402         bm = calloc(1, sizeof(*bm) + strlen(name) + 1);
403         if (!bm)
404                 return NULL;
405
406         bm->bst = bst;
407         bm->dev.cb = bridge_member_cb;
408         bm->dev.hotplug = hotplug;
409         strcpy(bm->name, name);
410         bm->dev.dev = dev;
411         vlist_add(&bst->members, &bm->node, bm->name);
412         // Need to look up the bridge member again as the above
413         // created pointer will be freed in case the bridge member
414         // already existed
415         bm = vlist_find(&bst->members, name, bm, node);
416         if (hotplug && bm)
417                 bm->node.version = -1;
418
419         return bm;
420 }
421
422 static void
423 bridge_member_update(struct vlist_tree *tree, struct vlist_node *node_new,
424                      struct vlist_node *node_old)
425 {
426         struct bridge_member *bm;
427         struct device *dev;
428
429         if (node_new) {
430                 bm = container_of(node_new, struct bridge_member, node);
431
432                 if (node_old) {
433                         free(bm);
434                         return;
435                 }
436
437                 dev = bm->dev.dev;
438                 bm->dev.dev = NULL;
439                 device_add_user(&bm->dev, dev);
440         }
441
442
443         if (node_old) {
444                 bm = container_of(node_old, struct bridge_member, node);
445                 bridge_free_member(bm);
446         }
447 }
448
449
450 static void
451 bridge_add_member(struct bridge_state *bst, const char *name)
452 {
453         struct device *dev;
454
455         dev = device_get(name, true);
456         if (!dev)
457                 return;
458
459         bridge_create_member(bst, name, dev, false);
460 }
461
462 static int
463 bridge_hotplug_add(struct device *dev, struct device *member)
464 {
465         struct bridge_state *bst = container_of(dev, struct bridge_state, dev);
466
467         bridge_create_member(bst, member->ifname, member, true);
468
469         return 0;
470 }
471
472 static int
473 bridge_hotplug_del(struct device *dev, struct device *member)
474 {
475         struct bridge_state *bst = container_of(dev, struct bridge_state, dev);
476         struct bridge_member *bm;
477
478         bm = vlist_find(&bst->members, member->ifname, bm, node);
479         if (!bm)
480                 return UBUS_STATUS_NOT_FOUND;
481
482         vlist_delete(&bst->members, &bm->node);
483         return 0;
484 }
485
486 static int
487 bridge_hotplug_prepare(struct device *dev)
488 {
489         struct bridge_state *bst;
490
491         bst = container_of(dev, struct bridge_state, dev);
492         bst->force_active = true;
493         device_set_present(&bst->dev, true);
494
495         return 0;
496 }
497
498 static const struct device_hotplug_ops bridge_ops = {
499         .prepare = bridge_hotplug_prepare,
500         .add = bridge_hotplug_add,
501         .del = bridge_hotplug_del
502 };
503
504 static void
505 bridge_free(struct device *dev)
506 {
507         struct bridge_state *bst;
508
509         bst = container_of(dev, struct bridge_state, dev);
510         vlist_flush_all(&bst->members);
511         free(bst->config_data);
512         free(bst);
513 }
514
515 static void
516 bridge_dump_info(struct device *dev, struct blob_buf *b)
517 {
518         struct bridge_state *bst;
519         struct bridge_member *bm;
520         void *list;
521
522         bst = container_of(dev, struct bridge_state, dev);
523
524         system_if_dump_info(dev, b);
525         list = blobmsg_open_array(b, "bridge-members");
526
527         vlist_for_each_element(&bst->members, bm, node) {
528                 if (bm->dev.dev->hidden)
529                         continue;
530
531                 blobmsg_add_string(b, NULL, bm->dev.dev->ifname);
532         }
533
534         blobmsg_close_array(b, list);
535 }
536
537 static void
538 bridge_config_init(struct device *dev)
539 {
540         struct bridge_state *bst;
541         struct blob_attr *cur;
542         int rem;
543
544         bst = container_of(dev, struct bridge_state, dev);
545
546         if (bst->config.bridge_empty) {
547                 bst->force_active = true;
548                 device_set_present(&bst->dev, true);
549         }
550
551         bst->n_failed = 0;
552         vlist_update(&bst->members);
553         if (bst->ifnames) {
554                 blobmsg_for_each_attr(cur, bst->ifnames, rem) {
555                         bridge_add_member(bst, blobmsg_data(cur));
556                 }
557         }
558         vlist_flush(&bst->members);
559         bridge_check_retry(bst);
560 }
561
562 static void
563 bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb)
564 {
565         struct bridge_config *cfg = &bst->config;
566         struct blob_attr *cur;
567
568         /* defaults */
569         cfg->stp = false;
570         cfg->forward_delay = 2;
571         cfg->igmp_snoop = true;
572         cfg->multicast_querier = true;
573         cfg->robustness = 2;
574         cfg->query_interval = 12500;
575         cfg->query_response_interval = 1000;
576         cfg->last_member_interval = 100;
577         cfg->hash_max = 512;
578         cfg->bridge_empty = false;
579         cfg->priority = 0x7FFF;
580
581         if ((cur = tb[BRIDGE_ATTR_STP]))
582                 cfg->stp = blobmsg_get_bool(cur);
583
584         if ((cur = tb[BRIDGE_ATTR_FORWARD_DELAY]))
585                 cfg->forward_delay = blobmsg_get_u32(cur);
586
587         if ((cur = tb[BRIDGE_ATTR_PRIORITY]))
588                 cfg->priority = blobmsg_get_u32(cur);
589
590         if ((cur = tb[BRIDGE_ATTR_IGMP_SNOOP]))
591                 cfg->multicast_querier = cfg->igmp_snoop = blobmsg_get_bool(cur);
592
593         if ((cur = tb[BRIDGE_ATTR_MULTICAST_QUERIER]))
594                 cfg->multicast_querier = blobmsg_get_bool(cur);
595
596         if ((cur = tb[BRIDGE_ATTR_HASH_MAX]))
597                 cfg->hash_max = blobmsg_get_u32(cur);
598
599         if ((cur = tb[BRIDGE_ATTR_ROBUSTNESS])) {
600                 cfg->robustness = blobmsg_get_u32(cur);
601                 cfg->flags |= BRIDGE_OPT_ROBUSTNESS;
602         }
603
604         if ((cur = tb[BRIDGE_ATTR_QUERY_INTERVAL])) {
605                 cfg->query_interval = blobmsg_get_u32(cur);
606                 cfg->flags |= BRIDGE_OPT_QUERY_INTERVAL;
607         }
608
609         if ((cur = tb[BRIDGE_ATTR_QUERY_RESPONSE_INTERVAL])) {
610                 cfg->query_response_interval = blobmsg_get_u32(cur);
611                 cfg->flags |= BRIDGE_OPT_QUERY_RESPONSE_INTERVAL;
612         }
613
614         if ((cur = tb[BRIDGE_ATTR_LAST_MEMBER_INTERVAL])) {
615                 cfg->last_member_interval = blobmsg_get_u32(cur);
616                 cfg->flags |= BRIDGE_OPT_LAST_MEMBER_INTERVAL;
617         }
618
619         if ((cur = tb[BRIDGE_ATTR_AGEING_TIME])) {
620                 cfg->ageing_time = blobmsg_get_u32(cur);
621                 cfg->flags |= BRIDGE_OPT_AGEING_TIME;
622         }
623
624         if ((cur = tb[BRIDGE_ATTR_HELLO_TIME])) {
625                 cfg->hello_time = blobmsg_get_u32(cur);
626                 cfg->flags |= BRIDGE_OPT_HELLO_TIME;
627         }
628
629         if ((cur = tb[BRIDGE_ATTR_MAX_AGE])) {
630                 cfg->max_age = blobmsg_get_u32(cur);
631                 cfg->flags |= BRIDGE_OPT_MAX_AGE;
632         }
633
634         if ((cur = tb[BRIDGE_ATTR_BRIDGE_EMPTY]))
635                 cfg->bridge_empty = blobmsg_get_bool(cur);
636 }
637
638 enum dev_change_type
639 bridge_reload(struct device *dev, struct blob_attr *attr)
640 {
641         struct blob_attr *tb_dev[__DEV_ATTR_MAX];
642         struct blob_attr *tb_br[__BRIDGE_ATTR_MAX];
643         enum dev_change_type ret = DEV_CONFIG_APPLIED;
644         unsigned long diff;
645         struct bridge_state *bst;
646
647         BUILD_BUG_ON(sizeof(diff) < __BRIDGE_ATTR_MAX / 8);
648         BUILD_BUG_ON(sizeof(diff) < __DEV_ATTR_MAX / 8);
649
650         bst = container_of(dev, struct bridge_state, dev);
651         attr = blob_memdup(attr);
652
653         blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, tb_dev,
654                 blob_data(attr), blob_len(attr));
655         blobmsg_parse(bridge_attrs, __BRIDGE_ATTR_MAX, tb_br,
656                 blob_data(attr), blob_len(attr));
657
658         if (tb_dev[DEV_ATTR_MACADDR])
659                 bst->primary_port = NULL;
660
661         bst->ifnames = tb_br[BRIDGE_ATTR_IFNAME];
662         device_init_settings(dev, tb_dev);
663         bridge_apply_settings(bst, tb_br);
664
665         if (bst->config_data) {
666                 struct blob_attr *otb_dev[__DEV_ATTR_MAX];
667                 struct blob_attr *otb_br[__BRIDGE_ATTR_MAX];
668
669                 blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, otb_dev,
670                         blob_data(bst->config_data), blob_len(bst->config_data));
671
672                 diff = 0;
673                 uci_blob_diff(tb_dev, otb_dev, &device_attr_list, &diff);
674                 if (diff)
675                     ret = DEV_CONFIG_RESTART;
676
677                 blobmsg_parse(bridge_attrs, __BRIDGE_ATTR_MAX, otb_br,
678                         blob_data(bst->config_data), blob_len(bst->config_data));
679
680                 diff = 0;
681                 uci_blob_diff(tb_br, otb_br, &bridge_attr_list, &diff);
682                 if (diff & ~(1 << BRIDGE_ATTR_IFNAME))
683                     ret = DEV_CONFIG_RESTART;
684
685                 bridge_config_init(dev);
686         }
687
688         free(bst->config_data);
689         bst->config_data = attr;
690         return ret;
691 }
692
693 static void
694 bridge_retry_members(struct uloop_timeout *timeout)
695 {
696         struct bridge_state *bst = container_of(timeout, struct bridge_state, retry);
697         struct bridge_member *bm;
698
699         bst->n_failed = 0;
700         vlist_for_each_element(&bst->members, bm, node) {
701                 if (bm->present)
702                         continue;
703
704                 if (!bm->dev.dev->present)
705                         continue;
706
707                 bm->present = true;
708                 bst->n_present++;
709                 bridge_enable_member(bm);
710         }
711 }
712
713 static struct device *
714 bridge_create(const char *name, struct device_type *devtype,
715         struct blob_attr *attr)
716 {
717         struct bridge_state *bst;
718         struct device *dev = NULL;
719
720         bst = calloc(1, sizeof(*bst));
721         if (!bst)
722                 return NULL;
723
724         dev = &bst->dev;
725         device_init(dev, devtype, name);
726         dev->config_pending = true;
727         bst->retry.cb = bridge_retry_members;
728
729         bst->set_state = dev->set_state;
730         dev->set_state = bridge_set_state;
731
732         dev->hotplug_ops = &bridge_ops;
733
734         vlist_init(&bst->members, avl_strcmp, bridge_member_update);
735         bst->members.keep_old = true;
736         bridge_reload(dev, attr);
737
738         return dev;
739 }
740
741 static void __init bridge_device_type_init(void)
742 {
743         device_type_add(&bridge_device_type);
744 }