On 2/9/26 7:09 PM, Eli Britstein wrote:
> A linux interface is limited to IFNAMSIZ length (16). In case a tap
> interface is created, add a validity check for it.

Thanks, Eli, for the update!

I think, we need to remove the 'tap' part from the patch name and the
commit message, as the change affects all kinds of linux devices, not
only tap.

> 
> Signed-off-by: Eli Britstein <[email protected]>
> ---
>  lib/netdev-linux.c        |  3 +++
>  tests/system-interface.at | 16 ++++++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
> index f4d2685a2..e4a70d071 100644
> --- a/lib/netdev-linux.c
> +++ b/lib/netdev-linux.c
> @@ -962,6 +962,9 @@ netdev_linux_common_construct(struct netdev *netdev_)
>                       name);
>          return EINVAL;
>      }
> +    if (strlen(name) >= IFNAMSIZ) {
> +        return ENAMETOOLONG;
> +    }
>  
>      /* The device could be in the same network namespace or in another one. 
> */
>      netnsid_unset(&netdev->netnsid);
> diff --git a/tests/system-interface.at b/tests/system-interface.at
> index 15c4a0e2e..52539848f 100644
> --- a/tests/system-interface.at
> +++ b/tests/system-interface.at
> @@ -221,3 +221,19 @@ half
>  
>  OVS_TRAFFIC_VSWITCHD_STOP
>  AT_CLEANUP
> +
> +AT_SETUP([interface - name too long])
> +
> +OVS_VSWITCHD_START()

This should be the TRAFFIC variant, otherwise it runs with a dummy
datapath by default and we need to check both kernel and userspace.

The STOP macro should also be adjusted accordingly.

> +
> +BR_NAME=a234567890b23456
> +
> +AT_CHECK([
> +    ovs-vsctl add-br $BR_NAME -- \
> +        set bridge $BR_NAME datapath_type=netdev
> +], [65], [ignore], [stderr])

We need to check different datapaths here, so it should be:

AT_CHECK([ovs-vsctl -- _ADD_BR([a234567890b23456])], [65], [ignore], [stderr])

> +
> +AT_CHECK([grep 'name too long' stderr], [0], [ignore])
> +
> +OVS_VSWITCHD_STOP(["/could not open network device.*name too long/d"])
> +AT_CLEANUP

Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to