All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Stable interface index option
@ 2015-12-01 12:04 Maximilian Wilhelm
  2015-12-01 15:34 ` Sowmini Varadhan
  0 siblings, 1 reply; 21+ messages in thread
From: Maximilian Wilhelm @ 2015-12-01 12:04 UTC (permalink / raw)
  To: netdev

[-- Attachment #1: Type: text/plain, Size: 2767 bytes --]

Hi,

we are operating some free wifi networks (»Freifunk« in Germany)
including a backbone in the DFZ all running on Linux boxes, thanks to
all the cool stuff available there! :)

For a while now we are struggling with unstable/random interface
indexes as our interfaces (GRE tunnels, OpenVPN/Tinc tunnels, etc.)
come and go as users come and go and are obviously rearranged after a
reboot because of undeterministic start up behaviour of services.

Arguably we could force the interface indexes of GRE tunnels and
OpenVPN interfaces to be stable when creating them manually and not
rely on the infrastructure provided by the distribution (Debian in
most cases). That would fix some of our problems, but currently I
don't see a way to create tinc interfaces or even l2tp interfaces this
way with stable indexes.

The reason we would like to have those is quite simple: As we operate
a somewhat larger network we would like to monitor it accordingly and
see when links get saturated etc. Therefore we used snmp based
solutions and the net-snmp daemon on all the boxes. Now SNMP uses
interface indexes for identifying the interfaces. If they aren't
stable the monitoring software will see a lot of new interfaces now
and then, e.g. after a OpenVPN server/client restarted (which is bad)
or even mix up interfaces (which is worse).

As the first approach of hacking the net-snmp daemon to map the
interface ids of interfaces with certian names to stable ids got messy
and doesn't seem suitable we thought about solving the "underlying
problem" and add some mechanism for stable ids to the kernel. As there
already is an option to netlink/iproute to create certian interfaces
with a given index that seems as a nice way to go.

A prove of concept hack (see attached patch) works fine for me. The
idea I would propose would be to add some kind of bind/unbind
interface like for device drivers by which a user could add/remove and
in addition to driver bindings view the current "ifname -> ifindex"
bindings. I would assume that would best be done in sysfs? While
digging around a bit I didn't find a useful place where to place these
and I didn't find the relevant pieces of code where this is done to
add some PoC therefore as well.

I believe this would be a nice optional feature (I would assume this
would be something one could activate in Kconfig) to aid people using
Linux for heavy networking stuff. Any thoughs and hints on this?

At [42] you can see a console log showing the code works as intended.

Thanks in advance and best regards
Max

[42] http://files.rfc2324.org/kernel/stable_ifindexes/stable_ifindexes.txt
-- 
"I have to admit I've always suspected that MTBWTF would be a more useful
 metric of real-world performance."
 -- Valdis Kletnieks on NANOG

[-- Attachment #2: stable_ifindexes_poc.patch --]
[-- Type: text/x-diff, Size: 1071 bytes --]

diff --git a/net/core/dev.c b/net/core/dev.c
index ae00b89..4ea2ab410 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6611,6 +6611,7 @@ int register_netdevice(struct net_device *dev)
 {
 	int ret;
 	struct net *net = dev_net(dev);
+	int ifindex = 0;
 
 	BUG_ON(dev_boot_phase);
 	ASSERT_RTNL();
@@ -6648,6 +6649,23 @@ int register_netdevice(struct net_device *dev)
 	}
 
 	ret = -EBUSY;
+	/* See if interface name is present in name2index map */
+	if (!dev->ifindex) {
+		if (strcmp (dev->name, "gre_ffrl_fra_a") == 0) {
+			ifindex = 23;
+		} else if (strcmp (dev->name, "bb-pad-cr01") == 0) {
+			ifindex = 42;
+		}
+
+		/* If we found and index and it's not already in use, use it.
+		 * XXX: One could argue that if the users wants index X and it's
+		 *      already in use, this should raise EBUSY. Not decided yet
+		 *      which way would be preferable.
+		 */
+		if (ifindex && !__dev_get_by_index(net, ifindex))
+			dev->ifindex = ifindex;
+	}
+
 	if (!dev->ifindex)
 		dev->ifindex = dev_new_index(net);
 	else if (__dev_get_by_index(net, dev->ifindex))

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 12:04 [RFC] Stable interface index option Maximilian Wilhelm
@ 2015-12-01 15:34 ` Sowmini Varadhan
  2015-12-01 15:50   ` Maximilian Wilhelm
  0 siblings, 1 reply; 21+ messages in thread
From: Sowmini Varadhan @ 2015-12-01 15:34 UTC (permalink / raw)
  To: netdev

On (12/01/15 13:04), Maximilian Wilhelm wrote:
> 
> The reason we would like to have those is quite simple: As we operate
> a somewhat larger network we would like to monitor it accordingly and
> see when links get saturated etc. Therefore we used snmp based
> solutions and the net-snmp daemon on all the boxes. Now SNMP uses
> interface indexes for identifying the interfaces. If they aren't
> stable the monitoring software will see a lot of new interfaces now
> and then, e.g. after a OpenVPN server/client restarted (which is bad)
> or even mix up interfaces (which is worse).

FWIW, this is how router implementations such as cisco network OS-es
deal with this issue- every interface has 2 32-bit integers associated
with it, one is the "snmp-ifindex", conformant with rfc 2863, 
that never changes, and encodes positional information like slot#,
chassis#, card type etc.  This number is sparse (i.e., it
is not necessarily a consecutive number space) Encoding is implementation
specific, of course, and macros are supplied if you want to look into
the encoding itself.

the other number is the one used internally by the network stack,
and is subject to frequent change, as interfaces come and go (up/down,
virtual interfaces change etc). This is a packed number-space- next
available index is handed to each interface as it comes up.

SNMP mibs publish the first number, and apps can use that number
to uniquely identify an interface. 

If there are enough apps that rely on an immutable index to identify
an interface, it might be worthwhile to consider this type of approach.

> +	if (!dev->ifindex) {
> +		if (strcmp (dev->name, "gre_ffrl_fra_a") == 0) {
> +			ifindex = 23;
> +		} else if (strcmp (dev->name, "bb-pad-cr01") == 0) {
> +			ifindex = 42;
> +		}

I'm not sure I understand how this would work- are we going to 
pin down the ifindex for some subset of interfaces?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 15:34 ` Sowmini Varadhan
@ 2015-12-01 15:50   ` Maximilian Wilhelm
  2015-12-01 16:02     ` Hannes Frederic Sowa
  2015-12-01 16:11     ` Sowmini Varadhan
  0 siblings, 2 replies; 21+ messages in thread
From: Maximilian Wilhelm @ 2015-12-01 15:50 UTC (permalink / raw)
  To: netdev

Anno domini 2015 Sowmini Varadhan scripsit:

> On (12/01/15 13:04), Maximilian Wilhelm wrote:

> > The reason we would like to have those is quite simple: As we operate
> > a somewhat larger network we would like to monitor it accordingly and
> > see when links get saturated etc. Therefore we used snmp based
> > solutions and the net-snmp daemon on all the boxes. Now SNMP uses
> > interface indexes for identifying the interfaces. If they aren't
> > stable the monitoring software will see a lot of new interfaces now
> > and then, e.g. after a OpenVPN server/client restarted (which is bad)
> > or even mix up interfaces (which is worse).
> 
> FWIW, this is how router implementations such as cisco network OS-es
> deal with this issue- every interface has 2 32-bit integers associated
> with it, one is the "snmp-ifindex", conformant with rfc 2863, 
> that never changes, and encodes positional information like slot#,
> chassis#, card type etc.  This number is sparse (i.e., it
> is not necessarily a consecutive number space) Encoding is implementation
> specific, of course, and macros are supplied if you want to look into
> the encoding itself.
> 
> the other number is the one used internally by the network stack,
> and is subject to frequent change, as interfaces come and go (up/down,
> virtual interfaces change etc). This is a packed number-space- next
> available index is handed to each interface as it comes up.
> 
> SNMP mibs publish the first number, and apps can use that number
> to uniquely identify an interface. 
> 
> If there are enough apps that rely on an immutable index to identify
> an interface, it might be worthwhile to consider this type of approach.

I would assume that at least all snmp implementations and connected
system (libreNMS, Observium and the like) do.

> > +	if (!dev->ifindex) {
> > +		if (strcmp (dev->name, "gre_ffrl_fra_a") == 0) {
> > +			ifindex = 23;
> > +		} else if (strcmp (dev->name, "bb-pad-cr01") == 0) {
> > +			ifindex = 42;
> > +		}
> 
> I'm not sure I understand how this would work- are we going to 
> pin down the ifindex for some subset of interfaces?

I'm not sure what your idea is, but I guess we might mean the same
thing:

What I have in mind is that the user can supply a list of (ifname ->
ifindex) entries via a sysfs/procfs interface and if such a list is
present, the kernel will search the list for every ifname which is
registered and check if there is an entry. If there is, the ifindex
for this entry is used. If there is no entry found for the given
ifname, the usual algorithm is used (therefore inherently providing
backward compatibility).

What I'm not sure about is what to do if there is any entry in the
list but the ifindex is already in use. One option would be to fail
the register call because the user wanted this particular ifindex and
therefore is seen responsible for ensuring its availability. The other
option is to silenty fall back to the usual approach (as my hardcoded
hack currently does).

I hope I could clarify on my idea?

Kind regards
Max
-- 
"Du kannst die Grundlagen von C. Das einzige, was C++ Dir noch gibt, ist mehr Schmerz!
 Und ein paar mehr Schrotflinten in die Hand..."
  -- Matthias Bolte

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 15:50   ` Maximilian Wilhelm
@ 2015-12-01 16:02     ` Hannes Frederic Sowa
  2015-12-01 16:06       ` Stephen Hemminger
  2015-12-01 19:27       ` David Miller
  2015-12-01 16:11     ` Sowmini Varadhan
  1 sibling, 2 replies; 21+ messages in thread
