2 * Copyright (c) 2010, 2011 Nicira Networks.
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>
24 #include <linux/rtnetlink.h>
26 #include <sys/ioctl.h>
28 #include "byte-order.h"
31 #include "dpif-linux.h"
35 #include "netdev-linux.h"
36 #include "netdev-provider.h"
38 #include "netlink-notifier.h"
39 #include "netlink-socket.h"
41 #include "openvswitch/datapath-protocol.h"
42 #include "openvswitch/tunnel.h"
44 #include "route-table.h"
46 #include "socket-util.h"
49 VLOG_DEFINE_THIS_MODULE(netdev_vport);
51 struct netdev_dev_vport {
52 struct netdev_dev netdev_dev;
53 struct ofpbuf *options;
54 int dp_ifindex; /* -1 if unknown. */
55 uint32_t port_no; /* UINT32_MAX if unknown. */
56 unsigned int change_seq;
64 enum ovs_vport_type type;
65 struct netdev_class netdev_class;
66 int (*parse_config)(const char *name, const char *type,
67 const struct shash *args, struct ofpbuf *options);
68 int (*unparse_config)(const char *name, const char *type,
69 const struct nlattr *options, size_t options_len,
73 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
75 static int netdev_vport_create(const struct netdev_class *, const char *,
76 struct netdev_dev **);
77 static void netdev_vport_poll_notify(const struct netdev *);
78 static int tnl_port_config_from_nlattr(const struct nlattr *options,
80 struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1]);
82 static const char *netdev_vport_get_tnl_iface(const struct netdev *netdev);
85 is_vport_class(const struct netdev_class *class)
87 return class->create == netdev_vport_create;
90 static const struct vport_class *
91 vport_class_cast(const struct netdev_class *class)
93 assert(is_vport_class(class));
94 return CONTAINER_OF(class, struct vport_class, netdev_class);
97 static struct netdev_dev_vport *
98 netdev_dev_vport_cast(const struct netdev_dev *netdev_dev)
100 assert(is_vport_class(netdev_dev_get_class(netdev_dev)));
101 return CONTAINER_OF(netdev_dev, struct netdev_dev_vport, netdev_dev);
104 static struct netdev_vport *
105 netdev_vport_cast(const struct netdev *netdev)
107 struct netdev_dev *netdev_dev = netdev_get_dev(netdev);
108 assert(is_vport_class(netdev_dev_get_class(netdev_dev)));
109 return CONTAINER_OF(netdev, struct netdev_vport, netdev);
112 /* If 'netdev' is a vport netdev, returns an ofpbuf that contains Netlink
113 * options to include in OVS_VPORT_ATTR_OPTIONS for configuring that vport.
114 * Otherwise returns NULL. */
115 const struct ofpbuf *
116 netdev_vport_get_options(const struct netdev *netdev)
118 const struct netdev_dev *dev = netdev_get_dev(netdev);
120 return (is_vport_class(netdev_dev_get_class(dev))
121 ? netdev_dev_vport_cast(dev)->options
126 netdev_vport_get_vport_type(const struct netdev *netdev)
128 const struct netdev_dev *dev = netdev_get_dev(netdev);
129 const struct netdev_class *class = netdev_dev_get_class(dev);
131 return (is_vport_class(class) ? vport_class_cast(class)->type
132 : class == &netdev_internal_class ? OVS_VPORT_TYPE_INTERNAL
133 : class == &netdev_linux_class ? OVS_VPORT_TYPE_NETDEV
134 : OVS_VPORT_TYPE_UNSPEC);
138 netdev_vport_get_netdev_type(const struct dpif_linux_vport *vport)
140 struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1];
142 switch (vport->type) {
143 case OVS_VPORT_TYPE_UNSPEC:
146 case OVS_VPORT_TYPE_NETDEV:
149 case OVS_VPORT_TYPE_INTERNAL:
152 case OVS_VPORT_TYPE_PATCH:
155 case OVS_VPORT_TYPE_GRE:
156 if (tnl_port_config_from_nlattr(vport->options, vport->options_len,
160 return (nl_attr_get_u32(a[OVS_TUNNEL_ATTR_FLAGS]) & TNL_F_IPSEC
161 ? "ipsec_gre" : "gre");
163 case OVS_VPORT_TYPE_CAPWAP:
166 case __OVS_VPORT_TYPE_MAX:
170 VLOG_WARN_RL(&rl, "dp%d: port `%s' has unsupported type %u",
171 vport->dp_ifindex, vport->name, (unsigned int) vport->type);
176 netdev_vport_create(const struct netdev_class *netdev_class, const char *name,
177 struct netdev_dev **netdev_devp)
179 struct netdev_dev_vport *dev;
181 dev = xmalloc(sizeof *dev);
182 netdev_dev_init(&dev->netdev_dev, name, netdev_class);
184 dev->dp_ifindex = -1;
185 dev->port_no = UINT32_MAX;
188 *netdev_devp = &dev->netdev_dev;
189 route_table_register();
195 netdev_vport_destroy(struct netdev_dev *netdev_dev_)
197 struct netdev_dev_vport *netdev_dev = netdev_dev_vport_cast(netdev_dev_);
199 route_table_unregister();
204 netdev_vport_open(struct netdev_dev *netdev_dev_, struct netdev **netdevp)
206 struct netdev_vport *netdev;
208 netdev = xmalloc(sizeof *netdev);
209 netdev_init(&netdev->netdev, netdev_dev_);
211 *netdevp = &netdev->netdev;
216 netdev_vport_close(struct netdev *netdev_)
218 struct netdev_vport *netdev = netdev_vport_cast(netdev_);
223 netdev_vport_get_config(struct netdev_dev *dev_, struct shash *args)
225 const struct netdev_class *netdev_class = netdev_dev_get_class(dev_);
226 const struct vport_class *vport_class = vport_class_cast(netdev_class);
227 struct netdev_dev_vport *dev = netdev_dev_vport_cast(dev_);
228 const char *name = netdev_dev_get_name(dev_);
232 struct dpif_linux_vport reply;
235 error = dpif_linux_vport_get(name, &reply, &buf);
237 VLOG_ERR_RL(&rl, "%s: vport query failed (%s)",
238 name, strerror(error));
242 dev->options = ofpbuf_clone_data(reply.options, reply.options_len);
243 dev->dp_ifindex = reply.dp_ifindex;
244 dev->port_no = reply.port_no;
248 error = vport_class->unparse_config(name, netdev_class->type,
253 VLOG_ERR_RL(&rl, "%s: failed to parse kernel config (%s)",
254 name, strerror(error));
260 netdev_vport_set_config(struct netdev_dev *dev_, const struct shash *args)
262 const struct netdev_class *netdev_class = netdev_dev_get_class(dev_);
263 const struct vport_class *vport_class = vport_class_cast(netdev_class);
264 struct netdev_dev_vport *dev = netdev_dev_vport_cast(dev_);
265 const char *name = netdev_dev_get_name(dev_);
266 struct ofpbuf *options;
269 options = ofpbuf_new(64);
270 error = vport_class->parse_config(name, netdev_dev_get_type(dev_),
274 || options->size != dev->options->size
275 || memcmp(options->data, dev->options->data, options->size))) {
276 struct dpif_linux_vport vport;
278 dpif_linux_vport_init(&vport);
279 vport.cmd = OVS_VPORT_CMD_SET;
281 vport.options = options->data;
282 vport.options_len = options->size;
283 error = dpif_linux_vport_transact(&vport, NULL, NULL);
284 if (!error || error == ENODEV) {
285 /* Either reconfiguration succeeded or this vport is not installed
286 * in the kernel (e.g. it hasn't been added to a dpif yet with
287 * dpif_port_add()). */
288 ofpbuf_delete(dev->options);
289 dev->options = options;
294 ofpbuf_delete(options);
300 netdev_vport_send(struct netdev *netdev, const void *data, size_t size)
302 struct netdev_dev *dev_ = netdev_get_dev(netdev);
303 struct netdev_dev_vport *dev = netdev_dev_vport_cast(dev_);
305 if (dev->dp_ifindex == -1) {
306 const char *name = netdev_get_name(netdev);
307 struct dpif_linux_vport reply;
311 error = dpif_linux_vport_get(name, &reply, &buf);
313 VLOG_ERR_RL(&rl, "%s: failed to query vport for send (%s)",
314 name, strerror(error));
317 dev->dp_ifindex = reply.dp_ifindex;
318 dev->port_no = reply.port_no;
322 return dpif_linux_vport_send(dev->dp_ifindex, dev->port_no, data, size);
326 netdev_vport_set_etheraddr(struct netdev *netdev,
327 const uint8_t mac[ETH_ADDR_LEN])
329 struct dpif_linux_vport vport;
332 dpif_linux_vport_init(&vport);
333 vport.cmd = OVS_VPORT_CMD_SET;
334 vport.name = netdev_get_name(netdev);
337 error = dpif_linux_vport_transact(&vport, NULL, NULL);
339 netdev_vport_poll_notify(netdev);
345 netdev_vport_get_etheraddr(const struct netdev *netdev,
346 uint8_t mac[ETH_ADDR_LEN])
348 struct dpif_linux_vport reply;
352 error = dpif_linux_vport_get(netdev_get_name(netdev), &reply, &buf);
355 memcpy(mac, reply.address, ETH_ADDR_LEN);
365 netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats)
367 struct dpif_linux_vport reply;
371 error = dpif_linux_vport_get(netdev_get_name(netdev), &reply, &buf);
374 } else if (!reply.stats) {
379 netdev_stats_from_rtnl_link_stats64(stats, reply.stats);
387 netdev_vport_set_stats(struct netdev *netdev, const struct netdev_stats *stats)
389 struct rtnl_link_stats64 rtnl_stats;
390 struct dpif_linux_vport vport;
393 netdev_stats_to_rtnl_link_stats64(&rtnl_stats, stats);
395 dpif_linux_vport_init(&vport);
396 vport.cmd = OVS_VPORT_CMD_SET;
397 vport.name = netdev_get_name(netdev);
398 vport.stats = &rtnl_stats;
400 err = dpif_linux_vport_transact(&vport, NULL, NULL);
402 /* If the vport layer doesn't know about the device, that doesn't mean it
403 * doesn't exist (after all were able to open it when netdev_open() was
404 * called), it just means that it isn't attached and we'll be getting
405 * stats a different way. */
414 netdev_vport_get_status(const struct netdev *netdev, struct shash *sh)
416 const char *iface = netdev_vport_get_tnl_iface(netdev);
419 struct netdev *egress_netdev;
421 shash_add(sh, "tunnel_egress_iface", xstrdup(iface));
423 if (!netdev_open(iface, "system", &egress_netdev)) {
424 shash_add(sh, "tunnel_egress_iface_carrier",
425 xstrdup(netdev_get_carrier(egress_netdev)
427 netdev_close(egress_netdev);
435 netdev_vport_update_flags(struct netdev *netdev OVS_UNUSED,
436 enum netdev_flags off, enum netdev_flags on OVS_UNUSED,
437 enum netdev_flags *old_flagsp)
439 if (off & (NETDEV_UP | NETDEV_PROMISC)) {
443 *old_flagsp = NETDEV_UP | NETDEV_PROMISC;
448 netdev_vport_change_seq(const struct netdev *netdev)
450 return netdev_dev_vport_cast(netdev_get_dev(netdev))->change_seq;
454 netdev_vport_run(void)
460 netdev_vport_wait(void)
465 /* get_tnl_iface() implementation. */
467 netdev_vport_get_tnl_iface(const struct netdev *netdev)
469 struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1];
471 struct netdev_dev_vport *ndv;
472 static char name[IFNAMSIZ];
474 ndv = netdev_dev_vport_cast(netdev_get_dev(netdev));
475 if (tnl_port_config_from_nlattr(ndv->options->data, ndv->options->size,
479 route = nl_attr_get_be32(a[OVS_TUNNEL_ATTR_DST_IPV4]);
481 if (route_table_get_name(route, name)) {
488 /* Helper functions. */
491 netdev_vport_poll_notify(const struct netdev *netdev)
493 struct netdev_dev_vport *ndv;
495 ndv = netdev_dev_vport_cast(netdev_get_dev(netdev));
498 if (!ndv->change_seq) {
503 /* Code specific to individual vport types. */
506 set_key(const struct shash *args, const char *name, uint16_t type,
507 struct ofpbuf *options)
511 s = shash_find_data(args, name);
513 s = shash_find_data(args, "key");
519 if (!strcmp(s, "flow")) {
520 /* This is the default if no attribute is present. */
522 nl_msg_put_be64(options, type, htonll(strtoull(s, NULL, 0)));
527 parse_tunnel_config(const char *name, const char *type,
528 const struct shash *args, struct ofpbuf *options)
531 bool is_ipsec = false;
532 struct shash_node *node;
533 bool ipsec_mech_set = false;
534 ovs_be32 daddr = htonl(0);
537 flags = TNL_F_DF_DEFAULT | TNL_F_PMTUD | TNL_F_HDR_CACHE;
538 if (!strcmp(type, "gre")) {
540 } else if (!strcmp(type, "ipsec_gre")) {
543 flags |= TNL_F_IPSEC;
544 flags &= ~TNL_F_HDR_CACHE;
547 SHASH_FOR_EACH (node, args) {
548 if (!strcmp(node->name, "remote_ip")) {
549 struct in_addr in_addr;
550 if (lookup_ip(node->data, &in_addr)) {
551 VLOG_WARN("%s: bad %s 'remote_ip'", name, type);
553 daddr = in_addr.s_addr;
555 } else if (!strcmp(node->name, "local_ip")) {
556 struct in_addr in_addr;
557 if (lookup_ip(node->data, &in_addr)) {
558 VLOG_WARN("%s: bad %s 'local_ip'", name, type);
560 nl_msg_put_be32(options, OVS_TUNNEL_ATTR_SRC_IPV4,
563 } else if (!strcmp(node->name, "tos")) {
564 if (!strcmp(node->data, "inherit")) {
565 flags |= TNL_F_TOS_INHERIT;
567 nl_msg_put_u8(options, OVS_TUNNEL_ATTR_TOS, atoi(node->data));
569 } else if (!strcmp(node->name, "ttl")) {
570 if (!strcmp(node->data, "inherit")) {
571 flags |= TNL_F_TTL_INHERIT;
573 nl_msg_put_u8(options, OVS_TUNNEL_ATTR_TTL, atoi(node->data));
575 } else if (!strcmp(node->name, "csum") && is_gre) {
576 if (!strcmp(node->data, "true")) {
579 } else if (!strcmp(node->name, "df_inherit")) {
580 if (!strcmp(node->data, "true")) {
581 flags |= TNL_F_DF_INHERIT;
583 } else if (!strcmp(node->name, "df_default")) {
584 if (!strcmp(node->data, "false")) {
585 flags &= ~TNL_F_DF_DEFAULT;
587 } else if (!strcmp(node->name, "pmtud")) {
588 if (!strcmp(node->data, "false")) {
589 flags &= ~TNL_F_PMTUD;
591 } else if (!strcmp(node->name, "header_cache")) {
592 if (!strcmp(node->data, "false")) {
593 flags &= ~TNL_F_HDR_CACHE;
595 } else if (!strcmp(node->name, "peer_cert") && is_ipsec) {
596 if (shash_find(args, "certificate")) {
597 ipsec_mech_set = true;
599 const char *use_ssl_cert;
601 /* If the "use_ssl_cert" is true, then "certificate" and
602 * "private_key" will be pulled from the SSL table. The
603 * use of this option is strongly discouraged, since it
604 * will like be removed when multiple SSL configurations
605 * are supported by OVS.
607 use_ssl_cert = shash_find_data(args, "use_ssl_cert");
608 if (!use_ssl_cert || strcmp(use_ssl_cert, "true")) {
609 VLOG_ERR("%s: 'peer_cert' requires 'certificate' argument",
613 ipsec_mech_set = true;
615 } else if (!strcmp(node->name, "psk") && is_ipsec) {
616 ipsec_mech_set = true;
618 && (!strcmp(node->name, "certificate")
619 || !strcmp(node->name, "private_key")
620 || !strcmp(node->name, "use_ssl_cert"))) {
621 /* Ignore options not used by the netdev. */
622 } else if (!strcmp(node->name, "key") ||
623 !strcmp(node->name, "in_key") ||
624 !strcmp(node->name, "out_key")) {
625 /* Handled separately below. */
627 VLOG_WARN("%s: unknown %s argument '%s'", name, type, node->name);
632 char *file_name = xasprintf("%s/%s", ovs_rundir(),
633 "ovs-monitor-ipsec.pid");
634 pid_t pid = read_pidfile(file_name);
637 VLOG_ERR("%s: IPsec requires the ovs-monitor-ipsec daemon",
642 if (shash_find(args, "peer_cert") && shash_find(args, "psk")) {
643 VLOG_ERR("%s: cannot define both 'peer_cert' and 'psk'", name);
647 if (!ipsec_mech_set) {
648 VLOG_ERR("%s: IPsec requires an 'peer_cert' or psk' argument",
654 set_key(args, "in_key", OVS_TUNNEL_ATTR_IN_KEY, options);
655 set_key(args, "out_key", OVS_TUNNEL_ATTR_OUT_KEY, options);
658 VLOG_ERR("%s: %s type requires valid 'remote_ip' argument",
662 nl_msg_put_be32(options, OVS_TUNNEL_ATTR_DST_IPV4, daddr);
664 nl_msg_put_u32(options, OVS_TUNNEL_ATTR_FLAGS, flags);
670 tnl_port_config_from_nlattr(const struct nlattr *options, size_t options_len,
671 struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1])
673 static const struct nl_policy ovs_tunnel_policy[] = {
674 [OVS_TUNNEL_ATTR_FLAGS] = { .type = NL_A_U32 },
675 [OVS_TUNNEL_ATTR_DST_IPV4] = { .type = NL_A_BE32 },
676 [OVS_TUNNEL_ATTR_SRC_IPV4] = { .type = NL_A_BE32, .optional = true },
677 [OVS_TUNNEL_ATTR_IN_KEY] = { .type = NL_A_BE64, .optional = true },
678 [OVS_TUNNEL_ATTR_OUT_KEY] = { .type = NL_A_BE64, .optional = true },
679 [OVS_TUNNEL_ATTR_TOS] = { .type = NL_A_U8, .optional = true },
680 [OVS_TUNNEL_ATTR_TTL] = { .type = NL_A_U8, .optional = true },
684 ofpbuf_use_const(&buf, options, options_len);
685 if (!nl_policy_parse(&buf, 0, ovs_tunnel_policy,
686 a, ARRAY_SIZE(ovs_tunnel_policy))) {
693 get_be64_or_zero(const struct nlattr *a)
695 return a ? ntohll(nl_attr_get_be64(a)) : 0;
699 unparse_tunnel_config(const char *name OVS_UNUSED, const char *type OVS_UNUSED,
700 const struct nlattr *options, size_t options_len,
703 struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1];
708 error = tnl_port_config_from_nlattr(options, options_len, a);
713 flags = nl_attr_get_u32(a[OVS_TUNNEL_ATTR_FLAGS]);
714 if (!(flags & TNL_F_HDR_CACHE) == !(flags & TNL_F_IPSEC)) {
715 smap_add(args, "header_cache",
716 flags & TNL_F_HDR_CACHE ? "true" : "false");
719 daddr = nl_attr_get_be32(a[OVS_TUNNEL_ATTR_DST_IPV4]);
720 shash_add(args, "remote_ip", xasprintf(IP_FMT, IP_ARGS(&daddr)));
722 if (a[OVS_TUNNEL_ATTR_SRC_IPV4]) {
723 ovs_be32 saddr = nl_attr_get_be32(a[OVS_TUNNEL_ATTR_SRC_IPV4]);
724 shash_add(args, "local_ip", xasprintf(IP_FMT, IP_ARGS(&saddr)));
727 if (!a[OVS_TUNNEL_ATTR_IN_KEY] && !a[OVS_TUNNEL_ATTR_OUT_KEY]) {
728 smap_add(args, "key", "flow");
730 uint64_t in_key = get_be64_or_zero(a[OVS_TUNNEL_ATTR_IN_KEY]);
731 uint64_t out_key = get_be64_or_zero(a[OVS_TUNNEL_ATTR_OUT_KEY]);
733 if (in_key && in_key == out_key) {
734 shash_add(args, "key", xasprintf("%"PRIu64, in_key));
736 if (!a[OVS_TUNNEL_ATTR_IN_KEY]) {
737 smap_add(args, "in_key", "flow");
739 shash_add(args, "in_key", xasprintf("%"PRIu64, in_key));
742 if (!a[OVS_TUNNEL_ATTR_OUT_KEY]) {
743 smap_add(args, "out_key", "flow");
744 } else if (out_key) {
745 shash_add(args, "out_key", xasprintf("%"PRIu64, out_key));
750 if (flags & TNL_F_TTL_INHERIT) {
751 smap_add(args, "tos", "inherit");
752 } else if (a[OVS_TUNNEL_ATTR_TTL]) {
753 int ttl = nl_attr_get_u8(a[OVS_TUNNEL_ATTR_TTL]);
754 shash_add(args, "tos", xasprintf("%d", ttl));
757 if (flags & TNL_F_TOS_INHERIT) {
758 smap_add(args, "tos", "inherit");
759 } else if (a[OVS_TUNNEL_ATTR_TOS]) {
760 int tos = nl_attr_get_u8(a[OVS_TUNNEL_ATTR_TOS]);
761 shash_add(args, "tos", xasprintf("%d", tos));
764 if (flags & TNL_F_CSUM) {
765 smap_add(args, "csum", "true");
767 if (flags & TNL_F_DF_INHERIT) {
768 smap_add(args, "df_inherit", "true");
770 if (!(flags & TNL_F_DF_DEFAULT)) {
771 smap_add(args, "df_default", "false");
773 if (!(flags & TNL_F_PMTUD)) {
774 smap_add(args, "pmtud", "false");
781 parse_patch_config(const char *name, const char *type OVS_UNUSED,
782 const struct shash *args, struct ofpbuf *options)
786 peer = shash_find_data(args, "peer");
788 VLOG_ERR("%s: patch type requires valid 'peer' argument", name);
792 if (shash_count(args) > 1) {
793 VLOG_ERR("%s: patch type takes only a 'peer' argument", name);
797 if (strlen(peer) >= IFNAMSIZ) {
798 VLOG_ERR("%s: patch 'peer' arg too long", name);
802 if (!strcmp(name, peer)) {
803 VLOG_ERR("%s: patch peer must not be self", name);
807 nl_msg_put_string(options, OVS_PATCH_ATTR_PEER, peer);
813 unparse_patch_config(const char *name OVS_UNUSED, const char *type OVS_UNUSED,
814 const struct nlattr *options, size_t options_len,
817 static const struct nl_policy ovs_patch_policy[] = {
818 [OVS_PATCH_ATTR_PEER] = { .type = NL_A_STRING,
823 struct nlattr *a[ARRAY_SIZE(ovs_patch_policy)];
826 ofpbuf_use_const(&buf, options, options_len);
827 if (!nl_policy_parse(&buf, 0, ovs_patch_policy,
828 a, ARRAY_SIZE(ovs_patch_policy))) {
832 smap_add(args, "peer", nl_attr_get_string(a[OVS_PATCH_ATTR_PEER]));
836 #define VPORT_FUNCTIONS(GET_STATUS) \
841 netdev_vport_create, \
842 netdev_vport_destroy, \
843 netdev_vport_get_config, \
844 netdev_vport_set_config, \
847 netdev_vport_close, \
849 NULL, /* enumerate */ \
853 NULL, /* recv_wait */ \
856 netdev_vport_send, /* send */ \
857 NULL, /* send_wait */ \
859 netdev_vport_set_etheraddr, \
860 netdev_vport_get_etheraddr, \
861 NULL, /* get_mtu */ \
862 NULL, /* set_mtu */ \
863 NULL, /* get_ifindex */ \
864 NULL, /* get_carrier */ \
865 NULL, /* get_miimon */ \
866 netdev_vport_get_stats, \
867 netdev_vport_set_stats, \
869 NULL, /* get_features */ \
870 NULL, /* set_advertisements */ \
871 NULL, /* get_vlan_vid */ \
873 NULL, /* set_policing */ \
874 NULL, /* get_qos_types */ \
875 NULL, /* get_qos_capabilities */ \
876 NULL, /* get_qos */ \
877 NULL, /* set_qos */ \
878 NULL, /* get_queue */ \
879 NULL, /* set_queue */ \
880 NULL, /* delete_queue */ \
881 NULL, /* get_queue_stats */ \
882 NULL, /* dump_queues */ \
883 NULL, /* dump_queue_stats */ \
885 NULL, /* get_in4 */ \
886 NULL, /* set_in4 */ \
887 NULL, /* get_in6 */ \
888 NULL, /* add_router */ \
889 NULL, /* get_next_hop */ \
891 NULL, /* arp_lookup */ \
893 netdev_vport_update_flags, \
895 netdev_vport_change_seq
898 netdev_vport_register(void)
900 static const struct vport_class vport_classes[] = {
901 { OVS_VPORT_TYPE_GRE,
902 { "gre", VPORT_FUNCTIONS(netdev_vport_get_status) },
903 parse_tunnel_config, unparse_tunnel_config },
905 { OVS_VPORT_TYPE_GRE,
906 { "ipsec_gre", VPORT_FUNCTIONS(netdev_vport_get_status) },
907 parse_tunnel_config, unparse_tunnel_config },
909 { OVS_VPORT_TYPE_CAPWAP,
910 { "capwap", VPORT_FUNCTIONS(netdev_vport_get_status) },
911 parse_tunnel_config, unparse_tunnel_config },
913 { OVS_VPORT_TYPE_PATCH,
914 { "patch", VPORT_FUNCTIONS(NULL) },
915 parse_patch_config, unparse_patch_config }
920 for (i = 0; i < ARRAY_SIZE(vport_classes); i++) {
921 netdev_register_provider(&vport_classes[i].netdev_class);