Subject: Re: Last remaining insque / remque uses
To: Tom Spindler <dogcow@babymeat.com>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-net
Date: 10/24/2007 19:52:32
On Tue, 23 Oct 2007, Tom Spindler wrote:

> > 3 if_eon.c         eonrtrequest   269 remque(&el->el_qhdr);

> Given that many of these pieces of sh^W^W^Wlovely source files
> don't actually bother using 'struct queue', and far more often
> monkey around with the affected structures themselves - it might
> be better to just embed local copies of the routines into the
> affected sources. (As the defs are all of five lines of code each,
> I don't think it'd be a horrible burden.)

'options EON' brings in the eon code, which accounts for one of these
usages, patch below. It builds but I can't test it as I have no idea what
EON is. If it a) looks fine, or b) somebody can test then I'll commit
that.

(the list is otherwise unused, it could as easily be removed)

I was looking at the other netiso usages and yeah, that code is gangly..
how much effort is too much effort for this?

iain

--- /usr/src/sys/netiso/eonvar.h	2007-07-20 22:24:51.000000000 +0100
+++ eonvar.h	2007-10-23 21:40:09.000000000 +0100
@@ -159,18 +159,14 @@
 #undef IncStat
 #define IncStat(xxx) eonstat.xxx++

-typedef struct qhdr {
-	struct qhdr    *link, *rlink;
-}              *queue_t;
-
 struct eon_llinfo {
-	struct qhdr     el_qhdr;/* keep all in a list */
 	int             el_flags;	/* cache valid ? */
 	int             el_snpaoffset;	/* IP address contained in dst nsap */
 	struct rtentry *el_rt;	/* back pointer to parent route */
 	struct eon_iphdr el_ei;	/* precomputed portion of hdr */
 	struct route    el_iproute;	/* if direct route cache IP info */
 	/* if gateway, cache secondary route */
+	LIST_ENTRY(eon_llinfo) el_next;	/* next entry */
 };
 #define el_iphdr el_ei.ei_ip
 #define el_eonhdr el_ei.ei_eh
--- /usr/src/sys/netiso/if_eon.c	2007-09-05 22:23:55.000000000 +0100
+++ if_eon.c	2007-10-23 22:53:35.000000000 +0100
@@ -80,6 +80,7 @@
 #include <sys/mbuf.h>
 #include <sys/buf.h>
 #include <sys/protosw.h>
+#include <sys/queue.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/errno.h>
@@ -119,7 +120,7 @@
 	(void) eonattach();
 }

-struct eon_llinfo eon_llinfo;
+LIST_HEAD(eon_llhead, eon_llinfo) eon_llhead;
 #define PROBE_OK 0;


@@ -155,8 +156,7 @@
 	if_attach(ifp);
 	if_alloc_sadl(ifp);
 	eonioctl(ifp, SIOCSIFADDR, (void *) ifp->if_addrlist.tqh_first);
-	eon_llinfo.el_qhdr.link =
-		eon_llinfo.el_qhdr.rlink = &(eon_llinfo.el_qhdr);
+	LIST_INIT(&eon_llhead);

 #ifdef ARGO_DEBUG
 	if (argo_debug[D_EON]) {
@@ -266,7 +266,7 @@
 	switch (cmd) {
 	case RTM_DELETE:
 		if (el) {
-			remque(&el->el_qhdr);
+			LIST_REMOVE(el, el_next);
 			rtcache_free(&el->el_iproute);
 			Free(el);
 			rt->rt_llinfo = NULL;
@@ -281,7 +281,7 @@
 		if (el == NULL)
 			return;
 		memset(el, 0, sizeof(*el));
-		insque(&el->el_qhdr, &eon_llinfo.el_qhdr);
+		LIST_INSERT_HEAD(&eon_llhead, el, el_next);
 		el->el_rt = rt;
 		break;
 	}