From: Hannes Frederic Sowa @ 2015-12-01 16:02 UTC (permalink / raw)
  To: Maximilian Wilhelm, netdev

On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> > I'm not sure I understand how this would work- are we going to 
> > pin down the ifindex for some subset of interfaces?
> 
> I'm not sure what your idea is, but I guess we might mean the same
> thing:
> 
> What I have in mind is that the user can supply a list of (ifname ->
> ifindex) entries via a sysfs/procfs interface and if such a list is
> present, the kernel will search the list for every ifname which is
> registered and check if there is an entry. If there is, the ifindex
> for this entry is used. If there is no entry found for the given
> ifname, the usual algorithm is used (therefore inherently providing
> backward compatibility).

Sorry to ask because I don't like this feature at all. There was a lot
of work on stable interface names. Why do you need stable ifindexes,
which were never meant to be stable for a longer amount of time?

Bye,
Hannes

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 16:02     ` Hannes Frederic Sowa
@ 2015-12-01 16:06       ` Stephen Hemminger
  2015-12-01 19:28         ` David Miller
  2015-12-01 19:27       ` David Miller
  1 sibling, 1 reply; 21+ messages in thread
From: Stephen Hemminger @ 2015-12-01 16:06 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: Maximilian Wilhelm, netdev

On Tue, 01 Dec 2015 17:02:23 +0100
Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:

