2 * Copyright (c) 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "netdev-vport.h"
23 #include <sys/socket.h>
25 #include <netinet/in.h>
26 #include <netinet/ip6.h>
27 #include <sys/ioctl.h>
29 #include "byte-order.h"
34 #include "dp-packet.h"
35 #include "openvswitch/dynamic-string.h"
39 #include "openvswitch/list.h"
40 #include "netdev-provider.h"
41 #include "netdev-vport-private.h"
42 #include "odp-netlink.h"
43 #include "dp-packet.h"
44 #include "ovs-router.h"
46 #include "poll-loop.h"
47 #include "route-table.h"
49 #include "socket-util.h"
50 #include "netdev-native-tnl.h"
51 #include "openvswitch/vlog.h"
52 #include "unaligned.h"
56 VLOG_DEFINE_THIS_MODULE(netdev_vport);
58 #define GENEVE_DST_PORT 6081
59 #define VXLAN_DST_PORT 4789
60 #define LISP_DST_PORT 4341
61 #define STT_DST_PORT 7471
63 #define DEFAULT_TTL 64
65 /* Last read of the route-table's change number. */
66 static uint64_t rt_change_seqno;
68 static int get_patch_config(const struct netdev *netdev, struct smap *args);
69 static int get_tunnel_config(const struct netdev *, struct smap *args);
70 static bool tunnel_check_status_change__(struct netdev_vport *);
73 const char *dpif_port;
74 struct netdev_class netdev_class;
78 netdev_vport_is_vport_class(const struct netdev_class *class)
80 return is_vport_class(class);
83 static const struct vport_class *
84 vport_class_cast(const struct netdev_class *class)
86 ovs_assert(is_vport_class(class));
87 return CONTAINER_OF(class, struct vport_class, netdev_class);
90 static const struct netdev_tunnel_config *
91 get_netdev_tunnel_config(const struct netdev *netdev)
93 return &netdev_vport_cast(netdev)->tnl_cfg;
97 netdev_vport_is_patch(const struct netdev *netdev)
99 const struct netdev_class *class = netdev_get_class(netdev);
101 return class->get_config == get_patch_config;
105 netdev_vport_is_layer3(const struct netdev *dev)
107 const char *type = netdev_get_type(dev);
109 return (!strcmp("lisp", type));
113 netdev_vport_needs_dst_port(const struct netdev *dev)
115 const struct netdev_class *class = netdev_get_class(dev);
116 const char *type = netdev_get_type(dev);
118 return (class->get_config == get_tunnel_config &&
119 (!strcmp("geneve", type) || !strcmp("vxlan", type) ||
120 !strcmp("lisp", type) || !strcmp("stt", type)) );
124 netdev_vport_class_get_dpif_port(const struct netdev_class *class)
126 return is_vport_class(class) ? vport_class_cast(class)->dpif_port : NULL;
130 netdev_vport_get_dpif_port(const struct netdev *netdev,
131 char namebuf[], size_t bufsize)
133 const struct netdev_class *class = netdev_get_class(netdev);
134 const char *dpif_port = netdev_vport_class_get_dpif_port(class);
137 return netdev_get_name(netdev);
140 if (netdev_vport_needs_dst_port(netdev)) {
141 const struct netdev_vport *vport = netdev_vport_cast(netdev);
144 * Note: IFNAMSIZ is 16 bytes long. Implementations should choose
145 * a dpif port name that is short enough to fit including any
146 * port numbers but assert just in case.
148 BUILD_ASSERT(NETDEV_VPORT_NAME_BUFSIZE >= IFNAMSIZ);
149 ovs_assert(strlen(dpif_port) + 6 < IFNAMSIZ);
150 snprintf(namebuf, bufsize, "%s_%d", dpif_port,
151 ntohs(vport->tnl_cfg.dst_port));
159 netdev_vport_get_dpif_port_strdup(const struct netdev *netdev)
161 char namebuf[NETDEV_VPORT_NAME_BUFSIZE];
163 return xstrdup(netdev_vport_get_dpif_port(netdev, namebuf,
167 /* Whenever the route-table change number is incremented,
168 * netdev_vport_route_changed() should be called to update
169 * the corresponding tunnel interface status. */
171 netdev_vport_route_changed(void)
173 struct netdev **vports;
176 vports = netdev_get_vports(&n_vports);
177 for (i = 0; i < n_vports; i++) {
178 struct netdev *netdev_ = vports[i];
179 struct netdev_vport *netdev = netdev_vport_cast(netdev_);
181 ovs_mutex_lock(&netdev->mutex);
182 /* Finds all tunnel vports. */
183 if (ipv6_addr_is_set(&netdev->tnl_cfg.ipv6_dst)) {
184 if (tunnel_check_status_change__(netdev)) {
185 netdev_change_seq_changed(netdev_);
188 ovs_mutex_unlock(&netdev->mutex);
190 netdev_close(netdev_);
196 static struct netdev *
197 netdev_vport_alloc(void)
199 struct netdev_vport *netdev = xzalloc(sizeof *netdev);
204 netdev_vport_construct(struct netdev *netdev_)
206 struct netdev_vport *dev = netdev_vport_cast(netdev_);
207 const char *type = netdev_get_type(netdev_);
209 ovs_mutex_init(&dev->mutex);
210 eth_addr_random(&dev->etheraddr);
212 /* Add a default destination port for tunnel ports if none specified. */
213 if (!strcmp(type, "geneve")) {
214 dev->tnl_cfg.dst_port = htons(GENEVE_DST_PORT);
215 } else if (!strcmp(type, "vxlan")) {
216 dev->tnl_cfg.dst_port = htons(VXLAN_DST_PORT);
217 } else if (!strcmp(type, "lisp")) {
218 dev->tnl_cfg.dst_port = htons(LISP_DST_PORT);
219 } else if (!strcmp(type, "stt")) {
220 dev->tnl_cfg.dst_port = htons(STT_DST_PORT);
223 dev->tnl_cfg.dont_fragment = true;
224 dev->tnl_cfg.ttl = DEFAULT_TTL;
229 netdev_vport_destruct(struct netdev *netdev_)
231 struct netdev_vport *netdev = netdev_vport_cast(netdev_);
234 ovs_mutex_destroy(&netdev->mutex);
238 netdev_vport_dealloc(struct netdev *netdev_)
240 struct netdev_vport *netdev = netdev_vport_cast(netdev_);
245 netdev_vport_set_etheraddr(struct netdev *netdev_, const struct eth_addr mac)
247 struct netdev_vport *netdev = netdev_vport_cast(netdev_);
249 ovs_mutex_lock(&netdev->mutex);
250 netdev->etheraddr = mac;
251 ovs_mutex_unlock(&netdev->mutex);
252 netdev_change_seq_changed(netdev_);
258 netdev_vport_get_etheraddr(const struct netdev *netdev_, struct eth_addr *mac)
260 struct netdev_vport *netdev = netdev_vport_cast(netdev_);
262 ovs_mutex_lock(&netdev->mutex);
263 *mac = netdev->etheraddr;
264 ovs_mutex_unlock(&netdev->mutex);
269 /* Checks if the tunnel status has changed and returns a boolean.
270 * Updates the tunnel status if it has changed. */
272 tunnel_check_status_change__(struct netdev_vport *netdev)
273 OVS_REQUIRES(netdev->mutex)
275 char iface[IFNAMSIZ];
277 struct in6_addr *route;
281 route = &netdev->tnl_cfg.ipv6_dst;
282 if (ovs_router_lookup(route, iface, NULL, &gw)) {
283 struct netdev *egress_netdev;
285 if (!netdev_open(iface, "system", &egress_netdev)) {
286 status = netdev_get_carrier(egress_netdev);
287 netdev_close(egress_netdev);
291 if (strcmp(netdev->egress_iface, iface)
292 || netdev->carrier_status != status) {
293 ovs_strlcpy(netdev->egress_iface, iface, IFNAMSIZ);
294 netdev->carrier_status = status;
303 tunnel_get_status(const struct netdev *netdev_, struct smap *smap)
305 struct netdev_vport *netdev = netdev_vport_cast(netdev_);
307 if (netdev->egress_iface[0]) {
308 smap_add(smap, "tunnel_egress_iface", netdev->egress_iface);
310 smap_add(smap, "tunnel_egress_iface_carrier",
311 netdev->carrier_status ? "up" : "down");
318 netdev_vport_update_flags(struct netdev *netdev OVS_UNUSED,
319 enum netdev_flags off,
320 enum netdev_flags on OVS_UNUSED,
321 enum netdev_flags *old_flagsp)
323 if (off & (NETDEV_UP | NETDEV_PROMISC)) {
327 *old_flagsp = NETDEV_UP | NETDEV_PROMISC;
332 netdev_vport_run(void)
337 seq = route_table_get_change_seq();
338 if (rt_change_seqno != seq) {
339 rt_change_seqno = seq;
340 netdev_vport_route_changed();
345 netdev_vport_wait(void)
350 seq = route_table_get_change_seq();
351 if (rt_change_seqno != seq) {
352 poll_immediate_wake();
356 /* Code specific to tunnel types. */
359 parse_key(const struct smap *args, const char *name,
360 bool *present, bool *flow)
367 s = smap_get(args, name);
369 s = smap_get(args, "key");
377 if (!strcmp(s, "flow")) {
381 return htonll(strtoull(s, NULL, 0));
386 parse_tunnel_ip(const char *value, bool accept_mcast, bool *flow,
387 struct in6_addr *ipv6, uint16_t *protocol)
389 if (!strcmp(value, "flow")) {
394 if (addr_is_ipv6(value)) {
395 if (lookup_ipv6(value, ipv6)) {
398 if (!accept_mcast && ipv6_addr_is_multicast(ipv6)) {
401 *protocol = ETH_TYPE_IPV6;
404 if (lookup_ip(value, &ip)) {
407 if (!accept_mcast && ip_is_multicast(ip.s_addr)) {
410 in6_addr_set_mapped_ipv4(ipv6, ip.s_addr);
411 *protocol = ETH_TYPE_IP;
417 set_tunnel_config(struct netdev *dev_, const struct smap *args)
419 struct netdev_vport *dev = netdev_vport_cast(dev_);
420 const char *name = netdev_get_name(dev_);
421 const char *type = netdev_get_type(dev_);
422 bool ipsec_mech_set, needs_dst_port, has_csum;
423 uint16_t dst_proto = 0, src_proto = 0;
424 struct netdev_tunnel_config tnl_cfg;
425 struct smap_node *node;
427 has_csum = strstr(type, "gre") || strstr(type, "geneve") ||
428 strstr(type, "stt") || strstr(type, "vxlan");
429 ipsec_mech_set = false;
430 memset(&tnl_cfg, 0, sizeof tnl_cfg);
432 /* Add a default destination port for tunnel ports if none specified. */
433 if (!strcmp(type, "geneve")) {
434 tnl_cfg.dst_port = htons(GENEVE_DST_PORT);
437 if (!strcmp(type, "vxlan")) {
438 tnl_cfg.dst_port = htons(VXLAN_DST_PORT);
441 if (!strcmp(type, "lisp")) {
442 tnl_cfg.dst_port = htons(LISP_DST_PORT);
445 if (!strcmp(type, "stt")) {
446 tnl_cfg.dst_port = htons(STT_DST_PORT);
449 needs_dst_port = netdev_vport_needs_dst_port(dev_);
450 tnl_cfg.ipsec = strstr(type, "ipsec");
451 tnl_cfg.dont_fragment = true;
453 SMAP_FOR_EACH (node, args) {
454 if (!strcmp(node->key, "remote_ip")) {
456 err = parse_tunnel_ip(node->value, false, &tnl_cfg.ip_dst_flow,
457 &tnl_cfg.ipv6_dst, &dst_proto);
460 VLOG_WARN("%s: bad %s 'remote_ip'", name, type);
463 VLOG_WARN("%s: multicast remote_ip=%s not allowed",
467 } else if (!strcmp(node->key, "local_ip")) {
469 err = parse_tunnel_ip(node->value, true, &tnl_cfg.ip_src_flow,
470 &tnl_cfg.ipv6_src, &src_proto);
473 VLOG_WARN("%s: bad %s 'local_ip'", name, type);
476 } else if (!strcmp(node->key, "tos")) {
477 if (!strcmp(node->value, "inherit")) {
478 tnl_cfg.tos_inherit = true;
482 tos = strtol(node->value, &endptr, 0);
483 if (*endptr == '\0' && tos == (tos & IP_DSCP_MASK)) {
486 VLOG_WARN("%s: invalid TOS %s", name, node->value);
489 } else if (!strcmp(node->key, "ttl")) {
490 if (!strcmp(node->value, "inherit")) {
491 tnl_cfg.ttl_inherit = true;
493 tnl_cfg.ttl = atoi(node->value);
495 } else if (!strcmp(node->key, "dst_port") && needs_dst_port) {
496 tnl_cfg.dst_port = htons(atoi(node->value));
497 } else if (!strcmp(node->key, "csum") && has_csum) {
498 if (!strcmp(node->value, "true")) {
501 } else if (!strcmp(node->key, "df_default")) {
502 if (!strcmp(node->value, "false")) {
503 tnl_cfg.dont_fragment = false;
505 } else if (!strcmp(node->key, "peer_cert") && tnl_cfg.ipsec) {
506 if (smap_get(args, "certificate")) {
507 ipsec_mech_set = true;
509 const char *use_ssl_cert;
511 /* If the "use_ssl_cert" is true, then "certificate" and
512 * "private_key" will be pulled from the SSL table. The
513 * use of this option is strongly discouraged, since it
514 * will like be removed when multiple SSL configurations
515 * are supported by OVS.
517 use_ssl_cert = smap_get(args, "use_ssl_cert");
518 if (!use_ssl_cert || strcmp(use_ssl_cert, "true")) {
519 VLOG_ERR("%s: 'peer_cert' requires 'certificate' argument",
523 ipsec_mech_set = true;
525 } else if (!strcmp(node->key, "psk") && tnl_cfg.ipsec) {
526 ipsec_mech_set = true;
527 } else if (tnl_cfg.ipsec
528 && (!strcmp(node->key, "certificate")
529 || !strcmp(node->key, "private_key")
530 || !strcmp(node->key, "use_ssl_cert"))) {
531 /* Ignore options not used by the netdev. */
532 } else if (!strcmp(node->key, "key") ||
533 !strcmp(node->key, "in_key") ||
534 !strcmp(node->key, "out_key")) {
535 /* Handled separately below. */
536 } else if (!strcmp(node->key, "exts")) {
537 char *str = xstrdup(node->value);
538 char *ext, *save_ptr = NULL;
542 ext = strtok_r(str, ",", &save_ptr);
544 if (!strcmp(type, "vxlan") && !strcmp(ext, "gbp")) {
545 tnl_cfg.exts |= (1 << OVS_VXLAN_EXT_GBP);
547 VLOG_WARN("%s: unknown extension '%s'", name, ext);
550 ext = strtok_r(NULL, ",", &save_ptr);
555 VLOG_WARN("%s: unknown %s argument '%s'", name, type, node->key);
560 static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
561 static pid_t pid = 0;
564 ovs_mutex_lock(&mutex);
566 char *file_name = xasprintf("%s/%s", ovs_rundir(),
567 "ovs-monitor-ipsec.pid");
568 pid = read_pidfile(file_name);
571 ovs_mutex_unlock(&mutex);
575 VLOG_ERR("%s: IPsec requires the ovs-monitor-ipsec daemon",
580 if (smap_get(args, "peer_cert") && smap_get(args, "psk")) {
581 VLOG_ERR("%s: cannot define both 'peer_cert' and 'psk'", name);
585 if (!ipsec_mech_set) {
586 VLOG_ERR("%s: IPsec requires an 'peer_cert' or psk' argument",
592 if (!ipv6_addr_is_set(&tnl_cfg.ipv6_dst) && !tnl_cfg.ip_dst_flow) {
593 VLOG_ERR("%s: %s type requires valid 'remote_ip' argument",
597 if (tnl_cfg.ip_src_flow && !tnl_cfg.ip_dst_flow) {
598 VLOG_ERR("%s: %s type requires 'remote_ip=flow' with 'local_ip=flow'",
602 if (src_proto && dst_proto && src_proto != dst_proto) {
603 VLOG_ERR("%s: 'remote_ip' and 'local_ip' has to be of the same address family",
608 tnl_cfg.ttl = DEFAULT_TTL;
611 tnl_cfg.in_key = parse_key(args, "in_key",
612 &tnl_cfg.in_key_present,
613 &tnl_cfg.in_key_flow);
615 tnl_cfg.out_key = parse_key(args, "out_key",
616 &tnl_cfg.out_key_present,
617 &tnl_cfg.out_key_flow);
619 ovs_mutex_lock(&dev->mutex);
620 if (memcmp(&dev->tnl_cfg, &tnl_cfg, sizeof tnl_cfg)) {
621 dev->tnl_cfg = tnl_cfg;
622 tunnel_check_status_change__(dev);
623 netdev_change_seq_changed(dev_);
625 ovs_mutex_unlock(&dev->mutex);
631 get_tunnel_config(const struct netdev *dev, struct smap *args)
633 struct netdev_vport *netdev = netdev_vport_cast(dev);
634 struct netdev_tunnel_config tnl_cfg;
636 ovs_mutex_lock(&netdev->mutex);
637 tnl_cfg = netdev->tnl_cfg;
638 ovs_mutex_unlock(&netdev->mutex);
640 if (ipv6_addr_is_set(&tnl_cfg.ipv6_dst)) {
641 smap_add_ipv6(args, "remote_ip", &tnl_cfg.ipv6_dst);
642 } else if (tnl_cfg.ip_dst_flow) {
643 smap_add(args, "remote_ip", "flow");
646 if (ipv6_addr_is_set(&tnl_cfg.ipv6_src)) {
647 smap_add_ipv6(args, "local_ip", &tnl_cfg.ipv6_src);
648 } else if (tnl_cfg.ip_src_flow) {
649 smap_add(args, "local_ip", "flow");
652 if (tnl_cfg.in_key_flow && tnl_cfg.out_key_flow) {
653 smap_add(args, "key", "flow");
654 } else if (tnl_cfg.in_key_present && tnl_cfg.out_key_present
655 && tnl_cfg.in_key == tnl_cfg.out_key) {
656 smap_add_format(args, "key", "%"PRIu64, ntohll(tnl_cfg.in_key));
658 if (tnl_cfg.in_key_flow) {
659 smap_add(args, "in_key", "flow");
660 } else if (tnl_cfg.in_key_present) {
661 smap_add_format(args, "in_key", "%"PRIu64,
662 ntohll(tnl_cfg.in_key));
665 if (tnl_cfg.out_key_flow) {
666 smap_add(args, "out_key", "flow");
667 } else if (tnl_cfg.out_key_present) {
668 smap_add_format(args, "out_key", "%"PRIu64,
669 ntohll(tnl_cfg.out_key));
673 if (tnl_cfg.ttl_inherit) {
674 smap_add(args, "ttl", "inherit");
675 } else if (tnl_cfg.ttl != DEFAULT_TTL) {
676 smap_add_format(args, "ttl", "%"PRIu8, tnl_cfg.ttl);
679 if (tnl_cfg.tos_inherit) {
680 smap_add(args, "tos", "inherit");
681 } else if (tnl_cfg.tos) {
682 smap_add_format(args, "tos", "0x%x", tnl_cfg.tos);
685 if (tnl_cfg.dst_port) {
686 uint16_t dst_port = ntohs(tnl_cfg.dst_port);
687 const char *type = netdev_get_type(dev);
689 if ((!strcmp("geneve", type) && dst_port != GENEVE_DST_PORT) ||
690 (!strcmp("vxlan", type) && dst_port != VXLAN_DST_PORT) ||
691 (!strcmp("lisp", type) && dst_port != LISP_DST_PORT) ||
692 (!strcmp("stt", type) && dst_port != STT_DST_PORT)) {
693 smap_add_format(args, "dst_port", "%d", dst_port);
698 smap_add(args, "csum", "true");
701 if (!tnl_cfg.dont_fragment) {
702 smap_add(args, "df_default", "false");
708 /* Code specific to patch ports. */
710 /* If 'netdev' is a patch port, returns the name of its peer as a malloc()'d
711 * string that the caller must free.
713 * If 'netdev' is not a patch port, returns NULL. */
715 netdev_vport_patch_peer(const struct netdev *netdev_)
719 if (netdev_vport_is_patch(netdev_)) {
720 struct netdev_vport *netdev = netdev_vport_cast(netdev_);
722 ovs_mutex_lock(&netdev->mutex);
724 peer = xstrdup(netdev->peer);
726 ovs_mutex_unlock(&netdev->mutex);
733 netdev_vport_inc_rx(const struct netdev *netdev,
734 const struct dpif_flow_stats *stats)
736 if (is_vport_class(netdev_get_class(netdev))) {
737 struct netdev_vport *dev = netdev_vport_cast(netdev);
739 ovs_mutex_lock(&dev->mutex);
740 dev->stats.rx_packets += stats->n_packets;
741 dev->stats.rx_bytes += stats->n_bytes;
742 ovs_mutex_unlock(&dev->mutex);
747 netdev_vport_inc_tx(const struct netdev *netdev,
748 const struct dpif_flow_stats *stats)
750 if (is_vport_class(netdev_get_class(netdev))) {
751 struct netdev_vport *dev = netdev_vport_cast(netdev);
753 ovs_mutex_lock(&dev->mutex);
754 dev->stats.tx_packets += stats->n_packets;
755 dev->stats.tx_bytes += stats->n_bytes;
756 ovs_mutex_unlock(&dev->mutex);
761 get_patch_config(const struct netdev *dev_, struct smap *args)
763 struct netdev_vport *dev = netdev_vport_cast(dev_);
765 ovs_mutex_lock(&dev->mutex);
767 smap_add(args, "peer", dev->peer);
769 ovs_mutex_unlock(&dev->mutex);
775 set_patch_config(struct netdev *dev_, const struct smap *args)
777 struct netdev_vport *dev = netdev_vport_cast(dev_);
778 const char *name = netdev_get_name(dev_);
781 peer = smap_get(args, "peer");
783 VLOG_ERR("%s: patch type requires valid 'peer' argument", name);
787 if (smap_count(args) > 1) {
788 VLOG_ERR("%s: patch type takes only a 'peer' argument", name);
792 if (!strcmp(name, peer)) {
793 VLOG_ERR("%s: patch peer must not be self", name);
797 ovs_mutex_lock(&dev->mutex);
798 if (!dev->peer || strcmp(dev->peer, peer)) {
800 dev->peer = xstrdup(peer);
801 netdev_change_seq_changed(dev_);
803 ovs_mutex_unlock(&dev->mutex);
809 get_stats(const struct netdev *netdev, struct netdev_stats *stats)
811 struct netdev_vport *dev = netdev_vport_cast(netdev);
813 ovs_mutex_lock(&dev->mutex);
814 /* Passing only collected counters */
815 stats->tx_packets = dev->stats.tx_packets;
816 stats->tx_bytes = dev->stats.tx_bytes;
817 stats->rx_packets = dev->stats.rx_packets;
818 stats->rx_bytes = dev->stats.rx_bytes;
819 ovs_mutex_unlock(&dev->mutex);
825 #define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG, \
826 GET_TUNNEL_CONFIG, GET_STATUS, \
828 PUSH_HEADER, POP_HEADER) \
833 netdev_vport_alloc, \
834 netdev_vport_construct, \
835 netdev_vport_destruct, \
836 netdev_vport_dealloc, \
843 NULL, /* get_numa_id */ \
844 NULL, /* set_multiq */ \
847 NULL, /* send_wait */ \
849 netdev_vport_set_etheraddr, \
850 netdev_vport_get_etheraddr, \
851 NULL, /* get_mtu */ \
852 NULL, /* set_mtu */ \
853 NULL, /* get_ifindex */ \
854 NULL, /* get_carrier */ \
855 NULL, /* get_carrier_resets */ \
856 NULL, /* get_miimon */ \
859 NULL, /* get_features */ \
860 NULL, /* set_advertisements */ \
862 NULL, /* set_policing */ \
863 NULL, /* get_qos_types */ \
864 NULL, /* get_qos_capabilities */ \
865 NULL, /* get_qos */ \
866 NULL, /* set_qos */ \
867 NULL, /* get_queue */ \
868 NULL, /* set_queue */ \
869 NULL, /* delete_queue */ \
870 NULL, /* get_queue_stats */ \
871 NULL, /* queue_dump_start */ \
872 NULL, /* queue_dump_next */ \
873 NULL, /* queue_dump_done */ \
874 NULL, /* dump_queue_stats */ \
876 NULL, /* set_in4 */ \
877 NULL, /* get_addr_list */ \
878 NULL, /* add_router */ \
879 NULL, /* get_next_hop */ \
881 NULL, /* arp_lookup */ \
883 netdev_vport_update_flags, \
885 NULL, /* rx_alloc */ \
886 NULL, /* rx_construct */ \
887 NULL, /* rx_destruct */ \
888 NULL, /* rx_dealloc */ \
889 NULL, /* rx_recv */ \
890 NULL, /* rx_wait */ \
894 #define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER) \
897 VPORT_FUNCTIONS(get_tunnel_config, \
899 get_netdev_tunnel_config, \
901 BUILD_HEADER, PUSH_HEADER, POP_HEADER) }}
904 netdev_vport_tunnel_register(void)
906 /* The name of the dpif_port should be short enough to accomodate adding
907 * a port number to the end if one is necessary. */
908 static const struct vport_class vport_classes[] = {
909 TUNNEL_CLASS("geneve", "genev_sys", netdev_geneve_build_header,
910 netdev_tnl_push_udp_header,
911 netdev_geneve_pop_header),
912 TUNNEL_CLASS("gre", "gre_sys", netdev_gre_build_header,
913 netdev_gre_push_header,
914 netdev_gre_pop_header),
915 TUNNEL_CLASS("ipsec_gre", "gre_sys", NULL, NULL, NULL),
916 TUNNEL_CLASS("vxlan", "vxlan_sys", netdev_vxlan_build_header,
917 netdev_tnl_push_udp_header,
918 netdev_vxlan_pop_header),
919 TUNNEL_CLASS("lisp", "lisp_sys", NULL, NULL, NULL),
920 TUNNEL_CLASS("stt", "stt_sys", NULL, NULL, NULL),
922 static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
924 if (ovsthread_once_start(&once)) {
927 for (i = 0; i < ARRAY_SIZE(vport_classes); i++) {
928 netdev_register_provider(&vport_classes[i].netdev_class);
931 unixctl_command_register("tnl/egress_port_range", "min max", 0, 2,
932 netdev_tnl_egress_port_range, NULL);
934 ovsthread_once_done(&once);
939 netdev_vport_patch_register(void)
941 static const struct vport_class patch_class =
944 VPORT_FUNCTIONS(get_patch_config,
947 NULL, NULL, NULL, NULL) }};
948 netdev_register_provider(&patch_class.netdev_class);