Re: pppx(4) and a pppx interface group

2013-02-03 Thread Mattieu Baptiste
On Fri, Feb 1, 2013 at 10:17 PM, Stuart Henderson s...@spacehopper.orgwrote:

 In gmane.os.openbsd.misc, Mattieu Baptiste wrote:
  Hi,
 
  I'm testing npppd with pppx(4).
 
  As i'm understanding npppd, a new pppx(4) interface is created for every
  new session. Thus, new /dev/pppxN nodes must be created for the sessions
  that we intend to have.
 
  But at this point, filtering with PF needs special handling for every
  pppx(4) interface. How about adding these interfaces to a pppx
 interface
  group, by adding the if_addgroup() call ?
 
  What do you think ?

 This makes sense to me, and the diff below seems to work:



Hello Stuart,

Thanks, this works as expected.




 Index: if_pppx.c
 ===
 RCS file: /cvs/src/sys/net/if_pppx.c,v
 retrieving revision 1.15
 diff -u -p -r1.15 if_pppx.c
 --- if_pppx.c   19 Sep 2012 17:50:17 -  1.15
 +++ if_pppx.c   1 Feb 2013 21:15:47 -
 @@ -874,6 +874,7 @@ pppx_add_session(struct pppx_dev *pxd, s
 pipex_timer_start();

 if_attach(ifp);
 +   if_addgroup(ifp, pppx);
 if_alloc_sadl(ifp);

  #if NBPFILTER  0




-- 
Mattieu Baptiste
/earth is 102% full ... please delete anyone you can.


scsi_xfers and hand rolled queue.h type operations

2013-02-03 Thread David Gwynne
scsi_xfers have a thing in them for letting adapters store them on
lists via a LIST_ENTRY. turns out most adapters want SIMPLEQ type
operations, so they end up doing things by hand. LIST_ENTRYs and
SIMPLEQ_ENTRYs are the same size, so this is effectively just a
code simplification.

id appreciate it if a gdt user could test this for me. isp seems
to be fine so far.

ok?

Index: scsi/scsiconf.h
===
RCS file: /cvs/src/sys/scsi/scsiconf.h,v
retrieving revision 1.150
diff -u -p -r1.150 scsiconf.h
--- scsi/scsiconf.h 1 Jul 2012 01:41:13 -   1.150
+++ scsi/scsiconf.h 4 Feb 2013 04:24:40 -
@@ -390,7 +390,7 @@ struct scsi_attach_args {
  * (via the scsi_link structure)
  */
 struct scsi_xfer {
-   LIST_ENTRY(scsi_xfer) free_list;
+   SIMPLEQ_ENTRY(scsi_xfer) xfer_list;
int flags;
struct  scsi_link *sc_link; /* all about our device and adapter */
int retries;/* the number of times to retry */
@@ -414,6 +414,7 @@ struct scsi_xfer {
 
void *io;   /* adapter io resource */
 };
+SIMPLEQ_HEAD(scsi_xfer_list, scsi_xfer);
 
 /*
  * Per-request Flag values
Index: dev/ic/gdt_common.c
===
RCS file: /cvs/src/sys/dev/ic/gdt_common.c,v
retrieving revision 1.61
diff -u -p -r1.61 gdt_common.c
--- dev/ic/gdt_common.c 15 Aug 2012 02:38:14 -  1.61
+++ dev/ic/gdt_common.c 4 Feb 2013 04:24:40 -
@@ -129,7 +129,7 @@ gdt_attach(struct gdt_softc *sc)
TAILQ_INIT(sc-sc_free_ccb);
TAILQ_INIT(sc-sc_ccbq);
TAILQ_INIT(sc-sc_ucmdq);
-   LIST_INIT(sc-sc_queue);
+   SIMPLEQ_INIT(sc-sc_queue);
 
mtx_init(sc-sc_ccb_mtx, IPL_BIO);
scsi_iopool_init(sc-sc_iopool, sc, gdt_ccb_alloc, gdt_ccb_free);
@@ -517,14 +517,10 @@ gdt_eval_mapping(u_int32_t size, int *cy
 void
 gdt_enqueue(struct gdt_softc *sc, struct scsi_xfer *xs, int infront)
 {
-   if (infront || LIST_FIRST(sc-sc_queue) == NULL) {
-   if (LIST_FIRST(sc-sc_queue) == NULL)
-   sc-sc_queuelast = xs;
-   LIST_INSERT_HEAD(sc-sc_queue, xs, free_list);
-   return;
-   }
-   LIST_INSERT_AFTER(sc-sc_queuelast, xs, free_list);
-   sc-sc_queuelast = xs;
+   if (infront)
+   SIMPLEQ_INSERT_HEAD(sc-sc_queue, xs, xfer_list);
+   else
+   SIMPLEQ_INSERT_TAIL(sc-sc_queue, xs, xfer_list);
 }
 
 /*
@@ -535,13 +531,9 @@ gdt_dequeue(struct gdt_softc *sc)
 {
struct scsi_xfer *xs;
 
-   xs = LIST_FIRST(sc-sc_queue);
-   if (xs == NULL)
-   return (NULL);
-   LIST_REMOVE(xs, free_list);
-
-   if (LIST_FIRST(sc-sc_queue) == NULL)
-   sc-sc_queuelast = NULL;
+   xs = SIMPLEQ_FIRST(sc-sc_queue);
+   if (xs != NULL)
+   SIMPLEQ_REMOVE_HEAD(sc-sc_queue, xfer_list);
 
return (xs);
 }
@@ -584,7 +576,7 @@ gdt_scsi_cmd(struct scsi_xfer *xs)
}
 
/* Don't double enqueue if we came from gdt_chain. */
-   if (xs != LIST_FIRST(sc-sc_queue))
+   if (xs != SIMPLEQ_FIRST(sc-sc_queue))
gdt_enqueue(sc, xs, 0);
 
while ((xs = gdt_dequeue(sc)) != NULL) {
@@ -1307,8 +1299,8 @@ gdt_chain(struct gdt_softc *sc)
 {
GDT_DPRINTF(GDT_D_INTR, (gdt_chain(%p) , sc));
 
-   if (LIST_FIRST(sc-sc_queue))
-   gdt_scsi_cmd(LIST_FIRST(sc-sc_queue));
+   if (!SIMPLEQ_EMPTY(sc-sc_queue))
+   gdt_scsi_cmd(SIMPLEQ_FIRST(sc-sc_queue));
 }
 
 void
Index: dev/ic/gdtvar.h
===
RCS file: /cvs/src/sys/dev/ic/gdtvar.h,v
retrieving revision 1.21
diff -u -p -r1.21 gdtvar.h
--- dev/ic/gdtvar.h 15 Aug 2012 02:38:14 -  1.21
+++ dev/ic/gdtvar.h 4 Feb 2013 04:24:40 -
@@ -131,8 +131,7 @@ struct gdt_softc {
struct gdt_ccb sc_ccbs[GDT_MAXCMDS];
TAILQ_HEAD(, gdt_ccb) sc_free_ccb, sc_ccbq;
TAILQ_HEAD(, gdt_ucmd) sc_ucmdq;
-   LIST_HEAD(, scsi_xfer) sc_queue;
-   struct scsi_xfer *sc_queuelast;
+   struct scsi_xfer_list sc_queue;
 
struct mutexsc_ccb_mtx;
struct scsi_iopool  sc_iopool;
Index: dev/ic/isp_openbsd.c
===
RCS file: /cvs/src/sys/dev/ic/isp_openbsd.c,v
retrieving revision 1.47
diff -u -p -r1.47 isp_openbsd.c
--- dev/ic/isp_openbsd.c22 Oct 2011 19:34:06 -  1.47
+++ dev/ic/isp_openbsd.c4 Feb 2013 04:24:40 -
@@ -103,7 +103,7 @@ isp_attach(struct ispsoftc *isp)
 * We only manage a single wait queues for dual bus controllers.
 * This is arguably broken.
 */
-   isp-isp_osinfo.wqf = isp-isp_osinfo.wqt = NULL;
+   SIMPLEQ_INIT(isp-isp_osinfo.wq);
 
lptr-adapter_softc = isp;
lptr-adapter = isp-isp_osinfo._adapter;
@@ -276,13 +276,7 @@