> On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> > > I'm not sure I understand how this would work- are we going to 
> > > pin down the ifindex for some subset of interfaces?
> > 
> > I'm not sure what your idea is, but I guess we might mean the same
> > thing:
> > 
> > What I have in mind is that the user can supply a list of (ifname ->
> > ifindex) entries via a sysfs/procfs interface and if such a list is
> > present, the kernel will search the list for every ifname which is
> > registered and check if there is an entry. If there is, the ifindex
> > for this entry is used. If there is no entry found for the given
> > ifname, the usual algorithm is used (therefore inherently providing
> > backward compatibility).
> 
> Sorry to ask because I don't like this feature at all. There was a lot
> of work on stable interface names. Why do you need stable ifindexes,
> which were never meant to be stable for a longer amount of time?

Also current versions of SNMP provide more useful information about
network interface slot information in ifDescription

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 15:50   ` Maximilian Wilhelm
  2015-12-01 16:02     ` Hannes Frederic Sowa
@ 2015-12-01 16:11     ` Sowmini Varadhan
  1 sibling, 0 replies; 21+ messages in thread
From: Sowmini Varadhan @ 2015-12-01 16:11 UTC (permalink / raw)
  To: netdev

On (12/01/15 16:50), Maximilian Wilhelm wrote:
> What I have in mind is that the user can supply a list of (ifname ->
> ifindex) entries via a sysfs/procfs interface and if such a list is
> present, the kernel will search the list for every ifname which is

Having the user supply such a list is hazardous for the reason below,
esp if you consider that you can have virtual interfaces that 
take up that number.  It also allows for a sparse ifindex number
space, which can be inefficient (thus the cisco choice)

> What I'm not sure about is what to do if there is any entry in the
> list but the ifindex is already in use. One option would be to fail
> the register call because the user wanted this particular ifindex ..

If you want to do this, it's simpler to have the kernel
track 2 separate indices (the packed index and the sparse snmp-index)
per net_device. Changes to achieve it are non-trivial, of course,
and that's why I'd question how badly this is needed.

the other issue to confront is- what do you want ioctls like SIOCGIFINDEX
to return- the packed one or the sparse one? What about if_nametoindex etc?
If they return the sparse index, can they use it back with existing
ifioctl and other calls?  i.e., API compat will have some rough edges.

--Sowmini

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 16:02     ` Hannes Frederic Sowa
  2015-12-01 16:06       ` Stephen Hemminger
@ 2015-12-01 19:27       ` David Miller
  2015-12-01 20:26         ` Hannes Frederic Sowa
  1 sibling, 1 reply; 21+ messages in thread
From: David Miller @ 2015-12-01 19:27 UTC (permalink / raw)
  To: hannes; +Cc: max, netdev

From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Tue, 01 Dec 2015 17:02:23 +0100

> On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
>> > I'm not sure I understand how this would work- are we going to 
>> > pin down the ifindex for some subset of interfaces?
>> 
>> I'm not sure what your idea is, but I guess we might mean the same
>> thing:
>> 
>> What I have in mind is that the user can supply a list of (ifname ->
>> ifindex) entries via a sysfs/procfs interface and if such a list is
>> present, the kernel will search the list for every ifname which is
>> registered and check if there is an entry. If there is, the ifindex
>> for this entry is used. If there is no entry found for the given
>> ifname, the usual algorithm is used (therefore inherently providing
>> backward compatibility).
> 
> Sorry to ask because I don't like this feature at all. There was a lot
> of work on stable interface names. Why do you need stable ifindexes,
> which were never meant to be stable for a longer amount of time?

Because all the remote SNMP tools work with interface indexes, not names.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 16:06       ` Stephen Hemminger
@ 2015-12-01 19:28         ` David Miller
  2015-12-01 20:20           ` Stephen Hemminger
  0 siblings, 1 reply; 21+ messages in thread
From: David Miller @ 2015-12-01 19:28 UTC (permalink / raw)
  To: stephen; +Cc: hannes, max, netdev

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Tue, 1 Dec 2015 08:06:52 -0800

> On Tue, 01 Dec 2015 17:02:23 +0100
> Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
> 
>> On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
>> > > I'm not sure I understand how this would work- are we going to 
>> > > pin down the ifindex for some subset of interfaces?
>> > 
>> > I'm not sure what your idea is, but I guess we might mean the same
>> > thing:
>> > 
>> > What I have in mind is that the user can supply a list of (ifname ->
>> > ifindex) entries via a sysfs/procfs interface and if such a list is
>> > present, the kernel will search the list for every ifname which is
>> > registered and check if there is an entry. If there is, the ifindex
>> > for this entry is used. If there is no entry found for the given
>> > ifname, the usual algorithm is used (therefore inherently providing
>> > backward compatibility).
>> 
>> Sorry to ask because I don't like this feature at all. There was a lot
>> of work on stable interface names. Why do you need stable ifindexes,
>> which were never meant to be stable for a longer amount of time?
> 
> Also current versions of SNMP provide more useful information about
> network interface slot information in ifDescription

