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