wsmouse re-enabling

2016-07-13 Thread Ulf Brosziewski
Sorry for the repetition, it seems that single-touch state
needs the same treatment as MT state when wsmouse is being
reopened. Single-touch state "synchronizes" itself immediately
when the first changes occur, but it may happen that the first
touch after a restart with dirty state won't trigger pointer
motion (if there is no update of the contact count).

The patch reverts wsmouse_mt_init to its previous form, the
input state will now be cleared completely by wsmousedoopen.

OK?


Index: wsmouse.c
===
RCS file: /cvs/src/sys/dev/wscons/wsmouse.c,v
retrieving revision 1.32
diff -u -p -r1.32 wsmouse.c
--- wsmouse.c   12 Jul 2016 22:02:53 -  1.32
+++ wsmouse.c   13 Jul 2016 21:59:01 -
@@ -379,6 +379,8 @@ wsmousedoopen(struct wsmouse_softc *sc, 
 {
sc->sc_base.me_evp = evp;
 
+   wsmouse_input_reset(>input);
+
/* enable the device, and punt if that's not possible */
return (*sc->sc_accessops->enable)(sc->sc_accesscookie);
 }
@@ -1266,8 +1268,11 @@ wsmouse_mt_init(struct device *sc, int n
&((struct wsmouse_softc *) sc)->input;
int n, size;
 
+   if (num_slots == input->mt.num_slots
+   && (!tracking == ((input->flags & MT_TRACKING) == 0)))
+   return (0);
+
free_mt_slots(input);
-   memset(>mt, 0, sizeof(struct mt_state));
 
if (tracking)
input->flags |= MT_TRACKING;
@@ -1375,4 +1380,25 @@ void
 wsmouse_input_cleanup(struct wsmouseinput *input)
 {
free_mt_slots(input);
+}
+
+void
+wsmouse_input_reset(struct wsmouseinput *input)
+{
+   int num_slots, *matrix;
+   struct mt_slot *slots;
+
+   memset(>btn, 0, sizeof(struct btn_state));
+   memset(>motion, 0, sizeof(struct motion_state));
+   memset(>touch, 0, sizeof(struct touch_state));
+   input->touch.min_pressure = input->params.pressure_hi;
+   if ((num_slots = input->mt.num_slots)) {
+   slots = input->mt.slots;
+   matrix = input->mt.matrix;
+   memset(>mt, 0, sizeof(struct mt_state));
+   memset(slots, 0, num_slots * sizeof(struct mt_slot));
+   input->mt.num_slots = num_slots;
+   input->mt.slots = slots;
+   input->mt.matrix = matrix;
+   }
 }
Index: wsmouseinput.h
===
RCS file: /cvs/src/sys/dev/wscons/wsmouseinput.h,v
retrieving revision 1.1
diff -u -p -r1.1 wsmouseinput.h
--- wsmouseinput.h  30 Mar 2016 23:34:12 -  1.1
+++ wsmouseinput.h  13 Jul 2016 21:59:01 -
@@ -141,6 +141,7 @@ void wsmouse_init_scaling(struct wsmouse
 
 void wsmouse_input_init(struct wsmouseinput *, struct wseventvar **);
 void wsmouse_input_cleanup(struct wsmouseinput *);
+void wsmouse_input_reset(struct wsmouseinput *);
 
 
 #define FOREACHBIT(v, i) \



Re: bgpd: print AS range

2016-07-13 Thread Sebastian Benoit
Hei,

i finally commited this.

Thank you.

Denis Fondras(open...@ledeuns.net) on 2016.06.05 11:02:31 +0200:
> On Sun, Jun 05, 2016 at 10:28:05AM +0200, Sebastian Benoit wrote:
> > hei,
> > 
> > thanks! i forgot that we print the config.
> > 
> > ok benno@, with whitespace fixed.
> > 
> 
> 
> Index: printconf.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/printconf.c,v
> retrieving revision 1.96
> diff -u -p -r1.96 printconf.c
> --- printconf.c   21 Sep 2015 09:47:15 -  1.96
> +++ printconf.c   5 Jun 2016 09:00:18 -
> @@ -41,8 +41,9 @@ void print_peer(struct peer_config *, 
>  const char   *print_auth_alg(u_int8_t);
>  const char   *print_enc_alg(u_int8_t);
>  void  print_announce(struct peer_config *, const char *);
> +void  print_as(struct filter_rule *);
>  void  print_rule(struct peer *, struct filter_rule *);
> -const char *  mrt_type(enum mrt_type);
> +const char   *mrt_type(enum mrt_type);
>  void  print_mrt(struct bgpd_config *, u_int32_t, u_int32_t,
>   const char *, const char *);
>  void  print_groups(struct bgpd_config *, struct peer *);
> @@ -506,6 +507,26 @@ print_announce(struct peer_config *p, co
>   printf("%s\tannounce %s\n", c, aid2str(aid));
>  }
>  
> +void print_as(struct filter_rule *r)
> +{
> + switch(r->match.as.op) {
> + case OP_RANGE:
> + printf("%s - ", log_as(r->match.as.as_min));
> + printf("%s ", log_as(r->match.as.as_max));
> + break;  
> + case OP_XRANGE:
> + printf("%s >< ", log_as(r->match.as.as_min));
> + printf("%s ", log_as(r->match.as.as_max));
> + break;
> + case OP_NE:
> + printf("!= %s ", log_as(r->match.as.as));
> + break;
> + default:
> + printf("%s ", log_as(r->match.as.as));
> + break;
> + }
> +}
> +
>  void
>  print_rule(struct peer *peer_l, struct filter_rule *r)
>  {
> @@ -577,15 +598,16 @@ print_rule(struct peer *peer_l, struct f
>  
>   if (r->match.as.type) {
>   if (r->match.as.type == AS_ALL)
> - printf("AS %s ", log_as(r->match.as.as));
> + printf("AS ");
>   else if (r->match.as.type == AS_SOURCE)
> - printf("source-as %s ", log_as(r->match.as.as));
> + printf("source-as ");
>   else if (r->match.as.type == AS_TRANSIT)
> - printf("transit-as %s ", log_as(r->match.as.as));
> + printf("transit-as ");
>   else if (r->match.as.type == AS_PEER)
> - printf("peer-as %s ", log_as(r->match.as.as));
> + printf("peer-as ");
>   else
> - printf("unfluffy-as %s ", log_as(r->match.as.as));
> + printf("unfluffy-as ");
> + print_as(r);
>   }
>  
>   if (r->match.aslen.type) {
> 

-- 



Remove unused function ether_cmp() from smc91cxx.c

2016-07-13 Thread Tom Cosgrove

Index: sys/dev/ic/smc91cxx.c
===
RCS file: /home/OpenBSD/cvs/src/sys/dev/ic/smc91cxx.c,v
retrieving revision 1.47
diff -u -p -r1.47 smc91cxx.c
--- sys/dev/ic/smc91cxx.c   13 Apr 2016 10:49:26 -  1.47
+++ sys/dev/ic/smc91cxx.c   12 Jul 2016 14:32:13 -
@@ -181,18 +181,6 @@ void   smc91cxx_resume(struct smc91cxx_sof
 void   smc91cxx_watchdog(struct ifnet *);
 intsmc91cxx_ioctl(struct ifnet *, u_long, caddr_t);
 
-static __inline int ether_cmp(void *, void *);
-static __inline int
-ether_cmp(va, vb)
-   void *va, *vb;
-{
-   u_int8_t *a = va;
-   u_int8_t *b = vb;
-
-   return ((a[5] != b[5]) || (a[4] != b[4]) || (a[3] != b[3]) ||
-   (a[2] != b[2]) || (a[1] != b[1]) || (a[0] != b[0]));
-}
-
 void
 smc91cxx_attach(sc, myea)
struct smc91cxx_softc *sc;



ratecheck.9 example

2016-07-13 Thread Artturi Alm
i like2be able2cpypaste

-Artturi

diff --git a/share/man/man9/ratecheck.9 b/share/man/man9/ratecheck.9
index 4e36e33..1e22053 100644
--- a/share/man/man9/ratecheck.9
+++ b/share/man/man9/ratecheck.9
@@ -106,7 +106,7 @@ drv_errhandler(int err1, int err2)
...
 
drv_err1count++;
-   if (ratecheck(_lasterr1notice,
+   if (ratecheck(_lasterr1time,
_errinterval)) {
printf("drv: %ld err1 errors occurred",
drv_err1count);
@@ -118,7 +118,7 @@ drv_errhandler(int err1, int err2)
...
 
drv_err2count++;
-   if (ratecheck(_lasterr2notice,
+   if (ratecheck(_lasterr2time,
_errinterval)) {
printf("drv: %ld err2 errors occurred",
drv_err2count);



Re: Race in ARP

2016-07-13 Thread Mike Belopuhov
On 12 July 2016 at 10:45, Martin Pieuchot  wrote:
> dlg@ could reproduce a panic by running dhclient in a loop on one of his
> machines.
>
> Turns out that there's a race between arplookup() and arpcache() inside
> in_arpinput().  If another CPU removes the ARP entry from the table, via
> RTM_DELETE, it will free the ARP storage.  That means we cannot update
> an ARP cache without holding the KERNEL_LOCK().
>
> Diff below should prevent the race.  A better solution would be to delay
> the pool_put() until we call rtfree(9), but this needs more work.
>

Sounds reasonable. OK mikeb



armv7 diff for testing

2016-07-13 Thread Mark Kettenis
The diff below removes the last board ID dependent code for the i.MX6
platform.  It affects all boards that use a Micrel PHY, which would
show up as "ukphy0" in your dmesg.  If you have such a board (udoo,
novena and sabrelight, there may be others), I'd apprciate if you
could test this diff and check whether the network interface still
works.

I'll probably commit the diff in a couple of days if I don't get any
test reports.

Thanks,

Mark


Index: arch/armv7/imx/if_fec.c
===
RCS file: /cvs/src/sys/arch/armv7/imx/if_fec.c,v
retrieving revision 1.6
diff -u -p -r1.6 if_fec.c
--- arch/armv7/imx/if_fec.c 11 Jul 2016 14:56:18 -  1.6
+++ arch/armv7/imx/if_fec.c 13 Jul 2016 09:14:27 -
@@ -225,7 +225,7 @@ struct fec_softc {
struct device   sc_dev;
struct arpcom   sc_ac;
struct mii_data sc_mii;
-   int sc_phyno;
+   int sc_node;
bus_space_tag_t sc_iot;
bus_space_handle_t  sc_ioh;
void*sc_ih; /* Interrupt handler */
@@ -247,7 +247,6 @@ struct fec_softc *fec_sc;
 
 int fec_match(struct device *, void *, void *);
 void fec_attach(struct device *, struct device *, void *);
-void fec_chip_init(struct fec_softc *);
 void fec_phy_init(struct fec_softc *, struct mii_softc *);
 int fec_ioctl(struct ifnet *, u_long, caddr_t);
 void fec_start(struct ifnet *);
@@ -305,6 +304,7 @@ fec_attach(struct device *parent, struct
intr, sizeof(intr)) < sizeof(intr))
return;
 
+   sc->sc_node = faa->fa_node;
sc->sc_iot = faa->fa_iot;
if (bus_space_map(sc->sc_iot, faa->fa_reg[0],
faa->fa_reg[1], 0, >sc_ioh))
@@ -403,8 +403,9 @@ fec_attach(struct device *parent, struct
printf("%s: address %s\n", sc->sc_dev.dv_xname,
ether_sprintf(sc->sc_ac.ac_enaddr));
 
-   /* initialize the chip */
-   fec_chip_init(sc);
+   /* initialize the MII clock */
+   HWRITE4(sc, ENET_MSCR,
+   (((imxccm_get_fecclk() + (ENET_MII_CLK << 2) - 1) / (ENET_MII_CLK 
<< 2)) << 1) | 0x100);
 
/* Initialize MII/media info. */
mii = >sc_mii;
@@ -445,94 +446,6 @@ bad:
 }
 
 void
-fec_chip_init(struct fec_softc *sc)
-{
-   struct device *dev = (struct device *) sc;
-   int phy = 0;
-
-   bus_space_write_4(sc->sc_iot, sc->sc_ioh, ENET_MSCR,
-   (((imxccm_get_fecclk() + (ENET_MII_CLK << 2) - 1) / (ENET_MII_CLK 
<< 2)) << 1) | 0x100);
-
-   switch (board_id)
-   {
-   case BOARD_ID_IMX6_SABRELITE:
-   phy = ENET_SABRELITE_PHY;
-   break;
-   case BOARD_ID_IMX6_UDOO:
-   phy = ENET_UDOO_PHY;
-   break;
-   case BOARD_ID_IMX6_NOVENA:
-   phy = ENET_NOVENA_PHY;
-   break;
-   }
-
-   switch (board_id)
-   {
-   case BOARD_ID_IMX6_UDOO:/* Micrel KSZ9031 */
-   /* prefer master mode */
-   fec_miibus_writereg(dev, phy, 0x9, 0x1c00);
-
-   /* control data pad skew */
-   fec_miibus_writereg(dev, phy, 0x0d, 0x0002);
-   fec_miibus_writereg(dev, phy, 0x0e, 0x0004);
-   fec_miibus_writereg(dev, phy, 0x0d, 0x4002);
-   fec_miibus_writereg(dev, phy, 0x0e, 0x);
-
-   /* rx data pad skew */
-   fec_miibus_writereg(dev, phy, 0x0d, 0x0002);
-   fec_miibus_writereg(dev, phy, 0x0e, 0x0005);
-   fec_miibus_writereg(dev, phy, 0x0d, 0x4002);
-   fec_miibus_writereg(dev, phy, 0x0e, 0x);
-
-   /* tx data pad skew */
-   fec_miibus_writereg(dev, phy, 0x0d, 0x0002);
-   fec_miibus_writereg(dev, phy, 0x0e, 0x0006);
-   fec_miibus_writereg(dev, phy, 0x0d, 0x4002);
-   fec_miibus_writereg(dev, phy, 0x0e, 0x);
-
-   /* gtx and rx data pad skew */
-   fec_miibus_writereg(dev, phy, 0x0d, 0x0002);
-   fec_miibus_writereg(dev, phy, 0x0e, 0x0008);
-   fec_miibus_writereg(dev, phy, 0x0d, 0x4002);
-   fec_miibus_writereg(dev, phy, 0x0e, 0x03ff);
-   break;
-   case BOARD_ID_IMX6_SABRELITE:   /* Micrel KSZ9021 */
-   /* prefer master mode */
-   fec_miibus_writereg(dev, phy, 0x9, 0x1f00);
-
-   /* min rx data delay */
-   fec_miibus_writereg(dev, phy, 0x0b, 0x8105);
-   fec_miibus_writereg(dev, phy, 0x0c, 0x);
-
-   /* min tx data delay */
-   fec_miibus_writereg(dev, phy, 0x0b, 0x8106);
-   fec_miibus_writereg(dev, phy, 0x0c, 0x);
-
-   /* max rx/tx clock delay, min rx/tx control delay */
-   fec_miibus_writereg(dev, phy, 0x0b, 0x8104);
-   fec_miibus_writereg(dev, phy, 0x0c, 0xf0f0);
-   

Re: Auto tunnel - RFC4213

2016-07-13 Thread Alexander Bluhm
On Tue, Jul 12, 2016 at 11:46:43AM +0200, Martin Pieuchot wrote:
> > Would you then remove the ::/96 reject route from the routing table?
> 
> I think this should be a second discussion.  We also have a route for
> IPv4-mapped IPv6 addresses & have a similar check enabled in ip6_input():
> 
> :::0.0.0.0/96::1  UGRS0   0 32768 8 lo0  
> 
> Now routes also prevent any user from sending packets to such destinations. 
> Note that we don't have similar checks in ip6_output().

I would leave the reject route as it is.

OK bluhm@

> > > Index: netinet6/ip6_input.c
> > > ===
> > > RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
> > > retrieving revision 1.162
> > > diff -u -p -r1.162 ip6_input.c
> > > --- netinet6/ip6_input.c  6 Jul 2016 15:50:00 -   1.162
> > > +++ netinet6/ip6_input.c  12 Jul 2016 09:17:04 -
> > > @@ -299,20 +299,17 @@ ip6_input(struct mbuf *m)
> > >   ip6stat.ip6s_badscope++;
> > >   goto bad;
> > >   }
> > > -#if 0
> > > +
> > >   /*
> > >* Reject packets with IPv4 compatible addresses (auto tunnel).
> > >*
> > > -  * The code forbids auto tunnel relay case in RFC1933 (the check is
> > > -  * stronger than RFC1933).  We may want to re-enable it if mech-xx
> > > -  * is revised to forbid relaying case.
> > > +  * The code forbids automatic tunneling as per RFC4213.
> > >*/
> > >   if (IN6_IS_ADDR_V4COMPAT(>ip6_src) ||
> > >   IN6_IS_ADDR_V4COMPAT(>ip6_dst)) {
> > >   ip6stat.ip6s_badscope++;
> > >   goto bad;
> > >   }
> > > -#endif
> > >  
> > >   /*
> > >* If the packet has been received on a loopback interface it
> > > 
> > 
> > -- 
> > :wq Claudio
> > 



Re: Auto tunnel - RFC4213

2016-07-13 Thread Claudio Jeker
On Tue, Jul 12, 2016 at 11:46:43AM +0200, Martin Pieuchot wrote:
> On 12/07/16(Tue) 11:33, Claudio Jeker wrote:
> > On Tue, Jul 12, 2016 at 11:28:47AM +0200, Martin Pieuchot wrote:
> > > By default we have a route to reject compatible addresses:
> > > 
> > > ::/96 ::1UGRS 0  0 32768 8 lo0  
> > > 
> > > But the corresponding check in ip6_input() is still commented because it
> > > is "stronger than RFC1933".  However since 1996 this RFC has been
> > > obsoleted twice and the newer one, RFC4213 says:
> > > 
> > >   The following changes have been performed since RFC 2893:
> > > 
> > > - Removed automatic tunneling and use of IPv4-compatible
> > >   addresses.
> > > 
> > > - [...]
> > > 
> > > 
> > > Then later it explicitly documents:
> > > 
> > >   After the decapsulation, the node MUST silently discard a packet with
> > >   an invalid IPv6 source address. The list of invalid source addresses
> > >   SHOULD include at least:
> > > 
> > > - all the IPv4-compatible IPv6 addresses [RFC3513] (::/96),
> > >   excluding the unspecified address for Duplicate Address Detection
> > >   (::/128)
> > > 
> > > - [...]
> > > 
> > > 
> > > Do I understand correctly that it is time to enable this check?
> > 
> > Would you then remove the ::/96 reject route from the routing table?
> 
> I think this should be a second discussion.  We also have a route for
> IPv4-mapped IPv6 addresses & have a similar check enabled in ip6_input():
> 
> :::0.0.0.0/96::1  UGRS0   0 32768 8 lo0  
> 
> Now routes also prevent any user from sending packets to such destinations. 
> Note that we don't have similar checks in ip6_output().

Yes, this what was I was wondering. The route covers the output path and
forwarding path. So if we want to remove them we need to add an equivalent
check in ip6_output().
 
> > Or is this more a belt and suspender kind of thing? 
> 
> It is.

OK claudio@

PS: Not sure if ip6stat.ip6s_badscope is the right error counter but I think
it is the best we have and it is also used for the IPv4 mapped addrs.
 
> > > Index: netinet6/ip6_input.c
> > > ===
> > > RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
> > > retrieving revision 1.162
> > > diff -u -p -r1.162 ip6_input.c
> > > --- netinet6/ip6_input.c  6 Jul 2016 15:50:00 -   1.162
> > > +++ netinet6/ip6_input.c  12 Jul 2016 09:17:04 -
> > > @@ -299,20 +299,17 @@ ip6_input(struct mbuf *m)
> > >   ip6stat.ip6s_badscope++;
> > >   goto bad;
> > >   }
> > > -#if 0
> > > +
> > >   /*
> > >* Reject packets with IPv4 compatible addresses (auto tunnel).
> > >*
> > > -  * The code forbids auto tunnel relay case in RFC1933 (the check is
> > > -  * stronger than RFC1933).  We may want to re-enable it if mech-xx
> > > -  * is revised to forbid relaying case.
> > > +  * The code forbids automatic tunneling as per RFC4213.
> > >*/
> > >   if (IN6_IS_ADDR_V4COMPAT(>ip6_src) ||
> > >   IN6_IS_ADDR_V4COMPAT(>ip6_dst)) {
> > >   ip6stat.ip6s_badscope++;
> > >   goto bad;
> > >   }
> > > -#endif
> > >  
> > >   /*
> > >* If the packet has been received on a loopback interface it
> > > 
> > 
> > -- 
> > :wq Claudio
> > 
> 

-- 
:wq Claudio