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