[systemd-devel] [PATCH] libnetworkd: only allow positive ifindex

Umut Tezduyar Lindskog umut at tezduyar.com
Sun Apr 13 05:42:44 PDT 2014


Hi,

On Sat, Apr 12, 2014 at 10:46 PM, Zbigniew Jędrzejewski-Szmek
<zbyszek at in.waw.pl> wrote:
> On Sat, Apr 12, 2014 at 09:59:52PM +0200, Tom Gundersen wrote:
>> On Sat, Apr 12, 2014 at 7:26 PM, Zbigniew Jędrzejewski-Szmek
>> <zbyszek at in.waw.pl> wrote:
>> > On Sat, Apr 12, 2014 at 01:19:48PM +0200, Umut Tezduyar Lindskog wrote:
>> >> Patch doesn't apply anymore after reference counting changes. I will
>> >> re-send it along with ipv4ll tests which is coming up right away.
>> > Cool. Could you add a bit of a commit message explaining the change for
>> > the poor ignorant sods like me who don't know why indexes start at 0 or 1?

We have already don't allow to start dhcp or ipv4ll with 0 or negative
index (sd_ipv4ll_start, sd_dhcp_client_start). My patch only fixes the
setter for the index.

>>
>> FWIW: the kernel starts enumerating interfaces at 1 [0]. Varies API's
>> accept ifindex=0 to refer to "unknown"/"any"/"all" interfaces. That's
>> not useful in these libraries though, as we only want to run these
>> clients on a given interface, so restricting to ifindex > 0 makes
>> sense.

"-1" is a valid index but kernel will interpret it as the last dev in
the array [0]

>>
>> Umut, will you resend with a bit more detailed commit message or
>> should I fix it up when applying your patch?

As a reminder, I have combined the content of this patch with
http://lists.freedesktop.org/archives/systemd-devel/2014-April/018628.html
(status: waiting) since I needed the correction for unit tests. If
there will be reviews on the patch and I have to send an updated
version, then I will write up more detailed message. Otherwise, could
you please do it while taken the patch in.

> Thanks.
>
> Zbyszek
>
>> [0]: <https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/core/dev.c#n5524>
>>

[0] - https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/net/core/dev.c#n194

Umut


More information about the systemd-devel mailing list