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