Well if they do provide strings, then that is probably a better way
forward than messing with the kernel.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 19:28         ` David Miller
@ 2015-12-01 20:20           ` Stephen Hemminger
  2015-12-01 20:57             ` David Miller
  0 siblings, 1 reply; 21+ messages in thread
From: Stephen Hemminger @ 2015-12-01 20:20 UTC (permalink / raw)
  To: David Miller; +Cc: hannes, max, netdev

On Tue, 01 Dec 2015 14:28:47 -0500 (EST)
David Miller <davem@davemloft.net> wrote:

> From: Stephen Hemminger <stephen@networkplumber.org>
> Date: Tue, 1 Dec 2015 08:06:52 -0800
> 
> > On Tue, 01 Dec 2015 17:02:23 +0100
> > Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
> > 
> >> On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> >> > > I'm not sure I understand how this would work- are we going to 
> >> > > pin down the ifindex for some subset of interfaces?
> >> > 
> >> > I'm not sure what your idea is, but I guess we might mean the same
> >> > thing:
> >> > 
> >> > What I have in mind is that the user can supply a list of (ifname ->
> >> > ifindex) entries via a sysfs/procfs interface and if such a list is
> >> > present, the kernel will search the list for every ifname which is
> >> > registered and check if there is an entry. If there is, the ifindex
> >> > for this entry is used. If there is no entry found for the given
> >> > ifname, the usual algorithm is used (therefore inherently providing
> >> > backward compatibility).
> >> 
> >> Sorry to ask because I don't like this feature at all. There was a lot
> >> of work on stable interface names. Why do you need stable ifindexes,
> >> which were never meant to be stable for a longer amount of time?
> > 
> > Also current versions of SNMP provide more useful information about
> > network interface slot information in ifDescription
> 
> Well if they do provide strings, then that is probably a better way
> forward than messing with the kernel.

It gives strings based on PCI information but nothing useful
on tunnels.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 19:27       ` David Miller
@ 2015-12-01 20:26         ` Hannes Frederic Sowa
  2015-12-01 22:43           ` Maximilian Wilhelm
  0 siblings, 1 reply; 21+ messages in thread
From: Hannes Frederic Sowa @ 2015-12-01 20:26 UTC (permalink / raw)
  To: David Miller; +Cc: max, netdev

On Tue, Dec 1, 2015, at 20:27, David Miller wrote:
> From: Hannes Frederic Sowa <hannes@stressinduktion.org>
> Date: Tue, 01 Dec 2015 17:02:23 +0100
> 
> > On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> >> > I'm not sure I understand how this would work- are we going to 
> >> > pin down the ifindex for some subset of interfaces?
> >> 
> >> I'm not sure what your idea is, but I guess we might mean the same
> >> thing:
> >> 
> >> What I have in mind is that the user can supply a list of (ifname ->
> >> ifindex) entries via a sysfs/procfs interface and if such a list is
> >> present, the kernel will search the list for every ifname which is
> >> registered and check if there is an entry. If there is, the ifindex
> >> for this entry is used. If there is no entry found for the given
> >> ifname, the usual algorithm is used (therefore inherently providing
> >> backward compatibility).
> > 
> > Sorry to ask because I don't like this feature at all. There was a lot
> > of work on stable interface names. Why do you need stable ifindexes,
> > which were never meant to be stable for a longer amount of time?
> 
> Because all the remote SNMP tools work with interface indexes, not names.

I know, but it should be terribly simply to patch SNMP tools to even
store the table of ifindex <-> name mappings persistently on the disk
and thus completely avoid this issue. Even though they can check on
interfaces if they have the same characteristics, e.g. tunnel to the
same destinations etc. Those are all policies which user space should
handle.

I agree it would make life much easier for user space if the kernel
would keep the ifindex stable over reboots etc. but for a much higher
costs at kernel maintenance.

Bye,
Hannes

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 20:20           ` Stephen Hemminger
@ 2015-12-01 20:57             ` David Miller
  2015-12-01 21:06               ` Sowmini Varadhan
  2015-12-01 21:14               ` Hannes Frederic Sowa
  0 siblings, 2 replies; 21+ messages in thread
From: David Miller @ 2015-12-01 20:57 UTC (permalink / raw)
  To: stephen; +Cc: hannes, max, netdev

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Tue, 1 Dec 2015 12:20:38 -0800

> On Tue, 01 Dec 2015 14:28:47 -0500 (EST)
> David Miller <davem@davemloft.net> wrote:
> 
>> From: Stephen Hemminger <stephen@networkplumber.org>
>> Date: Tue, 1 Dec 2015 08:06:52 -0800
>> 
>> > On Tue, 01 Dec 2015 17:02:23 +0100
>> > Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
>> > 
>> >> On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
>> >> > > I'm not sure I understand how this would work- are we going to 
>> >> > > pin down the ifindex for some subset of interfaces?
>> >> > 
>> >> > I'm not sure what your idea is, but I guess we might mean the same
>> >> > thing:
>> >> > 
>> >> > What I have in mind is that the user can supply a list of (ifname ->
>> >> > ifindex) entries via a sysfs/procfs interface and if such a list is
>> >> > present, the kernel will search the list for every ifname which is
>> >> > registered and check if there is an entry. If there is, the ifindex
>> >> > for this entry is used. If there is no entry found for the given
>> >> > ifname, the usual algorithm is used (therefore inherently providing
>> >> > backward compatibility).
>> >> 
>> >> Sorry to ask because I don't like this feature at all. There was a lot
>> >> of work on stable interface names. Why do you need stable ifindexes,
>> >> which were never meant to be stable for a longer amount of time?
>> > 
>> > Also current versions of SNMP provide more useful information about
>> > network interface slot information in ifDescription
>> 
>> Well if they do provide strings, then that is probably a better way
>> forward than messing with the kernel.
> 
> It gives strings based on PCI information but nothing useful
> on tunnels.

