Update the default VXLAN destination UDP port to the IANA assigned port
[sliver-openvswitch.git] / lib / netdev-vport.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 "netdev-vport.h"
20
21 #include <errno.h>
22 #include <fcntl.h>
23 #include <sys/socket.h>
24 #include <net/if.h>
25 #include <sys/ioctl.h>
26
27 #include "byte-order.h"
28 #include "daemon.h"
29 #include "dirs.h"
30 #include "dpif.h"
31 #include "hash.h"
32 #include "hmap.h"
33 #include "list.h"
34 #include "netdev-provider.h"
35 #include "ofpbuf.h"
36 #include "packets.h"
37 #include "route-table.h"
38 #include "shash.h"
39 #include "socket-util.h"
40 #include "vlog.h"
41
42 VLOG_DEFINE_THIS_MODULE(netdev_vport);
43
44 /* Default to the OTV port, per the VXLAN IETF draft. */
45 #define VXLAN_DST_PORT 4789
46
47 #define LISP_DST_PORT 4341
48
49 #define DEFAULT_TTL 64
50
51 struct netdev_dev_vport {
52     struct netdev_dev netdev_dev;
53     unsigned int change_seq;
54     uint8_t etheraddr[ETH_ADDR_LEN];
55     struct netdev_stats stats;
56
57     /* Tunnels. */
58     struct netdev_tunnel_config tnl_cfg;
59
60     /* Patch Ports. */
61     char *peer;
62 };
63
64 struct vport_class {
65     const char *dpif_port;
66     struct netdev_class netdev_class;
67 };
68
69 static int netdev_vport_create(const struct netdev_class *, const char *,
70                                struct netdev_dev **);
71 static int get_patch_config(struct netdev_dev *, struct smap *args);
72 static int get_tunnel_config(struct netdev_dev *, struct smap *args);
73 static void netdev_vport_poll_notify(struct netdev_dev_vport *);
74
75 static bool
76 is_vport_class(const struct netdev_class *class)
77 {
78     return class->create == netdev_vport_create;
79 }
80
81 static const struct vport_class *
82 vport_class_cast(const struct netdev_class *class)
83 {
84     ovs_assert(is_vport_class(class));
85     return CONTAINER_OF(class, struct vport_class, netdev_class);
86 }
87
88 static struct netdev_dev_vport *
89 netdev_dev_vport_cast(const struct netdev_dev *netdev_dev)
90 {
91     ovs_assert(is_vport_class(netdev_dev_get_class(netdev_dev)));
92     return CONTAINER_OF(netdev_dev, struct netdev_dev_vport, netdev_dev);
93 }
94
95 static struct netdev_dev_vport *
96 netdev_vport_get_dev(const struct netdev *netdev)
97 {
98     return netdev_dev_vport_cast(netdev_get_dev(netdev));
99 }
100
101 static const struct netdev_tunnel_config *
102 get_netdev_tunnel_config(const struct netdev_dev *netdev_dev)
103 {
104     return &netdev_dev_vport_cast(netdev_dev)->tnl_cfg;
105 }
106
107 bool
108 netdev_vport_is_patch(const struct netdev *netdev)
109 {
110     const struct netdev_dev *dev = netdev_get_dev(netdev);
111     const struct netdev_class *class = netdev_dev_get_class(dev);
112
113     return class->get_config == get_patch_config;
114 }
115
116 static bool
117 netdev_vport_needs_dst_port(const struct netdev_dev *dev)
118 {
119     const struct netdev_class *class = netdev_dev_get_class(dev);
120     const char *type = netdev_dev_get_type(dev);
121
122     return (class->get_config == get_tunnel_config &&
123             (!strcmp("vxlan", type) || !strcmp("lisp", type)));
124 }
125
126 const char *
127 netdev_vport_get_dpif_port(const struct netdev *netdev)
128 {
129     const struct netdev_dev *dev = netdev_get_dev(netdev);
130     const struct netdev_class *class = netdev_dev_get_class(dev);
131     const char *dpif_port;
132
133     if (netdev_vport_needs_dst_port(dev)) {
134         const struct netdev_dev_vport *vport = netdev_vport_get_dev(netdev);
135         const char *type = netdev_dev_get_type(dev);
136         static char dpif_port_combined[IFNAMSIZ];
137
138         /*
139          * Note: IFNAMSIZ is 16 bytes long. The maximum length of a VXLAN
140          * or LISP port name below is 15 or 14 bytes respectively. Still,
141          * assert here on the size of strlen(type) in case that changes
142          * in the future.
143          */
144         ovs_assert(strlen(type) + 10 < IFNAMSIZ);
145         snprintf(dpif_port_combined, IFNAMSIZ, "%s_sys_%d", type,
146                  ntohs(vport->tnl_cfg.dst_port));
147         return dpif_port_combined;
148     } else {
149         dpif_port = (is_vport_class(class)
150                      ? vport_class_cast(class)->dpif_port
151                      : NULL);
152     }
153
154     return dpif_port ? dpif_port : netdev_get_name(netdev);
155 }
156
157 static int
158 netdev_vport_create(const struct netdev_class *netdev_class, const char *name,
159                     struct netdev_dev **netdev_devp)
160 {
161     struct netdev_dev_vport *dev;
162
163     dev = xzalloc(sizeof *dev);
164     netdev_dev_init(&dev->netdev_dev, name, netdev_class);
165     dev->change_seq = 1;
166     eth_addr_random(dev->etheraddr);
167
168     *netdev_devp = &dev->netdev_dev;
169     route_table_register();
170
171     return 0;
172 }
173
174 static void
175 netdev_vport_destroy(struct netdev_dev *netdev_dev_)
176 {
177     struct netdev_dev_vport *netdev_dev = netdev_dev_vport_cast(netdev_dev_);
178
179     route_table_unregister();
180     free(netdev_dev->peer);
181     free(netdev_dev);
182 }
183
184 static int
185 netdev_vport_open(struct netdev_dev *netdev_dev, struct netdev **netdevp)
186 {
187     *netdevp = xmalloc(sizeof **netdevp);
188     netdev_init(*netdevp, netdev_dev);
189     return 0;
190 }
191
192 static void
193 netdev_vport_close(struct netdev *netdev)
194 {
195     free(netdev);
196 }
197
198 static int
199 netdev_vport_set_etheraddr(struct netdev *netdev,
200                            const uint8_t mac[ETH_ADDR_LEN])
201 {
202     struct netdev_dev_vport *dev = netdev_vport_get_dev(netdev);
203     memcpy(dev->etheraddr, mac, ETH_ADDR_LEN);
204     netdev_vport_poll_notify(dev);
205     return 0;
206 }
207
208 static int
209 netdev_vport_get_etheraddr(const struct netdev *netdev,
210                            uint8_t mac[ETH_ADDR_LEN])
211 {
212     memcpy(mac, netdev_vport_get_dev(netdev)->etheraddr, ETH_ADDR_LEN);
213     return 0;
214 }
215
216 static int
217 tunnel_get_status(const struct netdev *netdev, struct smap *smap)
218 {
219     static char iface[IFNAMSIZ];
220     ovs_be32 route;
221
222     route = netdev_vport_get_dev(netdev)->tnl_cfg.ip_dst;
223     if (route_table_get_name(route, iface)) {
224         struct netdev *egress_netdev;
225
226         smap_add(smap, "tunnel_egress_iface", iface);
227
228         if (!netdev_open(iface, "system", &egress_netdev)) {
229             smap_add(smap, "tunnel_egress_iface_carrier",
230                      netdev_get_carrier(egress_netdev) ? "up" : "down");
231             netdev_close(egress_netdev);
232         }
233     }
234
235     return 0;
236 }
237
238 static int
239 netdev_vport_update_flags(struct netdev *netdev OVS_UNUSED,
240                         enum netdev_flags off, enum netdev_flags on OVS_UNUSED,
241                         enum netdev_flags *old_flagsp)
242 {
243     if (off & (NETDEV_UP | NETDEV_PROMISC)) {
244         return EOPNOTSUPP;
245     }
246
247     *old_flagsp = NETDEV_UP | NETDEV_PROMISC;
248     return 0;
249 }
250
251 static unsigned int
252 netdev_vport_change_seq(const struct netdev *netdev)
253 {
254     return netdev_vport_get_dev(netdev)->change_seq;
255 }
256
257 static void
258 netdev_vport_run(void)
259 {
260     route_table_run();
261 }
262
263 static void
264 netdev_vport_wait(void)
265 {
266     route_table_wait();
267 }
268 \f
269 /* Helper functions. */
270
271 static void
272 netdev_vport_poll_notify(struct netdev_dev_vport *ndv)
273 {
274     ndv->change_seq++;
275     if (!ndv->change_seq) {
276         ndv->change_seq++;
277     }
278 }
279 \f
280 /* Code specific to tunnel types. */
281
282 static ovs_be64
283 parse_key(const struct smap *args, const char *name,
284           bool *present, bool *flow)
285 {
286     const char *s;
287
288     *present = false;
289     *flow = false;
290
291     s = smap_get(args, name);
292     if (!s) {
293         s = smap_get(args, "key");
294         if (!s) {
295             return 0;
296         }
297     }
298
299     *present = true;
300
301     if (!strcmp(s, "flow")) {
302         *flow = true;
303         return 0;
304     } else {
305         return htonll(strtoull(s, NULL, 0));
306     }
307 }
308
309 static int
310 set_tunnel_config(struct netdev_dev *dev_, const struct smap *args)
311 {
312     struct netdev_dev_vport *dev = netdev_dev_vport_cast(dev_);
313     const char *name = netdev_dev_get_name(dev_);
314     const char *type = netdev_dev_get_type(dev_);
315     bool ipsec_mech_set, needs_dst_port, has_csum;
316     struct netdev_tunnel_config tnl_cfg;
317     struct smap_node *node;
318
319     has_csum = strstr(type, "gre");
320     ipsec_mech_set = false;
321     memset(&tnl_cfg, 0, sizeof tnl_cfg);
322
323     needs_dst_port = netdev_vport_needs_dst_port(dev_);
324     tnl_cfg.ipsec = strstr(type, "ipsec");
325     tnl_cfg.dont_fragment = true;
326
327     SMAP_FOR_EACH (node, args) {
328         if (!strcmp(node->key, "remote_ip")) {
329             struct in_addr in_addr;
330             if (lookup_ip(node->value, &in_addr)) {
331                 VLOG_WARN("%s: bad %s 'remote_ip'", name, type);
332             } else if (ip_is_multicast(in_addr.s_addr)) {
333                 VLOG_WARN("%s: multicast remote_ip="IP_FMT" not allowed",
334                           name, IP_ARGS(in_addr.s_addr));
335                 return EINVAL;
336             } else {
337                 tnl_cfg.ip_dst = in_addr.s_addr;
338             }
339         } else if (!strcmp(node->key, "local_ip")) {
340             struct in_addr in_addr;
341             if (lookup_ip(node->value, &in_addr)) {
342                 VLOG_WARN("%s: bad %s 'local_ip'", name, type);
343             } else {
344                 tnl_cfg.ip_src = in_addr.s_addr;
345             }
346         } else if (!strcmp(node->key, "tos")) {
347             if (!strcmp(node->value, "inherit")) {
348                 tnl_cfg.tos_inherit = true;
349             } else {
350                 char *endptr;
351                 int tos;
352                 tos = strtol(node->value, &endptr, 0);
353                 if (*endptr == '\0' && tos == (tos & IP_DSCP_MASK)) {
354                     tnl_cfg.tos = tos;
355                 } else {
356                     VLOG_WARN("%s: invalid TOS %s", name, node->value);
357                 }
358             }
359         } else if (!strcmp(node->key, "ttl")) {
360             if (!strcmp(node->value, "inherit")) {
361                 tnl_cfg.ttl_inherit = true;
362             } else {
363                 tnl_cfg.ttl = atoi(node->value);
364             }
365         } else if (!strcmp(node->key, "dst_port") && needs_dst_port) {
366             tnl_cfg.dst_port = htons(atoi(node->value));
367         } else if (!strcmp(node->key, "csum") && has_csum) {
368             if (!strcmp(node->value, "true")) {
369                 tnl_cfg.csum = true;
370             }
371         } else if (!strcmp(node->key, "df_default")) {
372             if (!strcmp(node->value, "false")) {
373                 tnl_cfg.dont_fragment = false;
374             }
375         } else if (!strcmp(node->key, "peer_cert") && tnl_cfg.ipsec) {
376             if (smap_get(args, "certificate")) {
377                 ipsec_mech_set = true;
378             } else {
379                 const char *use_ssl_cert;
380
381                 /* If the "use_ssl_cert" is true, then "certificate" and
382                  * "private_key" will be pulled from the SSL table.  The
383                  * use of this option is strongly discouraged, since it
384                  * will like be removed when multiple SSL configurations
385                  * are supported by OVS.
386                  */
387                 use_ssl_cert = smap_get(args, "use_ssl_cert");
388                 if (!use_ssl_cert || strcmp(use_ssl_cert, "true")) {
389                     VLOG_ERR("%s: 'peer_cert' requires 'certificate' argument",
390                              name);
391                     return EINVAL;
392                 }
393                 ipsec_mech_set = true;
394             }
395         } else if (!strcmp(node->key, "psk") && tnl_cfg.ipsec) {
396             ipsec_mech_set = true;
397         } else if (tnl_cfg.ipsec
398                 && (!strcmp(node->key, "certificate")
399                     || !strcmp(node->key, "private_key")
400                     || !strcmp(node->key, "use_ssl_cert"))) {
401             /* Ignore options not used by the netdev. */
402         } else if (!strcmp(node->key, "key") ||
403                    !strcmp(node->key, "in_key") ||
404                    !strcmp(node->key, "out_key")) {
405             /* Handled separately below. */
406         } else {
407             VLOG_WARN("%s: unknown %s argument '%s'", name, type, node->key);
408         }
409     }
410
411     /* Add a default destination port for VXLAN if none specified. */
412     if (!strcmp(type, "vxlan") && !tnl_cfg.dst_port) {
413         tnl_cfg.dst_port = htons(VXLAN_DST_PORT);
414     }
415
416     /* Add a default destination port for LISP if none specified. */
417     if (!strcmp(type, "lisp") && !tnl_cfg.dst_port) {
418         tnl_cfg.dst_port = htons(LISP_DST_PORT);
419     }
420
421     if (tnl_cfg.ipsec) {
422         static pid_t pid = 0;
423         if (pid <= 0) {
424             char *file_name = xasprintf("%s/%s", ovs_rundir(),
425                                         "ovs-monitor-ipsec.pid");
426             pid = read_pidfile(file_name);
427             free(file_name);
428         }
429
430         if (pid < 0) {
431             VLOG_ERR("%s: IPsec requires the ovs-monitor-ipsec daemon",
432                      name);
433             return EINVAL;
434         }
435
436         if (smap_get(args, "peer_cert") && smap_get(args, "psk")) {
437             VLOG_ERR("%s: cannot define both 'peer_cert' and 'psk'", name);
438             return EINVAL;
439         }
440
441         if (!ipsec_mech_set) {
442             VLOG_ERR("%s: IPsec requires an 'peer_cert' or psk' argument",
443                      name);
444             return EINVAL;
445         }
446     }
447
448     if (!tnl_cfg.ip_dst) {
449         VLOG_ERR("%s: %s type requires valid 'remote_ip' argument",
450                  name, type);
451         return EINVAL;
452     }
453     if (!tnl_cfg.ttl) {
454         tnl_cfg.ttl = DEFAULT_TTL;
455     }
456
457     tnl_cfg.in_key = parse_key(args, "in_key",
458                                &tnl_cfg.in_key_present,
459                                &tnl_cfg.in_key_flow);
460
461     tnl_cfg.out_key = parse_key(args, "out_key",
462                                &tnl_cfg.out_key_present,
463                                &tnl_cfg.out_key_flow);
464
465     dev->tnl_cfg = tnl_cfg;
466     netdev_vport_poll_notify(dev);
467
468     return 0;
469 }
470
471 static int
472 get_tunnel_config(struct netdev_dev *dev, struct smap *args)
473 {
474     const struct netdev_tunnel_config *tnl_cfg =
475         &netdev_dev_vport_cast(dev)->tnl_cfg;
476
477     if (tnl_cfg->ip_dst) {
478         smap_add_format(args, "remote_ip", IP_FMT, IP_ARGS(tnl_cfg->ip_dst));
479     }
480
481     if (tnl_cfg->ip_src) {
482         smap_add_format(args, "local_ip", IP_FMT, IP_ARGS(tnl_cfg->ip_src));
483     }
484
485     if (tnl_cfg->in_key_flow && tnl_cfg->out_key_flow) {
486         smap_add(args, "key", "flow");
487     } else if (tnl_cfg->in_key_present && tnl_cfg->out_key_present
488                && tnl_cfg->in_key == tnl_cfg->out_key) {
489         smap_add_format(args, "key", "%"PRIu64, ntohll(tnl_cfg->in_key));
490     } else {
491         if (tnl_cfg->in_key_flow) {
492             smap_add(args, "in_key", "flow");
493         } else if (tnl_cfg->in_key_present) {
494             smap_add_format(args, "in_key", "%"PRIu64,
495                             ntohll(tnl_cfg->in_key));
496         }
497
498         if (tnl_cfg->out_key_flow) {
499             smap_add(args, "out_key", "flow");
500         } else if (tnl_cfg->out_key_present) {
501             smap_add_format(args, "out_key", "%"PRIu64,
502                             ntohll(tnl_cfg->out_key));
503         }
504     }
505
506     if (tnl_cfg->ttl_inherit) {
507         smap_add(args, "ttl", "inherit");
508     } else if (tnl_cfg->ttl != DEFAULT_TTL) {
509         smap_add_format(args, "ttl", "%"PRIu8, tnl_cfg->ttl);
510     }
511
512     if (tnl_cfg->tos_inherit) {
513         smap_add(args, "tos", "inherit");
514     } else if (tnl_cfg->tos) {
515         smap_add_format(args, "tos", "0x%x", tnl_cfg->tos);
516     }
517
518     if (tnl_cfg->dst_port) {
519         uint16_t dst_port = ntohs(tnl_cfg->dst_port);
520         const char *type = netdev_dev_get_type(dev);
521
522         if ((!strcmp("vxlan", type) && dst_port != VXLAN_DST_PORT) ||
523             (!strcmp("lisp", type) && dst_port != LISP_DST_PORT)) {
524             smap_add_format(args, "dst_port", "%d", dst_port);
525         }
526     }
527
528     if (tnl_cfg->csum) {
529         smap_add(args, "csum", "true");
530     }
531
532     if (!tnl_cfg->dont_fragment) {
533         smap_add(args, "df_default", "false");
534     }
535
536     return 0;
537 }
538 \f
539 /* Code specific to patch ports. */
540
541 const char *
542 netdev_vport_patch_peer(const struct netdev *netdev)
543 {
544     return netdev_vport_is_patch(netdev)
545         ? netdev_vport_get_dev(netdev)->peer
546         : NULL;
547 }
548
549 void
550 netdev_vport_inc_rx(const struct netdev *netdev,
551                           const struct dpif_flow_stats *stats)
552 {
553     if (is_vport_class(netdev_dev_get_class(netdev_get_dev(netdev)))) {
554         struct netdev_dev_vport *dev = netdev_vport_get_dev(netdev);
555         dev->stats.rx_packets += stats->n_packets;
556         dev->stats.rx_bytes += stats->n_bytes;
557     }
558 }
559
560 void
561 netdev_vport_inc_tx(const struct netdev *netdev,
562                     const struct dpif_flow_stats *stats)
563 {
564     if (is_vport_class(netdev_dev_get_class(netdev_get_dev(netdev)))) {
565         struct netdev_dev_vport *dev = netdev_vport_get_dev(netdev);
566         dev->stats.tx_packets += stats->n_packets;
567         dev->stats.tx_bytes += stats->n_bytes;
568     }
569 }
570
571 static int
572 get_patch_config(struct netdev_dev *dev_, struct smap *args)
573 {
574     struct netdev_dev_vport *dev = netdev_dev_vport_cast(dev_);
575
576     if (dev->peer) {
577         smap_add(args, "peer", dev->peer);
578     }
579     return 0;
580 }
581
582 static int
583 set_patch_config(struct netdev_dev *dev_, const struct smap *args)
584 {
585     struct netdev_dev_vport *dev = netdev_dev_vport_cast(dev_);
586     const char *name = netdev_dev_get_name(dev_);
587     const char *peer;
588
589     peer = smap_get(args, "peer");
590     if (!peer) {
591         VLOG_ERR("%s: patch type requires valid 'peer' argument", name);
592         return EINVAL;
593     }
594
595     if (smap_count(args) > 1) {
596         VLOG_ERR("%s: patch type takes only a 'peer' argument", name);
597         return EINVAL;
598     }
599
600     if (!strcmp(name, peer)) {
601         VLOG_ERR("%s: patch peer must not be self", name);
602         return EINVAL;
603     }
604
605     free(dev->peer);
606     dev->peer = xstrdup(peer);
607
608     return 0;
609 }
610
611 static int
612 get_stats(const struct netdev *netdev, struct netdev_stats *stats)
613 {
614     struct netdev_dev_vport *dev = netdev_vport_get_dev(netdev);
615     memcpy(stats, &dev->stats, sizeof *stats);
616     return 0;
617 }
618 \f
619 #define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG,             \
620                         GET_TUNNEL_CONFIG, GET_STATUS)      \
621     NULL,                                                   \
622     netdev_vport_run,                                       \
623     netdev_vport_wait,                                      \
624                                                             \
625     netdev_vport_create,                                    \
626     netdev_vport_destroy,                                   \
627     GET_CONFIG,                                             \
628     SET_CONFIG,                                             \
629     GET_TUNNEL_CONFIG,                                      \
630                                                             \
631     netdev_vport_open,                                      \
632     netdev_vport_close,                                     \
633                                                             \
634     NULL,                       /* listen */                \
635     NULL,                       /* recv */                  \
636     NULL,                       /* recv_wait */             \
637     NULL,                       /* drain */                 \
638                                                             \
639     NULL,                       /* send */                  \
640     NULL,                       /* send_wait */             \
641                                                             \
642     netdev_vport_set_etheraddr,                             \
643     netdev_vport_get_etheraddr,                             \
644     NULL,                       /* get_mtu */               \
645     NULL,                       /* set_mtu */               \
646     NULL,                       /* get_ifindex */           \
647     NULL,                       /* get_carrier */           \
648     NULL,                       /* get_carrier_resets */    \
649     NULL,                       /* get_miimon */            \
650     get_stats,                                              \
651     NULL,                       /* set_stats */             \
652                                                             \
653     NULL,                       /* get_features */          \
654     NULL,                       /* set_advertisements */    \
655                                                             \
656     NULL,                       /* set_policing */          \
657     NULL,                       /* get_qos_types */         \
658     NULL,                       /* get_qos_capabilities */  \
659     NULL,                       /* get_qos */               \
660     NULL,                       /* set_qos */               \
661     NULL,                       /* get_queue */             \
662     NULL,                       /* set_queue */             \
663     NULL,                       /* delete_queue */          \
664     NULL,                       /* get_queue_stats */       \
665     NULL,                       /* dump_queues */           \
666     NULL,                       /* dump_queue_stats */      \
667                                                             \
668     NULL,                       /* get_in4 */               \
669     NULL,                       /* set_in4 */               \
670     NULL,                       /* get_in6 */               \
671     NULL,                       /* add_router */            \
672     NULL,                       /* get_next_hop */          \
673     GET_STATUS,                                             \
674     NULL,                       /* arp_lookup */            \
675                                                             \
676     netdev_vport_update_flags,                              \
677                                                             \
678     netdev_vport_change_seq
679
680 #define TUNNEL_CLASS(NAME, DPIF_PORT)                       \
681     { DPIF_PORT,                                            \
682         { NAME, VPORT_FUNCTIONS(get_tunnel_config,          \
683                                 set_tunnel_config,          \
684                                 get_netdev_tunnel_config,   \
685                                 tunnel_get_status) }}
686
687 void
688 netdev_vport_tunnel_register(void)
689 {
690     static const struct vport_class vport_classes[] = {
691         TUNNEL_CLASS("gre", "gre_system"),
692         TUNNEL_CLASS("ipsec_gre", "gre_system"),
693         TUNNEL_CLASS("gre64", "gre64_system"),
694         TUNNEL_CLASS("ipsec_gre64", "gre64_system"),
695         TUNNEL_CLASS("vxlan", "vxlan_system"),
696         TUNNEL_CLASS("lisp", "lisp_system")
697     };
698
699     int i;
700
701     for (i = 0; i < ARRAY_SIZE(vport_classes); i++) {
702         netdev_register_provider(&vport_classes[i].netdev_class);
703     }
704 }
705
706 void
707 netdev_vport_patch_register(void)
708 {
709     static const struct vport_class patch_class =
710         { NULL,
711             { "patch", VPORT_FUNCTIONS(get_patch_config,
712                                        set_patch_config,
713                                        NULL,
714                                        NULL) }};
715     netdev_register_provider(&patch_class.netdev_class);
716 }