]> git.proxmox.com Git - mirror_ovs.git/blob - lib/netdev-dummy.c
netdev-dummy: Fix memory leak on error path in netdev_rx_dummy_recv().
[mirror_ovs.git] / lib / netdev-dummy.c
1 /*
2 * Copyright (c) 2010, 2011, 2012, 2013 Nicira, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <config.h>
18
19 #include "dummy.h"
20
21 #include <errno.h>
22
23 #include "flow.h"
24 #include "list.h"
25 #include "netdev-provider.h"
26 #include "netdev-vport.h"
27 #include "odp-util.h"
28 #include "ofp-print.h"
29 #include "ofpbuf.h"
30 #include "packets.h"
31 #include "poll-loop.h"
32 #include "shash.h"
33 #include "sset.h"
34 #include "stream.h"
35 #include "unaligned.h"
36 #include "unixctl.h"
37 #include "vlog.h"
38
39 VLOG_DEFINE_THIS_MODULE(netdev_dummy);
40
41 struct dummy_stream {
42 struct stream *stream;
43 struct ofpbuf rxbuf;
44 struct list txq;
45 };
46
47 struct netdev_dummy {
48 struct netdev up;
49 uint8_t hwaddr[ETH_ADDR_LEN];
50 int mtu;
51 struct netdev_stats stats;
52 enum netdev_flags flags;
53 unsigned int change_seq;
54 int ifindex;
55
56 struct pstream *pstream;
57 struct dummy_stream *streams;
58 size_t n_streams;
59
60 struct list rxes; /* List of child "netdev_rx_dummy"s. */
61 };
62
63 /* Max 'recv_queue_len' in struct netdev_dummy. */
64 #define NETDEV_DUMMY_MAX_QUEUE 100
65
66 struct netdev_rx_dummy {
67 struct netdev_rx up;
68 struct list node; /* In netdev_dummy's "rxes" list. */
69 struct list recv_queue;
70 int recv_queue_len; /* list_size(&recv_queue). */
71 bool listening;
72 };
73
74 static struct shash dummy_netdevs = SHASH_INITIALIZER(&dummy_netdevs);
75
76 static const struct netdev_rx_class netdev_rx_dummy_class;
77
78 static unixctl_cb_func netdev_dummy_set_admin_state;
79 static int netdev_dummy_create(const struct netdev_class *, const char *,
80 struct netdev **);
81 static void netdev_dummy_poll_notify(struct netdev_dummy *);
82 static void netdev_dummy_queue_packet(struct netdev_dummy *, struct ofpbuf *);
83
84 static void dummy_stream_close(struct dummy_stream *);
85
86 static bool
87 is_dummy_class(const struct netdev_class *class)
88 {
89 return class->create == netdev_dummy_create;
90 }
91
92 static struct netdev_dummy *
93 netdev_dummy_cast(const struct netdev *netdev)
94 {
95 ovs_assert(is_dummy_class(netdev_get_class(netdev)));
96 return CONTAINER_OF(netdev, struct netdev_dummy, up);
97 }
98
99 static struct netdev_rx_dummy *
100 netdev_rx_dummy_cast(const struct netdev_rx *rx)
101 {
102 netdev_rx_assert_class(rx, &netdev_rx_dummy_class);
103 return CONTAINER_OF(rx, struct netdev_rx_dummy, up);
104 }
105
106 static void
107 netdev_dummy_run(void)
108 {
109 struct shash_node *node;
110
111 SHASH_FOR_EACH (node, &dummy_netdevs) {
112 struct netdev_dummy *dev = node->data;
113 size_t i;
114
115 if (dev->pstream) {
116 struct stream *new_stream;
117 int error;
118
119 error = pstream_accept(dev->pstream, &new_stream);
120 if (!error) {
121 struct dummy_stream *s;
122
123 dev->streams = xrealloc(dev->streams,
124 ((dev->n_streams + 1)
125 * sizeof *dev->streams));
126 s = &dev->streams[dev->n_streams++];
127 s->stream = new_stream;
128 ofpbuf_init(&s->rxbuf, 2048);
129 list_init(&s->txq);
130 } else if (error != EAGAIN) {
131 VLOG_WARN("%s: accept failed (%s)",
132 pstream_get_name(dev->pstream), ovs_strerror(error));
133 pstream_close(dev->pstream);
134 dev->pstream = NULL;
135 }
136 }
137
138 for (i = 0; i < dev->n_streams; i++) {
139 struct dummy_stream *s = &dev->streams[i];
140 int error = 0;
141 size_t n;
142
143 stream_run(s->stream);
144
145 if (!list_is_empty(&s->txq)) {
146 struct ofpbuf *txbuf;
147 int retval;
148
149 txbuf = ofpbuf_from_list(list_front(&s->txq));
150 retval = stream_send(s->stream, txbuf->data, txbuf->size);
151 if (retval > 0) {
152 ofpbuf_pull(txbuf, retval);
153 if (!txbuf->size) {
154 list_remove(&txbuf->list_node);
155 ofpbuf_delete(txbuf);
156 }
157 } else if (retval != -EAGAIN) {
158 error = -retval;
159 }
160 }
161
162 if (!error) {
163 if (s->rxbuf.size < 2) {
164 n = 2 - s->rxbuf.size;
165 } else {
166 uint16_t frame_len;
167
168 frame_len = ntohs(get_unaligned_be16(s->rxbuf.data));
169 if (frame_len < ETH_HEADER_LEN) {
170 error = EPROTO;
171 n = 0;
172 } else {
173 n = (2 + frame_len) - s->rxbuf.size;
174 }
175 }
176 }
177 if (!error) {
178 int retval;
179
180 ofpbuf_prealloc_tailroom(&s->rxbuf, n);
181 retval = stream_recv(s->stream, ofpbuf_tail(&s->rxbuf), n);
182 if (retval > 0) {
183 s->rxbuf.size += retval;
184 if (retval == n && s->rxbuf.size > 2) {
185 ofpbuf_pull(&s->rxbuf, 2);
186 netdev_dummy_queue_packet(dev,
187 ofpbuf_clone(&s->rxbuf));
188 ofpbuf_clear(&s->rxbuf);
189 }
190 } else if (retval != -EAGAIN) {
191 error = (retval < 0 ? -retval
192 : s->rxbuf.size ? EPROTO
193 : EOF);
194 }
195 }
196
197 if (error) {
198 VLOG_DBG("%s: closing connection (%s)",
199 stream_get_name(s->stream),
200 ovs_retval_to_string(error));
201 dummy_stream_close(&dev->streams[i]);
202 dev->streams[i] = dev->streams[--dev->n_streams];
203 }
204 }
205 }
206 }
207
208 static void
209 dummy_stream_close(struct dummy_stream *s)
210 {
211 stream_close(s->stream);
212 ofpbuf_uninit(&s->rxbuf);
213 ofpbuf_list_delete(&s->txq);
214 }
215
216 static void
217 netdev_dummy_wait(void)
218 {
219 struct shash_node *node;
220
221 SHASH_FOR_EACH (node, &dummy_netdevs) {
222 struct netdev_dummy *dev = node->data;
223 size_t i;
224
225 if (dev->pstream) {
226 pstream_wait(dev->pstream);
227 }
228 for (i = 0; i < dev->n_streams; i++) {
229 struct dummy_stream *s = &dev->streams[i];
230
231 stream_run_wait(s->stream);
232 if (!list_is_empty(&s->txq)) {
233 stream_send_wait(s->stream);
234 }
235 stream_recv_wait(s->stream);
236 }
237 }
238 }
239
240 static int
241 netdev_dummy_create(const struct netdev_class *class, const char *name,
242 struct netdev **netdevp)
243 {
244 static atomic_uint next_n = ATOMIC_VAR_INIT(0xaa550000);
245 struct netdev_dummy *netdev;
246 unsigned int n;
247
248 atomic_add(&next_n, 1, &n);
249 netdev = xzalloc(sizeof *netdev);
250 netdev_init(&netdev->up, name, class);
251 netdev->hwaddr[0] = 0xaa;
252 netdev->hwaddr[1] = 0x55;
253 netdev->hwaddr[2] = n >> 24;
254 netdev->hwaddr[3] = n >> 16;
255 netdev->hwaddr[4] = n >> 8;
256 netdev->hwaddr[5] = n;
257 netdev->mtu = 1500;
258 netdev->flags = 0;
259 netdev->change_seq = 1;
260 netdev->ifindex = -EOPNOTSUPP;
261
262 netdev->pstream = NULL;
263 netdev->streams = NULL;
264 netdev->n_streams = 0;
265
266 list_init(&netdev->rxes);
267
268 shash_add(&dummy_netdevs, name, netdev);
269
270 *netdevp = &netdev->up;
271
272 return 0;
273 }
274
275 static void
276 netdev_dummy_destroy(struct netdev *netdev_)
277 {
278 struct netdev_dummy *netdev = netdev_dummy_cast(netdev_);
279 size_t i;
280
281 shash_find_and_delete(&dummy_netdevs,
282 netdev_get_name(netdev_));
283 pstream_close(netdev->pstream);
284 for (i = 0; i < netdev->n_streams; i++) {
285 dummy_stream_close(&netdev->streams[i]);
286 }
287 free(netdev->streams);
288 free(netdev);
289 }
290
291 static int
292 netdev_dummy_get_config(const struct netdev *netdev_, struct smap *args)
293 {
294 struct netdev_dummy *netdev = netdev_dummy_cast(netdev_);
295
296 if (netdev->ifindex >= 0) {
297 smap_add_format(args, "ifindex", "%d", netdev->ifindex);
298 }
299 if (netdev->pstream) {
300 smap_add(args, "pstream", pstream_get_name(netdev->pstream));
301 }
302 return 0;
303 }
304
305 static int
306 netdev_dummy_set_config(struct netdev *netdev_, const struct smap *args)
307 {
308 struct netdev_dummy *netdev = netdev_dummy_cast(netdev_);
309 const char *pstream;
310
311 netdev->ifindex = smap_get_int(args, "ifindex", -EOPNOTSUPP);
312
313 pstream = smap_get(args, "pstream");
314 if (!pstream
315 || !netdev->pstream
316 || strcmp(pstream_get_name(netdev->pstream), pstream)) {
317 pstream_close(netdev->pstream);
318 netdev->pstream = NULL;
319
320 if (pstream) {
321 int error;
322
323 error = pstream_open(pstream, &netdev->pstream, DSCP_DEFAULT);
324 if (error) {
325 VLOG_WARN("%s: open failed (%s)",
326 pstream, ovs_strerror(error));
327 }
328 }
329 }
330 return 0;
331 }
332
333 static int
334 netdev_dummy_rx_open(struct netdev *netdev_, struct netdev_rx **rxp)
335 {
336 struct netdev_dummy *netdev = netdev_dummy_cast(netdev_);
337 struct netdev_rx_dummy *rx;
338
339 rx = xmalloc(sizeof *rx);
340 netdev_rx_init(&rx->up, &netdev->up, &netdev_rx_dummy_class);
341 list_push_back(&netdev->rxes, &rx->node);
342 list_init(&rx->recv_queue);
343 rx->recv_queue_len = 0;
344
345 *rxp = &rx->up;
346 return 0;
347 }
348
349 static int
350 netdev_rx_dummy_recv(struct netdev_rx *rx_, void *buffer, size_t size)
351 {
352 struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
353 struct ofpbuf *packet;
354 int retval;
355
356 if (list_is_empty(&rx->recv_queue)) {
357 return -EAGAIN;
358 }
359
360 packet = ofpbuf_from_list(list_pop_front(&rx->recv_queue));
361 rx->recv_queue_len--;
362 if (packet->size <= size) {
363 memcpy(buffer, packet->data, packet->size);
364 retval = packet->size;
365 } else {
366 retval = -EMSGSIZE;
367 }
368 ofpbuf_delete(packet);
369
370 return retval;
371 }
372
373 static void
374 netdev_rx_dummy_destroy(struct netdev_rx *rx_)
375 {
376 struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
377 list_remove(&rx->node);
378 ofpbuf_list_delete(&rx->recv_queue);
379 free(rx);
380 }
381
382 static void
383 netdev_rx_dummy_wait(struct netdev_rx *rx_)
384 {
385 struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
386 if (!list_is_empty(&rx->recv_queue)) {
387 poll_immediate_wake();
388 }
389 }
390
391 static int
392 netdev_rx_dummy_drain(struct netdev_rx *rx_)
393 {
394 struct netdev_rx_dummy *rx = netdev_rx_dummy_cast(rx_);
395 ofpbuf_list_delete(&rx->recv_queue);
396 rx->recv_queue_len = 0;
397 return 0;
398 }
399
400 static int
401 netdev_dummy_send(struct netdev *netdev, const void *buffer, size_t size)
402 {
403 struct netdev_dummy *dev = netdev_dummy_cast(netdev);
404 size_t i;
405
406 if (size < ETH_HEADER_LEN) {
407 return EMSGSIZE;
408 } else {
409 const struct eth_header *eth = buffer;
410 int max_size;
411
412 max_size = dev->mtu + ETH_HEADER_LEN;
413 if (eth->eth_type == htons(ETH_TYPE_VLAN)) {
414 max_size += VLAN_HEADER_LEN;
415 }
416 if (size > max_size) {
417 return EMSGSIZE;
418 }
419 }
420
421 dev->stats.tx_packets++;
422 dev->stats.tx_bytes += size;
423
424 for (i = 0; i < dev->n_streams; i++) {
425 struct dummy_stream *s = &dev->streams[i];
426
427 if (list_size(&s->txq) < NETDEV_DUMMY_MAX_QUEUE) {
428 struct ofpbuf *b;
429
430 b = ofpbuf_clone_data_with_headroom(buffer, size, 2);
431 put_unaligned_be16(ofpbuf_push_uninit(b, 2), htons(size));
432 list_push_back(&s->txq, &b->list_node);
433 }
434 }
435
436 return 0;
437 }
438
439 static int
440 netdev_dummy_set_etheraddr(struct netdev *netdev,
441 const uint8_t mac[ETH_ADDR_LEN])
442 {
443 struct netdev_dummy *dev = netdev_dummy_cast(netdev);
444
445 if (!eth_addr_equals(dev->hwaddr, mac)) {
446 memcpy(dev->hwaddr, mac, ETH_ADDR_LEN);
447 netdev_dummy_poll_notify(dev);
448 }
449
450 return 0;
451 }
452
453 static int
454 netdev_dummy_get_etheraddr(const struct netdev *netdev,
455 uint8_t mac[ETH_ADDR_LEN])
456 {
457 const struct netdev_dummy *dev = netdev_dummy_cast(netdev);
458
459 memcpy(mac, dev->hwaddr, ETH_ADDR_LEN);
460 return 0;
461 }
462
463 static int
464 netdev_dummy_get_mtu(const struct netdev *netdev, int *mtup)
465 {
466 const struct netdev_dummy *dev = netdev_dummy_cast(netdev);
467
468 *mtup = dev->mtu;
469 return 0;
470 }
471
472 static int
473 netdev_dummy_set_mtu(const struct netdev *netdev, int mtu)
474 {
475 struct netdev_dummy *dev = netdev_dummy_cast(netdev);
476
477 dev->mtu = mtu;
478 return 0;
479 }
480
481 static int
482 netdev_dummy_get_stats(const struct netdev *netdev, struct netdev_stats *stats)
483 {
484 const struct netdev_dummy *dev = netdev_dummy_cast(netdev);
485
486 *stats = dev->stats;
487 return 0;
488 }
489
490 static int
491 netdev_dummy_set_stats(struct netdev *netdev, const struct netdev_stats *stats)
492 {
493 struct netdev_dummy *dev = netdev_dummy_cast(netdev);
494
495 dev->stats = *stats;
496 return 0;
497 }
498
499 static int
500 netdev_dummy_get_ifindex(const struct netdev *netdev)
501 {
502 struct netdev_dummy *dev = netdev_dummy_cast(netdev);
503
504 return dev->ifindex;
505 }
506
507 static int
508 netdev_dummy_update_flags(struct netdev *netdev_,
509 enum netdev_flags off, enum netdev_flags on,
510 enum netdev_flags *old_flagsp)
511 {
512 struct netdev_dummy *netdev = netdev_dummy_cast(netdev_);
513
514 if ((off | on) & ~(NETDEV_UP | NETDEV_PROMISC)) {
515 return EINVAL;
516 }
517
518 *old_flagsp = netdev->flags;
519 netdev->flags |= on;
520 netdev->flags &= ~off;
521 if (*old_flagsp != netdev->flags) {
522 netdev_dummy_poll_notify(netdev);
523 }
524 return 0;
525 }
526
527 static unsigned int
528 netdev_dummy_change_seq(const struct netdev *netdev)
529 {
530 return netdev_dummy_cast(netdev)->change_seq;
531 }
532 \f
533 /* Helper functions. */
534
535 static void
536 netdev_dummy_poll_notify(struct netdev_dummy *dev)
537 {
538 dev->change_seq++;
539 if (!dev->change_seq) {
540 dev->change_seq++;
541 }
542 }
543
544 static const struct netdev_class dummy_class = {
545 "dummy",
546 NULL, /* init */
547 netdev_dummy_run,
548 netdev_dummy_wait,
549
550 netdev_dummy_create,
551 netdev_dummy_destroy,
552 netdev_dummy_get_config,
553 netdev_dummy_set_config,
554 NULL, /* get_tunnel_config */
555
556 netdev_dummy_rx_open,
557
558 netdev_dummy_send, /* send */
559 NULL, /* send_wait */
560
561 netdev_dummy_set_etheraddr,
562 netdev_dummy_get_etheraddr,
563 netdev_dummy_get_mtu,
564 netdev_dummy_set_mtu,
565 netdev_dummy_get_ifindex,
566 NULL, /* get_carrier */
567 NULL, /* get_carrier_resets */
568 NULL, /* get_miimon */
569 netdev_dummy_get_stats,
570 netdev_dummy_set_stats,
571
572 NULL, /* get_features */
573 NULL, /* set_advertisements */
574
575 NULL, /* set_policing */
576 NULL, /* get_qos_types */
577 NULL, /* get_qos_capabilities */
578 NULL, /* get_qos */
579 NULL, /* set_qos */
580 NULL, /* get_queue */
581 NULL, /* set_queue */
582 NULL, /* delete_queue */
583 NULL, /* get_queue_stats */
584 NULL, /* dump_queues */
585 NULL, /* dump_queue_stats */
586
587 NULL, /* get_in4 */
588 NULL, /* set_in4 */
589 NULL, /* get_in6 */
590 NULL, /* add_router */
591 NULL, /* get_next_hop */
592 NULL, /* get_status */
593 NULL, /* arp_lookup */
594
595 netdev_dummy_update_flags,
596
597 netdev_dummy_change_seq
598 };
599
600 static const struct netdev_rx_class netdev_rx_dummy_class = {
601 netdev_rx_dummy_destroy,
602 netdev_rx_dummy_recv,
603 netdev_rx_dummy_wait,
604 netdev_rx_dummy_drain,
605 };
606
607 static struct ofpbuf *
608 eth_from_packet_or_flow(const char *s)
609 {
610 enum odp_key_fitness fitness;
611 struct ofpbuf *packet;
612 struct ofpbuf odp_key;
613 struct flow flow;
614 int error;
615
616 if (!eth_from_hex(s, &packet)) {
617 return packet;
618 }
619
620 /* Convert string to datapath key.
621 *
622 * It would actually be nicer to parse an OpenFlow-like flow key here, but
623 * the code for that currently calls exit() on parse error. We have to
624 * settle for parsing a datapath key for now.
625 */
626 ofpbuf_init(&odp_key, 0);
627 error = odp_flow_from_string(s, NULL, &odp_key, NULL);
628 if (error) {
629 ofpbuf_uninit(&odp_key);
630 return NULL;
631 }
632
633 /* Convert odp_key to flow. */
634 fitness = odp_flow_key_to_flow(odp_key.data, odp_key.size, &flow);
635 if (fitness == ODP_FIT_ERROR) {
636 ofpbuf_uninit(&odp_key);
637 return NULL;
638 }
639
640 packet = ofpbuf_new(0);
641 flow_compose(packet, &flow);
642
643 ofpbuf_uninit(&odp_key);
644 return packet;
645 }
646
647 static void
648 netdev_dummy_queue_packet__(struct netdev_rx_dummy *rx, struct ofpbuf *packet)
649 {
650 list_push_back(&rx->recv_queue, &packet->list_node);
651 rx->recv_queue_len++;
652 }
653
654 static void
655 netdev_dummy_queue_packet(struct netdev_dummy *dummy, struct ofpbuf *packet)
656 {
657 struct netdev_rx_dummy *rx, *prev;
658
659 prev = NULL;
660 LIST_FOR_EACH (rx, node, &dummy->rxes) {
661 if (rx->recv_queue_len < NETDEV_DUMMY_MAX_QUEUE) {
662 if (prev) {
663 netdev_dummy_queue_packet__(prev, ofpbuf_clone(packet));
664 }
665 prev = rx;
666 }
667 }
668 if (prev) {
669 netdev_dummy_queue_packet__(prev, packet);
670 } else {
671 ofpbuf_delete(packet);
672 }
673 }
674
675 static void
676 netdev_dummy_receive(struct unixctl_conn *conn,
677 int argc, const char *argv[], void *aux OVS_UNUSED)
678 {
679 struct netdev_dummy *dummy_dev;
680 int i;
681
682 dummy_dev = shash_find_data(&dummy_netdevs, argv[1]);
683 if (!dummy_dev) {
684 unixctl_command_reply_error(conn, "no such dummy netdev");
685 return;
686 }
687
688 for (i = 2; i < argc; i++) {
689 struct ofpbuf *packet;
690
691 packet = eth_from_packet_or_flow(argv[i]);
692 if (!packet) {
693 unixctl_command_reply_error(conn, "bad packet syntax");
694 return;
695 }
696
697 dummy_dev->stats.rx_packets++;
698 dummy_dev->stats.rx_bytes += packet->size;
699
700 netdev_dummy_queue_packet(dummy_dev, packet);
701 }
702
703 unixctl_command_reply(conn, NULL);
704 }
705
706 static void
707 netdev_dummy_set_admin_state__(struct netdev_dummy *dev, bool admin_state)
708 {
709 enum netdev_flags old_flags;
710
711 if (admin_state) {
712 netdev_dummy_update_flags(&dev->up, 0, NETDEV_UP, &old_flags);
713 } else {
714 netdev_dummy_update_flags(&dev->up, NETDEV_UP, 0, &old_flags);
715 }
716 }
717
718 static void
719 netdev_dummy_set_admin_state(struct unixctl_conn *conn, int argc,
720 const char *argv[], void *aux OVS_UNUSED)
721 {
722 bool up;
723
724 if (!strcasecmp(argv[argc - 1], "up")) {
725 up = true;
726 } else if ( !strcasecmp(argv[argc - 1], "down")) {
727 up = false;
728 } else {
729 unixctl_command_reply_error(conn, "Invalid Admin State");
730 return;
731 }
732
733 if (argc > 2) {
734 struct netdev_dummy *dummy_dev;
735
736 dummy_dev = shash_find_data(&dummy_netdevs, argv[1]);
737 if (dummy_dev) {
738 netdev_dummy_set_admin_state__(dummy_dev, up);
739 } else {
740 unixctl_command_reply_error(conn, "Unknown Dummy Interface");
741 return;
742 }
743 } else {
744 struct shash_node *node;
745
746 SHASH_FOR_EACH (node, &dummy_netdevs) {
747 netdev_dummy_set_admin_state__(node->data, up);
748 }
749 }
750 unixctl_command_reply(conn, "OK");
751 }
752
753 void
754 netdev_dummy_register(bool override)
755 {
756 unixctl_command_register("netdev-dummy/receive", "NAME PACKET|FLOW...",
757 2, INT_MAX, netdev_dummy_receive, NULL);
758 unixctl_command_register("netdev-dummy/set-admin-state",
759 "[netdev] up|down", 1, 2,
760 netdev_dummy_set_admin_state, NULL);
761
762 if (override) {
763 struct sset types;
764 const char *type;
765
766 sset_init(&types);
767 netdev_enumerate_types(&types);
768 SSET_FOR_EACH (type, &types) {
769 if (!netdev_unregister_provider(type)) {
770 struct netdev_class *class;
771
772 class = xmalloc(sizeof *class);
773 *class = dummy_class;
774 class->type = xstrdup(type);
775 netdev_register_provider(class);
776 }
777 }
778 sset_destroy(&types);
779 }
780 netdev_register_provider(&dummy_class);
781
782 netdev_vport_tunnel_register();
783 }