But at least in theory, that could be extended to do so right?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 20:57             ` David Miller
@ 2015-12-01 21:06               ` Sowmini Varadhan
  2015-12-01 21:14               ` Hannes Frederic Sowa
  1 sibling, 0 replies; 21+ messages in thread
From: Sowmini Varadhan @ 2015-12-01 21:06 UTC (permalink / raw)
  To: David Miller; +Cc: stephen, hannes, max, netdev

On (12/01/15 15:57), David Miller wrote:

> >> > Also current versions of SNMP provide more useful information about
> >> > network interface slot information in ifDescription
> >> 
> >> Well if they do provide strings, then that is probably a better way
> >> forward than messing with the kernel.
> > 
> > It gives strings based on PCI information but nothing useful
> > on tunnels.
> 
> But at least in theory, that could be extended to do so right?

iirc even for the cisco NOS-es, the snmp ifindex for virtual interfaces
(tunnels, vpc, loopback) etc would not have any slot etc info, but
would have other things (specific to the virtual interface type, e.g.,
FEX interface index had something that was pertinent to fex)

But the bigger reason they had a immutable snmp-ifindex was that
the uspace networking applications could build state based on that
immutable index and hang on to that number, regardless of any renumbering
that happened due to HA/failover.

And, since they did not (in general) have to deal with random third
party apps, they did not have to deal with questions like "what should
POSIX/glibc APIs send - the immutable or the mutable index?" so it
was ok for them to have the complexity of two interface indices.

--Sowmini

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 20:57             ` David Miller
  2015-12-01 21:06               ` Sowmini Varadhan
@ 2015-12-01 21:14               ` Hannes Frederic Sowa
  2015-12-01 21:44                 ` Stephen Hemminger
  1 sibling, 1 reply; 21+ messages in thread
From: Hannes Frederic Sowa @ 2015-12-01 21:14 UTC (permalink / raw)
  To: David Miller, stephen; +Cc: max, netdev

On Tue, Dec 1, 2015, at 21:57, David Miller wrote:
> From: Stephen Hemminger <stephen@networkplumber.org>
> Date: Tue, 1 Dec 2015 12:20:38 -0800
> 
> > On Tue, 01 Dec 2015 14:28:47 -0500 (EST)
> > David Miller <davem@davemloft.net> wrote:
> > 
> >> From: Stephen Hemminger <stephen@networkplumber.org>
> >> Date: Tue, 1 Dec 2015 08:06:52 -0800
> >> 
> >> > On Tue, 01 Dec 2015 17:02:23 +0100
> >> > Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
> >> > 
> >> >> On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> >> >> > > I'm not sure I understand how this would work- are we going to 
> >> >> > > pin down the ifindex for some subset of interfaces?
> >> >> > 
> >> >> > I'm not sure what your idea is, but I guess we might mean the same
> >> >> > thing:
> >> >> > 
> >> >> > What I have in mind is that the user can supply a list of (ifname ->
> >> >> > ifindex) entries via a sysfs/procfs interface and if such a list is
> >> >> > present, the kernel will search the list for every ifname which is
> >> >> > registered and check if there is an entry. If there is, the ifindex
> >> >> > for this entry is used. If there is no entry found for the given
> >> >> > ifname, the usual algorithm is used (therefore inherently providing
> >> >> > backward compatibility).
> >> >> 
> >> >> Sorry to ask because I don't like this feature at all. There was a lot
> >> >> of work on stable interface names. Why do you need stable ifindexes,
> >> >> which were never meant to be stable for a longer amount of time?
> >> > 
> >> > Also current versions of SNMP provide more useful information about
> >> > network interface slot information in ifDescription
> >> 
> >> Well if they do provide strings, then that is probably a better way
> >> forward than messing with the kernel.
> > 
> > It gives strings based on PCI information but nothing useful
> > on tunnels.
> 
> But at least in theory, that could be extended to do so right?

I had several snmp installations with net-snmp and munin, cacti and so
on and all had the interface name in ifDescription already some years
back.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 21:14               ` Hannes Frederic Sowa
@ 2015-12-01 21:44                 ` Stephen Hemminger
  2015-12-01 21:54                   ` Hannes Frederic Sowa
  0 siblings, 1 reply; 21+ messages in thread
From: Stephen Hemminger @ 2015-12-01 21:44 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: David Miller, max, netdev

On Tue, 01 Dec 2015 22:14:59 +0100
Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:

> On Tue, Dec 1, 2015, at 21:57, David Miller wrote:
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Date: Tue, 1 Dec 2015 12:20:38 -0800
> > 
> > > On Tue, 01 Dec 2015 14:28:47 -0500 (EST)
> > > David Miller <davem@davemloft.net> wrote:
> > > 
> > >> From: Stephen Hemminger <stephen@networkplumber.org>
> > >> Date: Tue, 1 Dec 2015 08:06:52 -0800
> > >> 
> > >> > On Tue, 01 Dec 2015 17:02:23 +0100
> > >> > Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
> > >> > 
> > >> >> On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> > >> >> > > I'm not sure I understand how this would work- are we going to 
> > >> >> > > pin down the ifindex for some subset of interfaces?
> > >> >> > 
> > >> >> > I'm not sure what your idea is, but I guess we might mean the same
> > >> >> > thing:
> > >> >> > 
> > >> >> > What I have in mind is that the user can supply a list of (ifname ->
> > >> >> > ifindex) entries via a sysfs/procfs interface and if such a list is
> > >> >> > present, the kernel will search the list for every ifname which is
> > >> >> > registered and check if there is an entry. If there is, the ifindex
> > >> >> > for this entry is used. If there is no entry found for the given
> > >> >> > ifname, the usual algorithm is used (therefore inherently providing
> > >> >> > backward compatibility).
> > >> >> 
> > >> >> Sorry to ask because I don't like this feature at all. There was a lot
> > >> >> of work on stable interface names. Why do you need stable ifindexes,
> > >> >> which were never meant to be stable for a longer amount of time?
> > >> > 
> > >> > Also current versions of SNMP provide more useful information about
> > >> > network interface slot information in ifDescription
> > >> 
> > >> Well if they do provide strings, then that is probably a better way
> > >> forward than messing with the kernel.
> > > 
> > > It gives strings based on PCI information but nothing useful
> > > on tunnels.
> > 
> > But at least in theory, that could be extended to do so right?
> 
> I had several snmp installations with net-snmp and munin, cacti and so
> on and all had the interface name in ifDescription already some years
> back.

