[OpenWrt-Devel] [PATCH netifd 1/3] device: Fix device find failure in avl list due to device name change

Eyal Birger eyal.birger at gmail.com
Mon Jun 6 06:38:30 EDT 2016


Hi Hans,

On Mon, Jun 6, 2016 at 1:03 PM, Hans Dedecker <dedeckeh at gmail.com> wrote:
> As device name is used as key in avl list a device name change will break the avl find logic.
> Function device_set_ifname offers api to set the device name and re-inserts the avl node in the list
> when the avl key value is changed.
>
> Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
> ---
>
> diff --git a/device.c b/device.c
> index 06c4820..7149d86 100644
> --- a/device.c
> +++ b/device.c
> @@ -422,14 +422,14 @@ void device_init_virtual(struct device *dev, const struct device_type *type, con
>         assert(dev);
>         assert(type);
>
> -       if (name)
> -               strncpy(dev->ifname, name, IFNAMSIZ);
> -
>         D(DEVICE, "Initialize device '%s'\n", dev->ifname);

Isn't this debug print broken by this change?

>         INIT_SAFE_LIST(&dev->users);
>         INIT_SAFE_LIST(&dev->aliases);
>         dev->type = type;
>
> +       if (name)
> +               device_set_ifname(dev, name);
> +


Eyal.
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list