svn commit: r190713 - head/sbin/routed

Poul-Henning Kamp phk at FreeBSD.org
Sun Apr 5 08:06:02 PDT 2009


Author: phk
Date: Sun Apr  5 15:06:02 2009
New Revision: 190713
URL: http://svn.freebsd.org/changeset/base/190713

Log:
  Convert list of remote interfaces to LIST_* macros

Modified:
  head/sbin/routed/defs.h
  head/sbin/routed/if.c
  head/sbin/routed/input.c

Modified: head/sbin/routed/defs.h
==============================================================================
--- head/sbin/routed/defs.h	Sun Apr  5 14:15:05 2009	(r190712)
+++ head/sbin/routed/defs.h	Sun Apr  5 15:06:02 2009	(r190713)
@@ -264,9 +264,9 @@ struct rt_entry {
  */
 struct interface {
 	LIST_ENTRY(interface)		int_list;
+	LIST_ENTRY(interface)		remote_list;
 	struct interface *int_ahash, **int_ahash_prev;
 	struct interface *int_bhash, **int_bhash_prev;
-	struct interface *int_rlink, **int_rlink_prev;
 	struct interface *int_nhash, **int_nhash_prev;
 	char	int_name[IF_NAME_LEN+1];
 	u_short	int_index;
@@ -486,7 +486,7 @@ extern naddr	loopaddr;		/* our address o
 extern int	tot_interfaces;		/* # of remote and local interfaces */
 extern int	rip_interfaces;		/* # of interfaces doing RIP */
 extern struct ifhead ifnet;		/* all interfaces */
-extern struct interface *remote_if;	/* remote interfaces */
+extern struct ifhead remote_if;		/* remote interfaces */
 extern int	have_ripv1_out;		/* have a RIPv1 interface */
 extern int	have_ripv1_in;
 extern int	need_flash;		/* flash update needed */

Modified: head/sbin/routed/if.c
==============================================================================
--- head/sbin/routed/if.c	Sun Apr  5 14:15:05 2009	(r190712)
+++ head/sbin/routed/if.c	Sun Apr  5 15:06:02 2009	(r190713)
@@ -42,6 +42,7 @@ __RCSID("$Revision: 2.27 $");
 #endif
 
 struct ifhead ifnet = LIST_HEAD_INITIALIZER(ifnet);	/* all interfaces */
+struct ifhead remote_if = LIST_HEAD_INITIALIZER(ifnet);	/* remote interfaces */
 
 /* hash table for all interfaces, big enough to tolerate ridiculous
  * numbers of IP aliases.  Crazy numbers of aliases such as 7000
@@ -56,7 +57,6 @@ struct interface *ahash_tbl[AHASH_LEN];
 #define BHASH(a) &bhash_tbl[(a)%BHASH_LEN]
 struct interface *bhash_tbl[BHASH_LEN];
 
-struct interface *remote_if;		/* remote interfaces */
 
 /* hash for physical interface names.
  * Assume there are never more 100 or 200 real interfaces, and that
@@ -117,13 +117,8 @@ if_link(struct interface *ifp)
 		*hifp = ifp;
 	}
 
-	if (ifp->int_state & IS_REMOTE) {
-		ifp->int_rlink_prev = &remote_if;
-		ifp->int_rlink = remote_if;
-		if (remote_if != 0)
-			remote_if->int_rlink_prev = &ifp->int_rlink;
-		remote_if = ifp;
-	}
+	if (ifp->int_state & IS_REMOTE)
+		LIST_INSERT_HEAD(&remote_if, ifp, remote_list);
 
 	hifp = nhash(ifp->int_name);
 	if (ifp->int_state & IS_ALIAS) {
@@ -467,11 +462,8 @@ ifdel(struct interface *ifp)
 		if (ifp->int_bhash != 0)
 			ifp->int_bhash->int_bhash_prev = ifp->int_bhash_prev;
 	}
-	if (ifp->int_state & IS_REMOTE) {
-		*ifp->int_rlink_prev = ifp->int_rlink;
-		if (ifp->int_rlink != 0)
-			ifp->int_rlink->int_rlink_prev = ifp->int_rlink_prev;
-	}
+	if (ifp->int_state & IS_REMOTE)
+		LIST_REMOVE(ifp, remote_list);
 
 	if (!(ifp->int_state & IS_ALIAS)) {
 		/* delete aliases when the main interface dies

Modified: head/sbin/routed/input.c
==============================================================================
--- head/sbin/routed/input.c	Sun Apr  5 14:15:05 2009	(r190712)
+++ head/sbin/routed/input.c	Sun Apr  5 15:06:02 2009	(r190713)
@@ -96,7 +96,7 @@ read_rip(int sock,
 			       cc+sizeof(inbuf.ifname));
 
 		/* check the remote interfaces first */
-		for (aifp = remote_if; aifp; aifp = aifp->int_rlink) {
+		LIST_FOREACH(aifp, &remote_if, remote_list) {
 			if (aifp->int_addr == from.sin_addr.s_addr)
 				break;
 		}


More information about the svn-src-head mailing list