Re: [PATCH 03/12] Prevent renaming interfaces to empty string.

Andreas Henriksson
2007-10-12T17:46:35Z

On fre, 2007-10-12 at 10:07 -0700, Stephen Hemminger wrote:

> > if (newname && strcmp(dev, newname)) {
> > + if (strlen(newname) == 0) {
> > + printf("\"\" is not valid device identifier\n");
> > + return -1;
> > + }
> > if (do_changename(dev, newname) < 0)
> > return -1;
> > dev = newname;
>
> The kernel should already be preventing this?

Looks like something prevents the interface to end up with no name, but
there's no error message...

./ip/ip is the "vanilla" and /sbin/ip is debians version.

$ sudo ./ip/ip link set skif name ""
$ echo $?
0
$ sudo /sbin/ip link set skif name ""
"" is not valid device identifier
$ echo $?
255

Reporting the error is probably the preferred behaviour (and return code
set to error is most likely helpful for scripts).

--
Regards,
Andreas Henriksson