Re: softraid random interleaving

2013-11-15 Thread Dmitry Bogdan
This may slow down sustained reads from softraid1 volume which consists of
drives w/ enabled read-ahead caches.
Just a guess, no tests performed.


2013/11/8 Ted Unangst 

> This may be a bad idea. I can't really think of any pros or cons,
> other than a general principle of "when feasible, prefer random over
> deterministic".
>
>
>
> Index: softraid_raid1.c
> ===
> RCS file: /cvs/src/sys/dev/softraid_raid1.c,v
> retrieving revision 1.54
> diff -u -p -r1.54 softraid_raid1.c
> --- softraid_raid1.c1 Nov 2013 17:36:19 -   1.54
> +++ softraid_raid1.c7 Nov 2013 14:32:33 -
> @@ -350,8 +350,8 @@ sr_raid1_rw(struct sr_workunit *wu)
> rt = 0;
>  ragain:
> /* interleave reads */
> -   chunk = sd->mds.mdd_raid1.sr1_counter++ %
> -   sd->sd_meta->ssdi.ssd_chunk_no;
> +   chunk =
> +
> arc4random_uniform(sd->sd_meta->ssdi.ssd_chunk_no);
> scp = sd->sd_vol.sv_chunks[chunk];
> switch (scp->src_meta.scm_status) {
> case BIOC_SDONLINE:
> Index: softraidvar.h
> ===
> RCS file: /cvs/src/sys/dev/softraidvar.h,v
> retrieving revision 1.140
> diff -u -p -r1.140 softraidvar.h
> --- softraidvar.h   4 Nov 2013 21:02:57 -   1.140
> +++ softraidvar.h   7 Nov 2013 14:32:33 -
> @@ -417,7 +417,7 @@ struct sr_raid0 {
>  /* RAID 1 */
>  #define SR_RAID1_NOWU  16
>  struct sr_raid1 {
> -   u_int32_t   sr1_counter;
> +   u_int32_t   sr1_unused;
>  };
>
>  /* RAID 4 */
>
>


Enable 802.11a for wpi(4)

2013-11-15 Thread Mark Kettenis
Seems to work fine on my home network.

ok?

Index: if_wpi.c
===
RCS file: /cvs/src/sys/dev/pci/if_wpi.c,v
retrieving revision 1.113
diff -u -p -r1.113 if_wpi.c
--- if_wpi.c1 Oct 2013 20:06:02 -   1.113
+++ if_wpi.c15 Nov 2013 21:04:54 -
@@ -921,6 +921,8 @@ wpi_read_eeprom_channels(struct wpi_soft
ic->ic_channels[chan].ic_freq =
ieee80211_ieee2mhz(chan, IEEE80211_CHAN_5GHZ);
ic->ic_channels[chan].ic_flags = IEEE80211_CHAN_A;
+   /* We have at least one valid 5GHz channel. */
+   sc->sc_flags |= WPI_FLAG_HAS_5GHZ;
}
 
/* Is active scan allowed on this channel? */



Re: Genesys Logic GL620USB-A, USB PC-to-PC link cable (take 2)

2013-11-15 Thread SASANO Takayoshi
Hello,

I committed ugl(4) driver to source tree.
The driver is derived from upl(4) driver, so licence is NetBSD.

Thanks.
--
SASANO Takayoshi 

At Fri, 15 Nov 2013 10:56:37 +0100,
Martin Pieuchot wrote:
> 
> On 14/11/13(Thu) 17:44, Brad Smith wrote:
> > On 14/11/13 3:29 PM, SASANO Takayoshi wrote:
> > >Hello,
> > >
> > >Here is Genesys Logic's GL620USB-A driver, new version.
> > >I fixed crashing bug when peer is not connected, rewrite "sc_dying" to
> > >usbd_is_dying() (advices from mpi@), and deleted useless codes.
> > >
> > >This is still work in progress, man is not yet. And please tell me
> > >which I have to write copyright notice --- NetBSD or OpenBSD.
> > >if_ugl.c is based on if_upl.c, and if_upl.c has NetBSD's one.
> > 
> > IMO this is in good enough shape to get it into the tree as is.
> > There are a few issues that need fixing but it would be better to
> > fix them once this has been commited to the tree.
> 
> I totally agree, please put it in.
> 
> M.
> 



Re: convert sppp(4) to taskq

2013-11-15 Thread Mike Belopuhov
On 15 November 2013 15:45, Stefan Sperling  wrote:
> On Fri, Nov 15, 2013 at 03:20:48PM +0100, Mike Belopuhov wrote:
>> On 15 November 2013 15:13, Stefan Sperling  wrote:
>> > Is this done right?
>> >
>> > Works here with pppoe(4) for both IPv4 and IPv6.
>> >
>>
>> i think this diff might lack task_del's in the detach code.
>
> Ooops, good catch.
>
>> have you tried destroying your pppoe interface?
>
> Yes, but evidently not while a task was scheduled.
>
> Same diff with task_del calls added.
>

looks fine to me so far.



Re: convert sppp(4) to taskq

2013-11-15 Thread Stefan Sperling
On Fri, Nov 15, 2013 at 03:20:48PM +0100, Mike Belopuhov wrote:
> On 15 November 2013 15:13, Stefan Sperling  wrote:
> > Is this done right?
> >
> > Works here with pppoe(4) for both IPv4 and IPv6.
> >
> 
> i think this diff might lack task_del's in the detach code.

Ooops, good catch.

> have you tried destroying your pppoe interface?

Yes, but evidently not while a task was scheduled.

Same diff with task_del calls added.

Index: if_sppp.h
===
RCS file: /cvs/src/sys/net/if_sppp.h,v
retrieving revision 1.19
diff -u -p -r1.19 if_sppp.h
--- if_sppp.h   14 Nov 2013 16:52:33 -  1.19
+++ if_sppp.h   15 Nov 2013 13:48:47 -
@@ -93,6 +93,12 @@ struct spppreq {
 #ifdef _KERNEL
 
 #include 
+#include 
+
+#ifdef INET6
+#include 
+#include 
+#endif
 
 #define IDX_LCP 0  /* idx into state table */
 
@@ -124,8 +130,13 @@ struct sipcp {
 #define IPV6CP_MYIFID_SEEN 2 /* have seen my suggested ifid */
u_int32_t saved_hisaddr; /* if hisaddr (IPv4) is dynamic, save
  * original one here, in network byte order */
-   u_int32_t req_hisaddr;  /* remote address requested */
-   u_int32_t req_myaddr;   /* local address requested */
+   u_int32_t req_hisaddr;  /* remote address requested (IPv4) */
+   u_int32_t req_myaddr;   /* local address requested (IPv4) */
+#ifdef INET6
+   struct in6_aliasreq req_ifid;   /* local ifid requested (IPv6) */
+#endif
+   struct task set_addr_task;  /* set address from process context */
+   struct task clear_addr_task;/* clear address from process context */
 };
 
 struct sauth {
Index: if_spppsubr.c
===
RCS file: /cvs/src/sys/net/if_spppsubr.c,v
retrieving revision 1.112
diff -u -p -r1.112 if_spppsubr.c
--- if_spppsubr.c   14 Nov 2013 16:52:33 -  1.112
+++ if_spppsubr.c   15 Nov 2013 14:37:24 -
@@ -46,7 +46,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -72,10 +71,6 @@
 
 #include 
 
-#ifdef INET6
-#include 
-#endif
-
 # define UNTIMEOUT(fun, arg, handle)   \
timeout_del(&(handle))
 
@@ -291,6 +286,7 @@ HIDE void sppp_lcp_check_and_close(struc
 HIDE int sppp_ncp_check(struct sppp *sp);
 
 HIDE void sppp_ipcp_init(struct sppp *sp);
+HIDE void sppp_ipcp_destroy(struct sppp *sp);
 HIDE void sppp_ipcp_up(struct sppp *sp);
 HIDE void sppp_ipcp_down(struct sppp *sp);
 HIDE void sppp_ipcp_open(struct sppp *sp);
@@ -306,6 +302,7 @@ HIDE void sppp_ipcp_tlf(struct sppp *sp)
 HIDE void sppp_ipcp_scr(struct sppp *sp);
 
 HIDE void sppp_ipv6cp_init(struct sppp *sp);
+HIDE void sppp_ipv6cp_destroy(struct sppp *sp);
 HIDE void sppp_ipv6cp_up(struct sppp *sp);
 HIDE void sppp_ipv6cp_down(struct sppp *sp);
 HIDE void sppp_ipv6cp_open(struct sppp *sp);
@@ -902,6 +899,9 @@ sppp_detach(struct ifnet *ifp)
struct sppp **q, *p, *sp = (struct sppp*) ifp;
int i;
 
+   sppp_ipcp_destroy(sp);
+   sppp_ipv6cp_destroy(sp);
+
/* Remove the entry from the keepalive list. */
for (q = &spppq; (p = *q); q = &p->pp_next)
if (p == sp) {
@@ -2637,6 +2637,15 @@ sppp_ipcp_init(struct sppp *sp)
sp->ipcp.flags = 0;
sp->state[IDX_IPCP] = STATE_INITIAL;
sp->fail_counter[IDX_IPCP] = 0;
+   task_set(&sp->ipcp.set_addr_task, sppp_set_ip_addrs, sp, NULL);
+   task_set(&sp->ipcp.clear_addr_task, sppp_clear_ip_addrs, sp, NULL);
+}
+
+HIDE void
+sppp_ipcp_destroy(struct sppp *sp)
+{
+   task_del(systq, &sp->ipcp.set_addr_task);
+   task_del(systq, &sp->ipcp.clear_addr_task);
 }
 
 HIDE void
@@ -2955,38 +2964,11 @@ sppp_ipcp_RCN_nak(struct sppp *sp, struc
addlog("\n");
 }
 
-struct sppp_set_ip_addrs_args {
-   struct sppp *sp;
-   u_int32_t myaddr;
-   u_int32_t hisaddr;
-};
-
 HIDE void
 sppp_ipcp_tlu(struct sppp *sp)
 {
-   struct ifnet *ifp = &sp->pp_if;
-   struct sppp_set_ip_addrs_args *args;
-
-   args = malloc(sizeof(*args), M_TEMP, M_NOWAIT);
-   if (args == NULL)
-   return;
-
-   args->sp = sp;
-
-   /* we are up. Set addresses and notify anyone interested */
-   sppp_get_ip_addrs(sp, &args->myaddr, &args->hisaddr, 0);
-   if ((sp->ipcp.flags & IPCP_MYADDR_DYN) &&
-   (sp->ipcp.flags & IPCP_MYADDR_SEEN))
-   args->myaddr = sp->ipcp.req_myaddr;
-   if ((sp->ipcp.flags & IPCP_HISADDR_DYN) &&
-   (sp->ipcp.flags & IPCP_HISADDR_SEEN))
-   args->hisaddr = sp->ipcp.req_hisaddr;
-
-   if (workq_add_task(NULL, 0, sppp_set_ip_addrs, args, NULL)) {
-   free(args, M_TEMP);
-   printf("%s: workq_add_task failed, cannot set "
-   "addresses\n", ifp->if_xname);
-   }
+   if (sp->ipcp.req_myaddr != 0 || sp->ipcp.req_hisaddr != 0)
+   task_add(systq, &sp->ipcp.set_addr_task);
 }
 
 HIDE void
@@ -

Re: convert sppp(4) to taskq

2013-11-15 Thread Mike Belopuhov
On 15 November 2013 15:13, Stefan Sperling  wrote:
> Is this done right?
>
> Works here with pppoe(4) for both IPv4 and IPv6.
>

i think this diff might lack task_del's in the detach code.
have you tried destroying your pppoe interface?



Re: IPv6 routing header type 0

2013-11-15 Thread Mike Belopuhov
On 15 November 2013 15:08, Alexander Bluhm  wrote:
> On Thu, Nov 14, 2013 at 05:38:14PM -0700, Theo de Raadt wrote:
>> Beautiful.
>
> I seems there was enough discussion.  The Security argument is more
> important than the others.  The new diff has no performance impact
> when pf is turned on.
>
> So I need OKs.
>
> bluhm
>

OK mikeb



Re: IPv6 routing header type 0

2013-11-15 Thread Theo de Raadt
> > >- It is pf's job to add more security.
> > It is.  However, you will note that in IPv4 land we have sysctl
> > net.inet.ip.sourceroute.  It defaults to 0 (off).  RH is like IPv4 source
> > routing, except on steriods.  Would any of us at this time recommend
> > net.inet.ip.sourceroute=1, or to go further, remove the code disabling code
> > from the kernel and assume that pf is doing the filtering?  I doubt it.
> 
> that analogy is actually a good one.
> net.inet.ip.sourceroute controls wether we OBEY src routes.
> as in, we don't by default, as we don't obey RH0 at all, without a
> button.
> we do, however, NOT remove src routing information from forwarded
> packets. 

the multiplicative effects are far too serious.



convert sppp(4) to taskq

2013-11-15 Thread Stefan Sperling
Is this done right?

Works here with pppoe(4) for both IPv4 and IPv6.

Index: if_sppp.h
===
RCS file: /cvs/src/sys/net/if_sppp.h,v
retrieving revision 1.19
diff -u -p -r1.19 if_sppp.h
--- if_sppp.h   14 Nov 2013 16:52:33 -  1.19
+++ if_sppp.h   15 Nov 2013 13:23:18 -
@@ -93,6 +93,12 @@ struct spppreq {
 #ifdef _KERNEL
 
 #include 
+#include 
+
+#ifdef INET6
+#include 
+#include 
+#endif
 
 #define IDX_LCP 0  /* idx into state table */
 
@@ -124,8 +130,13 @@ struct sipcp {
 #define IPV6CP_MYIFID_SEEN 2 /* have seen my suggested ifid */
u_int32_t saved_hisaddr; /* if hisaddr (IPv4) is dynamic, save
  * original one here, in network byte order */
-   u_int32_t req_hisaddr;  /* remote address requested */
-   u_int32_t req_myaddr;   /* local address requested */
+   u_int32_t req_hisaddr;  /* remote address requested (IPv4) */
+   u_int32_t req_myaddr;   /* local address requested (IPv4) */
+#ifdef INET6
+   struct in6_aliasreq req_ifid;   /* local ifid requested (IPv6) */
+#endif
+   struct task set_addr_task;  /* set address from process context */
+   struct task clear_addr_task;/* clear address from process context */
 };
 
 struct sauth {
Index: if_spppsubr.c
===
RCS file: /cvs/src/sys/net/if_spppsubr.c,v
retrieving revision 1.112
diff -u -p -r1.112 if_spppsubr.c
--- if_spppsubr.c   14 Nov 2013 16:52:33 -  1.112
+++ if_spppsubr.c   15 Nov 2013 13:24:45 -
@@ -46,7 +46,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -72,10 +71,6 @@
 
 #include 
 
-#ifdef INET6
-#include 
-#endif
-
 # define UNTIMEOUT(fun, arg, handle)   \
timeout_del(&(handle))
 
@@ -2637,6 +2632,8 @@ sppp_ipcp_init(struct sppp *sp)
sp->ipcp.flags = 0;
sp->state[IDX_IPCP] = STATE_INITIAL;
sp->fail_counter[IDX_IPCP] = 0;
+   task_set(&sp->ipcp.set_addr_task, sppp_set_ip_addrs, sp, NULL);
+   task_set(&sp->ipcp.clear_addr_task, sppp_clear_ip_addrs, sp, NULL);
 }
 
 HIDE void
@@ -2955,38 +2952,11 @@ sppp_ipcp_RCN_nak(struct sppp *sp, struc
addlog("\n");
 }
 
-struct sppp_set_ip_addrs_args {
-   struct sppp *sp;
-   u_int32_t myaddr;
-   u_int32_t hisaddr;
-};
-
 HIDE void
 sppp_ipcp_tlu(struct sppp *sp)
 {
-   struct ifnet *ifp = &sp->pp_if;
-   struct sppp_set_ip_addrs_args *args;
-
-   args = malloc(sizeof(*args), M_TEMP, M_NOWAIT);
-   if (args == NULL)
-   return;
-
-   args->sp = sp;
-
-   /* we are up. Set addresses and notify anyone interested */
-   sppp_get_ip_addrs(sp, &args->myaddr, &args->hisaddr, 0);
-   if ((sp->ipcp.flags & IPCP_MYADDR_DYN) &&
-   (sp->ipcp.flags & IPCP_MYADDR_SEEN))
-   args->myaddr = sp->ipcp.req_myaddr;
-   if ((sp->ipcp.flags & IPCP_HISADDR_DYN) &&
-   (sp->ipcp.flags & IPCP_HISADDR_SEEN))
-   args->hisaddr = sp->ipcp.req_hisaddr;
-
-   if (workq_add_task(NULL, 0, sppp_set_ip_addrs, args, NULL)) {
-   free(args, M_TEMP);
-   printf("%s: workq_add_task failed, cannot set "
-   "addresses\n", ifp->if_xname);
-   }
+   if (sp->ipcp.req_myaddr != 0 || sp->ipcp.req_hisaddr != 0)
+   task_add(systq, &sp->ipcp.set_addr_task);
 }
 
 HIDE void
@@ -3043,15 +3013,9 @@ sppp_ipcp_tls(struct sppp *sp)
 HIDE void
 sppp_ipcp_tlf(struct sppp *sp)
 {
-   struct ifnet *ifp = &sp->pp_if;
-
if (sp->ipcp.flags & (IPCP_MYADDR_DYN|IPCP_HISADDR_DYN))
/* Some address was dynamic, clear it again. */
-   if (workq_add_task(NULL, 0,
-   sppp_clear_ip_addrs, (void *)sp, NULL)) {
-   printf("%s: workq_add_task failed, cannot clear "
-   "addresses\n", ifp->if_xname);
-   }
+   task_add(systq, &sp->ipcp.clear_addr_task);
 
/* we no longer need LCP */
sp->lcp.protos &= ~(1 << IDX_IPCP);
@@ -3110,6 +3074,8 @@ sppp_ipv6cp_init(struct sppp *sp)
sp->ipv6cp.flags = 0;
sp->state[IDX_IPV6CP] = STATE_INITIAL;
sp->fail_counter[IDX_IPV6CP] = 0;
+   task_set(&sp->ipv6cp.set_addr_task, sppp_update_ip6_addr, sp,
+   &sp->ipv6cp.req_ifid);
 }
 
 HIDE void
@@ -4587,16 +4553,15 @@ sppp_update_gw(struct ifnet *ifp)
 }
 
 /*
- * Work queue task adding addresses from process context.
+ * Task adding addresses from process context.
  * If an address is 0, leave it the way it is.
  */
 HIDE void
 sppp_set_ip_addrs(void *arg1, void *arg2)
 {
-   struct sppp_set_ip_addrs_args *args = arg1;
-   struct sppp *sp = args->sp;
-   u_int32_t myaddr = args->myaddr;
-   u_int32_t hisaddr = args->hisaddr;
+   struct sppp *sp = arg1;
+   u_int32_t myaddr;
+   u_int32_t hisaddr;
 

Re: IPv6 routing header type 0

2013-11-15 Thread Alexander Bluhm
On Thu, Nov 14, 2013 at 05:38:14PM -0700, Theo de Raadt wrote:
> Beautiful.

I seems there was enough discussion.  The Security argument is more
important than the others.  The new diff has no performance impact
when pf is turned on.

So I need OKs.

bluhm

Index: net/pf.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/net/pf.c,v
retrieving revision 1.857
diff -u -p -u -p -r1.857 pf.c
--- net/pf.c30 Oct 2013 11:35:10 -  1.857
+++ net/pf.c13 Nov 2013 23:14:32 -
@@ -6490,6 +6490,7 @@ pf_test(sa_family_t af, int fwdir, struc
}
}
pd.eh = eh;
+   pd.m->m_pkthdr.pf.flags |= PF_TAG_PROCESSED;
 
switch (pd.virtual_proto) {
 
Index: netinet6/ip6_input.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.120
diff -u -p -u -p -r1.120 ip6_input.c
--- netinet6/ip6_input.c11 Nov 2013 09:15:35 -  1.120
+++ netinet6/ip6_input.c13 Nov 2013 23:38:22 -
@@ -122,6 +122,7 @@ struct ifqueue ip6intrq;
 struct ip6stat ip6stat;
 
 void ip6_init2(void *);
+int ip6_check_rh0hdr(struct mbuf *, int *);
 
 int ip6_hopopts_input(u_int32_t *, u_int32_t *, struct mbuf **, int *);
 struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int);
@@ -331,6 +332,20 @@ ip6_input(struct mbuf *m)
srcrt = !IN6_ARE_ADDR_EQUAL(&odst, &ip6->ip6_dst);
 #endif
 
+   /*
+* Be more secure than RFC5095 and scan for type 0 routing headers.
+* If pf has already scanned the header chain, do not do it twice.
+*/
+   if (!(m->m_pkthdr.pf.flags & PF_TAG_PROCESSED) &&
+   ip6_check_rh0hdr(m, &off)) {
+   ip6stat.ip6s_badoptions++;
+   in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
+   in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
+   icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, off);
+   /* m is already freed */
+   return;
+   }
+
if (IN6_IS_ADDR_LOOPBACK(&ip6->ip6_src) ||
IN6_IS_ADDR_LOOPBACK(&ip6->ip6_dst)) {
ours = 1;
@@ -698,6 +713,74 @@ ip6_input(struct mbuf *m)
return;
  bad:
m_freem(m);
+}
+
+/* scan packet for RH0 routing header. Mostly stolen from pf.c:pf_test() */
+int
+ip6_check_rh0hdr(struct mbuf *m, int *offp)
+{
+   struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
+   struct ip6_rthdr rthdr;
+   struct ip6_ext opt6;
+   u_int8_t proto = ip6->ip6_nxt;
+   int done = 0, lim, off, rh_cnt = 0;
+
+   off = ((caddr_t)ip6 - m->m_data) + sizeof(struct ip6_hdr);
+   lim = min(m->m_pkthdr.len, ntohs(ip6->ip6_plen) + sizeof(*ip6));
+   do {
+   switch (proto) {
+   case IPPROTO_ROUTING:
+   *offp = off;
+   if (rh_cnt++) {
+   /* more then one rh header present */
+   return (1);
+   }
+
+   if (off + sizeof(rthdr) > lim) {
+   /* packet to short to make sense */
+   return (1);
+   }
+
+   m_copydata(m, off, sizeof(rthdr), (caddr_t)&rthdr);
+
+   if (rthdr.ip6r_type == IPV6_RTHDR_TYPE_0) {
+   *offp += offsetof(struct ip6_rthdr, ip6r_type);
+   return (1);
+   }
+
+   off += (rthdr.ip6r_len + 1) * 8;
+   proto = rthdr.ip6r_nxt;
+   break;
+   case IPPROTO_AH:
+   case IPPROTO_HOPOPTS:
+   case IPPROTO_DSTOPTS:
+   /* get next header and header length */
+   if (off + sizeof(opt6) > lim) {
+   /*
+* Packet to short to make sense, we could
+* reject the packet but as a router we 
+* should not do that so forward it.
+*/
+   return (0);
+   }
+
+   m_copydata(m, off, sizeof(opt6), (caddr_t)&opt6);
+
+   if (proto == IPPROTO_AH)
+   off += (opt6.ip6e_len + 2) * 4;
+   else
+   off += (opt6.ip6e_len + 1) * 8;
+   proto = opt6.ip6e_nxt;
+   break;
+   case IPPROTO_FRAGMENT:
+   default:
+   /* end of header stack */
+   done = 1;
+   break;
+   }
+   } while (!done);
+
+   return (0);
 }
 
 /*
Index: sys/mbuf.h

Re: IPv6 routing header type 0

2013-11-15 Thread Henning Brauer
* Theo de Raadt  [2013-11-15 01:38]:
> >My diff was on tech@ for one day during a hackathon before I commited it.

NOT hidden / circulated privately.

> >The reasons why I removed the check in the stack are:
> >- Scanning headers in the forwarding path is against the spirit of IPv6.
> One day someone should find the people who pushed RH0 into IPv6 and punish
> them.

ok henning :)

> >- It is pf's job to add more security.
> It is.  However, you will note that in IPv4 land we have sysctl
> net.inet.ip.sourceroute.  It defaults to 0 (off).  RH is like IPv4 source
> routing, except on steriods.  Would any of us at this time recommend
> net.inet.ip.sourceroute=1, or to go further, remove the code disabling code
> from the kernel and assume that pf is doing the filtering?  I doubt it.

that analogy is actually a good one.
net.inet.ip.sourceroute controls wether we OBEY src routes.
as in, we don't by default, as we don't obey RH0 at all, without a
button.
we do, however, NOT remove src routing information from forwarded
packets. 

> >- The scanning was done twice with pf enabled.
> This latter point is very valid.  I am very happy with your new approach that
> does the extra scanning only if pf is disabled.

no doubt that is an improvement.

> I only believe in this approach when the header is already cache-hot, and 
> there
> is little performance.  Untimately if many feel "pf is always on", then there 
> is
> no argument for resisting code for the "pf is disabled" case... 

heh :)

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Services GmbH, http://bsws.de, Full-Service ISP
Secure Hosting, Mail and DNS Services. Dedicated Servers, Root to Fully Managed
Henning Brauer Consulting, http://henningbrauer.com/



Re: Documentation for Realtek 8188* devices

2013-11-15 Thread Dmitrij D. Czarkoff
Tobias Ulmer said:
> No, this is not how copyright works. What you want to learn from looking
> at their code is not the part that is copyrighted, but the facts, like
> which registers needs to be set to what value at which time and sequence.
> 
> Whoever wrote the driver copied those facts out of a datasheet as well.

I'm not worried about copyright - I'm worried about possible drama and
FUD, which inflict due damage regardless of underlying claims' validity.

-- 
Dmitrij D. Czarkoff



Re: Documentation for Realtek 8188* devices

2013-11-15 Thread Stefan Sperling
On Fri, Nov 15, 2013 at 04:55:23AM +0100, Dmitrij D. Czarkoff wrote:
> That was my plan, though I hoped there is some documentation from
> Realtek i could use to avoid looking at Linux driver - I'm afraid Linux
> people would react badly if their driver is used even as plain
> reference, without any code copying.

Yes, this needs to be done carefully. But it can and has been done.

Keep in mind that there is a difference between copy-pasting code
and between writing new code based on information obtained by
studying another code base. The degree of that difference might
vary between legal systems, and involve questions like whether
patents are involved. But after all, what you're really using is
publicly available *information*, not code.

And some parts of driver code, such as register offsets, are facts,
rather than a creative work, and thus aren't even copyrightable as such.

In this case, I believe you can safely use the Linux driver as a
documentation reference, and use the already working urtwn(4) driver
as a code base to start with.

Personally, and as a matter of principle, I don't think we should
let anyone (such as other open source projects, policy makers, or
companies) scare us away from writing new interoperable code for
our OS and release it under a free licence.
"I am not putting up with this bulling shit"

While writing rtsx(4) I found that Linux developers employed by Realtek
were trying to be very helpful, within limits imposed by NDAs they had
signed. They actually reviewed my code and found a show-stopper bug.
That's not perfect, because we still don't have docs and depend on
insiders to get information. I asked for data sheets several times,
and those requests were forwarded internally but it looked like their
legal team blocked those requests. But it doesn't hurt to ask. And the
more people ask the more attention will be brought to the problem.



Re: Documentation for Realtek 8188* devices

2013-11-15 Thread Tobias Ulmer
On Fri, Nov 15, 2013 at 04:55:23AM +0100, Dmitrij D. Czarkoff wrote:
> Stefan Sperling said:
> > I don't think there are any docs. The Linux driver is the only
> > reference I could find.
> > 
> > The linux driver has pci/usb shims around a common core, much like
> > some other OpenBSD wireless drivers do (e.g. athn(4)).
> > 
> > I believe a good approach would be to write a working PCI device driver
> > based on our USB one (urtwn(4)), and then factor out common code from
> > both into the sys/dev/ic/ directory in a separate step.
> 
> That was my plan, though I hoped there is some documentation from
> Realtek i could use to avoid looking at Linux driver - I'm afraid Linux
> people would react badly if their driver is used even as plain
> reference, without any code copying.

No, this is not how copyright works. What you want to learn from looking
at their code is not the part that is copyrighted, but the facts, like
which registers needs to be set to what value at which time and sequence.

Whoever wrote the driver copied those facts out of a datasheet as well.

> 
> -- 
> Dmitrij D. Czarkoff
> 



Re: Documentation for Realtek 8188* devices

2013-11-15 Thread Dmitrij D. Czarkoff
Stefan Sperling said:
> I don't think there are any docs. The Linux driver is the only
> reference I could find.
> 
> The linux driver has pci/usb shims around a common core, much like
> some other OpenBSD wireless drivers do (e.g. athn(4)).
> 
> I believe a good approach would be to write a working PCI device driver
> based on our USB one (urtwn(4)), and then factor out common code from
> both into the sys/dev/ic/ directory in a separate step.

That was my plan, though I hoped there is some documentation from
Realtek i could use to avoid looking at Linux driver - I'm afraid Linux
people would react badly if their driver is used even as plain
reference, without any code copying.

-- 
Dmitrij D. Czarkoff



Re: Genesys Logic GL620USB-A, USB PC-to-PC link cable (take 2)

2013-11-15 Thread Martin Pieuchot
On 14/11/13(Thu) 17:44, Brad Smith wrote:
> On 14/11/13 3:29 PM, SASANO Takayoshi wrote:
> >Hello,
> >
> >Here is Genesys Logic's GL620USB-A driver, new version.
> >I fixed crashing bug when peer is not connected, rewrite "sc_dying" to
> >usbd_is_dying() (advices from mpi@), and deleted useless codes.
> >
> >This is still work in progress, man is not yet. And please tell me
> >which I have to write copyright notice --- NetBSD or OpenBSD.
> >if_ugl.c is based on if_upl.c, and if_upl.c has NetBSD's one.
> 
> IMO this is in good enough shape to get it into the tree as is.
> There are a few issues that need fixing but it would be better to
> fix them once this has been commited to the tree.

I totally agree, please put it in.

M.



Re: Documentation for Realtek 8188* devices

2013-11-15 Thread Stefan Sperling
On Thu, Nov 14, 2013 at 05:49:44PM +0100, Dmitrij D. Czarkoff wrote:
> Hello!
> 
> I'm strugling to find any documentation for RTL8188* wireless devices
> (including those already supported in urtwn driver). I wrote to Realtek,
> but no responce followed.
> 
> My problem is that I have a MiniPCI RTL8188CE device in my ThinkPad, and
> I want to try writing a driver for it. AFAIK RTL8188CE-VAU (supported in
> urtwn) is essencially RTL8188CE with USB bridge, so having access to
> documentation urtwn driver was based on would be very helpful.
> 
> So, if anyone knows where these docs can be found, I would be very
> greatful.

I have this device too and would be happy to help out.
Some time ago I started looking into what would be necessary to
make it work.

I don't think there are any docs. The Linux driver is the only
reference I could find.

The linux driver has pci/usb shims around a common core, much like
some other OpenBSD wireless drivers do (e.g. athn(4)).

I believe a good approach would be to write a working PCI device driver
based on our USB one (urtwn(4)), and then factor out common code from
both into the sys/dev/ic/ directory in a separate step.



usb: kill matchlvl

2013-11-15 Thread Paul Irofti
I would like to kill matchlvl in order to move forward with cleaning
our usb stack. So I'd appreciate if people would test the following diff
and let me know if it breaks anything.

My devices don't seem to be affected by it.

Index: ugen.c
===
RCS file: /cvs/src/sys/dev/usb/ugen.c,v
retrieving revision 1.75
diff -u -p -r1.75 ugen.c
--- ugen.c  6 Nov 2013 16:58:13 -   1.75
+++ ugen.c  15 Nov 2013 08:50:12 -
@@ -140,10 +140,6 @@ ugen_match(struct device *parent, void *
 {
struct usb_attach_arg *uaa = aux;
 
-#if 0
-   if (uaa->matchlvl)
-   return (uaa->matchlvl);
-#endif
if (uaa->usegeneric) {
return (UMATCH_GENERIC);
} else
Index: uhid.c
===
RCS file: /cvs/src/sys/dev/usb/uhid.c,v
retrieving revision 1.54
diff -u -p -r1.54 uhid.c
--- uhid.c  15 Nov 2013 08:17:44 -  1.54
+++ uhid.c  15 Nov 2013 08:50:59 -
@@ -114,12 +114,12 @@ const struct cfattach uhid_ca = { 
 int
 uhid_match(struct device *parent, void *match, void *aux)
 {
+#ifdef UHID_DEBUG
struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
+#endif
 
DPRINTF(("uhid_match: report=%d\n", uha->reportid));
 
-   if (uha->matchlvl)
-   return (uha->matchlvl);
return (UMATCH_IFACECLASS_GENERIC);
 }
 
Index: uhidev.c
===
RCS file: /cvs/src/sys/dev/usb/uhidev.c,v
retrieving revision 1.50
diff -u -p -r1.50 uhidev.c
--- uhidev.c11 Nov 2013 09:16:03 -  1.50
+++ uhidev.c15 Nov 2013 08:51:00 -
@@ -110,8 +110,6 @@ uhidev_match(struct device *parent, void
return (UMATCH_NONE);
if (usbd_get_quirks(uaa->device)->uq_flags & UQ_BAD_HID)
return (UMATCH_NONE);
-   if (uaa->matchlvl)
-   return (uaa->matchlvl);
 
return (UMATCH_IFACECLASS_GENERIC);
 }
@@ -332,10 +330,6 @@ int uhidevsubmatch(struct device *parent
if (cf->uhidevcf_reportid != UHIDEV_UNK_REPORTID &&
cf->uhidevcf_reportid != uha->reportid)
return (0);
-   if (cf->uhidevcf_reportid == uha->reportid)
-   uha->matchlvl = UMATCH_VENDOR_PRODUCT;
-   else
-   uha->matchlvl = 0;
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
 }
 
Index: uhidev.h
===
RCS file: /cvs/src/sys/dev/usb/uhidev.h,v
retrieving revision 1.15
diff -u -p -r1.15 uhidev.h
--- uhidev.h15 Nov 2013 08:17:44 -  1.15
+++ uhidev.h15 Nov 2013 08:51:00 -
@@ -82,7 +82,6 @@ struct uhidev_attach_arg {
struct uhidev_softc *parent;
int reportid;
int reportsize;
-   int matchlvl;
 };
 
 void uhidev_get_report_desc(struct uhidev_softc *, void **, int *);
Index: usb_subr.c
===
RCS file: /cvs/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.94
diff -u -p -r1.94 usb_subr.c
--- usb_subr.c  2 Nov 2013 12:23:58 -   1.94
+++ usb_subr.c  15 Nov 2013 08:51:01 -
@@ -1300,18 +1300,6 @@ usbd_submatch(struct device *parent, voi
 )
   )
return 0;
-   if (cf->uhubcf_vendor != UHUB_UNK_VENDOR &&
-   cf->uhubcf_vendor == uaa->vendor &&
-   cf->uhubcf_product != UHUB_UNK_PRODUCT &&
-   cf->uhubcf_product == uaa->product) {
-   /* We have a vendor&product locator match */
-   if (cf->uhubcf_release != UHUB_UNK_RELEASE &&
-   cf->uhubcf_release == uaa->release)
-   uaa->matchlvl = UMATCH_VENDOR_PRODUCT_REV;
-   else
-   uaa->matchlvl = UMATCH_VENDOR_PRODUCT;
-   } else
-   uaa->matchlvl = 0;
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
 }
 
Index: usbdi.h
===
RCS file: /cvs/src/sys/dev/usb/usbdi.h,v
retrieving revision 1.58
diff -u -p -r1.58 usbdi.h
--- usbdi.h 13 Nov 2013 13:48:08 -  1.58
+++ usbdi.h 15 Nov 2013 08:51:01 -
@@ -219,7 +219,6 @@ struct usb_attach_arg {
int vendor;
int product;
int release;
-   int matchlvl;
struct usbd_device  *device;/* current device */
struct usbd_interface   *iface; /* current interface */
int usegeneric;