patch-2.0.31 linux/include/linux/net_alias.h

Next file: linux/include/linux/pagemap.h
Previous file: linux/include/linux/mroute.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.30/linux/include/linux/net_alias.h linux/include/linux/net_alias.h
@@ -2,7 +2,7 @@
  *		NET_ALIAS network device aliasing definitions.
  *
  *
- * Version:	@(#)net_alias.h	0.43   12/20/95
+ * Version:	@(#)net_alias.h	0.50   4/20/97
  *
  * Author:	Juan Jose Ciarlante, <jjciarla@raiz.uncu.edu.ar>
  *
@@ -12,6 +12,10 @@
  *	as published by the Free Software Foundation; either version
  *	2 of the License, or (at your option) any later version.
  *	
+ * Fixes:
+ *	Juan Jose Ciarlante	:	Added tx/rx stats for aliases.
+ *	Juan Jose Ciarlante 	:	hash_tab size now in net_alias.c
+ *	Juan Jose Ciarlante	:	added sysctl interface
  */
 
 #ifndef _NET_ALIAS_H
@@ -21,12 +25,6 @@
 #include <linux/if.h>
 #include <linux/netdevice.h>
 
-/*
- * max. alias slot number allowed 
- */
-
-#define NET_ALIAS_MAX_SLOT  256
-
 struct net_alias;
 struct net_alias_info;
 struct net_alias_type;
@@ -47,6 +45,8 @@
   struct device *main_dev;	/* pointer to main device */
   struct net_alias_type *nat;	/* alias type object bound */
   struct net_alias *next;	/* next alias (hashed linked list) */
+  unsigned long rx_lookups;     /* 'fake' rx pkts */
+  unsigned long tx_lookups;     /* 'fake' tx pkts */
 };
 
 
@@ -58,8 +58,11 @@
 struct net_alias_info
 {
   int n_aliases;		/* num aliases */
+  int truesize;                 /* actual malloc size for struct + hashtab */
   struct device *taildev;	/* my last (alias) device */
-  struct net_alias *hash_tab[16]; /* hashed alias table */
+  int max_aliases;              /* max aliases allowed for main device */
+  unsigned hash_tab_size;       /* hash_tab size in elements */
+  struct net_alias *hash_tab[0]; /* hashed alias table */
 };
 
 /*
@@ -110,23 +113,42 @@
   return (dev->alias_info != NULL);
 }
 
-
+/*
+ *	Initialise net_alias module
+ */
 extern void net_alias_init(void);
 
+/*
+ *	dev_get() with added aliasing magic
+ */
 extern struct device * net_alias_dev_get(char *dev_name, int aliasing_ok, int *err, struct sockaddr *sa, void *data);
 extern int net_alias_dev_rehash(struct device *dev, struct sockaddr *sa);
 
+/*
+ *	PROC_FS entries
+ */
 extern int net_alias_getinfo(char *buf, char **, off_t , int , int );
 extern int net_alias_types_getinfo(char *buf, char **, off_t , int , int );
 
+/*
+ *	net_alias_type (address family) registration 
+ */
 extern int register_net_alias_type(struct net_alias_type *nat, int type);
 extern int unregister_net_alias_type(struct net_alias_type *nat);
 
+/*
+ *	get alias device _with_ specified address
+ */
 extern struct device * net_alias_dev_chk(struct device *main_dev, struct sockaddr *sa, int flags_on, int flags_off);
 extern struct device * net_alias_dev_chk32(struct device *main_dev, int family, __u32 addr32, int flags_on, int flags_off);
 
-extern struct device * net_alias_dev_rcv_sel(struct device *main_dev, struct sockaddr *sa_src, struct sockaddr *sa_dst);
-extern struct device * net_alias_dev_rcv_sel32(struct device *main_dev, int family, __u32 src, __u32 dst);
+/*
+ *	get 'closest' device to specified address (returns main_dev if
+ *	nothing better)
+ *	if succesfull, also increment rx stats.
+ */
+extern struct device * net_alias_dev_rx(struct device *main_dev, struct sockaddr *sa_src, struct sockaddr *sa_dst);
+extern struct device * net_alias_dev_rx32(struct device *main_dev, int family, __u32 src, __u32 dst);
 
 
 /*
@@ -167,6 +189,32 @@
   }
   pdev->next = nextdev;
   return nextdev;
+}
+
+/*
+ *	lookup counters (used for alias devices stats)
+ */
+static __inline__ void net_alias_inc_rx(struct net_alias *alias)
+{
+        if (alias != NULL) alias->rx_lookups++;
+}
+static __inline__ void net_alias_inc_tx(struct net_alias *alias)
+{
+        if (alias != NULL) alias->tx_lookups++;
+}
+
+/*
+ *	To be called when passing down a pkt, to _switch_ from alias device
+ *	to actual device, also incr. alias tx counter.
+ */
+static __inline__ struct device *net_alias_dev_tx(struct device *dev)
+{
+        struct net_alias *alias = dev->my_alias;
+        if (alias) {
+                net_alias_inc_tx(alias);
+                return alias->main_dev;
+        } 
+        return dev;
 }
 
 #endif  /* _NET_ALIAS_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov