]> git.proxmox.com Git - mirror_ovs.git/blob - lib/netdev-vport.c
Add support for LISP tunneling
[mirror_ovs.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 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 {
333 tnl_cfg.ip_dst = in_addr.s_addr;
334 }
335 } else if (!strcmp(node->key, "local_ip")) {
336 struct in_addr in_addr;
337 if (lookup_ip(node->value, &in_addr)) {
338 VLOG_WARN("%s: bad %s 'local_ip'", name, type);
339 } else {
340 tnl_cfg.ip_src = in_addr.s_addr;
341 }
342 } else if (!strcmp(node->key, "tos")) {
343 if (!strcmp(node->value, "inherit")) {
344 tnl_cfg.tos_inherit = true;
345 } else {
346 char *endptr;
347 int tos;
348 tos = strtol(node->value, &endptr, 0);
349 if (*endptr == '\0' && tos == (tos & IP_DSCP_MASK)) {
350 tnl_cfg.tos = tos;
351 } else {
352 VLOG_WARN("%s: invalid TOS %s", name, node->value);
353 }
354 }
355 } else if (!strcmp(node->key, "ttl")) {
356 if (!strcmp(node->value, "inherit")) {
357 tnl_cfg.ttl_inherit = true;
358 } else {
359 tnl_cfg.ttl = atoi(node->value);
360 }
361 } else if (!strcmp(node->key, "dst_port") && needs_dst_port) {
362 tnl_cfg.dst_port = htons(atoi(node->value));
363 } else if (!strcmp(node->key, "csum") && has_csum) {
364 if (!strcmp(node->value, "true")) {
365 tnl_cfg.csum = true;
366 }
367 } else if (!strcmp(node->key, "df_default")) {
368 if (!strcmp(node->value, "false")) {
369 tnl_cfg.dont_fragment = false;
370 }
371 } else if (!strcmp(node->key, "peer_cert") && tnl_cfg.ipsec) {
372 if (smap_get(args, "certificate")) {
373 ipsec_mech_set = true;
374 } else {
375 const char *use_ssl_cert;
376
377 /* If the "use_ssl_cert" is true, then "certificate" and
378 * "private_key" will be pulled from the SSL table. The
379 * use of this option is strongly discouraged, since it
380 * will like be removed when multiple SSL configurations
381 * are supported by OVS.
382 */
383 use_ssl_cert = smap_get(args, "use_ssl_cert");
384 if (!use_ssl_cert || strcmp(use_ssl_cert, "true")) {
385 VLOG_ERR("%s: 'peer_cert' requires 'certificate' argument",
386 name);
387 return EINVAL;
388 }
389 ipsec_mech_set = true;
390 }
391 } else if (!strcmp(node->key, "psk") && tnl_cfg.ipsec) {
392 ipsec_mech_set = true;
393 } else if (tnl_cfg.ipsec
394 && (!strcmp(node->key, "certificate")
395 || !strcmp(node->key, "private_key")
396 || !strcmp(node->key, "use_ssl_cert"))) {
397 /* Ignore options not used by the netdev. */
398 } else if (!strcmp(node->key, "key") ||
399 !strcmp(node->key, "in_key") ||
400 !strcmp(node->key, "out_key")) {
401 /* Handled separately below. */
402 } else {
403 VLOG_WARN("%s: unknown %s argument '%s'", name, type, node->key);
404 }
405 }
406
407 /* Add a default destination port for VXLAN if none specified. */
408 if (!strcmp(type, "vxlan") && !tnl_cfg.dst_port) {
409 tnl_cfg.dst_port = htons(VXLAN_DST_PORT);
410 }
411
412 /* Add a default destination port for LISP if none specified. */
413 if (!strcmp(type, "lisp") && !tnl_cfg.dst_port) {
414 tnl_cfg.dst_port = htons(LISP_DST_PORT);
415 }
416
417 if (tnl_cfg.ipsec) {
418 static pid_t pid = 0;
419 if (pid <= 0) {
420 char *file_name = xasprintf("%s/%s", ovs_rundir(),
421 "ovs-monitor-ipsec.pid");
422 pid = read_pidfile(file_name);
423 free(file_name);
424 }
425
426 if (pid < 0) {
427 VLOG_ERR("%s: IPsec requires the ovs-monitor-ipsec daemon",
428 name);
429 return EINVAL;
430 }
431
432 if (smap_get(args, "peer_cert") && smap_get(args, "psk")) {
433 VLOG_ERR("%s: cannot define both 'peer_cert' and 'psk'", name);
434 return EINVAL;
435 }
436
437 if (!ipsec_mech_set) {
438 VLOG_ERR("%s: IPsec requires an 'peer_cert' or psk' argument",
439 name);
440 return EINVAL;
441 }
442 }
443
444 if (!tnl_cfg.ip_dst) {
445 VLOG_ERR("%s: %s type requires valid 'remote_ip' argument",
446 name, type);
447 return EINVAL;
448 }
449
450 if (tnl_cfg.ip_src) {
451 if (ip_is_multicast(tnl_cfg.ip_dst)) {
452 VLOG_WARN("%s: remote_ip is multicast, ignoring local_ip", name);
453 tnl_cfg.ip_src = 0;
454 }
455 }
456
457 if (!tnl_cfg.ttl) {
458 tnl_cfg.ttl = DEFAULT_TTL;
459 }
460
461 tnl_cfg.in_key = parse_key(args, "in_key",
462 &tnl_cfg.in_key_present,
463 &tnl_cfg.in_key_flow);
464
465 tnl_cfg.out_key = parse_key(args, "out_key",
466 &tnl_cfg.out_key_present,
467 &tnl_cfg.out_key_flow);
468
469 dev->tnl_cfg = tnl_cfg;
470 netdev_vport_poll_notify(dev);
471
472 return 0;
473 }
474
475 static int
476 get_tunnel_config(struct netdev_dev *dev, struct smap *args)
477 {
478 const struct netdev_tunnel_config *tnl_cfg =
479 &netdev_dev_vport_cast(dev)->tnl_cfg;
480
481 if (tnl_cfg->ip_dst) {
482 smap_add_format(args, "remote_ip", IP_FMT, IP_ARGS(tnl_cfg->ip_dst));
483 }
484
485 if (tnl_cfg->ip_src) {
486 smap_add_format(args, "local_ip", IP_FMT, IP_ARGS(tnl_cfg->ip_src));
487 }
488
489 if (tnl_cfg->in_key_flow && tnl_cfg->out_key_flow) {
490 smap_add(args, "key", "flow");
491 } else if (tnl_cfg->in_key_present && tnl_cfg->out_key_present
492 && tnl_cfg->in_key == tnl_cfg->out_key) {
493 smap_add_format(args, "key", "%"PRIu64, ntohll(tnl_cfg->in_key));
494 } else {
495 if (tnl_cfg->in_key_flow) {
496 smap_add(args, "in_key", "flow");
497 } else if (tnl_cfg->in_key_present) {
498 smap_add_format(args, "in_key", "%"PRIu64,
499 ntohll(tnl_cfg->in_key));
500 }
501
502 if (tnl_cfg->out_key_flow) {
503 smap_add(args, "out_key", "flow");
504 } else if (tnl_cfg->out_key_present) {
505 smap_add_format(args, "out_key", "%"PRIu64,
506 ntohll(tnl_cfg->out_key));
507 }
508 }
509
510 if (tnl_cfg->ttl_inherit) {
511 smap_add(args, "ttl", "inherit");
512 } else if (tnl_cfg->ttl != DEFAULT_TTL) {
513 smap_add_format(args, "ttl", "%"PRIu8, tnl_cfg->ttl);
514 }
515
516 if (tnl_cfg->tos_inherit) {
517 smap_add(args, "tos", "inherit");
518 } else if (tnl_cfg->tos) {
519 smap_add_format(args, "tos", "0x%x", tnl_cfg->tos);
520 }
521
522 if (tnl_cfg->dst_port) {
523 uint16_t dst_port = ntohs(tnl_cfg->dst_port);
524 if (dst_port != VXLAN_DST_PORT) {
525 smap_add_format(args, "dst_port", "%d", dst_port);
526 }
527 }
528
529 if (tnl_cfg->csum) {
530 smap_add(args, "csum", "true");
531 }
532
533 if (!tnl_cfg->dont_fragment) {
534 smap_add(args, "df_default", "false");
535 }
536
537 return 0;
538 }
539 \f
540 /* Code specific to patch ports. */
541
542 const char *
543 netdev_vport_patch_peer(const struct netdev *netdev)
544 {
545 return netdev_vport_is_patch(netdev)
546 ? netdev_vport_get_dev(netdev)->peer
547 : NULL;
548 }
549
550 void
551 netdev_vport_inc_rx(const struct netdev *netdev,
552 const struct dpif_flow_stats *stats)
553 {
554 if (is_vport_class(netdev_dev_get_class(netdev_get_dev(netdev)))) {
555 struct netdev_dev_vport *dev = netdev_vport_get_dev(netdev);
556 dev->stats.rx_packets += stats->n_packets;
557 dev->stats.rx_bytes += stats->n_bytes;
558 }
559 }
560
561 void
562 netdev_vport_inc_tx(const struct netdev *netdev,
563 const struct dpif_flow_stats *stats)
564 {
565 if (is_vport_class(netdev_dev_get_class(netdev_get_dev(netdev)))) {
566 struct netdev_dev_vport *dev = netdev_vport_get_dev(netdev);
567 dev->stats.tx_packets += stats->n_packets;
568 dev->stats.tx_bytes += stats->n_bytes;
569 }
570 }
571
572 static int
573 get_patch_config(struct netdev_dev *dev_, struct smap *args)
574 {
575 struct netdev_dev_vport *dev = netdev_dev_vport_cast(dev_);
576
577 if (dev->peer) {
578 smap_add(args, "peer", dev->peer);
579 }
580 return 0;
581 }
582
583 static int
584 set_patch_config(struct netdev_dev *dev_, const struct smap *args)
585 {
586 struct netdev_dev_vport *dev = netdev_dev_vport_cast(dev_);
587 const char *name = netdev_dev_get_name(dev_);
588 const char *peer;
589
590 peer = smap_get(args, "peer");
591 if (!peer) {
592 VLOG_ERR("%s: patch type requires valid 'peer' argument", name);
593 return EINVAL;
594 }
595
596 if (smap_count(args) > 1) {
597 VLOG_ERR("%s: patch type takes only a 'peer' argument", name);
598 return EINVAL;
599 }
600
601 if (!strcmp(name, peer)) {
602 VLOG_ERR("%s: patch peer must not be self", name);
603 return EINVAL;
604 }
605
606 free(dev->peer);
607 dev->peer = xstrdup(peer);
608
609 return 0;
610 }
611
612 static int
613 get_stats(const struct netdev *netdev, struct netdev_stats *stats)
614 {
615 struct netdev_dev_vport *dev = netdev_vport_get_dev(netdev);
616 memcpy(stats, &dev->stats, sizeof *stats);
617 return 0;
618 }
619 \f
620 #define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG, \
621 GET_TUNNEL_CONFIG, GET_STATUS) \
622 NULL, \
623 netdev_vport_run, \
624 netdev_vport_wait, \
625 \
626 netdev_vport_create, \
627 netdev_vport_destroy, \
628 GET_CONFIG, \
629 SET_CONFIG, \
630 GET_TUNNEL_CONFIG, \
631 \
632 netdev_vport_open, \
633 netdev_vport_close, \
634 \
635 NULL, /* listen */ \
636 NULL, /* recv */ \
637 NULL, /* recv_wait */ \
638 NULL, /* drain */ \
639 \
640 NULL, /* send */ \
641 NULL, /* send_wait */ \
642 \
643 netdev_vport_set_etheraddr, \
644 netdev_vport_get_etheraddr, \
645 NULL, /* get_mtu */ \
646 NULL, /* set_mtu */ \
647 NULL, /* get_ifindex */ \
648 NULL, /* get_carrier */ \
649 NULL, /* get_carrier_resets */ \
650 NULL, /* get_miimon */ \
651 get_stats, \
652 NULL, /* set_stats */ \
653 \
654 NULL, /* get_features */ \
655 NULL, /* set_advertisements */ \
656 \
657 NULL, /* set_policing */ \
658 NULL, /* get_qos_types */ \
659 NULL, /* get_qos_capabilities */ \
660 NULL, /* get_qos */ \
661 NULL, /* set_qos */ \
662 NULL, /* get_queue */ \
663 NULL, /* set_queue */ \
664 NULL, /* delete_queue */ \
665 NULL, /* get_queue_stats */ \
666 NULL, /* dump_queues */ \
667 NULL, /* dump_queue_stats */ \
668 \
669 NULL, /* get_in4 */ \
670 NULL, /* set_in4 */ \
671 NULL, /* get_in6 */ \
672 NULL, /* add_router */ \
673 NULL, /* get_next_hop */ \
674 GET_STATUS, \
675 NULL, /* arp_lookup */ \
676 \
677 netdev_vport_update_flags, \
678 \
679 netdev_vport_change_seq
680
681 #define TUNNEL_CLASS(NAME, DPIF_PORT) \
682 { DPIF_PORT, \
683 { NAME, VPORT_FUNCTIONS(get_tunnel_config, \
684 set_tunnel_config, \
685 get_netdev_tunnel_config, \
686 tunnel_get_status) }}
687
688 void
689 netdev_vport_tunnel_register(void)
690 {
691 static const struct vport_class vport_classes[] = {
692 TUNNEL_CLASS("gre", "gre_system"),
693 TUNNEL_CLASS("ipsec_gre", "gre_system"),
694 TUNNEL_CLASS("gre64", "gre64_system"),
695 TUNNEL_CLASS("ipsec_gre64", "gre64_system"),
696 TUNNEL_CLASS("vxlan", "vxlan_system"),
697 TUNNEL_CLASS("lisp", "lisp_system")
698 };
699
700 int i;
701
702 for (i = 0; i < ARRAY_SIZE(vport_classes); i++) {
703 netdev_register_provider(&vport_classes[i].netdev_class);
704 }
705 }
706
707 void
708 netdev_vport_patch_register(void)
709 {
710 static const struct vport_class patch_class =
711 { NULL,
712 { "patch", VPORT_FUNCTIONS(get_patch_config,
713 set_patch_config,
714 NULL,
715 NULL) }};
716 netdev_register_provider(&patch_class.netdev_class);
717 }