In net-snmp 5.7 or later ifDescr is set to result of pci_lookup_name
(by default).

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 21:44                 ` Stephen Hemminger
@ 2015-12-01 21:54                   ` Hannes Frederic Sowa
  2015-12-01 22:31                     ` Stephen Hemminger
  0 siblings, 1 reply; 21+ messages in thread
From: Hannes Frederic Sowa @ 2015-12-01 21:54 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Miller, max, netdev


On Tue, Dec 1, 2015, at 22:44, Stephen Hemminger wrote:
> On Tue, 01 Dec 2015 22:14:59 +0100
> Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
> > I had several snmp installations with net-snmp and munin, cacti and so
> > on and all had the interface name in ifDescription already some years
> > back.
> 
> In net-snmp 5.7 or later ifDescr is set to result of pci_lookup_name
> (by default).

Seems the data should simply be in ifName nowadays (unconfirmed):
<http://www.net-snmp.org/docs/mibs/ifMIBObjects.html>

Bye,
Hannes

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 21:54                   ` Hannes Frederic Sowa
@ 2015-12-01 22:31                     ` Stephen Hemminger
  0 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2015-12-01 22:31 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: David Miller, max, netdev

On Tue, 01 Dec 2015 22:54:54 +0100
Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:

> 
> On Tue, Dec 1, 2015, at 22:44, Stephen Hemminger wrote:
> > On Tue, 01 Dec 2015 22:14:59 +0100
> > Hannes Frederic Sowa <hannes@stressinduktion.org> wrote:
> > > I had several snmp installations with net-snmp and munin, cacti and so
> > > on and all had the interface name in ifDescription already some years
> > > back.
> > 
> > In net-snmp 5.7 or later ifDescr is set to result of pci_lookup_name
> > (by default).
> 
> Seems the data should simply be in ifName nowadays (unconfirmed):
> <http://www.net-snmp.org/docs/mibs/ifMIBObjects.html>
> 
> Bye,
> Hannes

By default
  ifDescr == ifName == interface name (ie eth0, enp0s1, ...)
If the device is on PCI bus then result is like:


IF-MIB::ifDescr.2 = STRING: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
IF-MIB::ifName.2 = STRING: enp3s0

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 20:26         ` Hannes Frederic Sowa
@ 2015-12-01 22:43           ` Maximilian Wilhelm
  2015-12-01 23:58             ` Hannes Frederic Sowa
  0 siblings, 1 reply; 21+ messages in thread
From: Maximilian Wilhelm @ 2015-12-01 22:43 UTC (permalink / raw)
  To: netdev

Anno domini 2015 Hannes Frederic Sowa scripsit:

> On Tue, Dec 1, 2015, at 20:27, David Miller wrote:
> > From: Hannes Frederic Sowa <hannes@stressinduktion.org>
> > Date: Tue, 01 Dec 2015 17:02:23 +0100
> > 
> > > On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> > >> > I'm not sure I understand how this would work- are we going to 
> > >> > pin down the ifindex for some subset of interfaces?
> > >> 
> > >> I'm not sure what your idea is, but I guess we might mean the same
> > >> thing:
> > >> 
> > >> What I have in mind is that the user can supply a list of (ifname ->
> > >> ifindex) entries via a sysfs/procfs interface and if such a list is
> > >> present, the kernel will search the list for every ifname which is
> > >> registered and check if there is an entry. If there is, the ifindex
> > >> for this entry is used. If there is no entry found for the given
> > >> ifname, the usual algorithm is used (therefore inherently providing
> > >> backward compatibility).
> > > 
> > > Sorry to ask because I don't like this feature at all. There was a lot
> > > of work on stable interface names. Why do you need stable ifindexes,
> > > which were never meant to be stable for a longer amount of time?
> > 
> > Because all the remote SNMP tools work with interface indexes, not names.

That's indeed true and the underlying problem which brought us to this
idea.

> I know, but it should be terribly simply to patch SNMP tools to even
> store the table of ifindex <-> name mappings persistently on the disk
> and thus completely avoid this issue. Even though they can check on
> interfaces if they have the same characteristics, e.g. tunnel to the
> same destinations etc. Those are all policies which user space should
> handle.

How should net-snmp handle cases where new interfaces come up on old
and now unused numbers? What should it report? That would escalate the
problem a lot IMHO.

> I agree it would make life much easier for user space if the kernel
> would keep the ifindex stable over reboots etc. but for a much higher
> costs at kernel maintenance.

What would that cost be in the implementation I sketched before?

I don't quite see what the higher cost would be. I currently can
manually set an ifindex of my choosing for newly created GRE tunnels,
vlan interfaces and the like. So what would be the difference of
having the optional ability to push some of these predefined ifindexes
into the kernel and don't bother while creating the interface and
having the same outcome? Same effect but easier to use once set up.

Regarding the performance issues raised before the same question
applies: What's the difference if I create some / a lot of interfaces
with sparse ifindexes by using "ip link add foo index 1234" or by
having a list within the kernel.

I still consider this a feature worth and simple enough to implement
which would serve as a great option for people with such usage
scenarios.

