octcf(4/octeon): switch disksort() to bufqs

2013-10-31 Thread David Gwynne
jmatthew@ tells me this compiles, but we dont have hardware to test
with.

tests? oks? go for its?

cheers,
dlg

Index: octcf.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/octcf.c,v
retrieving revision 1.12
diff -u -p -r1.12 octcf.c
--- octcf.c 11 Jun 2013 16:42:10 -  1.12
+++ octcf.c 31 Oct 2013 06:32:11 -
@@ -111,7 +111,7 @@ struct octcf_softc {
/* General disk infos */
struct device sc_dev;
struct disk sc_dk;
-   struct buf sc_q;
+   struct bufq sc_bufq;
struct buf *sc_bp;
struct ataparams sc_params;/* drive characteristics found */
int sc_flags;
@@ -260,6 +260,7 @@ octcfattach(struct device *parent, struc
 * Initialize disk structures.
 */
wd-sc_dk.dk_name = wd-sc_dev.dv_xname;
+   bufq_init(wd-sc_bufq, BUFQ_DEFAULT);
 
/* Attach disk. */
disk_attach(wd-sc_dev, wd-sc_dk);
@@ -326,9 +327,11 @@ octcfstrategy(struct buf *bp)
goto bad;
}
 
+   /* Queue the I/O */
+   bufq_queue(wd-sc_bufq, bp);
+
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
-   disksort(wd-sc_q, bp);
octcfstart(wd);
splx(s);
device_unref(wd-sc_dev);
@@ -352,18 +355,11 @@ void
 octcfstart(void *arg)
 {
struct octcf_softc *wd = arg;
-   struct buf *dp, *bp;
+   struct buf *bp;
 
OCTCFDEBUG_PRINT((%s %s\n, __func__, wd-sc_dev.dv_xname),
DEBUG_XFERS);
-   while (1) {
-   /* Remove the next buffer from the queue or stop. */
-   dp = wd-sc_q;
-   bp = dp-b_actf;
-   if (bp == NULL)
-   return;
-   dp-b_actf = bp-b_actf;
-
+   while ((bp = bufq_dequeue(wd-sc_bufq)) != NULL) {
/* Transfer this buffer now. */
_octcfstart(wd, bp);
}



Re: kernel route 64 bit expire time

2013-10-31 Thread Gregory Edigarov

On 10/15/2013 01:43 AM, Alexander Bluhm wrote:

Hi,

Convert the route expire timestamp in kernel and routing message
to 64 bit.  Add a small compatibility layer that allows to set
routes with old user land and new kernel.

ok?


just out for curiosity, shouldn't the expire time be u_int64_t?

--
With best regards,
 Gregory Edigarov



Re: kernel route 64 bit expire time

2013-10-31 Thread Alexander Bluhm
On Thu, Oct 31, 2013 at 11:44:12AM +0200, Gregory Edigarov wrote:
 On 10/15/2013 01:43 AM, Alexander Bluhm wrote:
 Hi,
 
 Convert the route expire timestamp in kernel and routing message
 to 64 bit.  Add a small compatibility layer that allows to set
 routes with old user land and new kernel.
 
 ok?
 
 just out for curiosity, shouldn't the expire time be u_int64_t?

Internally in the kernel rmx_expire is assigned from and compared
with time_second.  This variable is time_t which is __int64_t which
is a signed long long.

So signed is the better type.

bluhm



Re: octcf(4/octeon): switch disksort() to bufqs

2013-10-31 Thread Brian Callahan

On 10/31/2013 2:33 AM, David Gwynne wrote:

jmatthew@ tells me this compiles, but we dont have hardware to test
with.

tests? oks? go for its?



I'll run a test on my CAM-0100 later today.


cheers,
dlg

Index: octcf.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/octcf.c,v
retrieving revision 1.12
diff -u -p -r1.12 octcf.c
--- octcf.c 11 Jun 2013 16:42:10 -  1.12
+++ octcf.c 31 Oct 2013 06:32:11 -
@@ -111,7 +111,7 @@ struct octcf_softc {
/* General disk infos */
struct device sc_dev;
struct disk sc_dk;
-   struct buf sc_q;
+   struct bufq sc_bufq;
struct buf *sc_bp;
struct ataparams sc_params;/* drive characteristics found */
int sc_flags;
@@ -260,6 +260,7 @@ octcfattach(struct device *parent, struc
 * Initialize disk structures.
 */
wd-sc_dk.dk_name = wd-sc_dev.dv_xname;
+   bufq_init(wd-sc_bufq, BUFQ_DEFAULT);

/* Attach disk. */
disk_attach(wd-sc_dev, wd-sc_dk);
@@ -326,9 +327,11 @@ octcfstrategy(struct buf *bp)
goto bad;
}

+   /* Queue the I/O */
+   bufq_queue(wd-sc_bufq, bp);
+
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
-   disksort(wd-sc_q, bp);
octcfstart(wd);
splx(s);
device_unref(wd-sc_dev);
@@ -352,18 +355,11 @@ void
  octcfstart(void *arg)
  {
struct octcf_softc *wd = arg;
-   struct buf *dp, *bp;
+   struct buf *bp;

OCTCFDEBUG_PRINT((%s %s\n, __func__, wd-sc_dev.dv_xname),
DEBUG_XFERS);
-   while (1) {
-   /* Remove the next buffer from the queue or stop. */
-   dp = wd-sc_q;
-   bp = dp-b_actf;
-   if (bp == NULL)
-   return;
-   dp-b_actf = bp-b_actf;
-
+   while ((bp = bufq_dequeue(wd-sc_bufq)) != NULL) {
/* Transfer this buffer now. */
_octcfstart(wd, bp);
}





pflow in rdomain

2013-10-31 Thread Anders Berggren
We tried to get pflow running in a non-default rdomain, and found this to get 
it going. Make sense?

--- sys/net/if_pflow.c.orig Fri Sep 13 20:58:40 2013
+++ sys/net/if_pflow.c  Mon Sep 16 13:25:54 2013
@@ -1213,6 +1213,8 @@
sc-sc_if.if_opackets++;
sc-sc_if.if_obytes += m-m_pkthdr.len;
 
+   m-m_pkthdr.rdomain = sc-sc_if.if_rdomain;
+
if ((err = ip_output(m, NULL, NULL, IP_RAWOUTPUT, sc-sc_imo, NULL))) {
pflowstats.pflow_oerrors++;
sc-sc_if.if_oerrors++;



Re: unlimited HFSC v4: against -current with deferred pushing

2013-10-31 Thread Theo de Raadt
 +
 +/* XXX hack, because we need the structure definition */
 +#define ALTQ_IS_ENABLED  1
 +#include net/hfsc.h
 +#undef ALTQ_IS_ENABLED
 +/* XXX hack */
 +

Over my dead body.

If everyone needed a hack like that, we'd be in big trouble.  Please
refactor the code so that you don't need to do that.



Re: kernel route 64 bit expire time

2013-10-31 Thread Theo de Raadt
  Convert the route expire timestamp in kernel and routing message
  to 64 bit.  Add a small compatibility layer that allows to set
  routes with old user land and new kernel.
 
  ok?
 
 just out for curiosity, shouldn't the expire time be u_int64_t?

It seems such a simple concept.

It should never be signed, so let's just treat it as unsigned.

Except if it goes unsigned, the same problems develop as if when it
is signed.

So the rule remains the same.  This is the same mess that happened
with ssize_t and size_t.  A better rule would have been to restrict
both sizes to the same limit.  But no. we assume people can be
careful, or the little 'u' which avoids a warning will make things
better



Re: in6_leavegroup work queue

2013-10-31 Thread Alexander Bluhm
On Thu, Oct 31, 2013 at 09:56:11AM +0100, Martin Pieuchot wrote:
 On 30/10/13(Wed) 16:48, Alexander Bluhm wrote:
  Now I use the if_index to detect that the interface is gone.
 
 Do you know if the memory pointed by the imm pointer you're passing to
 your workq can be freed before the task got scheduled, if the interface
 is removed/destroyed for example?

I am pretty sure that this works.  The old in6_leavegroup() code
called free on it, so it must not be referenced anywhere else.  All
imm pointer come from the ia6_memberships list, it is emptied while
calling in6_leavegroup().

 There's also a risk of calling in6_leavegroup() a second time before the
 first task get scheduled, in this case the second task will have a bogus
 imm pointer.  This problem can be avoided by using a task(9) though. 

in6_leavegroup() is only called once per imm as it is the in6_multi_mship
free function.

Note that struct in6_multi has a reference counter, so imm-i6mm_maddr
should be valid memory.  Also in6_delmulti() itself calls splsoftnet()
so there never was protection against timeout or softnet interrupts
calling in6_leavegroup() again.

 I'm not sure to get the whole picture about this ioctl called in an
 interrupt context so feel free to correct me, but the only offending
 function is nd6_timer(), is that right?

No, this code is also called from softnet interrupt context.  An
autoconfigured IPv6 address can deleted by a timeout or by a router
advertisement.

nd6_ra_input() - prelist_update() - nd6_prelist_add() -
purge_detached() - in6_purgeaddr() - in6_leavegroup()

In theory we can ignore the incomming packet, we may always loose
packets and hope for a retransmit.  But that would mean to avoid
the sleep and do a rollback.  That would be a horrible diff.

 Finally since we are moving away from workq(9) to task(9) I'd suggest
 you to use the latter.

That is easy, but it does not solve the problems you describe.  I
have to call task_set() in in6_leavegroup() to set the if_index.
May be calling task_set() can be moved to somewhere else but that
does not look easy.

I am still not happy with this diff although I think it does not
cause memory corruption.  Look at this call path:

if_detach() - in6_ifdetach() - in6_purgeaddr() - in6_leavegroup()

As I delay the SIOCDELMULTI after the interface is destroyed,
the ioctl is never called.

Perhaps we look at the problem from the wrong direction.  Why do
some network drivers sleep when changing multicast groups?  Did
they always do that or was something changed?

bluhm

Index: netinet6/in6.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.122
diff -u -p -r1.122 in6.c
--- netinet6/in6.c  24 Oct 2013 11:20:18 -  1.122
+++ netinet6/in6.c  31 Oct 2013 14:40:05 -
@@ -124,6 +124,7 @@ int in6_lifaddr_ioctl(struct socket *, u
 int in6_ifinit(struct ifnet *, struct in6_ifaddr *, int);
 void in6_unlink_ifa(struct in6_ifaddr *, struct ifnet *);
 void in6_ifloop_request(int, struct ifaddr *);
+void in6_leavegroup_task(void *, void *);
 
 const struct sockaddr_in6 sa6_any = {
sizeof(sa6_any), AF_INET6, 0, 0, IN6ADDR_ANY_INIT, 0
@@ -1777,16 +1778,18 @@ in6_delmulti(struct in6_multi *in6m)
ifafree(in6m-in6m_ia-ia_ifa); /* release reference */
}
 
-   /*
-* Notify the network driver to update its multicast
-* reception filter.
-*/
-   bzero(ifr.ifr_addr, sizeof(struct sockaddr_in6));
-   ifr.ifr_addr.sin6_len = sizeof(struct sockaddr_in6);
-   ifr.ifr_addr.sin6_family = AF_INET6;
-   ifr.ifr_addr.sin6_addr = in6m-in6m_addr;
-   (*in6m-in6m_ifp-if_ioctl)(in6m-in6m_ifp,
-   SIOCDELMULTI, (caddr_t)ifr);
+   if (in6m-in6m_ifp != NULL) {
+   /*
+* Notify the network driver to update its multicast
+* reception filter.
+*/
+   bzero(ifr.ifr_addr, sizeof(struct sockaddr_in6));
+   ifr.ifr_addr.sin6_len = sizeof(struct sockaddr_in6);
+   ifr.ifr_addr.sin6_family = AF_INET6;
+   ifr.ifr_addr.sin6_addr = in6m-in6m_addr;
+   (*in6m-in6m_ifp-if_ioctl)(in6m-in6m_ifp,
+   SIOCDELMULTI, (caddr_t)ifr);
+   }
free(in6m, M_IPMADDR);
}
splx(s);
@@ -1814,11 +1817,27 @@ in6_joingroup(struct ifnet *ifp, struct 
 int
 in6_leavegroup(struct in6_multi_mship *imm)
 {
+   if (imm-i6mm_maddr) {
+   task_set(imm-i6mm_task, in6_leavegroup_task, imm,
+   (void *)(unsigned long)imm-i6mm_maddr-in6m_ifp-if_index);
+   task_add(systq, imm-i6mm_task);
+   } else
+   free(imm,  

remove some altq references from manuals

2013-10-31 Thread Arto Jonsson
Index: sbin/iked/iked.conf.5
===
RCS file: /cvs/src/sbin/iked/iked.conf.5,v
retrieving revision 1.25
diff -u -p -r1.25 iked.conf.5
--- sbin/iked/iked.conf.5   16 Jul 2013 09:45:28 -  1.25
+++ sbin/iked/iked.conf.5   19 Oct 2013 16:34:48 -
@@ -624,17 +624,16 @@ The following
 fragment uses queues for all IPsec traffic with special
 handling for developers and employees:
 .Bd -literal -offset indent
-altq on ix0 cbq bandwidth 1000Mb \e
-   queue { deflt, developers, employees, ipsec }
-queue deflt bandwidth 10% priority 0 cbq(default ecn)
-queue developers bandwidth 75% priority 7 cbq(borrow red)
-queue employees bandwidth 5% cbq(red)
-queue ipsec bandwidth 10% cbq(red)
+queue std on ix0 bandwidth 100M
+queue   deflt parent std bandwidth 10M default
+queue   developers parent std bandwidth 75M
+queue   employees parent std bandwidth 5M
+queue   ipsec parent std bandwidth 10M
 
-pass out on ix0 proto esp queue ipsec
+pass out on ix0 proto esp set queue ipsec
 
-pass out on ix0 tagged ipsec-developers.example.com queue developers
-pass out on ix0 tagged ipsec-employees.example.com queue employees
+pass out on ix0 tagged ipsec-developers.example.com set queue developers
+pass out on ix0 tagged ipsec-employees.example.com set queue employees
 .Ed
 .Pp
 The following example assigns the tags in the
Index: sbin/ipsecctl/ipsec.conf.5
===
RCS file: /cvs/src/sbin/ipsecctl/ipsec.conf.5,v
retrieving revision 1.143
diff -u -p -r1.143 ipsec.conf.5
--- sbin/ipsecctl/ipsec.conf.5  29 Jun 2013 09:08:41 -  1.143
+++ sbin/ipsecctl/ipsec.conf.5  19 Oct 2013 16:34:48 -
@@ -544,17 +544,16 @@ The following
 fragment uses queues for all IPsec traffic with special
 handling for developers and employees:
 .Bd -literal -offset indent
-altq on sk0 cbq bandwidth 1000Mb \e
-   queue { deflt, developers, employees, ipsec }
-queue deflt bandwidth 10% priority 0 cbq(default ecn)
-queue developers bandwidth 75% priority 7 cbq(borrow red)
-queue employees bandwidth 5% cbq(red)
-queue ipsec bandwidth 10% cbq(red)
+queue std on sk0 bandwidth 100M
+queue   deflt parent std bandwidth 10M default
+queue   developers parent std bandwidth 75M
+queue   employees parent std bandwidth 5M
+queue   ipsec parent std bandwidth 10M
 
-pass out on sk0 proto esp queue ipsec
+pass out on sk0 proto esp set queue ipsec
 
-pass out on sk0 tagged ipsec-developers.bar.org queue developers
-pass out on sk0 tagged ipsec-employees.bar.org queue employees
+pass out on sk0 tagged ipsec-developers.bar.org set queue developers
+pass out on sk0 tagged ipsec-employees.bar.org set queue employees
 .Ed
 .Pp
 The tags will be assigned by the following
Index: usr.bin/systat/systat.1
===
RCS file: /cvs/src/usr.bin/systat/systat.1,v
retrieving revision 1.96
diff -u -p -r1.96 systat.1
--- usr.bin/systat/systat.1 7 Sep 2013 11:43:50 -   1.96
+++ usr.bin/systat/systat.1 19 Oct 2013 16:34:56 -
@@ -376,9 +376,8 @@ Available orderings are:
 and
 .Ic number of pages .
 .It Ic queues
-Display statistics about the active
-.Xr altq 9
-queues, similar to the output of
+Display statistics about the active queues,
+similar to the output of
 .Cm pfctl Fl s Cm queue .
 .It Ic rules
 Display pf rules statistics, similar to the output of



Re: octcf(4/octeon): switch disksort() to bufqs

2013-10-31 Thread Brian Callahan

On 10/31/2013 10:49 AM, Brian Callahan wrote:

On 10/31/2013 2:33 AM, David Gwynne wrote:

jmatthew@ tells me this compiles, but we dont have hardware to test
with.

tests? oks? go for its?



I'll run a test on my CAM-0100 later today.



tests good. ok.


cheers,
dlg

Index: octcf.c
===
RCS file: /cvs/src/sys/arch/octeon/dev/octcf.c,v
retrieving revision 1.12
diff -u -p -r1.12 octcf.c
--- octcf.c11 Jun 2013 16:42:10 -1.12
+++ octcf.c31 Oct 2013 06:32:11 -
@@ -111,7 +111,7 @@ struct octcf_softc {
  /* General disk infos */
  struct device sc_dev;
  struct disk sc_dk;
-struct buf sc_q;
+struct bufq sc_bufq;
  struct buf *sc_bp;
  struct ataparams sc_params;/* drive characteristics found */
  int sc_flags;
@@ -260,6 +260,7 @@ octcfattach(struct device *parent, struc
   * Initialize disk structures.
   */
  wd-sc_dk.dk_name = wd-sc_dev.dv_xname;
+bufq_init(wd-sc_bufq, BUFQ_DEFAULT);

  /* Attach disk. */
  disk_attach(wd-sc_dev, wd-sc_dk);
@@ -326,9 +327,11 @@ octcfstrategy(struct buf *bp)
  goto bad;
  }

+/* Queue the I/O */
+bufq_queue(wd-sc_bufq, bp);
+
  /* Queue transfer on drive, activate drive and controller if
idle. */
  s = splbio();
-disksort(wd-sc_q, bp);
  octcfstart(wd);
  splx(s);
  device_unref(wd-sc_dev);
@@ -352,18 +355,11 @@ void
  octcfstart(void *arg)
  {
  struct octcf_softc *wd = arg;
-struct buf *dp, *bp;
+struct buf *bp;

  OCTCFDEBUG_PRINT((%s %s\n, __func__, wd-sc_dev.dv_xname),
  DEBUG_XFERS);
-while (1) {
-/* Remove the next buffer from the queue or stop. */
-dp = wd-sc_q;
-bp = dp-b_actf;
-if (bp == NULL)
-return;
-dp-b_actf = bp-b_actf;
-
+while ((bp = bufq_dequeue(wd-sc_bufq)) != NULL) {
  /* Transfer this buffer now. */
  _octcfstart(wd, bp);
  }