Re: Route mpath conflict tweak

2015-02-03 Thread Claudio Jeker
On Wed, Feb 04, 2015 at 02:15:22AM +0100, Martin Pieuchot wrote:
> On 03/02/15(Tue) 16:25, Claudio Jeker wrote:
> > On Tue, Feb 03, 2015 at 10:39:35AM +0100, Martin Pieuchot wrote:
> > > Diff below changes rt_mpath_conflict() to no longer rely on a fully
> > > initialized rtentry.  Right now it makes things prettier when adding
> > > a new route entry but later it will also help to dissociate "struct 
> > > radix_node" from "struct rtentry".
> > > 
> > > route(8) regression tests checking for conflicts are happy with this.
> > > 
> > > Ok?
> > 
> > Reads fine. Not sure if the regress test is enough for this.
> 
> I believe it covers all the different conflict cases, but if you think
> something is not covered we can always add new tests.
> 

I just don't trust myself to figure out all the crazy cases people come up
with... At least the history with the routing code teached me that there
is almost always on strange edge case that was missed.
Since we are heading into lock very soon I'm more conservative about
routing changes happening right now. I still think this is OK and it
should go in. I hope to have time to test it on the flight.

> >  
> > > Index: net/radix_mpath.c
> > > ===
> > > RCS file: /cvs/src/sys/net/radix_mpath.c,v
> > > retrieving revision 1.27
> > > diff -u -p -r1.27 radix_mpath.c
> > > --- net/radix_mpath.c 19 Dec 2014 17:14:40 -  1.27
> > > +++ net/radix_mpath.c 3 Feb 2015 09:20:38 -
> > > @@ -204,16 +204,15 @@ rt_mpath_matchgate(struct rtentry *rt, s
> > >   * check if we have the same key/mask/gateway on the table already.
> > >   */
> > >  int
> > > -rt_mpath_conflict(struct radix_node_head *rnh, struct rtentry *rt,
> > > -struct sockaddr *netmask, int mpathok)
> > > +rt_mpath_conflict(struct radix_node_head *rnh, struct sockaddr *dst,
> > > +struct sockaddr *netmask, struct sockaddr *gate, u_int8_t prio, int 
> > > mpathok)
> > >  {
> > > - struct radix_node *rn, *rn1;
> > > + struct radix_node *rn1;
> > >   struct rtentry *rt1;
> > >   char *p, *q, *eq;
> > >   int same, l, skip;
> > >  
> > > - rn = (struct radix_node *)rt;
> > > - rn1 = rnh->rnh_lookup(rt_key(rt), netmask, rnh);
> > > + rn1 = rnh->rnh_lookup(dst, netmask, rnh);
> > >   if (!rn1 || rn1->rn_flags & RNF_ROOT)
> > >   return 0;
> > >  
> > > @@ -224,8 +223,8 @@ rt_mpath_conflict(struct radix_node_head
> > >   rt1 = (struct rtentry *)rn1;
> > >  
> > >   /* compare key. */
> > > - if (rt_key(rt1)->sa_len != rt_key(rt)->sa_len ||
> > > - bcmp(rt_key(rt1), rt_key(rt), rt_key(rt1)->sa_len))
> > > + if (rt_key(rt1)->sa_len != dst->sa_len ||
> > > + bcmp(rt_key(rt1), dst, rt_key(rt1)->sa_len))
> > >   goto different;
> > >  
> > >   /* key was the same.  compare netmask.  hairy... */
> > > @@ -277,11 +276,11 @@ rt_mpath_conflict(struct radix_node_head
> > >   }
> > >  
> > >   maskmatched:
> > > - if (!mpathok && rt1->rt_priority == rt->rt_priority)
> > > + if (!mpathok && rt1->rt_priority == prio)
> > >   return EEXIST;
> > >  
> > >   /* key/mask were the same.  compare gateway for all multipaths */
> > > - if (rt_mpath_matchgate(rt1, rt->rt_gateway, rt->rt_priority))
> > > + if (rt_mpath_matchgate(rt1, gate, prio))
> > >   /* all key/mask/gateway are the same.  conflicting entry. */
> > >   return EEXIST;
> > >  
> > > Index: net/radix_mpath.h
> > > ===
> > > RCS file: /cvs/src/sys/net/radix_mpath.h,v
> > > retrieving revision 1.14
> > > diff -u -p -r1.14 radix_mpath.h
> > > --- net/radix_mpath.h 25 Nov 2014 14:50:46 -  1.14
> > > +++ net/radix_mpath.h 3 Feb 2015 09:20:07 -
> > > @@ -54,8 +54,8 @@ voidrn_mpath_adj_mpflag(struct radix_no
> > >  int  rn_mpath_active_count(struct radix_node *);
> > >  struct rtentry *rt_mpath_matchgate(struct rtentry *, struct sockaddr *,
> > >   u_int8_t);
> > > -int  rt_mpath_conflict(struct radix_node_head *, struct rtentry *,
> > > - struct sockaddr *, int);
> > > +int  rt_mpath_conflict(struct radix_node_head *, struct sockaddr *,
> > > + struct sockaddr *, struct sockaddr *, u_int8_t, int);
> > >  struct rtentry *rtalloc_mpath(struct sockaddr *, u_int32_t *, u_int);
> > >  int  rn_mpath_inithead(void **, int);
> > >  #endif /* _KERNEL */
> > > Index: net/route.c
> > > ===
> > > RCS file: /cvs/src/sys/net/route.c,v
> > > retrieving revision 1.203
> > > diff -u -p -r1.203 route.c
> > > --- net/route.c   28 Jan 2015 22:10:13 -  1.203
> > > +++ net/route.c   3 Feb 2015 09:23:26 -
> > > @@ -826,15 +826,25 @@ rtrequest1(int req, struct rt_addrinfo *
> > >   if (info->rti_ifa == NULL && (error = rt_getifa(info, tableid)))
> > >   return (error);
> > >   ifa = info->rti_ifa;
> > > + if (prio == 0)
> > > +   

Re: syslog over TLS

2015-02-03 Thread Ted Unangst
sven falempin wrote:
> 
> Dear Tech@openbsd.org

in the future, it's not really necessary to quote the entire diff.

> 
> 
> Most of TLS client got a few parameters like :
> 
> CRL,CA,and Client Certificat
> 
> Just look at < Document how to send syslog messages over TCP or TLS. >
> (because this TLS feature is SO cool).
> 
> So i guess the CA could be put in /etc/ssl but what if i'd like to
> authentify myself to the server ? is it in the roadmap ? is this
> already possible ?

libtls doesn't support client certs at this time.



Re: Route mpath conflict tweak

2015-02-03 Thread Martin Pieuchot
On 03/02/15(Tue) 16:25, Claudio Jeker wrote:
> On Tue, Feb 03, 2015 at 10:39:35AM +0100, Martin Pieuchot wrote:
> > Diff below changes rt_mpath_conflict() to no longer rely on a fully
> > initialized rtentry.  Right now it makes things prettier when adding
> > a new route entry but later it will also help to dissociate "struct 
> > radix_node" from "struct rtentry".
> > 
> > route(8) regression tests checking for conflicts are happy with this.
> > 
> > Ok?
> 
> Reads fine. Not sure if the regress test is enough for this.

I believe it covers all the different conflict cases, but if you think
something is not covered we can always add new tests.

>  
> > Index: net/radix_mpath.c
> > ===
> > RCS file: /cvs/src/sys/net/radix_mpath.c,v
> > retrieving revision 1.27
> > diff -u -p -r1.27 radix_mpath.c
> > --- net/radix_mpath.c   19 Dec 2014 17:14:40 -  1.27
> > +++ net/radix_mpath.c   3 Feb 2015 09:20:38 -
> > @@ -204,16 +204,15 @@ rt_mpath_matchgate(struct rtentry *rt, s
> >   * check if we have the same key/mask/gateway on the table already.
> >   */
> >  int
> > -rt_mpath_conflict(struct radix_node_head *rnh, struct rtentry *rt,
> > -  struct sockaddr *netmask, int mpathok)
> > +rt_mpath_conflict(struct radix_node_head *rnh, struct sockaddr *dst,
> > +struct sockaddr *netmask, struct sockaddr *gate, u_int8_t prio, int 
> > mpathok)
> >  {
> > -   struct radix_node *rn, *rn1;
> > +   struct radix_node *rn1;
> > struct rtentry *rt1;
> > char *p, *q, *eq;
> > int same, l, skip;
> >  
> > -   rn = (struct radix_node *)rt;
> > -   rn1 = rnh->rnh_lookup(rt_key(rt), netmask, rnh);
> > +   rn1 = rnh->rnh_lookup(dst, netmask, rnh);
> > if (!rn1 || rn1->rn_flags & RNF_ROOT)
> > return 0;
> >  
> > @@ -224,8 +223,8 @@ rt_mpath_conflict(struct radix_node_head
> > rt1 = (struct rtentry *)rn1;
> >  
> > /* compare key. */
> > -   if (rt_key(rt1)->sa_len != rt_key(rt)->sa_len ||
> > -   bcmp(rt_key(rt1), rt_key(rt), rt_key(rt1)->sa_len))
> > +   if (rt_key(rt1)->sa_len != dst->sa_len ||
> > +   bcmp(rt_key(rt1), dst, rt_key(rt1)->sa_len))
> > goto different;
> >  
> > /* key was the same.  compare netmask.  hairy... */
> > @@ -277,11 +276,11 @@ rt_mpath_conflict(struct radix_node_head
> > }
> >  
> >   maskmatched:
> > -   if (!mpathok && rt1->rt_priority == rt->rt_priority)
> > +   if (!mpathok && rt1->rt_priority == prio)
> > return EEXIST;
> >  
> > /* key/mask were the same.  compare gateway for all multipaths */
> > -   if (rt_mpath_matchgate(rt1, rt->rt_gateway, rt->rt_priority))
> > +   if (rt_mpath_matchgate(rt1, gate, prio))
> > /* all key/mask/gateway are the same.  conflicting entry. */
> > return EEXIST;
> >  
> > Index: net/radix_mpath.h
> > ===
> > RCS file: /cvs/src/sys/net/radix_mpath.h,v
> > retrieving revision 1.14
> > diff -u -p -r1.14 radix_mpath.h
> > --- net/radix_mpath.h   25 Nov 2014 14:50:46 -  1.14
> > +++ net/radix_mpath.h   3 Feb 2015 09:20:07 -
> > @@ -54,8 +54,8 @@ void  rn_mpath_adj_mpflag(struct radix_no
> >  intrn_mpath_active_count(struct radix_node *);
> >  struct rtentry *rt_mpath_matchgate(struct rtentry *, struct sockaddr *,
> > u_int8_t);
> > -intrt_mpath_conflict(struct radix_node_head *, struct rtentry *,
> > -   struct sockaddr *, int);
> > +intrt_mpath_conflict(struct radix_node_head *, struct sockaddr *,
> > +   struct sockaddr *, struct sockaddr *, u_int8_t, int);
> >  struct rtentry *rtalloc_mpath(struct sockaddr *, u_int32_t *, u_int);
> >  intrn_mpath_inithead(void **, int);
> >  #endif /* _KERNEL */
> > Index: net/route.c
> > ===
> > RCS file: /cvs/src/sys/net/route.c,v
> > retrieving revision 1.203
> > diff -u -p -r1.203 route.c
> > --- net/route.c 28 Jan 2015 22:10:13 -  1.203
> > +++ net/route.c 3 Feb 2015 09:23:26 -
> > @@ -826,15 +826,25 @@ rtrequest1(int req, struct rt_addrinfo *
> > if (info->rti_ifa == NULL && (error = rt_getifa(info, tableid)))
> > return (error);
> > ifa = info->rti_ifa;
> > +   if (prio == 0)
> > +   prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
> > +#ifndef SMALL_KERNEL
> > +   if (rn_mpath_capable(rnh)) {
> > +   /* do not permit exactly the same dst/mask/gw pair */
> > +   if (rt_mpath_conflict(rnh, info->rti_info[RTAX_DST],
> > +   info->rti_info[RTAX_NETMASK],
> > +   info->rti_info[RTAX_GATEWAY], prio,
> > +   info->rti_flags & RTF_MPATH)) {
> > +   return (EEXIST);
> > +   }
> > +   }
> > +#endif
> > 

Re: syslog over TLS

2015-02-03 Thread sven falempin
On Fri, Jan 16, 2015 at 12:54 PM, Reyk Floeter  wrote:
> On Fri, Jan 16, 2015 at 12:56:45PM +0100, Alexander Bluhm wrote:
>> On Fri, Jan 16, 2015 at 01:46:09AM +0100, Alexander Bluhm wrote:
>> > This diff enables sending syslog messages over TLS.
>>
>> Updated diff after sys/param.h commit.  Only some context changed.
>>
>> bluhm
>>
>
> Despite my scepticism about putting it into libevent -
>
> The diff looks and works fine (lightly tested).
>
> The evbuffer_tls.c code is similar enough to what we have in
> relayd/httpd and libevent;  so I don't see any problems here.
>
> Minor comments (not inline):
> - The ebuf[100] looks a bit weird, but it is not a problem.
> - I would prefer checking return value as -1 instead of < 0
>   (tls_init() and other calls below).
> - The manpage bits are missing.
>
> I'm fine with putting it in and to improve/discuss the API issues later.
>
> OK
>
> Reyk
>
>> Index: usr.sbin/syslogd/Makefile
>> ===
>> RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/Makefile,v
>> retrieving revision 1.6
>> diff -u -p -r1.6 Makefile
>> --- usr.sbin/syslogd/Makefile 5 Oct 2014 18:14:01 -   1.6
>> +++ usr.sbin/syslogd/Makefile 16 Jan 2015 11:45:40 -
>> @@ -1,9 +1,9 @@
>>  #$OpenBSD: Makefile,v 1.6 2014/10/05 18:14:01 bluhm Exp $
>>
>>  PROG=syslogd
>> -SRCS=syslogd.c ttymsg.c privsep.c privsep_fdpass.c ringbuf.c
>> +SRCS=syslogd.c ttymsg.c privsep.c privsep_fdpass.c ringbuf.c 
>> evbuffer_tls.c
>>  MAN= syslogd.8 syslog.conf.5
>> -LDADD=   -levent
>> -DPADD=   ${LIBEVENT}
>> +LDADD=   -levent -ltls -lssl -lcrypto
>> +DPADD=   ${LIBEVENT} ${LIBTLS} ${LIBSSL} ${LIBCRYPTO}
>>
>>  .include 
>> Index: usr.sbin/syslogd/evbuffer_tls.c
>> ===
>> RCS file: usr.sbin/syslogd/evbuffer_tls.c
>> diff -N usr.sbin/syslogd/evbuffer_tls.c
>> --- /dev/null 1 Jan 1970 00:00:00 -
>> +++ usr.sbin/syslogd/evbuffer_tls.c   16 Jan 2015 11:45:40 -
>> @@ -0,0 +1,357 @@
>> +/*   $OpenBSD$ */
>> +
>> +/*
>> + * Copyright (c) 2002-2004 Niels Provos 
>> + * Copyright (c) 2014-2015 Alexander Bluhm 
>> + * All rights reserved.
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + * 1. Redistributions of source code must retain the above copyright
>> + *notice, this list of conditions and the following disclaimer.
>> + * 2. Redistributions in binary form must reproduce the above copyright
>> + *notice, this list of conditions and the following disclaimer in the
>> + *documentation and/or other materials provided with the distribution.
>> + * 3. The name of the author may not be used to endorse or promote products
>> + *derived from this software without specific prior written permission.
>> + *
>> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
>> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
>> + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
>> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
>> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
>> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
>> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
>> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
>> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "evbuffer_tls.h"
>> +
>> +/* prototypes */
>> +
>> +void bufferevent_read_pressure_cb(struct evbuffer *, size_t, size_t, void 
>> *);
>> +int evtls_read(struct evbuffer *, int, int, struct tls *);
>> +int evtls_write(struct evbuffer *, int, struct tls *);
>> +
>> +static int
>> +bufferevent_add(struct event *ev, int timeout)
>> +{
>> + struct timeval tv, *ptv = NULL;
>> +
>> + if (timeout) {
>> + timerclear(&tv);
>> + tv.tv_sec = timeout;
>> + ptv = &tv;
>> + }
>> +
>> + return (event_add(ev, ptv));
>> +}
>> +
>> +static void
>> +buffertls_readcb(int fd, short event, void *arg)
>> +{
>> + struct buffertls *buftls = arg;
>> + struct bufferevent *bufev = buftls->bt_bufev;
>> + struct tls *ctx = buftls->bt_ctx;
>> + int res = 0;
>> + short what = EVBUFFER_READ;
>> + size_t len;
>> + int howmuch = -1;
>> +
>> + if (event == EV_TIMEOUT) {
>> + what |= EVBUFFER_TIMEOUT;
>> + goto error;
>> + }
>> +
>> + /*
>> +  * If we have a high watermark configured then we don

Re: elantech-v4 clickpad support

2015-02-03 Thread Ulf Brosziewski

On 01/30/2015 11:04 AM, Ulf Brosziewski wrote:

On 01/30/2015 07:15 AM, Martin Pieuchot wrote:

On 30/01/15(Fri) 01:25, Ulf Brosziewski wrote:

Probably I was too sceptical about synaptics.c. The bug I observed
with the ALPS touchpad seems to be due to a kind of mismatch between
the ALPS code in pms and the event handling in wsconscomm. The patch
below contains the initial change as well as what was necessary to
fix this.


Do you think it is possible to fix the pms(4) driver instead of adding
another quirk?


...


Certainly that would be a better solution. For synaptics hardware there
seems to be no specific W value that signals the end of a touch. If I
understand it correctly, the hardware reports zero coordinates instead
and the X driver adjusts its state accordingly. I will try to check soon
whether this is correct and whether the ALPS code could be adapted.




I couldn't test it directly, but according to the "Synaptics PS/2 TouchPad
Interfacing Guide" synaptics hardware does indeed signal a W value of 0 if
there is no pressure as well as for two-finger contacts. This means that
the ALPS part of pms is correct and shouldn't be changed. For a proper
finger count Z must be checked, and the place to do this is probably in
wsconscomm. I have changed the patch accordingly.

The change in the new version applies to all touchpad/clickpad models and
would require appropriate testing. In my own tests with the ALPS Glidepoint
touchpad and the Elantech Clickpad - and the patched pms version - I didn't
observe any problems.

diff --git a/wsconscomm.c b/wsconscomm.c
index df3512d..70c103a 100644
--- a/wsconscomm.c
+++ b/wsconscomm.c
@@ -132,12 +132,6 @@ WSConsReadHwState(InputInfoPtr pInfo,
 struct wscons_event event;
 Bool v;

-/* Reset cumulative values if buttons were not previously pressed */
-if (!hw->left && !hw->right && !hw->middle) {
-hw->cumulative_dx = hw->x;
-hw->cumulative_dy = hw->y;
-}
-
 while (WSConsReadEvent(pInfo, &event)) {
 switch (event.type) {
 case WSCONS_EVENT_MOUSE_UP:
@@ -187,9 +181,11 @@ WSConsReadHwState(InputInfoPtr pInfo,
 break;
 case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
 hw->x = event.value;
+hw->cumulative_dx = hw->x;
 break;
 case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
 hw->y = priv->maxy - event.value + priv->miny;
+hw->cumulative_dy = hw->y;
 break;
 case WSCONS_EVENT_MOUSE_ABSOLUTE_Z:
 hw->z = event.value;
@@ -218,6 +214,10 @@ WSConsReadHwState(InputInfoPtr pInfo,
 }
 break;
 case WSCONS_EVENT_SYNC:
+if (hw->z == 0) {
+hw->fingerWidth = 0;
+hw->numFingers = 0;
+}
 hw->millis = 1000 * event.time.tv_sec + event.time.tv_nsec / 
100;

 SynapticsCopyHwState(hwRet, hw);
 return TRUE;



Re: Unbreak !HIBERNATE builds (amd64)

2015-02-03 Thread Mike Larkin
On Tue, Feb 03, 2015 at 03:36:59AM -0700, David Coppa wrote:
> 
> ok?
> 
> Ciao,
> David
> 
> Index: arch/amd64/amd64/acpi_wakecode.S
> ===
> RCS file: /cvs/src/sys/arch/amd64/amd64/acpi_wakecode.S,v
> retrieving revision 1.35
> diff -u -p -u -p -r1.35 acpi_wakecode.S
> --- arch/amd64/amd64/acpi_wakecode.S  8 Dec 2014 07:12:37 -   1.35
> +++ arch/amd64/amd64/acpi_wakecode.S  3 Feb 2015 10:32:43 -
> @@ -627,12 +627,14 @@ _ACPI_TRMP_DATA_LABEL(acpi_saved_sfmask)
>   .align 4
>  _ACPI_TRMP_DATA_LABEL(acpi_pdirpa)
>   .long 0
> +#ifdef HIBERNATE
>  _ACPI_TRMP_DATA_LABEL(hibernate_indirect_16)
>   .long   hibernate_resume_vector_3
>   .word   0x18
>  _ACPI_TRMP_DATA_LABEL(hibernate_indirect_16b)
>   .long   hibernate_resume_vector_3b
>   .word   0x18
> +#endif /* HIBERNATE */
>  
>  _C_LABEL(acpi_tramp_data_end):
>  
> 

I think you'll have other trampoline problems besides this, but if this
works for you ... sure, I don't see any problem with it.

ok mlarkin@



Re: bgpd.conf macros on 5.5 and up

2015-02-03 Thread Denis Fondras
Hi all,

Here is a patch to revert back to 5.4 behaviour so the manual example with
braces works again :

# cat /etc/bgpd.conf

  
AS 65001
router-id 10.0.0.1

neighbor 10.0.2.0 {
remote-as   65004
descr   upstream2
local-address   10.0.0.8
ipsec ah ike
}

deny from any prefix { 192.168.0.0/16, 10.0.0.0/8 or-longer }
good="{ 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 }"
bad="{ 224.0.0.0/4 prefixlen >= 4, 240.0.0.0/4 prefixlen >= 4 }"
ugly="{ 127.0.0.1/8, 169.254.0.0/16 }"
deny from any prefix { $good $bad $ugly }


# bgpd -dnv
good = "{ 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 }"
bad = "{ 224.0.0.0/4 prefixlen >= 4, 240.0.0.0/4 prefixlen >= 4 }"
ugly = "{ 127.0.0.1/8, 169.254.0.0/16 }"
AS 65001
router-id 10.0.0.1
socket "/var/run/bgpd.sock"
holdtime min 3
fib-priority 48


rde rib Adj-RIB-In no evaluate
rde rib Loc-RIB rtable 0 fib-update yes


neighbor 10.0.2.0 {
descr "upstream2"
remote-as 65004
local-address 10.0.0.8
announce self
enforce neighbor-as yes
ipsec ah ike
announce IPv4 unicast
softreconfig in yes
softreconfig out yes
}

deny from any prefix 10.0.0.0/8 prefixlen >= 8 
deny from any prefix 192.168.0.0/16 
deny from any prefix 10.0.0.0/8 
deny from any prefix 172.16.0.0/12 
deny from any prefix 192.168.0.0/16 
deny from any prefix 240.0.0.0/4 prefixlen >= 4 
deny from any prefix 224.0.0.0/4 prefixlen >= 4 
deny from any prefix 169.254.0.0/16 
deny from any prefix 127.0.0.1/8 


Index: parse.y
===
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.275
diff -u -p -r1.275 parse.y
--- parse.y 20 Nov 2014 05:51:20 -  1.275
+++ parse.y 3 Feb 2015 16:39:40 -
@@ -211,7 +211,8 @@ typedef struct {
 %type prefixlenop
 %typefilter_set_opt
 %type   filter_set filter_set_l
-%type filter_prefix filter_prefix_l filter_prefix_h
+%type filter_prefix filter_prefix_l 
+%type filter_prefix_h filter_prefix_m
 %typeunaryop binaryop filter_as_type
 %type   encspec
 %%
@@ -1518,10 +1519,23 @@ filter_prefix_h : IPV4 prefixlenop
{
}
}
| PREFIX filter_prefix  { $$ = $2; }
-   | PREFIX '{' filter_prefix_l '}'{ $$ = $3; }
+   | PREFIX '{' filter_prefix_m '}'{ $$ = $3; }
;
 
-filter_prefix_l: filter_prefix { $$ = $1; }
+filter_prefix_m: filter_prefix_l
+   | '{' filter_prefix_l '}'   { $$ = $2; }
+   | '{' filter_prefix_l '}' filter_prefix_m
+   {
+   struct filter_prefix_l  *p;
+
+   /* merge, both can be lists */
+   for (p = $2; p != NULL && p->next != NULL; p = p->next)
+   ;   /* nothing */
+   if (p != NULL)
+   p->next = $4;
+   $$ = $2;
+   }
+filter_prefix_l: filter_prefix { $$ = $1; }
| filter_prefix_l comma filter_prefix   {
$3->next = $1;
$$ = $3;



Re: Route mpath conflict tweak

2015-02-03 Thread Claudio Jeker
On Tue, Feb 03, 2015 at 10:39:35AM +0100, Martin Pieuchot wrote:
> Diff below changes rt_mpath_conflict() to no longer rely on a fully
> initialized rtentry.  Right now it makes things prettier when adding
> a new route entry but later it will also help to dissociate "struct 
> radix_node" from "struct rtentry".
> 
> route(8) regression tests checking for conflicts are happy with this.
> 
> Ok?

Reads fine. Not sure if the regress test is enough for this.
 
> Index: net/radix_mpath.c
> ===
> RCS file: /cvs/src/sys/net/radix_mpath.c,v
> retrieving revision 1.27
> diff -u -p -r1.27 radix_mpath.c
> --- net/radix_mpath.c 19 Dec 2014 17:14:40 -  1.27
> +++ net/radix_mpath.c 3 Feb 2015 09:20:38 -
> @@ -204,16 +204,15 @@ rt_mpath_matchgate(struct rtentry *rt, s
>   * check if we have the same key/mask/gateway on the table already.
>   */
>  int
> -rt_mpath_conflict(struct radix_node_head *rnh, struct rtentry *rt,
> -struct sockaddr *netmask, int mpathok)
> +rt_mpath_conflict(struct radix_node_head *rnh, struct sockaddr *dst,
> +struct sockaddr *netmask, struct sockaddr *gate, u_int8_t prio, int 
> mpathok)
>  {
> - struct radix_node *rn, *rn1;
> + struct radix_node *rn1;
>   struct rtentry *rt1;
>   char *p, *q, *eq;
>   int same, l, skip;
>  
> - rn = (struct radix_node *)rt;
> - rn1 = rnh->rnh_lookup(rt_key(rt), netmask, rnh);
> + rn1 = rnh->rnh_lookup(dst, netmask, rnh);
>   if (!rn1 || rn1->rn_flags & RNF_ROOT)
>   return 0;
>  
> @@ -224,8 +223,8 @@ rt_mpath_conflict(struct radix_node_head
>   rt1 = (struct rtentry *)rn1;
>  
>   /* compare key. */
> - if (rt_key(rt1)->sa_len != rt_key(rt)->sa_len ||
> - bcmp(rt_key(rt1), rt_key(rt), rt_key(rt1)->sa_len))
> + if (rt_key(rt1)->sa_len != dst->sa_len ||
> + bcmp(rt_key(rt1), dst, rt_key(rt1)->sa_len))
>   goto different;
>  
>   /* key was the same.  compare netmask.  hairy... */
> @@ -277,11 +276,11 @@ rt_mpath_conflict(struct radix_node_head
>   }
>  
>   maskmatched:
> - if (!mpathok && rt1->rt_priority == rt->rt_priority)
> + if (!mpathok && rt1->rt_priority == prio)
>   return EEXIST;
>  
>   /* key/mask were the same.  compare gateway for all multipaths */
> - if (rt_mpath_matchgate(rt1, rt->rt_gateway, rt->rt_priority))
> + if (rt_mpath_matchgate(rt1, gate, prio))
>   /* all key/mask/gateway are the same.  conflicting entry. */
>   return EEXIST;
>  
> Index: net/radix_mpath.h
> ===
> RCS file: /cvs/src/sys/net/radix_mpath.h,v
> retrieving revision 1.14
> diff -u -p -r1.14 radix_mpath.h
> --- net/radix_mpath.h 25 Nov 2014 14:50:46 -  1.14
> +++ net/radix_mpath.h 3 Feb 2015 09:20:07 -
> @@ -54,8 +54,8 @@ voidrn_mpath_adj_mpflag(struct radix_no
>  int  rn_mpath_active_count(struct radix_node *);
>  struct rtentry *rt_mpath_matchgate(struct rtentry *, struct sockaddr *,
>   u_int8_t);
> -int  rt_mpath_conflict(struct radix_node_head *, struct rtentry *,
> - struct sockaddr *, int);
> +int  rt_mpath_conflict(struct radix_node_head *, struct sockaddr *,
> + struct sockaddr *, struct sockaddr *, u_int8_t, int);
>  struct rtentry *rtalloc_mpath(struct sockaddr *, u_int32_t *, u_int);
>  int  rn_mpath_inithead(void **, int);
>  #endif /* _KERNEL */
> Index: net/route.c
> ===
> RCS file: /cvs/src/sys/net/route.c,v
> retrieving revision 1.203
> diff -u -p -r1.203 route.c
> --- net/route.c   28 Jan 2015 22:10:13 -  1.203
> +++ net/route.c   3 Feb 2015 09:23:26 -
> @@ -826,15 +826,25 @@ rtrequest1(int req, struct rt_addrinfo *
>   if (info->rti_ifa == NULL && (error = rt_getifa(info, tableid)))
>   return (error);
>   ifa = info->rti_ifa;
> + if (prio == 0)
> + prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
> +#ifndef SMALL_KERNEL
> + if (rn_mpath_capable(rnh)) {
> + /* do not permit exactly the same dst/mask/gw pair */
> + if (rt_mpath_conflict(rnh, info->rti_info[RTAX_DST],
> + info->rti_info[RTAX_NETMASK],
> + info->rti_info[RTAX_GATEWAY], prio,
> + info->rti_flags & RTF_MPATH)) {
> + return (EEXIST);
> + }
> + }
> +#endif
>   rt = pool_get(&rtentry_pool, PR_NOWAIT | PR_ZERO);
>   if (rt == NULL)
>   return (ENOBUFS);
>  
>   rt->rt_flags = info->rti_flags;
>   rt->rt_tableid = tableid;
> -
> - if (prio == 0)
> - prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
>  

Unbreak !HIBERNATE builds (amd64)

2015-02-03 Thread David Coppa

ok?

Ciao,
David

Index: arch/amd64/amd64/acpi_wakecode.S
===
RCS file: /cvs/src/sys/arch/amd64/amd64/acpi_wakecode.S,v
retrieving revision 1.35
diff -u -p -u -p -r1.35 acpi_wakecode.S
--- arch/amd64/amd64/acpi_wakecode.S8 Dec 2014 07:12:37 -   1.35
+++ arch/amd64/amd64/acpi_wakecode.S3 Feb 2015 10:32:43 -
@@ -627,12 +627,14 @@ _ACPI_TRMP_DATA_LABEL(acpi_saved_sfmask)
.align 4
 _ACPI_TRMP_DATA_LABEL(acpi_pdirpa)
.long 0
+#ifdef HIBERNATE
 _ACPI_TRMP_DATA_LABEL(hibernate_indirect_16)
.long   hibernate_resume_vector_3
.word   0x18
 _ACPI_TRMP_DATA_LABEL(hibernate_indirect_16b)
.long   hibernate_resume_vector_3b
.word   0x18
+#endif /* HIBERNATE */
 
 _C_LABEL(acpi_tramp_data_end):
 



Route mpath conflict tweak

2015-02-03 Thread Martin Pieuchot
Diff below changes rt_mpath_conflict() to no longer rely on a fully
initialized rtentry.  Right now it makes things prettier when adding
a new route entry but later it will also help to dissociate "struct 
radix_node" from "struct rtentry".

route(8) regression tests checking for conflicts are happy with this.

Ok?

Index: net/radix_mpath.c
===
RCS file: /cvs/src/sys/net/radix_mpath.c,v
retrieving revision 1.27
diff -u -p -r1.27 radix_mpath.c
--- net/radix_mpath.c   19 Dec 2014 17:14:40 -  1.27
+++ net/radix_mpath.c   3 Feb 2015 09:20:38 -
@@ -204,16 +204,15 @@ rt_mpath_matchgate(struct rtentry *rt, s
  * check if we have the same key/mask/gateway on the table already.
  */
 int
-rt_mpath_conflict(struct radix_node_head *rnh, struct rtentry *rt,
-  struct sockaddr *netmask, int mpathok)
+rt_mpath_conflict(struct radix_node_head *rnh, struct sockaddr *dst,
+struct sockaddr *netmask, struct sockaddr *gate, u_int8_t prio, int 
mpathok)
 {
-   struct radix_node *rn, *rn1;
+   struct radix_node *rn1;
struct rtentry *rt1;
char *p, *q, *eq;
int same, l, skip;
 
-   rn = (struct radix_node *)rt;
-   rn1 = rnh->rnh_lookup(rt_key(rt), netmask, rnh);
+   rn1 = rnh->rnh_lookup(dst, netmask, rnh);
if (!rn1 || rn1->rn_flags & RNF_ROOT)
return 0;
 
@@ -224,8 +223,8 @@ rt_mpath_conflict(struct radix_node_head
rt1 = (struct rtentry *)rn1;
 
/* compare key. */
-   if (rt_key(rt1)->sa_len != rt_key(rt)->sa_len ||
-   bcmp(rt_key(rt1), rt_key(rt), rt_key(rt1)->sa_len))
+   if (rt_key(rt1)->sa_len != dst->sa_len ||
+   bcmp(rt_key(rt1), dst, rt_key(rt1)->sa_len))
goto different;
 
/* key was the same.  compare netmask.  hairy... */
@@ -277,11 +276,11 @@ rt_mpath_conflict(struct radix_node_head
}
 
  maskmatched:
-   if (!mpathok && rt1->rt_priority == rt->rt_priority)
+   if (!mpathok && rt1->rt_priority == prio)
return EEXIST;
 
/* key/mask were the same.  compare gateway for all multipaths */
-   if (rt_mpath_matchgate(rt1, rt->rt_gateway, rt->rt_priority))
+   if (rt_mpath_matchgate(rt1, gate, prio))
/* all key/mask/gateway are the same.  conflicting entry. */
return EEXIST;
 
Index: net/radix_mpath.h
===
RCS file: /cvs/src/sys/net/radix_mpath.h,v
retrieving revision 1.14
diff -u -p -r1.14 radix_mpath.h
--- net/radix_mpath.h   25 Nov 2014 14:50:46 -  1.14
+++ net/radix_mpath.h   3 Feb 2015 09:20:07 -
@@ -54,8 +54,8 @@ void  rn_mpath_adj_mpflag(struct radix_no
 intrn_mpath_active_count(struct radix_node *);
 struct rtentry *rt_mpath_matchgate(struct rtentry *, struct sockaddr *,
u_int8_t);
-intrt_mpath_conflict(struct radix_node_head *, struct rtentry *,
-   struct sockaddr *, int);
+intrt_mpath_conflict(struct radix_node_head *, struct sockaddr *,
+   struct sockaddr *, struct sockaddr *, u_int8_t, int);
 struct rtentry *rtalloc_mpath(struct sockaddr *, u_int32_t *, u_int);
 intrn_mpath_inithead(void **, int);
 #endif /* _KERNEL */
Index: net/route.c
===
RCS file: /cvs/src/sys/net/route.c,v
retrieving revision 1.203
diff -u -p -r1.203 route.c
--- net/route.c 28 Jan 2015 22:10:13 -  1.203
+++ net/route.c 3 Feb 2015 09:23:26 -
@@ -826,15 +826,25 @@ rtrequest1(int req, struct rt_addrinfo *
if (info->rti_ifa == NULL && (error = rt_getifa(info, tableid)))
return (error);
ifa = info->rti_ifa;
+   if (prio == 0)
+   prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
+#ifndef SMALL_KERNEL
+   if (rn_mpath_capable(rnh)) {
+   /* do not permit exactly the same dst/mask/gw pair */
+   if (rt_mpath_conflict(rnh, info->rti_info[RTAX_DST],
+   info->rti_info[RTAX_NETMASK],
+   info->rti_info[RTAX_GATEWAY], prio,
+   info->rti_flags & RTF_MPATH)) {
+   return (EEXIST);
+   }
+   }
+#endif
rt = pool_get(&rtentry_pool, PR_NOWAIT | PR_ZERO);
if (rt == NULL)
return (ENOBUFS);
 
rt->rt_flags = info->rti_flags;
rt->rt_tableid = tableid;
-
-   if (prio == 0)
-   prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
rt->rt_priority = prio; /* init routing priority */
LIST_INIT(&rt->rt_timer);
if ((error = rt_setgate(rt, info->rti_info[RTAX_DST],
@@ -851,16 +861,6 @@ rtrequest1(int req, struct rt_addrinfo *