[ovs-dev] [PATCH 2/6] netdev: get device type from vport prefix if not found
Ben Pfaff
blp at ovn.org
Fri Jun 3 20:02:04 UTC 2016
On Thu, May 26, 2016 at 05:34:59PM -0300, Thadeu Lima de Souza Cascardo wrote:
> If we cannot find the device type because it's not opened yet, check if it uses
> a reserved prefix for a vport type and return that type.
>
> Since these names are reserved, we can assume this is the right type.
>
> This is important when we are querying the datapath right after vswitch has
> started and using the right type will be even more important when we add support
> to creating tunnel ports with rtnetlink.
>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at redhat.com>
Thanks for the patch.
I haven't thought deeply yet about whether this is correct behavior, but
I have some comments nonetheless.
> +static const char *
> +netdev_vport_type_from_name(const char *name)
> +{
> + struct netdev_registered_class *rc;
> + const char *type;
I don't think we need to take netdev_class_mutex here. cmaps don't
inherently need to be protected against change during iteration, because
they are RCU-protected.
> + ovs_mutex_lock(&netdev_class_mutex);
> + CMAP_FOR_EACH (rc, cmap_node, &netdev_classes) {
> + const char *dpif_port = netdev_vport_class_get_dpif_port(rc->class);
> + if (dpif_port && !strncmp(name, dpif_port, strlen(dpif_port))) {
> + type = rc->class->type;
> + ovs_mutex_unlock(&netdev_class_mutex);
> + return type;
> + }
> + }
> + ovs_mutex_unlock(&netdev_class_mutex);
> + return NULL;
> +}
Here, please do not use the GCC x?:y extension, because OVS needs to
build with MSVC as well:
> + type = type ?: netdev_vport_type_from_name(name);
Thanks,
Ben.
More information about the dev
mailing list