Best
Max
-- 
"Does is bother me, that people hurt others, because they are to weak to face the truth? Yeah. Sorry 'bout that."
 -- Thirteen, House M.D.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 22:43           ` Maximilian Wilhelm
@ 2015-12-01 23:58             ` Hannes Frederic Sowa
  2015-12-02  1:41               ` Andrew Lunn
  2015-12-02 11:03               ` Marcelo Ricardo Leitner
  0 siblings, 2 replies; 21+ messages in thread
From: Hannes Frederic Sowa @ 2015-12-01 23:58 UTC (permalink / raw)
  To: Maximilian Wilhelm, netdev

Hello,

On Tue, Dec 1, 2015, at 23:43, Maximilian Wilhelm wrote:
> Anno domini 2015 Hannes Frederic Sowa scripsit:
> 
> > On Tue, Dec 1, 2015, at 20:27, David Miller wrote:
> > > From: Hannes Frederic Sowa <hannes@stressinduktion.org>
> > > Date: Tue, 01 Dec 2015 17:02:23 +0100
> > > 
> > > > On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> > > >> > I'm not sure I understand how this would work- are we going to 
> > > >> > pin down the ifindex for some subset of interfaces?
> > > >> 
> > > >> I'm not sure what your idea is, but I guess we might mean the same
> > > >> thing:
> > > >> 
> > > >> What I have in mind is that the user can supply a list of (ifname ->
> > > >> ifindex) entries via a sysfs/procfs interface and if such a list is
> > > >> present, the kernel will search the list for every ifname which is
> > > >> registered and check if there is an entry. If there is, the ifindex
> > > >> for this entry is used. If there is no entry found for the given
> > > >> ifname, the usual algorithm is used (therefore inherently providing
> > > >> backward compatibility).
> > > > 
> > > > Sorry to ask because I don't like this feature at all. There was a lot
> > > > of work on stable interface names. Why do you need stable ifindexes,
> > > > which were never meant to be stable for a longer amount of time?
> > > 
> > > Because all the remote SNMP tools work with interface indexes, not names.
> 
> That's indeed true and the underlying problem which brought us to this
> idea.

I do really understand the problem with SNMP tooling but I hope that
monitoring software can just ignore the ifindex for the time being and
just use it as a way to walk the table. The authoritative identifier
should be the name, this is were a lot of work went into from the
udev/systemd folks to be stable and that is already pretty hairy and
took a long time. Indexes are simply the way to walk snmp tables, names
won't work in the snmp design. But I don't see any reason why monitoring
software uses this ifindex as the key to store all subsequent interface
statistics.

> > I know, but it should be terribly simply to patch SNMP tools to even
> > store the table of ifindex <-> name mappings persistently on the disk
> > and thus completely avoid this issue. Even though they can check on
> > interfaces if they have the same characteristics, e.g. tunnel to the
> > same destinations etc. Those are all policies which user space should
> > handle.
> 
> How should net-snmp handle cases where new interfaces come up on old
> and now unused numbers? What should it report? That would escalate the
> problem a lot IMHO.

ifindexes are only reused when the ifindex allocator wraps around which
should hopefully take a while and that is exactly my point.

In general the ifindexes are designed to not be reused very fast. Most
ifindex usage is in socket layer where one specifies which way a packet
should go in sendto/msg calls to override routing lookups or use link
local addresses. Imagine an application looks up an interface and
determines the ifindex to send out data to an ipv6 link local address
(which needs the ifindex obviously). If we don't bias the ifindex
selection during device creation time the app will get an error and
won't race with other tunnels being setup and can handle that
accordingly because new tunnels simply have new ifindexes until the
per-namespace counter wraps around. If we have name based policies we
have to audit user space applications how they do interface name
selection to protect them against reusing interface names. Based on your
mail you simply already do ensure that interface names are unique, so
your monitoring software should use just them.

I simply see this feature being misused way too easily.

ip link ... index IDX was added to create devices in new netns for CRIU.
This does make sense but installing policy in the kernel for interface
indexes seems to much to me.

> > I agree it would make life much easier for user space if the kernel
> > would keep the ifindex stable over reboots etc. but for a much higher
> > costs at kernel maintenance.
> 
> What would that cost be in the implementation I sketched before?

I don't think there is a high performance cost. Only device allocation
path would need to be changed and this is not fast path at all.

> I don't quite see what the higher cost would be. I currently can
> manually set an ifindex of my choosing for newly created GRE tunnels,
> vlan interfaces and the like. So what would be the difference of
> having the optional ability to push some of these predefined ifindexes
> into the kernel and don't bother while creating the interface and
> having the same outcome? Same effect but easier to use once set up.
> 
> Regarding the performance issues raised before the same question
> applies: What's the difference if I create some / a lot of interfaces
> with sparse ifindexes by using "ip link add foo index 1234" or by
> having a list within the kernel.
> 
> I still consider this a feature worth and simple enough to implement
> which would serve as a great option for people with such usage
> scenarios.

Interface names are often renamed after instantiation, e.g.
automatically via systemd/udev or other system software. That means it
will be very confusing for users and hard to debug why a specific
ifindex was used just because the interface appeared under some name for
a few seconds. I don't think users will only use it for tunnels.

In case such a feature seems really useful besides my critique here, I
would suggest it should only work for newlink operations where the user
supplied a name and the ifindex allocator should not try to use the
ifindexes reserved by this feature.

