Re: two minor carp and pfsync fixes

2011-06-22 Thread Stefan Rinkes
On Tue, Jun 21, 2011 at 9:42 PM, Tobias Weingartner weing...@tepid.org
wrote:
 On Tue, Jun 21, 2011 at 11:52 AM, Stefan Rinkes
 stefan.rin...@googlemail.com wrote:

 while playing around with carp and pfsync I spotted
 two minor bugs.

 1. Not all pfstate flags are synced, cause pfsync uses
u_int8_t, while pf uses u_int16_t for state_flags.
Currently that means PFSTATE_SCRUB_TCP flags don't
get synced.

 retrieving revision 1.333
 diff -u -p -r1.333 pfvar.h
 --- sys/net/pfvar.h 20 Jun 2011 19:03:41 -  1.333
 +++ sys/net/pfvar.h 21 Jun 2011 17:33:31 -
 @@ -892,13 +892,13 @@ struct pfsync_state {
u_int8_t proto;
u_int8_t direction;
u_int8_t log;
 -   u_int8_t state_flags;
 +   u_int16_tstate_flags;
u_int8_t timeout;
u_int8_t sync_flags;
u_int8_t updates;
u_int8_t min_ttl;
u_int8_t set_tos;
 -   u_int8_t pad[4];
 +   u_int8_t pad[3];
  } __packed;

 Does this change the on-wire format?  Also, would the state_flags need to
 have htons/ntohs done to it?

 -Toby.


Hi,

I tested this diff quite carefully and used it for over a week now and
checked that all
state_flags are synced by adding a new flag which triggered a printf in pf(4)
:)

No issues/crashes have been seen so far.

Stefan



Re: two minor carp and pfsync fixes

2011-06-22 Thread Otto Moerbeek
On Wed, Jun 22, 2011 at 09:37:58AM +0200, Stefan Rinkes wrote:

 On Tue, Jun 21, 2011 at 9:42 PM, Tobias Weingartner weing...@tepid.org
 wrote:
  On Tue, Jun 21, 2011 at 11:52 AM, Stefan Rinkes
  stefan.rin...@googlemail.com wrote:
 
  while playing around with carp and pfsync I spotted
  two minor bugs.
 
  1. Not all pfstate flags are synced, cause pfsync uses
 u_int8_t, while pf uses u_int16_t for state_flags.
 Currently that means PFSTATE_SCRUB_TCP flags don't
 get synced.
 
  retrieving revision 1.333
  diff -u -p -r1.333 pfvar.h
  --- sys/net/pfvar.h 20 Jun 2011 19:03:41 -  1.333
  +++ sys/net/pfvar.h 21 Jun 2011 17:33:31 -
  @@ -892,13 +892,13 @@ struct pfsync_state {
 u_int8_t proto;
 u_int8_t direction;
 u_int8_t log;
  -   u_int8_t state_flags;
  +   u_int16_tstate_flags;
 u_int8_t timeout;
 u_int8_t sync_flags;
 u_int8_t updates;
 u_int8_t min_ttl;
 u_int8_t set_tos;
  -   u_int8_t pad[4];
  +   u_int8_t pad[3];
   } __packed;
 
  Does this change the on-wire format?  Also, would the state_flags need to
  have htons/ntohs done to it?
 
  -Toby.
 
 
 Hi,
 
 I tested this diff quite carefully and used it for over a week now and
 checked that all
 state_flags are synced by adding a new flag which triggered a printf in pf(4)
 :)
 
 No issues/crashes have been seen so far.
 
 Stefan

You didn'ty answer the questions...

What Tobias is asking is:

- will the break compatibility between an old and an updated machine
- will this break compatiblity between machines with different byte order? 

I suspect the answer will be 'yes' to both questions. So while the
initial observation is good, the work to fix it is not done yet.

-Otto



Re: wol for xl(4)

2011-06-22 Thread Thomas Gerlach
For me it works as well. :)

Just two more little flaws:

1) If you configure WOL inside /etc/hostname.if, then you get the following
error message during booting:

xl0: command never completed!
xl0: transmission error: ff

and you're not able to login. the problem is:
xl_init is called first, which makes a call to xl_stop. and xl_stop calls
xl_pci_power, which tries to bring the IF into D3 powerstate. more precisely,
the pci_conf_write routine is not able to set the XL_PSTATE_D3 bit (however,
it can set the XL_PME_ENABLE bit. i checked by setting just one of them.)

the initial disable mechanism of xl_attach doesn't work, since xl_init is
called _before_ xl_attach.

2) it would be nice if we push the wol setting stuff inside ONE routine, rather
than spreading it over several ones (that is, all the CSR_WRITE stuff together
into xl_pci_power.

i'm currently working on it...but maybe, stefan might be faster than me again
(if he wants to...). ;)

cheers



Re: wol for xl(4)

2011-06-22 Thread Thomas Gerlach
as for the pulling toghether, i would suggest something like this (draft,
patches against latest -current files, _without_ stefan's recent patches):

# diff -u xl.c.orig xl.c  xl.c.patch1

--- xl.c.orig   Sun Apr 17 22:52:43 2011
+++ xl.cWed Jun 22 11:53:45 2011
@@ -2373,8 +2373,9 @@
xl_freetxrx(sc);
 
 #ifndef SMALL_KERNEL
-   /* Call upper layer WOL power routine if WOL is enabled. */
-   if ((sc-xl_flags  XL_FLAG_WOL)  sc-wol_power)
+   /* Re-enable RX and call upper layer WOL power routine
+* if WOL power callback is registered. */
+   if (sc-wol_power)
sc-wol_power(sc-wol_power_arg);
 #endif
 }
@@ -2646,6 +2647,7 @@
CSR_WRITE_2(sc, XL_W0_MFG_ID, XL_NO_XCVR_PWR_MAGICBITS);
}
 
+#if 1
 #ifndef SMALL_KERNEL
/* Check availability of WOL. */
if ((sc-xl_caps  XL_CAPS_PWRMGMT) != 0) {
@@ -2654,6 +2656,7 @@
xl_wol(ifp, 0);
}
 #endif
+#endif
 
/*
 * Call MI attach routines.
@@ -2693,12 +2696,9 @@
 {
struct xl_softc *sc = ifp-if_softc;
 
-   XL_SEL_WIN(7);
if (enable) {
-   CSR_WRITE_2(sc, XL_W7_BM_PME, XL_BM_PME_MAGIC);
sc-xl_flags |= XL_FLAG_WOL;
} else {
-   CSR_WRITE_2(sc, XL_W7_BM_PME, 0);
sc-xl_flags = ~XL_FLAG_WOL;
}
return (0); 


# diff -u if_xl_pci.c.orig if_xl_pci.c  if_xl_pci.c.patch1

--- if_xl_pci.c.origSun Apr 17 22:52:43 2011
+++ if_xl_pci.c Wed Jun 22 11:53:06 2011
@@ -266,18 +266,6 @@
pci_conf_write(pc, pa-pa_tag, XL_PCI_LOMEM, mem);
pci_conf_write(pc, pa-pa_tag, XL_PCI_INTLINE, irq);
}
-
-#ifndef SMALL_KERNEL
-   /* The card is WOL-capable if it supports PME# assertion
-* from D3hot power state. Install a callback to configure
-* PCI power state for WOL. It will be invoked when the
-* interface stops and WOL was enabled. */
-   command = pci_conf_read(pc, pa-pa_tag, XL_PCI_PWRMGMTCAP);
-   if (command  XL_PME_CAP_D3_HOT) {
-   sc-wol_power = xl_pci_wol_power;
-   sc-wol_power_arg = psc; 
-   }
-#endif
}
 
/*
@@ -335,6 +323,16 @@
printf(: %s, intrstr);
 
xl_attach(sc);
+
+#ifndef SMALL_KERNEL
+   /* If the card is WOL-capable install a callback to configure
+* PCI power state for WOL. It will be invoked when the
+* interface stops and WOL was enabled. */
+   if (sc-xl_caps  XL_CAPS_PWRMGMT) {
+   sc-wol_power = xl_pci_wol_power;
+   sc-wol_power_arg = psc; 
+   }
+#endif
 }
 
 int
@@ -367,6 +365,22 @@
 {
u_int32_t   command;
struct xl_pci_softc *psc = (struct xl_pci_softc*)ppsc;
+   struct xl_softc *sc = psc-psc_softc;
+
+   XL_SEL_WIN(7);
+
+   /* Clear any pending PME events. */
+   CSR_READ_2(sc, XL_W7_BM_PME);
+
+   /* If WOL flag is not set make sure PME is disabled, and
+* return without doing anything. */
+   if ((sc-xl_flags  XL_FLAG_WOL) == 0) {
+   CSR_WRITE_2(sc, XL_W7_BM_PME, 0);
+   return;
+   }
+
+   CSR_WRITE_2(sc, XL_W7_BM_PME, XL_BM_PME_MAGIC);
+   CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_ENABLE);
 
/* Make sure power management is enabled, and set the card into
 * D3hot power state so it stays active after system shutdown. */



bridge diff needs testing

2011-06-22 Thread Bret S. Lambert
The following diff replaces the existing hash table with a red black
tree, to the acclaim of network hackers worldwide.

This has already received some testing, but needs some more shakedown
in order to make sure that nobody gets hosed by this. Folks with
more esoteric (read: vether and/or gif) setups are especially encouraged
to test, and may receive cookies.

- Bert

