[Lxc-users] SIOCGIFNAME

Daniel Lezcano daniel.lezcano at free.fr
Wed May 30 08:14:43 UTC 2012


On 05/30/2012 09:35 AM, Papp Tamas wrote:
> On 05/30/2012 04:28 AM, Daniel Lezcano wrote:
>>
>> On 05/29/2012 10:10 PM, Papp Tamas wrote:
>>> On 05/29/2012 07:29 PM, Daniel Lezcano wrote:
>>>>
>>>> On 05/29/2012 03:48 PM, Papp Tamas wrote:
>>>>> hi All,
>>>>>
>>>>>
>>>>> This doesn't work now:
>>>>>
>>>>> ioctl(3, SIOCGIFNAME, {ifr_index=0, ifr_name=???}) = -1 ENODEV (No
>>>>> such
>>>>> device)
>>>>>
>>>>>
>>>>> Is there any way to make it work?
>>>>
>>>> Yep, the index are not virtualized. So ifr_index=0 is for the
>>>> loopback in the init network namespace.
>>>
>>> So there is no way?
>>
>> What do you want to do exactly ?
>
>
> There is a license server and the license depends on the MAC address
> what is determined in this way. Of course I cannot modify the code or
> replace it with alternatives.

I am afraid the code is buggy because it plays with the interface
indexes assuming they will be always +1 and beginning with index 0 which
is not true.
I "assume" if you have your host with two network interfaces, so we have
indexes 0, 1, 2, and you unload the module for interface with index 1,
the license server will fail in the same way. Or you create several
virtual interfaces and then you load the physical network interface
module and destroy the virtual devices making a hole in the index
interval will lead to the same problem.

The correct way for this legacy interface is to use SIOCGIFCONF and then
use SIOCGIFHWADDR with the interface name. This is what does the
ifconfig command and it works well.

In the era of virtual network interfaces, this legacy code is broken
because it was written with stupid assumptions in mind. I know that does
not help you but it is an application bug.






More information about the lxc-users mailing list