+const char *
+netdev_vport_get_dpif_port(const struct netdev *netdev,
+ char namebuf[], size_t bufsize)
+{
+ if (netdev_vport_needs_dst_port(netdev)) {
+ const struct netdev_vport *vport = netdev_vport_cast(netdev);
+ const char *type = netdev_get_type(netdev);
+
+ /*
+ * Note: IFNAMSIZ is 16 bytes long. The maximum length of a VXLAN
+ * or LISP port name below is 15 or 14 bytes respectively. Still,
+ * assert here on the size of strlen(type) in case that changes
+ * in the future.
+ */
+ BUILD_ASSERT(NETDEV_VPORT_NAME_BUFSIZE >= IFNAMSIZ);
+ ovs_assert(strlen(type) + 10 < IFNAMSIZ);
+ snprintf(namebuf, bufsize, "%s_sys_%d", type,
+ ntohs(vport->tnl_cfg.dst_port));
+ return namebuf;
+ } else {
+ const struct netdev_class *class = netdev_get_class(netdev);
+ const char *dpif_port = netdev_vport_class_get_dpif_port(class);
+ return dpif_port ? dpif_port : netdev_get_name(netdev);
+ }
+}
+
+char *
+netdev_vport_get_dpif_port_strdup(const struct netdev *netdev)
+{
+ char namebuf[NETDEV_VPORT_NAME_BUFSIZE];
+
+ return xstrdup(netdev_vport_get_dpif_port(netdev, namebuf,
+ sizeof namebuf));
+}
+
+static struct netdev *
+netdev_vport_alloc(void)
+{
+ struct netdev_vport *netdev = xzalloc(sizeof *netdev);
+ return &netdev->up;