Index: if_bridge.h
===
RCS file: /cvs/src/sys/net/if_bridge.h,v
retrieving revision 1.32
diff -u -p -r1.32 if_bridge.h
--- if_bridge.h 28 Oct 2010 13:49:54 -  1.32
+++ if_bridge.h 29 Oct 2010 19:45:38 -
@@ -397,7 +397,7 @@ struct bridge_iflist {
  * Bridge route node
  */
 struct bridge_rtnode {
-   LIST_ENTRY(bridge_rtnode)   brt_next;   /* next in list */
+   RB_ENTRY(bridge_rtnode) brt_entry;  /* entry in rb tree */
struct  ifnet *brt_if;  /* destination ifs */
u_int8_tbrt_flags;  /* address flags */
u_int8_tbrt_age;/* age counter */
@@ -423,7 +423,7 @@ struct bridge_softc {
struct timeout  sc_brtimeout;   /* timeout state */
struct bstp_state   *sc_stp;/* stp state */
LIST_HEAD(, bridge_iflist)  sc_iflist;  /* interface list */
-   LIST_HEAD(, bridge_rtnode)  sc_rts[BRIDGE_RTABLE_SIZE]; /* hash 
table */
+   RB_HEAD(brt_tree, bridge_rtnode) sc_rts;/* route tree */
LIST_HEAD(, bridge_iflist)  sc_spanlist;/* span ports */
 };
 
Index: if_bridge.c
===
RCS file: /cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.186
diff -u -p -r1.186 if_bridge.c
--- if_bridge.c 28 Oct 2010 19:00:57 -  1.186
+++ if_bridge.c 29 Oct 2010 19:45:38 -
@@ -45,6 +45,7 @@
 #include sys/ioctl.h
 #include sys/errno.h
 #include sys/kernel.h
+#include sys/tree.h
 #include machine/cpu.h
 
 #include net/if.h
@@ -135,7 +136,7 @@ int bridge_rtfind(struct bridge_softc *,
 void   bridge_rtage(struct bridge_softc *);
 void   bridge_rttrim(struct bridge_softc *);
 intbridge_rtdaddr(struct bridge_softc *, struct ether_addr *);
-intbridge_rtflush(struct bridge_softc *, int);
+void   bridge_rtflush(struct bridge_softc *, int);
 struct ifnet * bridge_rtupdate(struct bridge_softc *,
 struct ether_addr *, struct ifnet *ifp, int, u_int8_t);
 struct ifnet * bridge_rtlookup(struct bridge_softc *,
@@ -180,6 +181,16 @@ LIST_HEAD(, bridge_softc) bridge_list;
 struct if_clone bridge_cloner =
 IF_CLONE_INITIALIZER(bridge, bridge_clone_create, bridge_clone_destroy);
 
+static __inline int brt_cmp(struct bridge_rtnode *, struct bridge_rtnode *);
+RB_PROTOTYPE(brt_tree, bridge_rtnode, brt_entry, brt_cmp);
+RB_GENERATE(brt_tree, bridge_rtnode, brt_entry, brt_cmp);
+
+static __inline int
+brt_cmp(struct bridge_rtnode *a, struct bridge_rtnode *b)
+{
+   return (memcmp(a-brt_addr, b-brt_addr, sizeof(a-brt_addr)));
+}
+
 /* ARGSUSED */
 void
 bridgeattach(int n)
@@ -194,7 +205,7 @@ bridge_clone_create(struct if_clone *ifc
 {
struct bridge_softc *sc;
struct ifnet *ifp;
-   int i, s;
+   int s;
 
sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
@@ -211,8 +222,7 @@ bridge_clone_create(struct if_clone *ifc
timeout_set(sc-sc_brtimeout, bridge_timer, sc);
LIST_INIT(sc-sc_iflist);
LIST_INIT(sc-sc_spanlist);
-   for (i = 0; i  BRIDGE_RTABLE_SIZE; i++)
-   LIST_INIT(sc-sc_rts[i]);
+   RB_INIT(sc-sc_rts);
sc-sc_hashkey = arc4random();
ifp = sc-sc_if;
snprintf(ifp-if_xname, sizeof ifp-if_xname, %s%d, ifc-ifc_name,
@@ -560,7 +570,7 @@ bridge_ioctl(struct ifnet *ifp, u_long c
if ((error = suser(curproc, 0)) != 0)
break;
 
-   error = bridge_rtflush(sc, req-ifbr_ifsflags);
+   bridge_rtflush(sc, req-ifbr_ifsflags);
break;
case SIOCBRDGSADDR:
if ((error = suser(curproc, 0)) != 0)
@@ -1003,7 +1013,7 @@ bridge_output(struct ifnet *ifp, struct 
struct ifnet *dst_if;
struct ether_addr *dst;
struct bridge_softc *sc;
-   int s, error, len;
+   int s, error;
 #ifdef IPSEC
struct m_tag *mtag;
 #endif /* IPSEC */
@@ -1109,33 +1119,12 @@ bridge_output(struct ifnet *ifp, struct 
used = 1;
mc = m;
} else {
-   struct mbuf *m1, *m2, *mx;
-
-   m1 = m_copym2(m, 0, ETHER_HDR_LEN,
-   M_DONTWAIT);
-   if (m1 == NULL) {
-   sc-sc_if.if_oerrors++;
-   continue;
- 

Re: wol for xl(4)

2011-06-22 Thread Stefan Sperling
On Wed, Jun 22, 2011 at 09:54:07AM +, Thomas Gerlach wrote:
 For me it works as well. :)
 
 Just two more little flaws:
 
 1) If you configure WOL inside /etc/hostname.if, then you get the following
 error message during booting:
 
 xl0: command never completed!
 xl0: transmission error: ff
 
 and you're not able to login. the problem is:
 xl_init is called first, which makes a call to xl_stop. and xl_stop 
 calls
 xl_pci_power, which tries to bring the IF into D3 powerstate. more 
 precisely,
 the pci_conf_write routine is not able to set the XL_PSTATE_D3 bit (however,
 it can set the XL_PME_ENABLE bit. i checked by setting just one of them.)
 
 the initial disable mechanism of xl_attach doesn't work, since xl_init is
 called _before_ xl_attach.

Can you please clarify with which code exactly you're seeing this problem?
What are you running?
Does it happens with the if_xl_pci.c hunk of my proposed diff, or without it?
Or does it always happen even in plain -current?
 
 2) it would be nice if we push the wol setting stuff inside ONE routine, 
 rather
 than spreading it over several ones (that is, all the CSR_WRITE stuff together
 into xl_pci_power.
 
 i'm currently working on it...but maybe, stefan might be faster than me again
 (if he wants to...). ;)

This doesn't sound like a good idea.
The PCI-specific layer of XL and the low-level layer in ic/ have to
cooperate. Else you'd have to call PCI-specific routines from the code
in ic/ which harms use of this driver with other buses.



Re: wol for xl(4)

2011-06-22 Thread Stefan Sperling
On Wed, Jun 22, 2011 at 10:02:42AM +, Thomas Gerlach wrote:
 as for the pulling toghether, i would suggest something like this (draft,
 patches against latest -current files, _without_ stefan's recent patches):

 +#if 1
  #ifndef SMALL_KERNEL

  #endif
 +#endif

Huh?

 @@ -367,6 +365,22 @@
  {
 u_int32_t   command;
 struct xl_pci_softc *psc = (struct xl_pci_softc*)ppsc;
 +   struct xl_softc *sc = psc-psc_softc;
 +
 +   XL_SEL_WIN(7);
 +
 +   /* Clear any pending PME events. */
 +   CSR_READ_2(sc, XL_W7_BM_PME);
 +
 +   /* If WOL flag is not set make sure PME is disabled, and
 +* return without doing anything. */
 +   if ((sc-xl_flags  XL_FLAG_WOL) == 0) {
 +   CSR_WRITE_2(sc, XL_W7_BM_PME, 0);
 +   return;
 +   }
 +
 +   CSR_WRITE_2(sc, XL_W7_BM_PME, XL_BM_PME_MAGIC);
 +   CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_ENABLE);

I see what you mean now but I don't know if putting these register
writes into the PCI glue code is appropriate.



pf ip reassembly test awesomization

2011-06-22 Thread Bret S. Lambert
There's no need to walk the entire fragment list to determine
if we have all the bytes of the unfragmented packet if we keep
a running count on how much we've seen already.

Please to be testing as we need to make sure that our userbase
remains unmolested.

- Bert

Index: pf_norm.c
===
RCS file: /cvs/src/sys/net/pf_norm.c,v
retrieving revision 1.132
diff -u -p -r1.132 pf_norm.c
--- pf_norm.c   23 Apr 2011 10:00:36 -  1.132
+++ pf_norm.c   16 May 2011 15:35:20 -
@@ -97,6 +97,7 @@ struct pf_fragment {
TAILQ_ENTRY(pf_fragment) frag_next;
u_int32_t   fr_timeout;
u_int16_t   fr_maxlen;  /* maximum length of single fragment */
+   u_int16_t   fr_qlen;/* length of current queue */
TAILQ_HEAD(pf_fragq, pf_frent) fr_queue;
 };
 
@@ -322,6 +323,7 @@ pf_fillup_fragment(struct pf_fragment_cm
*(struct pf_fragment_cmp *)frag = *key;
frag-fr_timeout = time_second;
frag-fr_maxlen = frent-fe_len;
+   frag-fr_qlen = frent-fe_len;
TAILQ_INIT(frag-fr_queue);
 
RB_INSERT(pf_frag_tree, pf_frag_tree, frag);
@@ -401,6 +403,9 @@ pf_fillup_fragment(struct pf_fragment_cm
pf_nfrents--;
}
 
+   /* Adjust queue length */
+   frag-fr_qlen += frent-fe_len;
+
if (prev == NULL)
TAILQ_INSERT_HEAD(frag-fr_queue, frent, fr_next);
else
@@ -419,8 +424,7 @@ pf_fillup_fragment(struct pf_fragment_cm
 int
 pf_isfull_fragment(struct pf_fragment *frag)
 {
-   struct pf_frent *frent, *next;
-   u_int16_toff, total;
+   u_int16_ttotal;
 
/* Check if we are completely reassembled */
if (TAILQ_LAST(frag-fr_queue, pf_fragq)-fe_mff)
@@ -431,22 +435,14 @@ pf_isfull_fragment(struct pf_fragment *f
TAILQ_LAST(frag-fr_queue, pf_fragq)-fe_len;
 
/* Check if we have all the data */
-   off = 0;
-   for (frent = TAILQ_FIRST(frag-fr_queue); frent; frent = next) {
-   next = TAILQ_NEXT(frent, fr_next);
-
-   off += frent-fe_len;
-   if (off  total  (next == NULL || next-fe_off != off)) {
-   DPFPRINTF(LOG_NOTICE,
-   missing fragment at %d, next %d, total %d,
-   off, next == NULL ? -1 : next-fe_off, total);
-   return (0);
-   }
-   }
-   DPFPRINTF(LOG_NOTICE, %d  %d?, off, total);
-   if (off  total)
+   if (frag-fr_qlen  total) {
+   DPFPRINTF(LOG_NOTICE,
+   missing fragment: need %d have %d, total, frag-fr_qlen);
return (0);
-   KASSERT(off == total);
+   }
+
+   DPFPRINTF(LOG_NOTICE, %d  %d?, frag-fr_qlen, total);
+   KASSERT(frag-fr_qlen  == total);
 
return (1);
 }



Re: wol for xl(4)

2011-06-22 Thread Thomas Gerlach
Stefan Sperling stsp at stsp.name writes:

 
 Can you please clarify with which code exactly you're seeing this problem?
 What are you running?
 Does it happens with the if_xl_pci.c hunk of my proposed diff, or without it?
 Or does it always happen even in plain -current?
 

ok, of course.
1) everything works fine with your latest patches, if i manually do an
ifconfig xl0 wol.

2) now i'd like to set the interface stuff in /etc/hostname.xl0. therefore,
i go with inet 192.168.0.2 255.255.255.0 192.168.0.255 wol.
(re)booting then results in those error messages i presented before

now what i found out so far is, that the problem seems to be with the
pci_conf_write call inside xl_pci_power in if_xl_pci.c
both the XL_PME_EN and XL_PSTATE_D3 state are to be set. i narrowed it down to
that call by try and error. so when you disable pci_conf_write, the error
disappears (of course no WOL then).
the problem is setting the XL_PSTATE_D3 bit.

it think, the error appears, because xl_stop is called inside xl_init
(both in xl.c). and xl_init is called _before_ xl_attach inside
xl_pci_attach (if_xl_pci.c), so the xl_wol(ifp, 0) of xl_attach call to
clear WOL flag doesn't work. somehow, this flag is set, and that's why it goes
down all the chain and pci_conf_write is called. however, since the system is
trying to bring the IF up, there's a conflict b/w bringing up and D3 power
state.
at least that's what i think...

the error appears with your patches only. that is, because -current
(checkout from yesterday) still has

if_xl_pci.c:

 command = pci_conf_read(pc, pa-pa_tag, XL_PCI_PWRMGMTCAP);
 if (command  XL_PME_CAP_D3_HOT) {
   sc-wol_power = xl_pci_wol_power;
   sc-wol_power_arg = psc; 
 }

so it never comes to register xl_pci_wol_power.


 This doesn't sound like a good idea.
 The PCI-specific layer of XL and the low-level layer in ic/ have to
 cooperate. Else you'd have to call PCI-specific routines from the code
 in ic/ which harms use of this driver with other buses.
 
 

i see your point. just got the idea from FreeBSD, it seems less confusing. :)

hope, this clears up the problem i see?


cheers



Re: wol for xl(4)

2011-06-22 Thread t . m . gerlach
 -

 

 On Wed, Jun 22, 2011 at 10:02:42AM +, Thomas Gerlach
wrote:

  as for the pulling toghether, i would suggest something like
this

 (draft,

  patches against latest -current files, _without_ stefan's
recent

 patches):

 

  +#if 1

   #ifndef SMALL_KERNEL

 

 
#endif

  +#endif

 

 Huh?



 that results from some testing. it's just
a draft, so i forgot to delete this...



  

  @@ -367,6 +365,22 @@

 
{

  u_int32_t   command;

  struct xl_pci_softc *psc
= (struct xl_pci_softc*)ppsc;

  +   struct xl_softc *sc =
amp;psc-psc_softc;

  +

  +   XL_SEL_WIN(7);

  +

  +   /*
Clear any pending PME events. */

  +   CSR_READ_2(sc, XL_W7_BM_PME);


 +

  +   /* If WOL flag is not set make sure PME is disabled, and

 
+* return without doing anything. */

  +   if ((sc-xl_flags
amp; XL_FLAG_WOL) == 0) {

  +   CSR_WRITE_2(sc, XL_W7_BM_PME,
0);

  +   return;

  +   }

  +

  +
CSR_WRITE_2(sc, XL_W7_BM_PME, XL_BM_PME_MAGIC);

  +   CSR_WRITE_2(sc,
XL_COMMAND, XL_CMD_RX_ENABLE);

 

 I see what you mean now but I don't know
if putting these register

 writes into the PCI glue code is appropriate.
...or we can just put it into the low level code? i mean, the power  routine
should only be registered, if power mgmt caps exist...

 ok, but the pci_conf
write is not low level. so maybe we just do it your way. :)







---
Nutzen
Sie freenet Mail optimal angepasst f|r Ihr iPhone, Android oder Nokia Handy
auch von unterwegs.
Alle Infos und Download unter
http://mail.freenet.de/mobile-email/index.html



Re: wol for xl(4)

2011-06-22 Thread Thomas Gerlach
...crap! sorry, something went wrong here. :(



Re: bridge diff needs testing

2011-06-22 Thread Bret S. Lambert
On Wed, Jun 22, 2011 at 01:21:28PM +0200, Camiel Dobbelaar wrote:
 
 Hi Bret,
 
 one comment from inspection, is the part below related to the RB tree?
 Or a seperate optimization?
 
 On 22-6-2011 12:21, Bret S. Lambert wrote:
 
  @@ -1109,33 +1119,12 @@ bridge_output(struct ifnet *ifp, struct 
  used = 1;
  mc = m;
  } else {
  -   struct mbuf *m1, *m2, *mx;
  -
  -   m1 = m_copym2(m, 0, ETHER_HDR_LEN,
  -   M_DONTWAIT);
  -   if (m1 == NULL) {
  -   sc-sc_if.if_oerrors++;
  -   continue;
  -   }
  -   m2 = m_copym2(m, ETHER_HDR_LEN,
  +   mc = m_copym2(m, 0,
  M_COPYALL, M_DONTWAIT);
  -   if (m2 == NULL) {
  -   m_freem(m1);
  +   if (mc == NULL) {
  sc-sc_if.if_oerrors++;
  continue;
  }
  -
  -   for (mx = m1; mx-m_next != NULL; mx = 
  mx-m_next)
  -   /*EMPTY*/;
  -   mx-m_next = m2;
  -
  -   if (m1-m_flags  M_PKTHDR) {
  -   len = 0;
  -   for (mx = m1; mx != NULL; mx = 
  mx-m_next)
  -   len += mx-m_len;
  -   m1-m_pkthdr.len = len;
  -   }
  -   mc = m1;
  }
   
  error = bridge_ifenqueue(sc, dst_if, mc);
 

Ack; had sent an older diff before I had ripped this out. Please ignore,
and use the following updated diff. Apologies for the noise.

Index: if_bridge.h
===
RCS file: /cvs/src/sys/net/if_bridge.h,v
retrieving revision 1.34
diff -u -p -r1.34 if_bridge.h
--- if_bridge.h 20 Nov 2010 14:23:09 -  1.34
+++ if_bridge.h 22 Jun 2011 12:46:52 -
@@ -396,7 +396,7 @@ struct bridge_iflist {
  * Bridge route node
  */
 struct bridge_rtnode {
-   LIST_ENTRY(bridge_rtnode)   brt_next;   /* next in list */
+   RB_ENTRY(bridge_rtnode) brt_entry;  /* entry in rb tree */
struct  ifnet *brt_if;  /* destination ifs */
u_int8_tbrt_flags;  /* address flags */
u_int8_tbrt_age;/* age counter */
@@ -422,7 +422,7 @@ struct bridge_softc {
struct timeout  sc_brtimeout;   /* timeout state */
struct bstp_state   *sc_stp;/* stp state */
LIST_HEAD(, bridge_iflist)  sc_iflist;  /* interface list */
-   LIST_HEAD(, bridge_rtnode)  sc_rts[BRIDGE_RTABLE_SIZE]; /* hash 
table */
+   RB_HEAD(brt_tree, bridge_rtnode) sc_rts;/* route tree */
LIST_HEAD(, bridge_iflist)  sc_spanlist;/* span ports */
 };
 
Index: if_bridge.c
===
RCS file: /cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.188
diff -u -p -r1.188 if_bridge.c
--- if_bridge.c 4 Nov 2010 23:07:15 -   1.188
+++ if_bridge.c 22 Jun 2011 12:46:52 -
@@ -45,6 +45,7 @@
 #include sys/ioctl.h
 #include sys/errno.h
 #include sys/kernel.h
+#include sys/tree.h
 #include machine/cpu.h
 
 #include net/if.h
@@ -135,7 +136,7 @@ int bridge_rtfind(struct bridge_softc *,
 void   bridge_rtage(struct bridge_softc *);
 void   bridge_rttrim(struct bridge_softc *);
 intbridge_rtdaddr(struct bridge_softc *, struct ether_addr *);
-intbridge_rtflush(struct bridge_softc *, int);
+void   bridge_rtflush(struct bridge_softc *, int);
 struct ifnet * bridge_rtupdate(struct bridge_softc *,
 struct ether_addr *, struct ifnet *ifp, int, u_int8_t);
 struct ifnet * bridge_rtlookup(struct bridge_softc *,
@@ -180,6 +181,16 @@ LIST_HEAD(, bridge_softc) bridge_list;
 struct if_clone bridge_cloner =
 IF_CLONE_INITIALIZER(bridge, bridge_clone_create, bridge_clone_destroy);
 
+static __inline int brt_cmp(struct bridge_rtnode *, struct bridge_rtnode *);
+RB_PROTOTYPE(brt_tree, bridge_rtnode, brt_entry, brt_cmp);
+RB_GENERATE(brt_tree, bridge_rtnode, brt_entry, brt_cmp);
+
+static __inline int
+brt_cmp(struct bridge_rtnode *a, struct bridge_rtnode *b)
+{
+   return (memcmp(a-brt_addr, b-brt_addr, sizeof(a-brt_addr)));
+}
+
 /* ARGSUSED */
 void
 bridgeattach(int n)
@@ -193,7 +204,7 @@ bridge_clone_create(struct if_clone *ifc
 {
struct bridge_softc *sc;
struct ifnet *ifp;
-   int i, s;
+   int s;
 
sc = malloc(sizeof(*sc), M_DEVBUF, 

Re: wol for xl(4)

2011-06-22 Thread Stefan Sperling
On Wed, Jun 22, 2011 at 11:43:27AM +, Thomas Gerlach wrote:
 ...crap! sorry, something went wrong here. :(

I'm not sure what you mean went wrong.

But in an effort to try to wrap this up, can you please try -current
with just this diff and report back if that works? Thanks!

Index: xl.c
===
RCS file: /cvs/src/sys/dev/ic/xl.c,v
retrieving revision 1.101
diff -u -p -r1.101 xl.c
--- xl.c17 Apr 2011 20:52:43 -  1.101
+++ xl.c22 Jun 2011 13:10:24 -
@@ -2373,9 +2373,13 @@ xl_stop(struct xl_softc *sc)
xl_freetxrx(sc);
 
 #ifndef SMALL_KERNEL
-   /* Call upper layer WOL power routine if WOL is enabled. */
-   if ((sc-xl_flags  XL_FLAG_WOL)  sc-wol_power)
+   /* Re-enable RX and call upper layer WOL power routine
+* if WOL is enabled. */
+   if ((sc-xl_flags  XL_FLAG_WOL)  sc-wol_power) {
+   CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_ENABLE);
+   xl_wait(sc);
sc-wol_power(sc-wol_power_arg);
+   }
 #endif
 }



Re: wol for xl(4)

2011-06-22 Thread Thomas Gerlach
Stefan Sperling stsp at stsp.name writes:

 
 On Wed, Jun 22, 2011 at 11:43:27AM +, Thomas Gerlach wrote:
  ...crap! sorry, something went wrong here. :(
 
 I'm not sure what you mean went wrong.
 
 But in an effort to try to wrap this up, can you please try -current
 with just this diff and report back if that works? Thanks!
 
 Index: xl.c
 ===
 RCS file: /cvs/src/sys/dev/ic/xl.c,v
 retrieving revision 1.101
 diff -u -p -r1.101 xl.c
 --- xl.c  17 Apr 2011 20:52:43 -  1.101
 +++ xl.c  22 Jun 2011 13:10:24 -
 @@ -2373,9 +2373,13 @@ xl_stop(struct xl_softc *sc)
   xl_freetxrx(sc);
 
  #ifndef SMALL_KERNEL
 - /* Call upper layer WOL power routine if WOL is enabled. */
 - if ((sc-xl_flags  XL_FLAG_WOL)  sc-wol_power)
 + /* Re-enable RX and call upper layer WOL power routine
 +  * if WOL is enabled. */
 + if ((sc-xl_flags  XL_FLAG_WOL)  sc-wol_power) {
 + CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_ENABLE);
 + xl_wait(sc);
   sc-wol_power(sc-wol_power_arg);
 + }
  #endif
  }
 
 


my email-client had a problm with sending the mail. it looked very crappy, i
guess. had nothing to do with the driver...

ok, i will test your patch, likely not before tomorrow morning.
but i guess, -current with only this patch won't enable WOL at all. as i
mentioned before, -current still has the test on XL_PME_CAP_D3_HOT in order
to register xl_pci_wol_power in file if_xl_pci.c. only your latest patch
tests on XL_CAPS_PWRMGMT.

but i will give it a shot, using both test versions. :)



Re: wol for xl(4)

2011-06-22 Thread Thomas Gerlach
 Stefan Sperling stsp at stsp.name writes:
  Index: xl.c
  ===
  RCS file: /cvs/src/sys/dev/ic/xl.c,v
  retrieving revision 1.101
  diff -u -p -r1.101 xl.c
  --- xl.c17 Apr 2011 20:52:43 -  1.101
  +++ xl.c22 Jun 2011 13:10:24 -
  @@ -2373,9 +2373,13 @@ xl_stop(struct xl_softc *sc)
  xl_freetxrx(sc);
  
   #ifndef SMALL_KERNEL
  -   /* Call upper layer WOL power routine if WOL is enabled. */
  -   if ((sc-xl_flags  XL_FLAG_WOL)  sc-wol_power)
  +   /* Re-enable RX and call upper layer WOL power routine
  +* if WOL is enabled. */
  +   if ((sc-xl_flags  XL_FLAG_WOL)  sc-wol_power) {
  +   CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_ENABLE);
  +   xl_wait(sc);
  sc-wol_power(sc-wol_power_arg);
  +   }
   #endif
   }
  
  

ok, i had to try...and it happens as i expected:

1) applying only the patch listed above, to -current, wol won't work, since
xl_pci_wol_power is not registered.

2) applying the patch to if_xl_pci.c you send me last weekend (with testing on
the XL_PME_CAPS_PWRMGMT bit), xl_pci_wol_power is registered, but the error
messages appear during the boot process...
of course only when adding wol keyword to /etc/hostname.xl0


regards...



macppc: CUDA, adb(4) controller, rewrite

2011-06-22 Thread Martin Pieuchot
The following diff is a partial rewrite of the actual adb(4) driver. It
only applies to CUDA-based machines:

$ dmesg |grep via-cuda  echo Test this diff

I tried to separate as much as possible the code responsible for the
CUDA chip, more or less like it is done for the PMU. It's a first step
toward creating two different drivers for the two kinds of chips present
in the macppc world, and a common adb interface.

This diff includes:
 - A better initialization sequence based on the xnu  linux drivers.
 - A simpler state machine which doesn't need a timer and shouldn't
   generate collision.

I haven't seen any problem so far with my iMac G3 but I'm very
interested in some more tests especially if you have a machine with an
adb keyboard  mouse.

Comments?

Martin


Index: conf/files.macppc
===
RCS file: /cvs/src/sys/arch/macppc/conf/files.macppc,v
retrieving revision 1.64
diff -u -p -r1.64 files.macppc
--- conf/files.macppc   25 May 2011 07:42:15 -  1.64
+++ conf/files.macppc   22 Jun 2011 13:18:37 -
@@ -153,6 +153,7 @@ filearch/macppc/dev/z8530tty.c  
zstty 
 device adb {}
 attach adb at macobio
 file   arch/macppc/dev/adb.c   adb needs-flag
+file   arch/macppc/dev/cuda.c  adb
 file   arch/macppc/dev/pm_direct.c adb
 
 includedev/adb/files.adb
Index: dev/adb.c
===
RCS file: /cvs/src/sys/arch/macppc/dev/adb.c,v
retrieving revision 1.34
diff -u -p -r1.34 adb.c
--- dev/adb.c   16 Jun 2011 10:51:48 -  1.34
+++ dev/adb.c   22 Jun 2011 13:18:37 -
@@ -80,13 +80,6 @@
  *  - (Related to above) Actually implement the adbOutbound queue.
  *This is fairly easy once you switch all the intr routines
  *over to using adbCommand structs directly.
- *  - There is a bug in the state machine of adb_intr_cuda
- *code that causes hangs, especially on 030 machines, probably
- *because of some timing issues. Because I have been unable to
- *determine the exact cause of this bug, I used the timeout function
- *to check for and recover from this condition. If anyone finds
- *the actual cause of this bug, the calls to timeout and the
- *adb_cuda_tickle routine can be removed.
  */
 
 #include sys/param.h
@@ -105,6 +98,7 @@
 
 #include dev/adb/adb.h
 #include macppc/dev/adbvar.h
+#include macppc/dev/cuda.h
 #include macppc/dev/pm_direct.h
 #include macppc/dev/viareg.h
 
@@ -123,56 +117,7 @@ intadb_polling;/* Are we polling?  (D
 intadb_debug;  /* Output debugging messages */
 #endif /* ADB_DEBUG */
 
-/* some misc. leftovers */
-#define vPB0x
-#define vPB3   0x08
-#define vPB4   0x10
-#define vPB5   0x20
-#define vSR_INT0x04
-#define vSR_OUT0x10
-
-/* the type of ADB action that we are currently performing */
-#define ADB_ACTION_NOTREADY0x1 /* has not been initialized yet */
-#define ADB_ACTION_IDLE0x2 /* the bus is currently idle */
-#define ADB_ACTION_OUT 0x3 /* sending out a command */
-#define ADB_ACTION_IN  0x4 /* receiving data */
-
-/*
- * Shortcuts for setting or testing the VIA bit states.
- * Not all shortcuts are used for every type of ADB hardware.
- */
-#define ADB_SET_STATE_IDLE_CUDA()   via_reg_or(VIA1, vBufB, (vPB4 | vPB5))
-#define ADB_SET_STATE_TIP()via_reg_and(VIA1, vBufB, ~vPB5)
-#define ADB_CLR_STATE_TIP()via_reg_or(VIA1, vBufB, vPB5)
-#define ADB_TOGGLE_STATE_ACK_CUDA() via_reg_xor(VIA1, vBufB, vPB4)
-#define ADB_SET_STATE_ACKOFF_CUDA() via_reg_or(VIA1, vBufB, vPB4)
-#define ADB_SET_SR_INPUT() via_reg_and(VIA1, vACR, ~vSR_OUT)
-#define ADB_SET_SR_OUTPUT()via_reg_or(VIA1, vACR, vSR_OUT)
-#define ADB_SR()   read_via_reg(VIA1, vSR)
-#define ADB_VIA_INTR_ENABLE()  write_via_reg(VIA1, vIER, 0x84)
-#define ADB_VIA_INTR_DISABLE() write_via_reg(VIA1, vIER, 0x04)
-#define ADB_VIA_CLR_INTR() write_via_reg(VIA1, vIFR, 0x04)
-#define ADB_INTR_IS_OFF   (vPB3 == (read_via_reg(VIA1, vBufB) 
 vPB3))
-#define ADB_INTR_IS_ON(0 == (read_via_reg(VIA1, vBufB)  vPB3))
-#define ADB_SR_INTR_IS_ON (vSR_INT == (read_via_reg(VIA1, \
-   vIFR)  vSR_INT))
-
-/*
- * This is the delay that is required (in uS) between certain
- * ADB transactions. The actual timing delay for for each uS is
- * calculated at boot time to account for differences in machine speed.
- */
-#define ADB_DELAY  150
-
-/*
- * Maximum ADB message length; includes space for data, result, and
- * device code - plus a little for safety.
- */
-#define ADB_MAX_MSG_LENGTH 16
-#define ADB_MAX_HDR_LENGTH 8
-
 #define ADB_QUEUE  32
-#define ADB_TICKLE_TICKS   4
 
 /*
  

Identifying disks by name

2011-06-22 Thread Wouter Coene
Hi all,

The patch below builds on the disk UID code to implement disk names. Disk
names must match [a-zA-Z0-9_]{1,10} and are stored encoded as 6 bits per
character into the disklabel UID field. With this patch, you can use disk
names in /etc/fstab:

bootdisk.a / ffs rw 1 1

And with every other program that uses the disk mapper or opendev(3).

The name can be set through the disklabel 'i' command:

 i
The disklabel UID is currently 9b3cf8a2ddef ('bootdisk')
duid: [] foo
 l
...
duid: ab3cc000 ('foo')

When parsing a UID/name, the decision to parse as a UID or as a name is made
based on the length of the string: 16-character strings are parsed as UIDs,
whereas anything = 10 is parsed as a name.

When displaying a UID/name, it is displayed both as a UID and as a name, as it
is unfortunately not possible to detect whether it was entered as a UID or a
name. This results in garbage names for randomly-generated UIDs:

 l
...
duid: c7b55168cd92a85f ('mwKGPBrHf4')

The pronouncibility of such names may leave something to be desired. :)

It's possible to change the encoding to 5 bits per character to gain an
additional 2 characters for the name, but this reduces the available character
set to 31 characters, not enough to store a full alphanumeric character set.
Changing over to 8 bits per character would reduce the maximum name length to
8 characters and make it necessary to guard against nefarious names that
scramble the terminal. So all-in-all I figured 6 bits is probably optimal.

Anyway, have fun with it.

Regards,
Wouter

PS, to mlarkin@  armani@: I've been out of it all for a while, I'll get back
to kvirt once I've got everything here up and running again.


Index: subr_disk.c
===
RCS file: /cvs/src/sys/kern/subr_disk.c,v
retrieving revision 1.114
diff -u -r1.114 subr_disk.c
--- subr_disk.c 24 Nov 2010 15:31:34 -  1.114
+++ subr_disk.c 22 Jun 2011 16:40:27 -
@@ -1352,49 +1352,96 @@
u_char uid[8];
char c, part;
int i;
+   size_t len;

/*
-* Attempt to map a request for a disklabel UID to the correct device.
-* We should be supplied with a disklabel UID which has the following
-* format:
+* Attempt to map a request for a disk name or disklabel UID to the
+* correct device. A disk name is a string up to 10 characters long,
+* and can consist of alphabetical and numeric characters and the
+* '_' character.
 *
-* [disklabel uid] . [partition]
+* If the DM_OPENPART flag is not set, the name or UID must be
+* followed by the partition:
 *
-* Alternatively, if the DM_OPENPART flag is set the disklabel UID can
-* based passed on its own.
+* [name or uid] . [partition]
 */

+   /* Verify that the device name is properly formed. */
if (strchr(path, '/') != NULL)
return -1;
-
-   /* Verify that the device name is properly formed. */
-   if (!((strlen(path) == 16  (flags  DM_OPENPART)) ||
-   (strlen(path) == 18  path[16] == '.')))
+   len = strlen(path);
+   if (len  18)
return -1;
+   if ((len = 2 || path[len - 2] != '.')  !(flags  DM_OPENPART))
+   return -1;
+   if (len  2  path[len - 2] == '.')
+   len -= 2;

/* Get partition. */
if (flags  DM_OPENPART)
part = 'a' + RAW_PART;
else
-   part = path[17];
+   part = path[len + 1];

if (part  'a' || part = 'a' + MAXPARTITIONS)
return -1;

-   /* Derive label UID. */
-   bzero(uid, sizeof(uid));
-   for (i = 0; i  16; i++) {
-   c = path[i];
-   if (c = '0'  c = '9')
-   c -= '0';
-   else if (c = 'a'  c = 'f')
-   c -= ('a' - 10);
-else
-   return -1;
-
-   uid[i / 2] = 4;
-   uid[i / 2] |= c  0xf;
-   }
+   /* Decode UID or name. */
+   if (len == 16) {
+   for (i = 0; i  16; i++) {
+   c = path[i];
+   if (c = '0'  c = '9')
+   c -= '0';
+   else if (c = 'a'  c = 'f')
+   c -= ('a' - 10);
+   else
+   return -1;
+
+   uid[i / 2] = 4;
+   uid[i / 2] |= c  0xf;
+   }
+   } else if (len = 10) {
+   u_char *p = uid;
+   int v = 0;
+
+   /* This is basically base64: read in 4 chars, shift out 3. */
+   bzero(uid, sizeof(uid));
+   for (i = 0; i  len; i++) {
+   c = path[i];
+   if 

ansi some files in dev

2011-06-22 Thread Ted Unangst
checked with md5, before line folding caused differences.


Index: cninit.c
===
RCS file: /home/tedu/cvs/src/sys/dev/cninit.c,v
retrieving revision 1.10
diff -u -r1.10 cninit.c
--- cninit.c26 Jun 2010 23:24:44 -  1.10
+++ cninit.c22 Jun 2011 17:03:06 -
@@ -54,7 +54,7 @@
 struct consdev *cn_tab = NULL;
 
 void
-cninit()
+cninit(void)
 {
struct consdev *cp;
 
@@ -82,8 +82,7 @@
 }
 
 int
-cnset(dev)
-   dev_t dev;
+cnset(dev_t dev)
 {
struct consdev *cp;
 
Index: ksyms.c
===
RCS file: /home/tedu/cvs/src/sys/dev/ksyms.c,v
retrieving revision 1.20
diff -u -r1.20 ksyms.c
--- ksyms.c 26 Dec 2010 15:41:00 -  1.20
+++ ksyms.c 22 Jun 2011 17:01:08 -
@@ -62,8 +62,7 @@
 
 /*ARGSUSED*/
 void
-ksymsattach(num)
-   int num;
+ksymsattach(int num)
 {
 
 #if defined(__sparc64__) || defined(__mips__)
@@ -152,10 +151,7 @@
 
 /*ARGSUSED*/
 int
-ksymsopen(dev, flag, mode, p)
-   dev_t dev;
-   int flag, mode;
-   struct proc *p;
+ksymsopen(dev_t dev, int flag, int mode, struct proc *p)
 {
 
/* There are no non-zero minor devices */
@@ -175,10 +171,7 @@
 
 /*ARGSUSED*/
 int
-ksymsclose(dev, flag, mode, p)
-   dev_t dev;
-   int flag, mode;
-   struct proc *p;
+ksymsclose(dev_t dev, int flag, int mode, struct proc *p)
 {
 
return (0);
@@ -186,10 +179,7 @@
 
 /*ARGSUSED*/
 int
-ksymsread(dev, uio, flags)
-   dev_t dev;
-   struct uio *uio;
-   int flags;
+ksymsread(dev_t dev, struct uio *uio, int flags)
 {
int error;
size_t len;
@@ -218,32 +208,3 @@
 
return (0);
 }
-
-/* XXX - not yet */
-#if 0
-paddr_t
-ksymsmmap(dev, off, prot)
-   dev_t dev;
-   off_t off;
-   int prot;
-{
-   vaddr_t va;
-   paddr_t pa;
-
-   if (off  0)
-   return (-1);
-   if (off = ksym_head_size + ksym_syms_size)
-   return (-1);
-
-   if ((vaddr_t)off  ksym_head_size) {
-   va = (vaddr_t)ksym_head + off;
-   } else {
-   va = (vaddr_t)ksym_syms + off;
-   }
-
-   if (pmap_extract(pmap_kernel, va, pa) == FALSE)
-   panic(ksymsmmap: unmapped page);
-
-   return (pa);
-}
-#endif
Index: sequencer.c
===
RCS file: /home/tedu/cvs/src/sys/dev/sequencer.c,v
retrieving revision 1.20
diff -u -r1.20 sequencer.c
--- sequencer.c 18 Nov 2010 21:15:14 -  1.20
+++ sequencer.c 22 Jun 2011 17:01:38 -
@@ -1250,7 +1250,7 @@
  */
 
 int
-midi_unit_count()
+midi_unit_count(void)
 {
return (0);
 }
Index: systrace.c
===
RCS file: /home/tedu/cvs/src/sys/dev/systrace.c,v
retrieving revision 1.54
diff -u -r1.54 systrace.c
--- systrace.c  2 Apr 2011 17:04:35 -   1.54
+++ systrace.c  22 Jun 2011 16:59:32 -
@@ -199,11 +199,8 @@
 
 /* ARGSUSED */
 int
-systracef_read(fp, poff, uio, cred)
-   struct file *fp;
-   off_t *poff;
-   struct uio *uio;
-   struct ucred *cred;
+systracef_read(struct file *fp, off_t *poff, struct uio *uio,
+struct ucred *cred)
 {
struct fsystrace *fst = (struct fsystrace *)fp-f_data;
struct str_process *process;
@@ -250,11 +247,8 @@
 
 /* ARGSUSED */
 int
-systracef_write(fp, poff, uio, cred)
-   struct file *fp;
-   off_t *poff;
-   struct uio *uio;
-   struct ucred *cred;
+systracef_write(struct file *fp, off_t *poff, struct uio *uio,
+struct ucred *cred)
 {
return (EIO);
 }
@@ -265,11 +259,7 @@
 
 /* ARGSUSED */
 int
-systracef_ioctl(fp, cmd, data, p)
-   struct file *fp;
-   u_long cmd;
-   caddr_t data;
-   struct proc *p;
+systracef_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p)
 {
int ret = 0;
struct fsystrace *fst = (struct fsystrace *)fp-f_data;
@@ -409,10 +399,7 @@
 
 /* ARGSUSED */
 int
-systracef_poll(fp, events, p)
-   struct file *fp;
-   int events;
-   struct proc *p;
+systracef_poll(struct file *fp, int events, struct proc *p)
 {
struct fsystrace *fst = (struct fsystrace *)fp-f_data;
int revents = 0;
@@ -434,28 +421,21 @@
 
 /* ARGSUSED */
 int
-systracef_kqfilter(fp, kn)
-   struct file *fp;
-   struct knote *kn;
+systracef_kqfilter(struct file *fp, struct knote *kn)
 {
return (1);
 }
 
 /* ARGSUSED */
 int
-systracef_stat(fp, sb, p)
-   struct file *fp;
-   struct stat *sb;
-   struct proc *p;
+systracef_stat(struct file *fp, struct stat *sb, struct proc *p)
 {
return (EOPNOTSUPP);
 }
 
 /* ARGSUSED */
 int
-systracef_close(fp, p)
-   struct file *fp;
-   struct proc *p;
+systracef_close(struct file *fp, struct proc *p)
 {
struct fsystrace *fst = (struct fsystrace *)fp-f_data;
struct str_process *strp;
@@ -510,32 

Re: fix a few uvm includes

2011-06-22 Thread Ted Unangst
On Mon, 20 Jun 2011, Miod Vallat wrote:

  uvm_extern.h is the header people should be consuming.  change a few uvm.h 
  to uvm_extern.h.
 
 This is not what, say, kern_fork.c does. If you include uvm.h, you
 don't need any other uvm_whatever.h, and definitely not
 uvm/uvm_extern.h.
 
  also, simplify and move the bufcache adjustment code from sysctl to the 
  vfs_bio.c where it fits nicer.
 
 Separate diff please.



Thanks.  Let's try this again.

Index: kern/exec_subr.c
===
RCS file: /home/tedu/cvs/src/sys/kern/exec_subr.c,v
retrieving revision 1.28
diff -u -r1.28 exec_subr.c
--- kern/exec_subr.c14 Nov 2006 18:00:27 -  1.28
+++ kern/exec_subr.c20 Jun 2011 19:22:34 -
@@ -41,7 +41,7 @@
 #include sys/mman.h
 #include sys/resourcevar.h
 
-#include uvm/uvm.h
+#include uvm/uvm_extern.h
 
 #ifdef DEBUG
 /*
Index: kern/init_main.c
===
RCS file: /home/tedu/cvs/src/sys/kern/init_main.c,v
retrieving revision 1.177
diff -u -r1.177 init_main.c
--- kern/init_main.c18 Apr 2011 21:44:56 -  1.177
+++ kern/init_main.c20 Jun 2011 19:22:34 -
@@ -85,7 +85,7 @@
 
 #include machine/cpu.h
 
-#include uvm/uvm.h
+#include uvm/uvm_extern.h
 
 #include net/if.h
 #include net/raw_cb.h
Index: kern/kern_fork.c
===
RCS file: /home/tedu/cvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.126
diff -u -r1.126 kern_fork.c
--- kern/kern_fork.c6 Jun 2011 17:05:46 -   1.126
+++ kern/kern_fork.c22 Jun 2011 17:07:30 -
@@ -62,8 +62,7 @@
 #include systrace.h
 #include dev/systrace.h
 
-#include uvm/uvm_extern.h
-#include uvm/uvm_map.h
+#include uvm/uvm.h
 
 intnprocs = 1; /* process 0 */
 intrandompid;  /* when set to 1, pid's go random */
Index: kern/kern_sysctl.c
===
RCS file: /home/tedu/cvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.203
diff -u -r1.203 kern_sysctl.c
--- kern/kern_sysctl.c  9 Jun 2011 21:10:55 -   1.203
+++ kern/kern_sysctl.c  22 Jun 2011 17:10:40 -
@@ -54,7 +54,6 @@
 #include sys/tty.h
 #include sys/disklabel.h
 #include sys/disk.h
-#include uvm/uvm_extern.h
 #include sys/sysctl.h
 #include sys/msgbuf.h
 #include sys/dkstat.h
@@ -103,6 +102,8 @@
 #ifdef SYSVSHM
 #include sys/shm.h
 #endif
+
+#include uvm/uvm.h
 
 extern struct forkstat forkstat;
 extern struct nchstats nchstats;
Index: kern/uipc_mbuf.c
===
RCS file: /home/tedu/cvs/src/sys/kern/uipc_mbuf.c,v
retrieving revision 1.157
diff -u -r1.157 uipc_mbuf.c
--- kern/uipc_mbuf.c4 May 2011 16:05:49 -   1.157
+++ kern/uipc_mbuf.c20 Jun 2011 19:22:34 -
@@ -89,7 +89,6 @@
 
 #include machine/cpu.h
 
-#include uvm/uvm.h
 #include uvm/uvm_extern.h
 
 #ifdef DDB
Index: kern/vfs_bio.c
===
RCS file: /home/tedu/cvs/src/sys/kern/vfs_bio.c,v
retrieving revision 1.130
diff -u -r1.130 vfs_bio.c
--- kern/vfs_bio.c  5 Jun 2011 19:41:04 -   1.130
+++ kern/vfs_bio.c  22 Jun 2011 17:09:49 -
@@ -57,7 +57,7 @@
 #include sys/conf.h
 #include sys/kernel.h
 
-#include uvm/uvm_extern.h
+#include uvm/uvm.h
 
 #include miscfs/specfs/specdev.h
 
Index: kern/vfs_biomem.c
===
RCS file: /home/tedu/cvs/src/sys/kern/vfs_biomem.c,v
retrieving revision 1.17
diff -u -r1.17 vfs_biomem.c
--- kern/vfs_biomem.c   7 Apr 2011 19:07:42 -   1.17
+++ kern/vfs_biomem.c   20 Jun 2011 19:22:34 -
@@ -24,7 +24,6 @@
 #include sys/mount.h
 
 #include uvm/uvm_extern.h
-#include uvm/uvm.h
 
 vaddr_t buf_kva_start, buf_kva_end;
 int buf_needva;
Index: sys/pipe.h
===
RCS file: /home/tedu/cvs/src/sys/sys/pipe.h,v
retrieving revision 1.13
diff -u -r1.13 pipe.h
--- sys/pipe.h  21 Nov 2005 18:16:46 -  1.13
+++ sys/pipe.h  20 Jun 2011 19:22:34 -
@@ -27,7 +27,6 @@
 #ifndef _KERNEL
 #include sys/time.h  /* for struct timeval */
 #include sys/selinfo.h   /* for struct selinfo */
-#include uvm/uvm_extern.h/* for vm_page_t */
 #include machine/param.h /* for PAGE_SIZE */
 #endif /* _KERNEL */
 
Index: sys/user.h
===
RCS file: /home/tedu/cvs/src/sys/sys/user.h,v
retrieving revision 1.7
diff -u -r1.7 user.h
--- sys/user.h  29 Jun 2010 20:48:50 -  1.7
+++ sys/user.h  20 Jun 2011 19:22:34 -
@@ -42,8 +42,6 @@
 #include sys/uio.h
 #endif
 #include sys/resourcevar.h
-#include uvm/uvm_extern.h/* XXX */
-#include sys/sysctl.h
 
 
 /*
Index: sys/vnode.h
===
RCS 

disable altq functions

2011-06-22 Thread Ted Unangst
Does anybody use altq cdnr or rio?  Do they work?  Why do we have them, 
but not enabled?

The last function commit to cdnr was over 8 years ago, and says it's still 
not ready for pf.  So that seems really dead.  rio may work, but what good 
are disabled options?

RIO is documented in options(4), CDNR is not.  options also documents the 
old ALTQ_NOPCC option which doesn't exist.  I intend to delete that, but 
should I delete RIO as well?

Index: files
===
RCS file: /home/tedu/cvs/src/sys/conf/files,v
retrieving revision 1.512
diff -u -r1.512 files
--- files   7 Apr 2011 13:42:53 -   1.512
+++ files   22 Jun 2011 17:21:09 -
@@ -558,10 +558,8 @@
 file altq/altq_red.c   altq
 file altq/altq_cbq.c   altq
 file altq/altq_rmclass.c   altq
-file altq/altq_cdnr.c  altq_cdnr
 file altq/altq_hfsc.c  altq
 file altq/altq_priq.c  altq
-file altq/altq_rio.c   altq_rio
 file ddb/db_access.c   ddb | kgdb
 file ddb/db_aout.c ddb
 file ddb/db_break.cddb



Re: Identifying disks by name

2011-06-22 Thread Kenneth R Westerback
On Wed, Jun 22, 2011 at 06:48:14PM +0200, Wouter Coene wrote:
 Hi all,
 
 The patch below builds on the disk UID code to implement disk names. Disk
 names must match [a-zA-Z0-9_]{1,10} and are stored encoded as 6 bits per
 character into the disklabel UID field. With this patch, you can use disk
 names in /etc/fstab:
 
   bootdisk.a / ffs rw 1 1

Why? This seems to add nothing but extra code and increase the
chances some twit will name multiple disks 'MYDISK' and screw
her/himself royally. Also, DUIDs identify a DISKLABEL and not a
disk.

 Ken



Re: ansi some files in dev

2011-06-22 Thread Kenneth R Westerback
sure. ok krw@

 Ken

On Wed, Jun 22, 2011 at 01:06:49PM -0400, Ted Unangst wrote:
 checked with md5, before line folding caused differences.
 
 
 Index: cninit.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/cninit.c,v
 retrieving revision 1.10
 diff -u -r1.10 cninit.c
 --- cninit.c  26 Jun 2010 23:24:44 -  1.10
 +++ cninit.c  22 Jun 2011 17:03:06 -
 @@ -54,7 +54,7 @@
  struct consdev *cn_tab = NULL;
  
  void
 -cninit()
 +cninit(void)
  {
   struct consdev *cp;
  
 @@ -82,8 +82,7 @@
  }
  
  int
 -cnset(dev)
 - dev_t dev;
 +cnset(dev_t dev)
  {
   struct consdev *cp;
  
 Index: ksyms.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/ksyms.c,v
 retrieving revision 1.20
 diff -u -r1.20 ksyms.c
 --- ksyms.c   26 Dec 2010 15:41:00 -  1.20
 +++ ksyms.c   22 Jun 2011 17:01:08 -
 @@ -62,8 +62,7 @@
  
  /*ARGSUSED*/
  void
 -ksymsattach(num)
 - int num;
 +ksymsattach(int num)
  {
  
  #if defined(__sparc64__) || defined(__mips__)
 @@ -152,10 +151,7 @@
  
  /*ARGSUSED*/
  int
 -ksymsopen(dev, flag, mode, p)
 - dev_t dev;
 - int flag, mode;
 - struct proc *p;
 +ksymsopen(dev_t dev, int flag, int mode, struct proc *p)
  {
  
   /* There are no non-zero minor devices */
 @@ -175,10 +171,7 @@
  
  /*ARGSUSED*/
  int
 -ksymsclose(dev, flag, mode, p)
 - dev_t dev;
 - int flag, mode;
 - struct proc *p;
 +ksymsclose(dev_t dev, int flag, int mode, struct proc *p)
  {
  
   return (0);
 @@ -186,10 +179,7 @@
  
  /*ARGSUSED*/
  int
 -ksymsread(dev, uio, flags)
 - dev_t dev;
 - struct uio *uio;
 - int flags;
 +ksymsread(dev_t dev, struct uio *uio, int flags)
  {
   int error;
   size_t len;
 @@ -218,32 +208,3 @@
  
   return (0);
  }
 -
 -/* XXX - not yet */
 -#if 0
 -paddr_t
 -ksymsmmap(dev, off, prot)
 - dev_t dev;
 - off_t off;
 - int prot;
 -{
 - vaddr_t va;
 - paddr_t pa;
 -
 - if (off  0)
 - return (-1);
 - if (off = ksym_head_size + ksym_syms_size)
 - return (-1);
 -
 - if ((vaddr_t)off  ksym_head_size) {
 - va = (vaddr_t)ksym_head + off;
 - } else {
 - va = (vaddr_t)ksym_syms + off;
 - }
 -
 - if (pmap_extract(pmap_kernel, va, pa) == FALSE)
 - panic(ksymsmmap: unmapped page);
 -
 - return (pa);
 -}
 -#endif
 Index: sequencer.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/sequencer.c,v
 retrieving revision 1.20
 diff -u -r1.20 sequencer.c
 --- sequencer.c   18 Nov 2010 21:15:14 -  1.20
 +++ sequencer.c   22 Jun 2011 17:01:38 -
 @@ -1250,7 +1250,7 @@
   */
  
  int
 -midi_unit_count()
 +midi_unit_count(void)
  {
   return (0);
  }
 Index: systrace.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/systrace.c,v
 retrieving revision 1.54
 diff -u -r1.54 systrace.c
 --- systrace.c2 Apr 2011 17:04:35 -   1.54
 +++ systrace.c22 Jun 2011 16:59:32 -
 @@ -199,11 +199,8 @@
  
  /* ARGSUSED */
  int
 -systracef_read(fp, poff, uio, cred)
 - struct file *fp;
 - off_t *poff;
 - struct uio *uio;
 - struct ucred *cred;
 +systracef_read(struct file *fp, off_t *poff, struct uio *uio,
 +struct ucred *cred)
  {
   struct fsystrace *fst = (struct fsystrace *)fp-f_data;
   struct str_process *process;
 @@ -250,11 +247,8 @@
  
  /* ARGSUSED */
  int
 -systracef_write(fp, poff, uio, cred)
 - struct file *fp;
 - off_t *poff;
 - struct uio *uio;
 - struct ucred *cred;
 +systracef_write(struct file *fp, off_t *poff, struct uio *uio,
 +struct ucred *cred)
  {
   return (EIO);
  }
 @@ -265,11 +259,7 @@
  
  /* ARGSUSED */
  int
 -systracef_ioctl(fp, cmd, data, p)
 - struct file *fp;
 - u_long cmd;
 - caddr_t data;
 - struct proc *p;
 +systracef_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p)
  {
   int ret = 0;
   struct fsystrace *fst = (struct fsystrace *)fp-f_data;
 @@ -409,10 +399,7 @@
  
  /* ARGSUSED */
  int
 -systracef_poll(fp, events, p)
 - struct file *fp;
 - int events;
 - struct proc *p;
 +systracef_poll(struct file *fp, int events, struct proc *p)
  {
   struct fsystrace *fst = (struct fsystrace *)fp-f_data;
   int revents = 0;
 @@ -434,28 +421,21 @@
  
  /* ARGSUSED */
  int
 -systracef_kqfilter(fp, kn)
 - struct file *fp;
 - struct knote *kn;
 +systracef_kqfilter(struct file *fp, struct knote *kn)
  {
   return (1);
  }
  
  /* ARGSUSED */
  int
 -systracef_stat(fp, sb, p)
 - struct file *fp;
 - struct stat *sb;
 - struct proc *p;
 +systracef_stat(struct file *fp, struct stat *sb, struct proc *p)
  {
   return (EOPNOTSUPP);
  }
  
  /* ARGSUSED */
  int
 -systracef_close(fp, p)
 - struct file *fp;
 

Re: Identifying disks by name

2011-06-22 Thread Wouter Coene
On 22 jun 2011, at 20:53, Kenneth R Westerback wrote:
 On Wed, Jun 22, 2011 at 06:48:14PM +0200, Wouter Coene wrote:
 The patch below builds on the disk UID code to implement disk names. Disk
 names must match [a-zA-Z0-9_]{1,10} and are stored encoded as 6 bits per
 character into the disklabel UID field. With this patch, you can use disk
 names in /etc/fstab:

  bootdisk.a / ffs rw 1 1

 Why? This seems to add nothing but extra code and increase the
 chances some twit will name multiple disks 'MYDISK' and screw
 her/himself royally. Also, DUIDs identify a DISKLABEL and not a
 disk.

Right now, nothing is stopping you from naming multiple disks 1234567890abcdef
either. Twits will be twits, I'm just looking for something that's easier to
type (and remember) than a hex-string.

Also, this is certainly not useless if you have more than a handfull of disks
or SAN volumes, or for removable media. Which of the following is more
readable?

mount 1234567890abcdef.a /mnt
mount backups.a /mnt

Regards,
Wouter



Re: Identifying disks by name

2011-06-22 Thread Stuart Henderson
On 2011/06/22 21:07, Wouter Coene wrote:
 
 Also, this is certainly not useless if you have more than a handfull of disks
 or SAN volumes, or for removable media. Which of the following is more
 readable?
 
   mount 1234567890abcdef.a /mnt
   mount backups.a /mnt

mount bac1.a /mnt isn't too bad :-)



Re: Identifying disks by name

2011-06-22 Thread Thordur Bjornsson
On Wed, Jun 22, 2011 at 09:07:41PM +0200, Wouter Coene wrote:
 On 22 jun 2011, at 20:53, Kenneth R Westerback wrote:
  On Wed, Jun 22, 2011 at 06:48:14PM +0200, Wouter Coene wrote:
  The patch below builds on the disk UID code to implement disk names. Disk
  names must match [a-zA-Z0-9_]{1,10} and are stored encoded as 6 bits per
  character into the disklabel UID field. With this patch, you can use disk
  names in /etc/fstab:
 
 bootdisk.a / ffs rw 1 1
 
  Why? This seems to add nothing but extra code and increase the
  chances some twit will name multiple disks 'MYDISK' and screw
  her/himself royally. Also, DUIDs identify a DISKLABEL and not a
  disk.
 
 Right now, nothing is stopping you from naming multiple disks 1234567890abcdef
 either. Twits will be twits, I'm just looking for something that's easier to
 type (and remember) than a hex-string.
 
 Also, this is certainly not useless if you have more than a handfull of disks
 or SAN volumes, or for removable media. Which of the following is more
 readable?
 
   mount 1234567890abcdef.a /mnt
   mount backups.a /mnt
For this type of stuff, you are looking for hotplugd(8); And duids make
writing hotplug scripts much easier.

While I do see the allure of having nice names for disks, this is
problematic (like ken pointed out) so I think I'll have to agree with
ken for now that this is extra code for a very minimal gain.

Anyways, always nice to see diffs!

cheers, thib.



Re: bus_dmamem_map fix (test+ok)

2011-06-22 Thread Ariane van der Steldt
On Tue, Jun 21, 2011 at 09:00:49PM +0200, Ariane van der Steldt wrote:
 Bus_dmamem_map has a bug in its error path, where it frees the wrong
 memory in the wrong way.

After some discussion on icb, the comments and the pmap_remove can go
too. The pmap_remove is executed by uvm_km_free() at uvm_unmap_remove()
and uvm_km_free won't use the pmap but the object to lookup pages (and
the object has none at these addresses).

Ok?
-- 
Ariane


Index: arch/alpha/dev/bus_dma.c
===
RCS file: /cvs/src/sys/arch/alpha/dev/bus_dma.c,v
retrieving revision 1.30
diff -u -d -p -r1.30 bus_dma.c
--- arch/alpha/dev/bus_dma.c26 Dec 2010 15:40:58 -  1.30
+++ arch/alpha/dev/bus_dma.c22 Jun 2011 18:59:28 -
@@ -614,12 +614,8 @@ _bus_dmamem_map(t, segs, nsegs, size, kv
VM_PROT_READ | VM_PROT_WRITE, VM_PROT_READ |
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
-   /*
-* Clean up after ourselves.
-* XXX uvm_wait on WAITOK
-*/
pmap_update(pmap_kernel());
-   uvm_km_free(kernel_map, va, ssize);
+   uvm_km_free(kernel_map, sva, ssize);
return (error);
}
}
Index: arch/amd64/amd64/bus_dma.c
===
RCS file: /cvs/src/sys/arch/amd64/amd64/bus_dma.c,v
retrieving revision 1.36
diff -u -d -p -r1.36 bus_dma.c
--- arch/amd64/amd64/bus_dma.c  2 Apr 2011 16:37:39 -   1.36
+++ arch/amd64/amd64/bus_dma.c  22 Jun 2011 18:59:28 -
@@ -492,12 +492,8 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma
VM_PROT_READ | VM_PROT_WRITE, VM_PROT_READ |
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
-   /*
-* Clean up after ourselves.
-* XXX uvm_wait on WAITOK
-*/
pmap_update(pmap_kernel());
-   uvm_km_free(kernel_map, va, ssize);
+   uvm_km_free(kernel_map, sva, ssize);
return (error);
}
}
Index: arch/arm/arm/bus_dma.c
===
RCS file: /cvs/src/sys/arch/arm/arm/bus_dma.c,v
retrieving revision 1.20
diff -u -d -p -r1.20 bus_dma.c
--- arch/arm/arm/bus_dma.c  4 Jan 2011 21:12:55 -   1.20
+++ arch/arm/arm/bus_dma.c  22 Jun 2011 18:59:30 -
@@ -718,12 +718,8 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma
VM_PROT_READ | VM_PROT_WRITE, VM_PROT_READ |
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
-   /*
-* Clean up after ourselves.
-* XXX uvm_wait on WAITOK
-*/
pmap_update(pmap_kernel());
-   uvm_km_free(kernel_map, va, ssize);
+   uvm_km_free(kernel_map, sva, ssize);
return (error);
}
/*
Index: arch/aviion/aviion/bus_dma.c
===
RCS file: /cvs/src/sys/arch/aviion/aviion/bus_dma.c,v
retrieving revision 1.3
diff -u -d -p -r1.3 bus_dma.c
--- arch/aviion/aviion/bus_dma.c26 Dec 2010 15:40:59 -  1.3
+++ arch/aviion/aviion/bus_dma.c22 Jun 2011 18:59:30 -
@@ -544,12 +544,8 @@ bus_dmamem_map(t, segs, nsegs, size, kva
 VM_PROT_READ | VM_PROT_WRITE, VM_PROT_READ |
 VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
 if (error) {
-   /*
-* Clean up after ourselves.
-* XXX uvm_wait on WAITOK
-*/
pmap_update(pmap_kernel());
-   uvm_km_free(kernel_map, va, ssize);
+   uvm_km_free(kernel_map, sva, ssize);
return (error);
 }
 }
Index: arch/i386/i386/bus_dma.c
===
RCS file: /cvs/src/sys/arch/i386/i386/bus_dma.c,v
retrieving revision 1.24
diff -u -d -p -r1.24 bus_dma.c
--- arch/i386/i386/bus_dma.c26 Dec 2010 15:40:59 -  1.24
+++ 

Re: Identifying disks by name

2011-06-22 Thread Janjaap van Velthooven
On Wed, Jun 22, 2011 at 08:12:28PM +0100, Stuart Henderson wrote:
 On 2011/06/22 21:07, Wouter Coene wrote:
  Also, this is certainly not useless if you have more than a handfull of 
  disks
  or SAN volumes, or for removable media. Which of the following is more
  readable?
  
  mount 1234567890abcdef.a /mnt
  mount backups.a /mnt
 
 mount bac1.a /mnt isn't too bad :-)

Just a vague idea for the moment;

How aboot some mechanism that can do number lookups by name for disks?
( just like is done for host protocols ports or users and groups and possibly
more things.. )

for instance an /etc/disks with lines like:
1234567890abcdefbackups bac1

Anyways, as I have no code for something like this at this moment I'll shut up
for now on this.

Janjaap van Velthooven
--  
   / __/ /_/ __/ /_  __/ __/ /___  / 
  / /_  __/___/_/_  /___  / / __/ /___  / /  janj...@stack.nl
 /___/_/_/_/_/_/_/___/_/_/



Re: Identifying disks by name

2011-06-22 Thread Thordur Bjornsson
On Wed, Jun 22, 2011 at 09:34:55PM +0200, Janjaap van Velthooven wrote:
 On Wed, Jun 22, 2011 at 08:12:28PM +0100, Stuart Henderson wrote:
  On 2011/06/22 21:07, Wouter Coene wrote:
   Also, this is certainly not useless if you have more than a handfull of 
   disks
   or SAN volumes, or for removable media. Which of the following is more
   readable?
   
 mount 1234567890abcdef.a /mnt
 mount backups.a /mnt
  
  mount bac1.a /mnt isn't too bad :-)
 
 Just a vague idea for the moment;
 
 How aboot some mechanism that can do number lookups by name for disks?
 ( just like is done for host protocols ports or users and groups and possibly
 more things.. )
 
 for instance an /etc/disks with lines like:
 1234567890abcdef  backups bac1
 
 Anyways, as I have no code for something like this at this moment I'll shut up
 for now on this.

/etc/disks
DUIDmyrootdisk

/etc/fstab
myrootdisk.a / ffs rw,softdep 1 1

And now I'm royally fucked.



Re: Identifying disks by name

2011-06-22 Thread roberth
On Wed, 22 Jun 2011 21:07:41 +0200
Wouter Coene wou...@irdc.nl wrote:

   mount 1234567890abcdef.a /mnt
   mount backups.a /mnt

# export backups=1234567890abcdef
# mount $backups.a /mnt

I myself prefere to include the slice, less to remember/look up.



Re: two minor carp and pfsync fixes

2011-06-22 Thread Tobias Weingartner
I'm sure you did.  Did you test it with one patched and one not?

-Toby.

On Wed, Jun 22, 2011 at 1:37 AM, Stefan Rinkes
stefan.rin...@googlemail.com wrote:
 On Tue, Jun 21, 2011 at 9:42 PM, Tobias Weingartner weing...@tepid.org
wrote:
 On Tue, Jun 21, 2011 at 11:52 AM, Stefan Rinkes
 stefan.rin...@googlemail.com wrote:

 while playing around with carp and pfsync I spotted
 two minor bugs.

 1. Not all pfstate flags are synced, cause pfsync uses
u_int8_t, while pf uses u_int16_t for state_flags.
Currently that means PFSTATE_SCRUB_TCP flags don't
get synced.

 retrieving revision 1.333
 diff -u -p -r1.333 pfvar.h
 --- sys/net/pfvar.h 20 Jun 2011 19:03:41 -  1.333
 +++ sys/net/pfvar.h 21 Jun 2011 17:33:31 -
 @@ -892,13 +892,13 @@ struct pfsync_state {
u_int8_t proto;
u_int8_t direction;
u_int8_t log;
 -   u_int8_t state_flags;
 +   u_int16_tstate_flags;
u_int8_t timeout;
u_int8_t sync_flags;
u_int8_t updates;
u_int8_t min_ttl;
u_int8_t set_tos;
 -   u_int8_t pad[4];
 +   u_int8_t pad[3];
  } __packed;

 Does this change the on-wire format?  Also, would the state_flags need to
 have htons/ntohs done to it?

 -Toby.


 Hi,

 I tested this diff quite carefully and used it for over a week now and
 checked that all
 state_flags are synced by adding a new flag which triggered a printf in
pf(4) :)

 No issues/crashes have been seen so far.

 Stefan



Re: Identifying disks by name

2011-06-22 Thread Thordur Bjornsson
On Wed, Jun 22, 2011 at 09:54:07PM +0200, Janjaap van Velthooven wrote:
 Thordur Bjornsson wrote and mailed:
  On Wed, Jun 22, 2011 at 09:34:55PM +0200, Janjaap van Velthooven wrote:
   Just a vague idea for the moment;
   
   How aboot some mechanism that can do number lookups by name for disks?
   ( just like is done for host protocols ports or users and groups and 
   possibly
   more things.. )
   
   for instance an /etc/disks with lines like:
   1234567890abcdef  backups bac1
   
   Anyways, as I have no code for something like this at this moment I'll 
   shut up
   for now on this.
 
  /etc/disks
  DUIDmyrootdisk
  
  /etc/fstab
  myrootdisk.a / ffs rw,softdep 1 1
  
  And now I'm royally fucked.

And I smoke to much dope (or not enough?).



Re: two minor carp and pfsync fixes

2011-06-22 Thread David Gwynne
On 22/06/2011, at 3:52 AM, Stefan Rinkes wrote:

 Hi,

 while playing around with carp and pfsync I spotted
 two minor bugs.

 1. Not all pfstate flags are synced, cause pfsync uses
u_int8_t, while pf uses u_int16_t for state_flags.
Currently that means PFSTATE_SCRUB_TCP flags don't
get synced.

 retrieving revision 1.333
 diff -u -p -r1.333 pfvar.h
 --- sys/net/pfvar.h 20 Jun 2011 19:03:41 -  1.333
 +++ sys/net/pfvar.h 21 Jun 2011 17:33:31 -
 @@ -892,13 +892,13 @@ struct pfsync_state {
u_int8_t proto;
u_int8_t direction;
u_int8_t log;
 -   u_int8_t state_flags;
 +   u_int16_tstate_flags;
u_int8_t timeout;
u_int8_t sync_flags;
u_int8_t updates;
u_int8_t min_ttl;
u_int8_t set_tos;
 -   u_int8_t pad[4];
 +   u_int8_t pad[3];
 } __packed;

 #define PFSYNC_FLAG_SRCNODE0x04


this diff is not ok.

you changed the wire format, didnt considering endianness, and it looks like
you put a multibyte value on an unaligned boundary.

i'll have a look at the missing flags problem myself in the next few days.

 2. If you are using IP balanced carp and set one of
the interface to down, the mbufs still reach pf.
Cause carp_ourether() returns NULL if the interface
is down and the mbufs gets copied by carp_input(),
cause the M_MCAST flag is set. The copied mbuf is
dropped in ether_input() since the carp interface is down
and the original mbuf reaches the pf. IMHO carp should always
take care of mbufs with his MAC address, else the machine has
to do some unnecessary work.

 retrieving revision 1.184
 diff -u -p -r1.184 ip_carp.c
 --- sys/netinet/ip_carp.c   4 May 2011 16:05:49 -   1.184
 +++ sys/netinet/ip_carp.c   21 Jun 2011 17:34:42 -
 @@ -1514,9 +1514,7 @@ carp_ourether(void *v, struct ether_head

TAILQ_FOREACH(vh, cif-vhif_vrs, sc_list) {
struct carp_vhost_entry *vhe;
 -   if ((vh-sc_if.if_flags  (IFF_UP|IFF_RUNNING)) !=
 -   (IFF_UP|IFF_RUNNING))
 -   continue;
 +
if (vh-sc_balancing == CARP_BAL_ARP) {
LIST_FOREACH(vhe, vh-carp_vhosts, vhost_entries)
if (vhe-state == MASTER 


this looks reasonable to me. mcbride, mpf, could you chip in on this?

dlg



Re: ansi some files in dev

2011-06-22 Thread David Gwynne
ok

On 23/06/2011, at 3:06 AM, Ted Unangst wrote:

 checked with md5, before line folding caused differences.


 Index: cninit.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/cninit.c,v
 retrieving revision 1.10
 diff -u -r1.10 cninit.c
 --- cninit.c  26 Jun 2010 23:24:44 -  1.10
 +++ cninit.c  22 Jun 2011 17:03:06 -
 @@ -54,7 +54,7 @@
 struct consdev *cn_tab = NULL;

 void
 -cninit()
 +cninit(void)
 {
   struct consdev *cp;

 @@ -82,8 +82,7 @@
 }

 int
 -cnset(dev)
 - dev_t dev;
 +cnset(dev_t dev)
 {
   struct consdev *cp;

 Index: ksyms.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/ksyms.c,v
 retrieving revision 1.20
 diff -u -r1.20 ksyms.c
 --- ksyms.c   26 Dec 2010 15:41:00 -  1.20
 +++ ksyms.c   22 Jun 2011 17:01:08 -
 @@ -62,8 +62,7 @@

 /*ARGSUSED*/
 void
 -ksymsattach(num)
 - int num;
 +ksymsattach(int num)
 {

 #if defined(__sparc64__) || defined(__mips__)
 @@ -152,10 +151,7 @@

 /*ARGSUSED*/
 int
 -ksymsopen(dev, flag, mode, p)
 - dev_t dev;
 - int flag, mode;
 - struct proc *p;
 +ksymsopen(dev_t dev, int flag, int mode, struct proc *p)
 {

   /* There are no non-zero minor devices */
 @@ -175,10 +171,7 @@

 /*ARGSUSED*/
 int
 -ksymsclose(dev, flag, mode, p)
 - dev_t dev;
 - int flag, mode;
 - struct proc *p;
 +ksymsclose(dev_t dev, int flag, int mode, struct proc *p)
 {

   return (0);
 @@ -186,10 +179,7 @@

 /*ARGSUSED*/
 int
 -ksymsread(dev, uio, flags)
 - dev_t dev;
 - struct uio *uio;
 - int flags;
 +ksymsread(dev_t dev, struct uio *uio, int flags)
 {
   int error;
   size_t len;
 @@ -218,32 +208,3 @@

   return (0);
 }
 -
 -/* XXX - not yet */
 -#if 0
 -paddr_t
 -ksymsmmap(dev, off, prot)
 - dev_t dev;
 - off_t off;
 - int prot;
 -{
 - vaddr_t va;
 - paddr_t pa;
 -
 - if (off  0)
 - return (-1);
 - if (off = ksym_head_size + ksym_syms_size)
 - return (-1);
 -
 - if ((vaddr_t)off  ksym_head_size) {
 - va = (vaddr_t)ksym_head + off;
 - } else {
 - va = (vaddr_t)ksym_syms + off;
 - }
 -
 - if (pmap_extract(pmap_kernel, va, pa) == FALSE)
 - panic(ksymsmmap: unmapped page);
 -
 - return (pa);
 -}
 -#endif
 Index: sequencer.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/sequencer.c,v
 retrieving revision 1.20
 diff -u -r1.20 sequencer.c
 --- sequencer.c   18 Nov 2010 21:15:14 -  1.20
 +++ sequencer.c   22 Jun 2011 17:01:38 -
 @@ -1250,7 +1250,7 @@
  */

 int
 -midi_unit_count()
 +midi_unit_count(void)
 {
   return (0);
 }
 Index: systrace.c
 ===
 RCS file: /home/tedu/cvs/src/sys/dev/systrace.c,v
 retrieving revision 1.54
 diff -u -r1.54 systrace.c
 --- systrace.c2 Apr 2011 17:04:35 -   1.54
 +++ systrace.c22 Jun 2011 16:59:32 -
 @@ -199,11 +199,8 @@

 /* ARGSUSED */
 int
 -systracef_read(fp, poff, uio, cred)
 - struct file *fp;
 - off_t *poff;
 - struct uio *uio;
 - struct ucred *cred;
 +systracef_read(struct file *fp, off_t *poff, struct uio *uio,
 +struct ucred *cred)
 {
   struct fsystrace *fst = (struct fsystrace *)fp-f_data;
   struct str_process *process;
 @@ -250,11 +247,8 @@

 /* ARGSUSED */
 int
 -systracef_write(fp, poff, uio, cred)
 - struct file *fp;
 - off_t *poff;
 - struct uio *uio;
 - struct ucred *cred;
 +systracef_write(struct file *fp, off_t *poff, struct uio *uio,
 +struct ucred *cred)
 {
   return (EIO);
 }
 @@ -265,11 +259,7 @@

 /* ARGSUSED */
 int
 -systracef_ioctl(fp, cmd, data, p)
 - struct file *fp;
 - u_long cmd;
 - caddr_t data;
 - struct proc *p;
 +systracef_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p)
 {
   int ret = 0;
   struct fsystrace *fst = (struct fsystrace *)fp-f_data;
 @@ -409,10 +399,7 @@

 /* ARGSUSED */
 int
 -systracef_poll(fp, events, p)
 - struct file *fp;
 - int events;
 - struct proc *p;
 +systracef_poll(struct file *fp, int events, struct proc *p)
 {
   struct fsystrace *fst = (struct fsystrace *)fp-f_data;
   int revents = 0;
 @@ -434,28 +421,21 @@

 /* ARGSUSED */
 int
 -systracef_kqfilter(fp, kn)
 - struct file *fp;
 - struct knote *kn;
 +systracef_kqfilter(struct file *fp, struct knote *kn)
 {
   return (1);
 }

 /* ARGSUSED */
 int
 -systracef_stat(fp, sb, p)
 - struct file *fp;
 - struct stat *sb;
 - struct proc *p;
 +systracef_stat(struct file *fp, struct stat *sb, struct proc *p)
 {
   return (EOPNOTSUPP);
 }

 /* ARGSUSED */
 int
 -systracef_close(fp, p)
 - struct file *fp;
 - struct proc *p;
 +systracef_close(struct file *fp, struct proc *p)
 {
   struct fsystrace *fst = (struct fsystrace 

phantasia(6) remove unused code

2011-06-22 Thread Daniel Dickman
I guess the intent was to get a custom message at build time which would 
be shown when phantasia starts up. But --

(1) That would make the build interactive.
(2) _PATH_PHANTDIR is not defined anywhere so this won't compile.
(3) As the ifdef macro says, this can be done from the Makefile if 
needed...


Index: setup.c
===
RCS file: /home/cvs/src/games/phantasia/setup.c,v
retrieving revision 1.10
diff -u -r1.10 setup.c
--- setup.c 15 Dec 2010 06:40:39 -  1.10
+++ setup.c 23 Jun 2011 02:55:27 -
@@ -175,42 +175,6 @@
}
}
 
-#ifdef MAKE_INSTALLS_THIS_AND_DOESNT_WANT_TO_HEAR_ABOUT_IT
-/* write to motd file */
-printf(One line 'motd' ? );
-if (fgets(Databuf, SZ_DATABUF, stdin) == NULL)
-   Databuf[0] = '\0';
-snprintf(path, sizeof(path), %s%s, prefix?prefix:, _PATH_MOTD);
-if ((fp = fopen(path, w)) == NULL)
-   Error(Cannot update %s.\n, path);
-else
-   {
-   fwrite(Databuf, sizeof(char), strlen(Databuf), fp);
-   fclose(fp);
-   }
-
-/* report compile-time options */
-printf(Compiled options:\n\n);
-printf(Phantasia destination directory:  %s\n, _PATH_PHANTDIR);
-printf(Wizard: root UID: 0\n);
-
-#ifdef BSD41
-printf(Compiled for BSD 4.1\n);
-#endif
-
-#ifdef BSD42
-printf(Compiled for BSD 4.2\n);
-#endif
-
-#ifdef SYS3
-printf(Compiled for System III\n);
-#endif
-
-#ifdef SYS5
-printf(Compiled for System V\n);
-#endif
-#endif
-
 exit(0);
 /*NOTREACHED*/
 }



Fixes for re(4) chip identification.

2011-06-22 Thread Brad
Some fixes for re(4) chipset identification..

- Rename 8168 revision entries to 8168B to reflect proper naming.  From FreeBSD
- Change 8168C_SPIN2 rev string to differentiate from the first rev.
- Change 8169SBL ident string to also mention the 8110 chipset so the
  naming is consistent with the same family of chipsets.
- Remove tab in front of 8103E define in the header.


Index: re.c
===
RCS file: /home/cvs/src/sys/dev/ic/re.c,v
retrieving revision 1.136
diff -u -p -r1.136 re.c
--- re.c15 Jun 2011 13:19:19 -  1.136
+++ re.c15 Jun 2011 22:37:37 -
@@ -230,11 +230,11 @@ static const struct re_revision {
{ RL_HWREV_8103E,   RTL8103E },
{ RL_HWREV_8110S,   RTL8110S },
{ RL_HWREV_8139CPLUS,   RTL8139C+ },
-   { RL_HWREV_8168_SPIN1,  RTL8168 1 },
-   { RL_HWREV_8168_SPIN2,  RTL8168 2 },
-   { RL_HWREV_8168_SPIN3,  RTL8168 3 },
+   { RL_HWREV_8168B_SPIN1, RTL8168B 1 },
+   { RL_HWREV_8168B_SPIN2, RTL8168B 2 },
+   { RL_HWREV_8168B_SPIN3, RTL8168B 3 },
{ RL_HWREV_8168C,   RTL8168C/8111C },
-   { RL_HWREV_8168C_SPIN2, RTL8168C/8111C },
+   { RL_HWREV_8168C_SPIN2, RTL8168C/8111C 2 },
{ RL_HWREV_8168CP,  RTL8168CP/8111CP },
{ RL_HWREV_8105E,   RTL8105E },
{ RL_HWREV_8168D,   RTL8168D/8111D },
@@ -243,7 +243,7 @@ static const struct re_revision {
{ RL_HWREV_8168E_VL,RTL8168E/8111E-VL },
{ RL_HWREV_8169,RTL8169 },
{ RL_HWREV_8169_8110SB, RTL8169/8110SB },
-   { RL_HWREV_8169_8110SBL, RTL8169SBL },
+   { RL_HWREV_8169_8110SBL, RTL8169/8110SBL },
{ RL_HWREV_8169_8110SCd, RTL8169/8110SCd },
{ RL_HWREV_8169_8110SCe, RTL8169/8110SCe },
{ RL_HWREV_8169S,   RTL8169S },
Index: rtl81x9reg.h
===
RCS file: /home/cvs/src/sys/dev/ic/rtl81x9reg.h,v
retrieving revision 1.74
diff -u -p -r1.74 rtl81x9reg.h
--- rtl81x9reg.h14 Apr 2011 21:06:38 -  1.74
+++ rtl81x9reg.h15 Jun 2011 22:39:22 -
@@ -172,13 +172,13 @@
 #define RL_HWREV_8168DP0x2880
 #define RL_HWREV_8168E 0x2C00
 #define RL_HWREV_8168E_VL  0x2C80
-#define RL_HWREV_8168_SPIN10x3000
+#define RL_HWREV_8168B_SPIN1   0x3000
 #define RL_HWREV_8100E_SPIN1   0x3080
 #define RL_HWREV_8101E 0x3400
 #define RL_HWREV_8102E 0x3480
-#defineRL_HWREV_8103E  0x34C0
-#define RL_HWREV_8168_SPIN20x3800
-#define RL_HWREV_8168_SPIN30x3840
+#define RL_HWREV_8103E 0x34C0
+#define RL_HWREV_8168B_SPIN2   0x3800
+#define RL_HWREV_8168B_SPIN3   0x3840
 #define RL_HWREV_8100E_SPIN2   0x3880
 #define RL_HWREV_8168C 0x3c00
 #define RL_HWREV_8168C_SPIN2   0x3c40

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.