netdev-pltap: Make access to AF_INET socket thread-safe.
[sliver-openvswitch.git] / lib / netdev-pltap.c
1 /*
2  * Copyright (c) 2012 Giuseppe Lettieri
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 <sys/types.h>
20 #include <unistd.h>
21 #include <fcntl.h>
22 #include <arpa/inet.h>
23 #include <sys/ioctl.h>
24 #include <sys/socket.h>
25 #include <net/if.h>
26 #include <net/if_arp.h>
27 #include <linux/if_tun.h>
28 #include <netinet/in.h>
29 #include <errno.h>
30
31 #include "flow.h"
32 #include "list.h"
33 #include "netdev-provider.h"
34 #include "odp-util.h"
35 #include "ofp-print.h"
36 #include "ofpbuf.h"
37 #include "packets.h"
38 #include "poll-loop.h"
39 #include "shash.h"
40 #include "sset.h"
41 #include "unixctl.h"
42 #include "socket-util.h"
43 #include "vlog.h"
44 #include "tunalloc.h"
45
46 VLOG_DEFINE_THIS_MODULE(netdev_pltap);
47
48 struct netdev_pltap {
49     struct netdev up;
50     char *real_name;
51     struct netdev_stats stats;
52     enum netdev_flags new_flags;
53     enum netdev_flags flags;
54     int fd;
55     struct sockaddr_in local_addr;
56     int local_netmask;
57     bool valid_local_ip;
58     bool valid_local_netmask;
59     bool sync_flags_needed;
60     struct list sync_list;
61     unsigned int change_seq;
62 };
63
64 static const struct netdev_rx_class netdev_rx_pltap_class;
65
66 static struct list sync_list;
67
68 struct netdev_rx_pltap {
69     struct netdev_rx up;    
70     int fd;
71 };
72
73 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
74
75 static struct shash pltap_netdevs = SHASH_INITIALIZER(&pltap_netdevs);
76
77 static int netdev_pltap_create(const struct netdev_class *, const char *,
78                                struct netdev **);
79
80 static void netdev_pltap_update_seq(struct netdev_pltap *);
81 static int get_flags(struct netdev_pltap *dev, enum netdev_flags *flags);
82
83 static bool
84 netdev_pltap_finalized(struct netdev_pltap *dev)
85 {
86     return dev->valid_local_ip && dev->valid_local_netmask;
87 }
88
89 static bool
90 is_netdev_pltap_class(const struct netdev_class *class)
91 {
92     return class->create == netdev_pltap_create;
93 }
94
95 static struct netdev_pltap *
96 netdev_pltap_cast(const struct netdev *netdev)
97 {
98     ovs_assert(is_netdev_pltap_class(netdev_get_class(netdev)));
99     return CONTAINER_OF(netdev, struct netdev_pltap, up);
100 }
101
102 static struct netdev_rx_pltap*
103 netdev_rx_pltap_cast(const struct netdev_rx *rx)
104 {
105     netdev_rx_assert_class(rx, &netdev_rx_pltap_class);
106     return CONTAINER_OF(rx, struct netdev_rx_pltap, up);
107 }
108
109 static void sync_needed(struct netdev_pltap *dev)
110 {
111     if (dev->sync_flags_needed)
112         return;
113
114     dev->sync_flags_needed = true;
115     list_insert(&sync_list, &dev->sync_list);
116         
117 }
118
119 static void sync_done(struct netdev_pltap *dev)
120 {
121     if (!dev->sync_flags_needed)
122         return;
123
124     (void) list_remove(&dev->sync_list);
125     dev->sync_flags_needed = false;
126 }
127
128 static int
129 netdev_pltap_create(const struct netdev_class *class OVS_UNUSED, const char *name,
130                     struct netdev **netdevp)
131 {
132     struct netdev_pltap *netdev;
133     int error;
134
135     netdev = xzalloc(sizeof *netdev);
136
137     netdev->real_name = xzalloc(IFNAMSIZ + 1);
138     memset(&netdev->local_addr, 0, sizeof(netdev->local_addr));
139     netdev->valid_local_ip = false;
140     netdev->valid_local_netmask = false;
141     netdev->flags = 0;
142     netdev->sync_flags_needed = false;
143     list_init(&netdev->sync_list);
144
145
146     /* Open tap device. */
147     netdev->fd = tun_alloc(IFF_TAP, netdev->real_name);
148     if (netdev->fd < 0) {
149         error = errno;
150         VLOG_WARN("tun_alloc(IFF_TAP, %s) failed: %s", name, ovs_strerror(error));
151         goto cleanup;
152     }
153     VLOG_DBG("real_name = %s", netdev->real_name);
154
155     /* Make non-blocking. */
156     error = set_nonblocking(netdev->fd);
157     if (error) {
158         goto cleanup;
159     }
160
161     netdev_init(&netdev->up, name, &netdev_pltap_class);
162     shash_add(&pltap_netdevs, name, netdev);
163     *netdevp = &netdev->up;
164     return 0;
165
166 cleanup:
167     free(netdev);
168     return error;
169 }
170
171 static void
172 netdev_pltap_destroy(struct netdev *netdev_)
173 {
174     struct netdev_pltap *netdev = netdev_pltap_cast(netdev_);
175
176     if (netdev->fd != -1)
177         close(netdev->fd);
178
179     sync_done(netdev);
180
181     shash_find_and_delete(&pltap_netdevs,
182                           netdev_get_name(netdev_));
183     free(netdev);
184 }
185
186 static int netdev_pltap_up(struct netdev_pltap *dev);
187
188 static int
189 netdev_pltap_rx_open(struct netdev *netdev_, struct netdev_rx **rxp)
190 {
191     struct netdev_pltap *netdev =
192         netdev_pltap_cast(netdev_);
193     struct netdev_rx_pltap *rx;
194     int err;
195
196     rx = xmalloc(sizeof *rx);
197     netdev_rx_init(&rx->up, netdev_, &netdev_rx_pltap_class);
198     rx->fd = netdev->fd;
199     *rxp = &rx->up;
200     if (!netdev_pltap_finalized(netdev))
201         return 0;
202     err = netdev_pltap_up(netdev);
203     if (err) {
204         free(rx);
205         *rxp = NULL;
206         return err;
207     }
208     return 0;
209 }
210
211 static void
212 netdev_rx_pltap_destroy(struct netdev_rx *rx_)
213 {
214     struct netdev_rx_pltap *rx = netdev_rx_pltap_cast(rx_);
215     free(rx);
216 }
217
218 static int vsys_transaction(const char *script,
219         const char **preply, char *format, ...)
220 {
221     char *msg = NULL, *reply = NULL;
222     const size_t reply_size = 1024;
223     int ifd = -1, ofd = -1, maxfd;
224     size_t bytes_to_write, bytes_to_read,
225            bytes_written = 0, bytes_read = 0;
226     int error = 0;
227     char *ofname = NULL, *ifname = NULL;
228     va_list args;
229
230     va_start(args, format);
231     msg = xvasprintf(format, args);
232     va_end(args);
233     reply = (char*)xmalloc(reply_size);
234     if (!msg || !reply) {
235         VLOG_ERR("Out of memory");
236         error = ENOMEM;
237         goto cleanup;
238     }
239
240     ofname = xasprintf("/vsys/%s.out", script);
241     ifname = xasprintf("/vsys/%s.in", script);
242     if (!ofname || !ifname) {
243         VLOG_ERR("Out of memory");
244         error = ENOMEM;
245         goto cleanup;
246     }
247
248     ofd = open(ofname, O_RDONLY | O_NONBLOCK);
249     if (ofd < 0) {
250         VLOG_ERR("Cannot open %s: %s", ofname, ovs_strerror(errno));
251         error = errno;
252         goto cleanup;
253     }
254     ifd = open(ifname, O_WRONLY | O_NONBLOCK);
255     if (ifd < 0) {
256         VLOG_ERR("Cannot open %s: %s", ifname, ovs_strerror(errno));
257         error = errno;
258         goto cleanup;
259     }
260     maxfd = (ifd < ofd) ? ofd : ifd;
261
262     bytes_to_write = strlen(msg);
263     bytes_to_read = reply_size;
264     while (bytes_to_write || bytes_to_read) {
265         fd_set readset, writeset, errorset;
266
267         FD_ZERO(&readset);
268         FD_ZERO(&writeset);
269         FD_ZERO(&errorset);
270         if (bytes_to_write) {
271             FD_SET(ifd, &writeset);
272             FD_SET(ifd, &errorset);
273         }
274         FD_SET(ofd, &readset);
275         FD_SET(ofd, &errorset);
276         if (select(maxfd + 1, &readset, &writeset, &errorset, NULL) < 0) {
277             if (errno == EINTR)
278                 continue;
279             VLOG_ERR("selec error: %s", ovs_strerror(errno));
280             error = errno;
281             goto cleanup;
282         }
283         if (FD_ISSET(ifd, &errorset) || FD_ISSET(ofd, &errorset)) {
284             VLOG_ERR("error condition on ifd or ofd");
285             goto cleanup;
286         }
287         if (FD_ISSET(ifd, &writeset)) {
288             ssize_t n = write(ifd, msg + bytes_written, bytes_to_write);    
289             if (n < 0) {
290                 if (errno != EAGAIN && errno != EINTR) {
291                     VLOG_ERR("write on %s: %s", ifname, ovs_strerror(errno));
292                     error = errno;
293                     goto cleanup;
294                 }
295             } else {
296                 bytes_written += n;
297                 bytes_to_write -= n;
298                 if (bytes_to_write == 0)
299                     close(ifd);
300             }
301         }
302         if (FD_ISSET(ofd, &readset)) {
303             ssize_t n = read(ofd, reply + bytes_read, bytes_to_read);    
304             if (n < 0) {
305                 if (errno != EAGAIN && errno != EINTR) {
306                     VLOG_ERR("read on %s: %s", ofname, ovs_strerror(errno));
307                     error = errno;
308                     goto cleanup;
309                 }
310             } else if (n == 0) {
311                 bytes_to_read = 0;
312             } else {
313                 bytes_read += n;
314                 bytes_to_read -= n;
315             }
316         }
317     }
318     if (bytes_read) {
319         reply[bytes_read] = '\0';
320         if (preply) {
321                 *preply = reply;
322                 reply = NULL; /* prevent freeing the reply msg */
323         } else {
324                 VLOG_ERR("%s returned: %s", script, reply);
325         }
326         error = EAGAIN;
327         goto cleanup;
328     }
329
330 cleanup:
331     free(msg);
332     free(reply);
333     free(ofname);
334     free(ifname);
335     close(ifd);
336     close(ofd);
337     return error;
338 }
339
340 static int
341 netdev_pltap_up(struct netdev_pltap *dev)
342 {
343     if (!netdev_pltap_finalized(dev)) {
344         return 0;
345     }
346     
347     return vsys_transaction("vif_up", NULL, "%s\n"IP_FMT"\n%d\n",
348                dev->real_name,
349                IP_ARGS(dev->local_addr.sin_addr.s_addr),
350                dev->local_netmask);
351 }
352
353 static int
354 netdev_pltap_down(struct netdev_pltap *dev)
355 {
356     if (!netdev_pltap_finalized(dev)) {
357         return 0;
358     }
359     
360     return vsys_transaction("vif_down", NULL, "%s\n", dev->real_name);
361 }
362
363 static int
364 netdev_pltap_promisc(struct netdev_pltap *dev, bool promisc)
365 {
366     if (!netdev_pltap_finalized(dev)) {
367         return 0;
368     }
369
370     return vsys_transaction("promisc", NULL, "%s\n%s",
371                dev->real_name,
372                (promisc ? "" : "-\n"));
373 }
374
375 static void
376 netdev_pltap_sync_flags(struct netdev_pltap *dev)
377 {
378
379     if (dev->fd < 0 || !netdev_pltap_finalized(dev)) {
380         sync_done(dev);
381         return;
382     }
383     
384     VLOG_DBG("sync_flags(%s): current: %s %s  target: %s %s",
385         dev->real_name,
386         (dev->flags & NETDEV_UP ? "UP" : "-"),
387         (dev->flags & NETDEV_PROMISC ? "PROMISC" : "-"),
388         (dev->new_flags & NETDEV_UP ? "UP" : "-"),
389         (dev->new_flags & NETDEV_PROMISC ? "PROMISC" : "-"));
390
391     if ((dev->new_flags & NETDEV_UP) && !(dev->flags & NETDEV_UP)) {
392         (void) netdev_pltap_up(dev);
393     } else if (!(dev->new_flags & NETDEV_UP) && (dev->flags & NETDEV_UP)) {
394         (void) netdev_pltap_down(dev);
395     }
396
397     if ((dev->new_flags & NETDEV_PROMISC) ^ (dev->flags & NETDEV_PROMISC)) {
398         (void) netdev_pltap_promisc(dev, dev->new_flags & NETDEV_PROMISC);
399     }
400
401     netdev_pltap_update_seq(dev);
402     sync_done(dev);
403 }
404
405
406 static int
407 netdev_pltap_get_config(const struct netdev *dev_, struct smap *args)
408 {
409     struct netdev_pltap *netdev = netdev_pltap_cast(dev_);
410
411     if (netdev->valid_local_ip)
412         smap_add_format(args, "local_ip", IP_FMT,
413             IP_ARGS(netdev->local_addr.sin_addr.s_addr));
414     if (netdev->valid_local_netmask)
415         smap_add_format(args, "local_netmask", "%"PRIu32,
416             ntohs(netdev->local_netmask));
417     return 0;
418 }
419
420 static int
421 netdev_pltap_set_config(struct netdev *dev_, const struct smap *args)
422 {
423     struct netdev_pltap *netdev = netdev_pltap_cast(dev_);
424     struct shash_node *node;
425
426     VLOG_DBG("pltap_set_config(%s)", netdev_get_name(dev_));
427     SMAP_FOR_EACH(node, args) {
428         VLOG_DBG("arg: %s->%s", node->name, (char*)node->data);
429         if (!strcmp(node->name, "local_ip")) {
430             struct in_addr addr;
431             if (lookup_ip(node->data, &addr)) {
432                 VLOG_WARN("%s: bad 'local_ip'", node->name);
433             } else {
434                 netdev->local_addr.sin_addr = addr;
435                 netdev->valid_local_ip = true;
436             }
437         } else if (!strcmp(node->name, "local_netmask")) {
438             netdev->local_netmask = atoi(node->data);
439             // XXX check valididy
440             netdev->valid_local_netmask = true;
441         } else {
442             VLOG_WARN("%s: unknown argument '%s'", 
443                 netdev_get_name(dev_), node->name);
444         }
445     }
446     if (netdev_pltap_finalized(netdev)) {
447         netdev->new_flags |= NETDEV_UP;
448         sync_needed(netdev);
449     }
450     return 0;
451 }
452
453 static int
454 netdev_rx_pltap_recv(struct netdev_rx *rx_, void *buffer, size_t size)
455 {
456     struct netdev_rx_pltap *rx = netdev_rx_pltap_cast(rx_);
457     struct tun_pi pi;
458     struct iovec iov[2] = {
459         { .iov_base = &pi, .iov_len = sizeof(pi) },
460         { .iov_base = buffer, .iov_len = size }
461     };
462     for (;;) {
463         ssize_t retval;
464         retval = readv(rx->fd, iov, 2);
465         if (retval >= 0) {
466             if (retval <= size) {
467                 return retval;
468             } else {
469                 return -EMSGSIZE;
470             }
471         } else if (errno != EINTR) {
472             if (errno != EAGAIN) {
473                 VLOG_WARN_RL(&rl, "error receiveing Ethernet packet on %s: %s",
474                     netdev_rx_get_name(rx_), ovs_strerror(errno));
475             }
476             return -errno;
477         }
478     }
479 }
480
481 static void
482 netdev_rx_pltap_wait(struct netdev_rx *rx_)
483 {
484     struct netdev_rx_pltap *rx = netdev_rx_pltap_cast(rx_);
485     struct netdev_pltap *netdev =
486         netdev_pltap_cast(rx->up.netdev);
487     if (rx->fd >= 0 && netdev_pltap_finalized(netdev)) {
488         poll_fd_wait(rx->fd, POLLIN);
489     }
490 }
491
492 static int
493 netdev_pltap_send(struct netdev *netdev_, const void *buffer, size_t size)
494 {
495     struct netdev_pltap *dev = 
496         netdev_pltap_cast(netdev_);
497     struct tun_pi pi = { 0, 0x86 };
498     struct iovec iov[2] = {
499         { .iov_base = &pi, .iov_len = sizeof(pi) },
500         { .iov_base = (char*) buffer, .iov_len = size }
501     };
502     if (dev->fd < 0)
503         return EAGAIN;
504     for (;;) {
505         ssize_t retval;
506         retval = writev(dev->fd, iov, 2);
507         if (retval >= 0) {
508             if (retval != size + 4) {
509                 VLOG_WARN_RL(&rl, "sent partial Ethernet packet (%zd bytes of %zu) on %s",
510                              retval, size + 4, netdev_get_name(netdev_));
511             }
512             return 0;
513         } else if (errno != EINTR) {
514             if (errno != EAGAIN) {
515                 VLOG_WARN_RL(&rl, "error sending Ethernet packet on %s: %s",
516                     netdev_get_name(netdev_), ovs_strerror(errno));
517             }
518             return errno;
519         }
520     }
521 }
522
523 static void
524 netdev_pltap_send_wait(struct netdev *netdev_)
525 {
526     struct netdev_pltap *dev = 
527         netdev_pltap_cast(netdev_);
528     if (dev->fd >= 0 && netdev_pltap_finalized(dev)) {
529         poll_fd_wait(dev->fd, POLLOUT);
530     }
531 }
532
533 static int
534 netdev_rx_pltap_drain(struct netdev_rx *rx_)
535 {
536     struct netdev_rx_pltap *rx = netdev_rx_pltap_cast(rx_);
537     char buffer[128];
538     int error;
539
540     if (rx->fd < 0)
541         return EAGAIN;
542     for (;;) {
543         error = recv(rx->fd, buffer, 128, MSG_TRUNC);
544         if (error) {
545             if (error == -EAGAIN)
546                 break;
547             else if (error != -EMSGSIZE)
548                 return error;
549         }
550     }
551     return 0;
552 }
553
554 static int
555 netdev_pltap_set_etheraddr(struct netdev *netdevi OVS_UNUSED,
556                            const uint8_t mac[ETH_ADDR_LEN] OVS_UNUSED)
557 {
558     return ENOTSUP;
559 }
560
561
562 // XXX from netdev-linux.c
563 static int
564 get_etheraddr(struct netdev_pltap *dev, uint8_t ea[ETH_ADDR_LEN])
565 {
566     struct ifreq ifr;
567     int hwaddr_family;
568     int error;
569
570     memset(&ifr, 0, sizeof ifr);
571     ovs_strzcpy(ifr.ifr_name, dev->real_name, sizeof ifr.ifr_name);
572     error = af_inet_ifreq_ioctl(dev->real_name, &ifr,
573         SIOCGIFHWADDR, "SIOCGIFHWADDR");
574     if (error) {
575         return errno;
576     }
577     hwaddr_family = ifr.ifr_hwaddr.sa_family;
578     if (hwaddr_family != AF_UNSPEC && hwaddr_family != ARPHRD_ETHER) {
579         VLOG_WARN("%s device has unknown hardware address family %d",
580                   dev->real_name, hwaddr_family);
581     }
582     memcpy(ea, ifr.ifr_hwaddr.sa_data, ETH_ADDR_LEN);
583     return 0;
584 }
585
586 static int
587 get_flags(struct netdev_pltap *dev, enum netdev_flags *flags)
588 {
589     struct ifreq ifr;
590     int error;
591
592     error = af_inet_ifreq_ioctl(dev->real_name, &ifr,
593         SIOCGIFFLAGS, "SIOCGIFFLAGS");
594     if (error) {
595         return error;
596     }
597     *flags = 0;
598     if (ifr.ifr_flags & IFF_UP)
599         *flags |= NETDEV_UP;
600     if (ifr.ifr_flags & IFF_PROMISC)
601         *flags |= NETDEV_PROMISC;
602     return 0;
603 }
604
605 static int
606 netdev_pltap_get_etheraddr(const struct netdev *netdev,
607                            uint8_t mac[ETH_ADDR_LEN])
608 {
609     struct netdev_pltap *dev = 
610         netdev_pltap_cast(netdev);
611     if (dev->fd < 0)
612         return EAGAIN;
613     return get_etheraddr(dev, mac);
614 }
615
616
617 // XXX can we read stats in planetlab?
618 static int
619 netdev_pltap_get_stats(const struct netdev *netdev OVS_UNUSED, struct netdev_stats *stats OVS_UNUSED)
620 {
621     return ENOTSUP;
622 }
623
624 static int
625 netdev_pltap_set_stats(struct netdev *netdev OVS_UNUSED, const struct netdev_stats *stats OVS_UNUSED)
626 {
627     return ENOTSUP;
628 }
629
630
631 static int
632 netdev_pltap_update_flags(struct netdev *dev_,
633                           enum netdev_flags off, enum netdev_flags on,
634                           enum netdev_flags *old_flagsp)
635 {
636     struct netdev_pltap *netdev =
637         netdev_pltap_cast(dev_);
638     int error = 0;
639
640     if ((off | on) & ~(NETDEV_UP | NETDEV_PROMISC)) {
641         return EINVAL;
642     }
643
644     if (netdev_pltap_finalized(netdev)) {
645         error = get_flags(netdev, &netdev->flags);
646     }
647     *old_flagsp = netdev->flags;
648     netdev->new_flags |= on;
649     netdev->new_flags &= ~off;
650     if (netdev->flags != netdev->new_flags) {
651         /* we cannot sync here, since we may be in a signal handler */
652         sync_needed(netdev);
653     }
654
655     return error;
656 }
657
658 static unsigned int
659 netdev_pltap_change_seq(const struct netdev *netdev)
660 {
661     return netdev_pltap_cast(netdev)->change_seq;
662 }
663 \f
664 /* Helper functions. */
665
666 static void
667 netdev_pltap_update_seq(struct netdev_pltap *dev)
668 {
669     dev->change_seq++;
670     if (!dev->change_seq) {
671         dev->change_seq++;
672     }
673 }
674
675 static void
676 netdev_pltap_get_real_name(struct unixctl_conn *conn,
677                      int argc OVS_UNUSED, const char *argv[], void *aux OVS_UNUSED)
678 {
679     struct netdev_pltap *pltap_dev;
680
681     pltap_dev = shash_find_data(&pltap_netdevs, argv[1]);
682     if (!pltap_dev) {
683         unixctl_command_reply_error(conn, "no such pltap netdev");
684         return;
685     }
686     if (pltap_dev->fd < 0) {
687         unixctl_command_reply_error(conn, "no real device attached");
688         return;
689     }
690
691     unixctl_command_reply(conn, pltap_dev->real_name);
692 }
693
694 static int
695 netdev_pltap_init(void)
696 {
697     list_init(&sync_list);
698     unixctl_command_register("netdev-pltap/get-tapname", "port",
699                              1, 1, netdev_pltap_get_real_name, NULL);
700     return 0;
701 }
702
703 static void
704 netdev_pltap_run(void)
705 {
706     struct netdev_pltap *iter, *next;
707     LIST_FOR_EACH_SAFE(iter, next, sync_list, &sync_list) {
708         netdev_pltap_sync_flags(iter);
709     }
710 }
711
712 static void
713 netdev_pltap_wait(void)
714 {
715     if (!list_is_empty(&sync_list)) {
716         VLOG_DBG("netdev_pltap: scheduling sync");
717         poll_immediate_wake();
718     }
719 }
720
721 const struct netdev_class netdev_pltap_class = {
722     "pltap",
723     netdev_pltap_init,
724     netdev_pltap_run,  
725     netdev_pltap_wait,            
726
727     netdev_pltap_create,
728     netdev_pltap_destroy,
729     netdev_pltap_get_config,
730     netdev_pltap_set_config, 
731     NULL,                       /* get_tunnel_config */
732
733     netdev_pltap_rx_open,
734
735     netdev_pltap_send, 
736     netdev_pltap_send_wait,  
737
738     netdev_pltap_set_etheraddr,
739     netdev_pltap_get_etheraddr,
740     NULL,                       /* get_mtu */
741     NULL,                       /* set_mtu */
742     NULL,                       /* get_ifindex */
743     NULL,                       /* get_carrier */
744     NULL,                       /* get_carrier_resets */
745     NULL,                       /* get_miimon */
746     netdev_pltap_get_stats,
747     netdev_pltap_set_stats,
748
749     NULL,                       /* get_features */
750     NULL,                       /* set_advertisements */
751
752     NULL,                       /* set_policing */
753     NULL,                       /* get_qos_types */
754     NULL,                       /* get_qos_capabilities */
755     NULL,                       /* get_qos */
756     NULL,                       /* set_qos */
757     NULL,                       /* get_queue */
758     NULL,                       /* set_queue */
759     NULL,                       /* delete_queue */
760     NULL,                       /* get_queue_stats */
761     NULL,                       /* dump_queues */
762     NULL,                       /* dump_queue_stats */
763
764     NULL,                       /* get_in4 */
765     NULL,                       /* set_in4 */
766     NULL,                       /* get_in6 */
767     NULL,                       /* add_router */
768     NULL,                       /* get_next_hop */
769     NULL,                       /* get_drv_info */
770     NULL,                       /* arp_lookup */
771
772     netdev_pltap_update_flags,
773
774     netdev_pltap_change_seq
775 };
776
777 static const struct netdev_rx_class netdev_rx_pltap_class = {
778     netdev_rx_pltap_destroy,
779     netdev_rx_pltap_recv,
780     netdev_rx_pltap_wait,
781     netdev_rx_pltap_drain,
782
783 };