missing aliased interfaces in /proc/net/dev

Erik Schoenfelder (schoenfr@gaertner.de)
Sat, 17 Jan 1998 17:06:02 +0100 (MET)


Hi,

Some dayes ago i asked about the vanished /prov/net/alias* files and
the missing aliased interfaces in /proc/net/dev, but got no answer.

So here is a first diff against 2.1.78 to add at least the missing
aliased interfaces in /proc/net/dev and to update the out-of-date
documentation:

--- linux/net/core/dev.c-2178 Sat Jan 17 12:22:18 1998
+++ linux/net/core/dev.c Sat Jan 17 15:23:37 1998
@@ -67,6 +67,7 @@
#include <linux/if_ether.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
+#include <linux/inetdevice.h>
#include <linux/notifier.h>
#include <linux/skbuff.h>
#include <net/sock.h>
@@ -1000,9 +1001,9 @@
off_t begin=0;
off_t pos=0;
int size;
-
- struct device *dev;

+ struct in_ifaddr *ifa = NULL;
+ struct device *dev = dev_base;

size = sprintf(buffer,
"Inter-| Receive | Transmit\n"
@@ -1011,10 +1012,28 @@
pos+=size;
len+=size;

+ while (dev != NULL) {

- for (dev = dev_base; dev != NULL; dev = dev->next)
- {
+#ifdef CONFIG_IP_ALIAS
+ if (ifa != NULL) {
+ if (strchr(ifa->ifa_label, ':'))
+ size = sprintf(buffer+len,
+ "%6s: No statistics available.\n",
+ ifa->ifa_label);
+ else
+ size = 0;
+ ifa = ifa->ifa_next;
+ } else {
+ size = sprintf_stats(buffer+len, dev);
+ if (dev->ip_ptr != NULL) {
+ struct in_device *id = dev->ip_ptr;
+ ifa = id->ifa_list;
+ }
+ }
+#else
size = sprintf_stats(buffer+len, dev);
+#endif
+
len+=size;
pos=begin+len;

@@ -1025,6 +1044,9 @@
}
if(pos>offset+length)
break;
+
+ if (! ifa)
+ dev = dev->next;
}

*start=buffer+(offset-begin); /* Start of wanted data */

--- linux/Documentation/networking/alias.txt-2178 Sat Jan 17 16:30:58 1998
+++ linux/Documentation/networking/alias.txt Sat Jan 17 16:30:23 1998
@@ -1,33 +1,11 @@
-NET_ALIAS device aliasing v0.4x
-===============================
- The main step taken in versions 0.40+ is the implementation of a
- device aliasing mechanism that creates *actual* devices.
- This development includes NET_ALIAS (generic aliasing) plus IP_ALIAS
- (specific IP) support.
-
-Features
---------
-o ACTUAL alias devices created & inserted in dev chain
-o AF_ independent: net_alias_type objects. Generic aliasing engine.
-o AF_INET optimized
-o hashed alias address lookup
-o net_alias_type objs registration/unreg., module-ables.
-o /proc/net/aliases & /proc/net/alias_types entries
-
-o IP alias implementation: static or runtime module.
-
-Usage (IP aliasing)
--------------------
- A very first step to test if you are running a net_alias-ed kernel
- is to check /proc/net/aliases & /proc/net/alias_types entries:
- # cat /proc/net/alias*
-
- For IP aliasing you must have IP_ALIAS support included by
- static linking ('y' to 2nd question above), or runtime module
- insertion ('m' to 2nd q. above):
- # insmod /usr/src/linux/modules/ip_alias.o (1.3.xx)
- # insmod /usr/src/ip_alias/ip_alias.o (1.2.xx) see above.

+IP-Aliasing:
+============
+
+
+o For IP aliasing you must have IP_ALIAS support included by static
+ linking; it is avail as a module.
+
o Alias creation.
Alias creation is done by 'magic' iface naming: eg. to create a
200.1.1.1 alias for eth0 ...
@@ -42,43 +20,29 @@
for eth0:0)

o Alias deletion.
- Also done by magic naming, eg:
+ Also done by shutting the interface down:

- # ifconfig eth0:0- 0 (maybe any address)
- ~~~ -> will delete alias (note '-' after dev name)
- alias device is closed before deletion, so all network stuff that
- points to it (routes, arp entries, ...) will be released.
+ # ifconfig eth0:0 down
+ ~~~~~~~~~~ -> will delete alias
+

Alias (re-)configuring
- Aliases *are* devices, so you configure and refer to them as usual (ifconfig,
- route, etc).
-
+
+ Aliases are no real devices, but should be able to configure and
+ refer to them as usual (ifconfig, route, etc).
+
o Procfs entries
- 2 entries are added to help fetching alias runtime configuration:
- a) /proc/net/alias_types
- Will show you alias_types registered (ie. address families that
- can be aliased).
- eg. for IP aliasing with 1 alias configured:
-
- # cat /proc/net/alias_types
- type name n_attach
- 2 ip 1
-
- b) /proc/net/aliases
- Will show aliased devices info, eg (same as above):
-
- # cat /proc/net/aliases
- device family address
- eth0:0 2 200.1.1.1
+
+ a) /proc/net/dev
+ Will show you aliases by a interface with a ':' in the name.
+

Relationship with main device
-----------------------------
- - On main device closing, all aliases will be closed and freed.
- - Each new alias created is inserted in dev_chain just before next
- main device (aliases get 'stacked' after main_dev), eg:
- lo->eth0->eth0:0->eth0:2->eth1->0
- If eth0 is unregistered, all it aliases will also be:
- lo->eth1->0
+
+ - the main device is an alias itself like additional aliases and can
+ be shut down without deleting other aliases.
+

Contact
-------

Thank's,
Erik