@@ -189,22 +189,34 @@ netdev_vport_alloc(void)
int
netdev_vport_construct(struct netdev *netdev_)
{
+ const struct netdev_class *class = netdev_get_class(netdev_);
+ const char *dpif_port = netdev_vport_class_get_dpif_port(class);
struct netdev_vport *dev = netdev_vport_cast(netdev_);
+ const char *p, *name = netdev_get_name(netdev_);
const char *type = netdev_get_type(netdev_);
+ uint16_t port = 0;
ovs_mutex_init(&dev->mutex);
eth_addr_random(&dev->etheraddr);
- /* Add a default destination port for tunnel ports if none specified. */
+ if (name && dpif_port && (strlen(name) > strlen(dpif_port) + 1) &&
+ (!strncmp(name, dpif_port, strlen(dpif_port)))) {
+ p = name + strlen(dpif_port) + 1;
+ port = atoi(p);
+ }
+
+ /* If a destination port for tunnel ports is specified in the netdev
+ * name, use it instead of the default one. Otherwise, use the default
+ * destination port */
if (!strcmp(type, "geneve")) {
- dev->tnl_cfg.dst_port = htons(GENEVE_DST_PORT);
+ dev->tnl_cfg.dst_port = port ? htons(port) : htons(GENEVE_DST_PORT);
} else if (!strcmp(type, "vxlan")) {
- dev->tnl_cfg.dst_port = htons(VXLAN_DST_PORT);
+ dev->tnl_cfg.dst_port = port ? htons(port) : htons(VXLAN_DST_PORT);
update_vxlan_global_cfg(netdev_, NULL, &dev->tnl_cfg);
} else if (!strcmp(type, "lisp")) {
- dev->tnl_cfg.dst_port = htons(LISP_DST_PORT);
+ dev->tnl_cfg.dst_port = port ? htons(port) : htons(LISP_DST_PORT);
} else if (!strcmp(type, "stt")) {
- dev->tnl_cfg.dst_port = htons(STT_DST_PORT);
+ dev->tnl_cfg.dst_port = port ? htons(port) : htons(STT_DST_PORT);
}
dev->tnl_cfg.dont_fragment = true;