Bye,
Hannes

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 23:58             ` Hannes Frederic Sowa
@ 2015-12-02  1:41               ` Andrew Lunn
  2015-12-02 11:03               ` Marcelo Ricardo Leitner
  1 sibling, 0 replies; 21+ messages in thread
From: Andrew Lunn @ 2015-12-02  1:41 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: Maximilian Wilhelm, netdev

> In general the ifindexes are designed to not be reused very fast.

Some parts of multicast group management rely on this. You need to
remove group memberships from a socket when an interface has
disappeared, e.g. a VPN interface has gone away. You can pass the
ifindex of the no longer existing interface when removing the group
memberships. If that ifindex has been re-used, you are going to have
interesting race conditions.

	    Andrew

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
  2015-12-01 23:58             ` Hannes Frederic Sowa
  2015-12-02  1:41               ` Andrew Lunn
@ 2015-12-02 11:03               ` Marcelo Ricardo Leitner
  1 sibling, 0 replies; 21+ messages in thread
From: Marcelo Ricardo Leitner @ 2015-12-02 11:03 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: Maximilian Wilhelm, netdev

Hi,

On Wed, Dec 02, 2015 at 12:58:58AM +0100, Hannes Frederic Sowa wrote:
> Hello,
> 
> On Tue, Dec 1, 2015, at 23:43, Maximilian Wilhelm wrote:
> > How should net-snmp handle cases where new interfaces come up on old
> > and now unused numbers? What should it report? That would escalate the
> > problem a lot IMHO.
> 
> ifindexes are only reused when the ifindex allocator wraps around which
> should hopefully take a while and that is exactly my point.
> 
> In general the ifindexes are designed to not be reused very fast. Most
> ifindex usage is in socket layer where one specifies which way a packet
> should go in sendto/msg calls to override routing lookups or use link
> local addresses. Imagine an application looks up an interface and
> determines the ifindex to send out data to an ipv6 link local address
> (which needs the ifindex obviously). If we don't bias the ifindex
> selection during device creation time the app will get an error and
> won't race with other tunnels being setup and can handle that
> accordingly because new tunnels simply have new ifindexes until the
> per-namespace counter wraps around. If we have name based policies we
> have to audit user space applications how they do interface name
> selection to protect them against reusing interface names. Based on your
> mail you simply already do ensure that interface names are unique, so
> your monitoring software should use just them.
> 
> I simply see this feature being misused way too easily.

This is very similar to processes and their pids. On (small) embedded
systems it's common that a given process will always have the same pid
after boot. Then for some reason a process is restarted and you want it
to have that same pid, which is not good.

Same semantics would apply, I think. Monitoring software has to know how
to handle with that change and cope with it.

I don't know the details but I know that it's also possible to monitor
processes via SNMP, meaning that monitoring apps must already do that
for processes, then why not for interfaces?

  Marcelo

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [RFC] Stable interface index option
@ 2015-12-01 16:10 Maximilian Wilhelm
  0 siblings, 0 replies; 21+ messages in thread
From: Maximilian Wilhelm @ 2015-12-01 16:10 UTC (permalink / raw)
  To: netdev

Anno domini 2015 Hannes Frederic Sowa scripsit:

> On Tue, Dec 1, 2015, at 16:50, Maximilian Wilhelm wrote:
> > > I'm not sure I understand how this would work- are we going to 
> > > pin down the ifindex for some subset of interfaces?
> > 
> > I'm not sure what your idea is, but I guess we might mean the same
> > thing:
> > 
> > What I have in mind is that the user can supply a list of (ifname ->
> > ifindex) entries via a sysfs/procfs interface and if such a list is
> > present, the kernel will search the list for every ifname which is
> > registered and check if there is an entry. If there is, the ifindex
> > for this entry is used. If there is no entry found for the given
> > ifname, the usual algorithm is used (therefore inherently providing
> > backward compatibility).

> Sorry to ask because I don't like this feature at all. There was a lot
> of work on stable interface names. Why do you need stable ifindexes,
> which were never meant to be stable for a longer amount of time?

As described in my first mail, there currently is a real-world problem
with snmp based monitoring of linux network devices. As snmp is the de
facto standard for monitoring of network devices this presents a
problem when working with the according tools (traffic graphs aren't
accurent or have to be changed manually on daily basis, weathermaps
aren't correct like show to few traffic or the "wrong" one, etc.)

So this is the most simple and most generic approach to fix this
problem.

What's the reason you don't like this feature at all?

Best
Max
-- 
     "really soon now":      an unspecified period of time, likly to
                             be greater than any reasonable definition
                             of "soon".

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2015-12-02 11:03 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 12:04 [RFC] Stable interface index option Maximilian Wilhelm
2015-12-01 15:34 ` Sowmini Varadhan
2015-12-01 15:50   ` Maximilian Wilhelm
2015-12-01 16:02     ` Hannes Frederic Sowa
2015-12-01 16:06       ` Stephen Hemminger
2015-12-01 19:28         ` David Miller
2015-12-01 20:20           ` Stephen Hemminger
2015-12-01 20:57             ` David Miller
2015-12-01 21:06               ` Sowmini Varadhan
2015-12-01 21:14               ` Hannes Frederic Sowa
2015-12-01 21:44                 ` Stephen Hemminger
2015-12-01 21:54                   ` Hannes Frederic Sowa
2015-12-01 22:31                     ` Stephen Hemminger
2015-12-01 19:27       ` David Miller
2015-12-01 20:26         ` Hannes Frederic Sowa
2015-12-01 22:43           ` Maximilian Wilhelm
2015-12-01 23:58             ` Hannes Frederic Sowa
2015-12-02  1:41               ` Andrew Lunn
2015-12-02 11:03               ` Marcelo Ricardo Leitner
2015-12-01 16:11     ` Sowmini Varadhan
2015-12-01 16:10 Maximilian Wilhelm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.