Re: icmp6_mtudisc_clone() tweak

2018-09-04 Thread Klemens Nanni
OK kn



Re: bgpd diff

2018-09-04 Thread Sebastian Benoit
reads ok

Claudio Jeker(cje...@diehard.n-r-g.com) on 2018.09.04 12:56:52 +0200:
> Yet another minor bgpd diff from a much bigger diff. This adds
> inet4applymask() similar to inet6applymask() and starts using it in a few
> places. This makes some of the INET vs INET6 cases more similar.

more better is good ;)

> OK?
> -- 
> :wq Claudio
> 
> Index: bgpd.h
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
> retrieving revision 1.331
> diff -u -p -r1.331 bgpd.h
> --- bgpd.h29 Aug 2018 19:47:47 -  1.331
> +++ bgpd.h3 Sep 2018 14:29:39 -
> @@ -1174,6 +1177,7 @@ int  nlri_get_vpn4(u_char *, u_int16_t,
>  int   prefix_compare(const struct bgpd_addr *,
>   const struct bgpd_addr *, int);
>  in_addr_t prefixlen2mask(u_int8_t);
> +void  inet4applymask(struct in_addr *, const struct in_addr *, int);
>  void  inet6applymask(struct in6_addr *, const struct in6_addr *,
>   int);
>  const char   *aid2str(u_int8_t);
> Index: rde_prefix.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/rde_prefix.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 rde_prefix.c
> --- rde_prefix.c  24 Jan 2017 04:22:42 -  1.33
> +++ rde_prefix.c  4 Sep 2018 10:15:42 -
> @@ -101,7 +101,6 @@ pt_fill(struct bgpd_addr *prefix, int pr
>   static struct pt_entry4 pte4;
>   static struct pt_entry6 pte6;
>   static struct pt_entry_vpn4 pte_vpn4;
> - in_addr_t   addr_hbo;
>  
>   switch (prefix->aid) {
>   case AID_INET:
> @@ -109,9 +108,7 @@ pt_fill(struct bgpd_addr *prefix, int pr
>   pte4.aid = prefix->aid;
>   if (prefixlen > 32)
>   fatalx("pt_fill: bad IPv4 prefixlen");
> - addr_hbo = ntohl(prefix->v4.s_addr);
> - pte4.prefix4.s_addr = htonl(addr_hbo &
> - prefixlen2mask(prefixlen));
> + inet4applymask(, >v4, prefixlen);
>   pte4.prefixlen = prefixlen;
>   return ((struct pt_entry *));
>   case AID_INET6:
> @@ -119,17 +116,16 @@ pt_fill(struct bgpd_addr *prefix, int pr
>   pte6.aid = prefix->aid;
>   if (prefixlen > 128)
>   fatalx("pt_get: bad IPv6 prefixlen");
> - pte6.prefixlen = prefixlen;
>   inet6applymask(, >v6, prefixlen);
> + pte6.prefixlen = prefixlen;
>   return ((struct pt_entry *));
>   case AID_VPN_IPv4:
>   bzero(_vpn4, sizeof(pte_vpn4));
>   pte_vpn4.aid = prefix->aid;
>   if (prefixlen > 32)
>   fatalx("pt_fill: bad IPv4 prefixlen");
> - addr_hbo = ntohl(prefix->vpn4.addr.s_addr);
> - pte_vpn4.prefix4.s_addr = htonl(addr_hbo &
> - prefixlen2mask(prefixlen));
> + inet4applymask(_vpn4.prefix4, >vpn4.addr,
> + prefixlen);
>   pte_vpn4.prefixlen = prefixlen;
>   pte_vpn4.rd = prefix->vpn4.rd;
>   pte_vpn4.labellen = prefix->vpn4.labellen;
> Index: session.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
> retrieving revision 1.365
> diff -u -p -r1.365 session.c
> --- session.c 11 Jul 2018 16:34:36 -  1.365
> +++ session.c 4 Sep 2018 10:07:34 -
> @@ -3150,19 +3150,20 @@ session_template_clone(struct peer *p, s
>  int
>  session_match_mask(struct peer *p, struct bgpd_addr *a)
>  {
> - in_addr_tv4mask;
> - struct in6_addr  masked;
> + struct in_addr   v4masked;
> + struct in6_addr  v6masked;
>  
>   switch (p->conf.remote_addr.aid) {
>   case AID_INET:
> - v4mask = htonl(prefixlen2mask(p->conf.remote_masklen));
> - if (p->conf.remote_addr.v4.s_addr == (a->v4.s_addr & v4mask))
> + inet4applymask(, >v4, p->conf.remote_masklen);
> + if (p->conf.remote_addr.v4.s_addr == v4masked.s_addr)
>   return (1);
>   return (0);
>   case AID_INET6:
> - inet6applymask(, >v6, p->conf.remote_masklen);
> + inet6applymask(, >v6, p->conf.remote_masklen);
>  
> - if (!memcmp(, >conf.remote_addr.v6, sizeof(masked)))
> + if (memcmp(, >conf.remote_addr.v6,
> + sizeof(v6masked)) == 0)
>   return (1);
>   return (0);
>   }
> Index: util.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/util.c,v
> retrieving revision 1.31
> diff -u -p -r1.31 util.c
> --- util.c29 Aug 2018 11:43:15 -  1.31
> +++ util.c30 Aug 2018 12:12:05 -
> @@ -732,6 +732,15 @@ prefixlen2mask(u_int8_t prefixlen)
>  }
>  
>  void
> +inet4applymask(struct in_addr 

Re: bgpd, allow for bigger (prefixlist) macros

2018-09-04 Thread Claudio Jeker
On Tue, Sep 04, 2018 at 08:15:23PM +0200, Denis Fondras wrote:
> Hi,
> 
> While generating big prefixlists macros with bgpq3 (big like 
> as2914:as-europe-v6
> for example), OpenBGPd cannot load the config file (error "string too long").
> This diff implements a dynamic buffer to overcome this limitation.

I would not go down this road. People should not use macros for massive
prefix lists or similar things. Instead prefix-sets should be used. There
are no such limitations with them and they will soon (as n2k18 is
aproaching) get better.

-- 
:wq Claudio

> Index: parse.y
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
> retrieving revision 1.331
> diff -u -p -r1.331 parse.y
> --- parse.y   27 Aug 2018 19:32:37 -  1.331
> +++ parse.y   4 Sep 2018 18:13:48 -
> @@ -2746,13 +2746,22 @@ findeol(void)
>   return (ERROR);
>  }
>  
> +#define READBUFFERSIZE   1024
> +
>  int
>  yylex(void)
>  {
> - u_char   buf[8096];
> + u_char  *buf = NULL;
>   u_char  *p, *val;
>   int  quotec, next, c;
>   int  token;
> + u_int32_t bufsize = READBUFFERSIZE;
> +
> + buf = malloc(bufsize);
> + if (buf == NULL) {
> + yyerror("malloc failed");
> + return (findeol());
> + }
>  
>  top:
>   p = buf;
> @@ -2765,12 +2774,19 @@ top:
>   ; /* nothing */
>   if (c == '$' && !expanding) {
>   while (1) {
> - if ((c = lgetc(0)) == EOF)
> + if ((c = lgetc(0)) == EOF) {
> + free(buf);
>   return (0);
> + }
>  
> - if (p + 1 >= buf + sizeof(buf) - 1) {
> - yyerror("string too long");
> - return (findeol());
> + if (p + 1 >= buf + bufsize - 1) {
> + bufsize += READBUFFERSIZE;
> + buf = realloc(buf, bufsize);
> + if (buf == NULL) {
> + yyerror("realloc failed");
> + return (findeol());
> + }
> + p = buf + bufsize - READBUFFERSIZE - 2;
>   }
>   if (isalnum(c) || c == '_') {
>   *p++ = c;
> @@ -2783,6 +2799,7 @@ top:
>   val = symget(buf);
>   if (val == NULL) {
>   yyerror("macro '%s' not defined", buf);
> + free(buf);
>   return (findeol());
>   }
>   p = val + strlen(val) - 1;
> @@ -2800,14 +2817,18 @@ top:
>   case '"':
>   quotec = c;
>   while (1) {
> - if ((c = lgetc(quotec)) == EOF)
> + if ((c = lgetc(quotec)) == EOF) {
> + free(buf);
>   return (0);
> + }
>   if (c == '\n') {
>   file->lineno++;
>   continue;
>   } else if (c == '\\') {
> - if ((next = lgetc(quotec)) == EOF)
> + if ((next = lgetc(quotec)) == EOF) {
> + free(buf);
>   return (0);
> + }
>   if (next == quotec || c == ' ' || c == '\t')
>   c = next;
>   else if (next == '\n') {
> @@ -2820,36 +2841,52 @@ top:
>   break;
>   } else if (c == '\0') {
>   yyerror("syntax error");
> + free(buf);
>   return (findeol());
>   }
> - if (p + 1 >= buf + sizeof(buf) - 1) {
> - yyerror("string too long");
> - return (findeol());
> + if (p + 1 >= buf + bufsize - 1) {
> + bufsize += READBUFFERSIZE;
> + buf = realloc(buf, bufsize);
> + if (buf == NULL) {
> + yyerror("realloc failed");
> + return (findeol());
> + }
> + p = buf + bufsize - READBUFFERSIZE - 2;
>   }
>   *p++ = c;
>   }
>   yylval.v.string = strdup(buf);
> - if (yylval.v.string == NULL)
> + if (yylval.v.string == NULL) {
> + free(buf);
>   fatal("yylex: strdup");
> + }
> 

bgpd, allow for bigger (prefixlist) macros

2018-09-04 Thread Denis Fondras
Hi,

While generating big prefixlists macros with bgpq3 (big like as2914:as-europe-v6
for example), OpenBGPd cannot load the config file (error "string too long").
This diff implements a dynamic buffer to overcome this limitation.

Index: parse.y
===
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.331
diff -u -p -r1.331 parse.y
--- parse.y 27 Aug 2018 19:32:37 -  1.331
+++ parse.y 4 Sep 2018 18:13:48 -
@@ -2746,13 +2746,22 @@ findeol(void)
return (ERROR);
 }
 
+#define READBUFFERSIZE 1024
+
 int
 yylex(void)
 {
-   u_char   buf[8096];
+   u_char  *buf = NULL;
u_char  *p, *val;
int  quotec, next, c;
int  token;
+   u_int32_t bufsize = READBUFFERSIZE;
+
+   buf = malloc(bufsize);
+   if (buf == NULL) {
+   yyerror("malloc failed");
+   return (findeol());
+   }
 
 top:
p = buf;
@@ -2765,12 +2774,19 @@ top:
; /* nothing */
if (c == '$' && !expanding) {
while (1) {
-   if ((c = lgetc(0)) == EOF)
+   if ((c = lgetc(0)) == EOF) {
+   free(buf);
return (0);
+   }
 
-   if (p + 1 >= buf + sizeof(buf) - 1) {
-   yyerror("string too long");
-   return (findeol());
+   if (p + 1 >= buf + bufsize - 1) {
+   bufsize += READBUFFERSIZE;
+   buf = realloc(buf, bufsize);
+   if (buf == NULL) {
+   yyerror("realloc failed");
+   return (findeol());
+   }
+   p = buf + bufsize - READBUFFERSIZE - 2;
}
if (isalnum(c) || c == '_') {
*p++ = c;
@@ -2783,6 +2799,7 @@ top:
val = symget(buf);
if (val == NULL) {
yyerror("macro '%s' not defined", buf);
+   free(buf);
return (findeol());
}
p = val + strlen(val) - 1;
@@ -2800,14 +2817,18 @@ top:
case '"':
quotec = c;
while (1) {
-   if ((c = lgetc(quotec)) == EOF)
+   if ((c = lgetc(quotec)) == EOF) {
+   free(buf);
return (0);
+   }
if (c == '\n') {
file->lineno++;
continue;
} else if (c == '\\') {
-   if ((next = lgetc(quotec)) == EOF)
+   if ((next = lgetc(quotec)) == EOF) {
+   free(buf);
return (0);
+   }
if (next == quotec || c == ' ' || c == '\t')
c = next;
else if (next == '\n') {
@@ -2820,36 +2841,52 @@ top:
break;
} else if (c == '\0') {
yyerror("syntax error");
+   free(buf);
return (findeol());
}
-   if (p + 1 >= buf + sizeof(buf) - 1) {
-   yyerror("string too long");
-   return (findeol());
+   if (p + 1 >= buf + bufsize - 1) {
+   bufsize += READBUFFERSIZE;
+   buf = realloc(buf, bufsize);
+   if (buf == NULL) {
+   yyerror("realloc failed");
+   return (findeol());
+   }
+   p = buf + bufsize - READBUFFERSIZE - 2;
}
*p++ = c;
}
yylval.v.string = strdup(buf);
-   if (yylval.v.string == NULL)
+   if (yylval.v.string == NULL) {
+   free(buf);
fatal("yylex: strdup");
+   }
return (STRING);
case '!':
next = lgetc(0);
-   if (next == '=')
+   if (next == '=') {
+   free(buf);
return (NE);
+   }
lungetc(next);
break;
case '<':
next = lgetc(0);
-   if (next == '=')
+   

Re: bgpd, streamline aspath matching

2018-09-04 Thread Claudio Jeker
On Tue, Sep 04, 2018 at 05:49:29PM +0200, Denis Fondras wrote:
> On Tue, Sep 04, 2018 at 01:56:12PM +0200, Claudio Jeker wrote:
> > On Mon, Aug 27, 2018 at 12:11:43PM +0200, Claudio Jeker wrote:
> > > This is in preparation for introducing as-sets (a fast lookup table for
> > > when you want to make sure that your peering partner is realy only passing
> > > you traffic he should).
> > > 
> > > To make as-set possible lets do some cleanup beforehands. This mainly
> > > removes one element from the filter_as struct, uses as_min for unary
> > > operations and changes the way we pass the and check the neighbor-as.
> > > as_compare() and aspath_match() now take the neighbor-as as last argument
> > > and will match against it if AS_FLAG_NEIGHBORAS is set. Simplifies the
> > > rde_filter_match() a fair bit.
> > > 
> > > OK?
> > 
> 
> OK denis@ if you patch bgpctl too.

There is a diff somewhere in the thread for bgpctl. So yes will make sure
it works there too.
 
> > -- 
> > :wq Claudio
> >  
> > 
> > Index: bgpd.h
> > ===
> > RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
> > retrieving revision 1.330
> > diff -u -p -r1.330 bgpd.h
> > --- bgpd.h  9 Aug 2018 21:12:33 -   1.330
> > +++ bgpd.h  27 Aug 2018 10:03:55 -
> > @@ -647,7 +647,6 @@ enum aslen_spec {
> >  };
> >  
> >  struct filter_as {
> > -   u_int32_t   as;
> > u_int16_t   flags;
> > enum as_spectype;
> > u_int8_top;
> > Index: parse.y
> > ===
> > RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
> > retrieving revision 1.330
> > diff -u -p -r1.330 parse.y
> > --- parse.y 27 Aug 2018 09:49:00 -  1.330
> > +++ parse.y 27 Aug 2018 10:03:56 -
> > @@ -1902,7 +1902,7 @@ filter_as : as4number_any {
> > if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
> > NULL)
> > fatal(NULL);
> > -   $$->a.as = $1;
> > +   $$->a.as_min = $1;
> > $$->a.op = OP_EQ;
> > }
> > | NEIGHBORAS{
> > @@ -1916,7 +1916,7 @@ filter_as : as4number_any {
> > NULL)
> > fatal(NULL);
> > $$->a.op = $1;
> > -   $$->a.as = $2;
> > +   $$->a.as_min = $2;
> > }
> > | as4number_any binaryop as4number_any {
> > if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
> > Index: printconf.c
> > ===
> > RCS file: /cvs/src/usr.sbin/bgpd/printconf.c,v
> > retrieving revision 1.109
> > diff -u -p -r1.109 printconf.c
> > --- printconf.c 11 Jul 2018 14:08:46 -  1.109
> > +++ printconf.c 27 Aug 2018 10:03:56 -
> > @@ -619,10 +619,10 @@ void print_as(struct filter_rule *r)
> > printf("%s ", log_as(r->match.as.as_max));
> > break;
> > case OP_NE:
> > -   printf("!= %s ", log_as(r->match.as.as));
> > +   printf("!= %s ", log_as(r->match.as.as_min));
> > break;
> > default:
> > -   printf("%s ", log_as(r->match.as.as));
> > +   printf("%s ", log_as(r->match.as.as_min));
> > break;
> > }
> >  }
> > Index: rde.c
> > ===
> > RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
> > retrieving revision 1.414
> > diff -u -p -r1.414 rde.c
> > --- rde.c   9 Aug 2018 12:54:06 -   1.414
> > +++ rde.c   27 Aug 2018 10:03:57 -
> > @@ -2149,7 +2149,7 @@ rde_dump_filter(struct prefix *p, struct
> > return;
> > if (req->type == IMSG_CTL_SHOW_RIB_AS &&
> > !aspath_match(asp->aspath->data, asp->aspath->len,
> > -   >as, req->as.as))
> > +   >as, 0))
> > return;
> > if (req->type == IMSG_CTL_SHOW_RIB_COMMUNITY &&
> > !community_match(asp, req->community.as,
> > @@ -3769,5 +3769,4 @@ rde_mark_prefixsets_dirty(struct prefixs
> > }
> > }
> > }
> > -   return;
> >  }
> > Index: rde_filter.c
> > ===
> > RCS file: /cvs/src/usr.sbin/bgpd/rde_filter.c,v
> > retrieving revision 1.99
> > diff -u -p -r1.99 rde_filter.c
> > --- rde_filter.c3 Aug 2018 16:31:22 -   1.99
> > +++ rde_filter.c27 Aug 2018 10:03:57 -
> > @@ -340,7 +340,6 @@ int
> >  rde_filter_match(struct filter_rule *f, struct rde_peer *peer,
> >  struct filterstate *state, struct prefix *p)
> >  {
> > -   u_int32_t   pas;
> > int cas, type;
> > int64_t las, ld1, ld2;
> > struct prefixset_item   *psi;
> > @@ -349,20 +348,16 @@ rde_filter_match(struct filter_rule *f, 
> > 

icmp6_mtudisc_clone() tweak

2018-09-04 Thread Michael Mikonos
Hello,

The code executed on failure in icmp6_mtudisc_clone() is always
the same so it can be declared in one place. Is anyone happy to
OK this?

- Michael


Index: icmp6.c
===
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.225
diff -u -p -u -r1.225 icmp6.c
--- icmp6.c 11 Jul 2018 13:06:16 -  1.225
+++ icmp6.c 4 Sep 2018 15:50:29 -
@@ -1768,20 +1768,16 @@ icmp6_mtudisc_clone(struct sockaddr *dst
rt = rtalloc(dst, RT_RESOLVE, rtableid);
 
/* Check if the route is actually usable */
-   if (!rtisvalid(rt) || (rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE))) {
-   rtfree(rt);
-   return (NULL);
-   }
+   if (!rtisvalid(rt) || (rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)))
+   goto bad;
 
/*
 * No PMTU for local routes and permanent neighbors,
 * ARP and NDP use the same expire timer as the route.
 */
if (ISSET(rt->rt_flags, RTF_LOCAL) ||
-   (ISSET(rt->rt_flags, RTF_LLINFO) && rt->rt_expire == 0)) {
-   rtfree(rt);
-   return (NULL);
-   }
+   (ISSET(rt->rt_flags, RTF_LLINFO) && rt->rt_expire == 0))
+   goto bad;
 
/* If we didn't get a host route, allocate one */
if ((rt->rt_flags & RTF_HOST) == 0) {
@@ -1799,10 +1795,8 @@ icmp6_mtudisc_clone(struct sockaddr *dst
 
error = rtrequest(RTM_ADD, , rt->rt_priority, ,
rtableid);
-   if (error) {
-   rtfree(rt);
-   return (NULL);
-   }
+   if (error)
+   goto bad;
nrt->rt_rmx = rt->rt_rmx;
rtfree(rt);
rt = nrt;
@@ -1810,12 +1804,13 @@ icmp6_mtudisc_clone(struct sockaddr *dst
}
error = rt_timer_add(rt, icmp6_mtudisc_timeout, icmp6_mtudisc_timeout_q,
rtableid);
-   if (error) {
-   rtfree(rt);
-   return (NULL);
-   }
+   if (error)
+   goto bad;
 
return (rt);
+bad:
+   rtfree(rt);
+   return (NULL);
 }
 
 void



Re: bgpd, streamline aspath matching

2018-09-04 Thread Denis Fondras
On Tue, Sep 04, 2018 at 01:56:12PM +0200, Claudio Jeker wrote:
> On Mon, Aug 27, 2018 at 12:11:43PM +0200, Claudio Jeker wrote:
> > This is in preparation for introducing as-sets (a fast lookup table for
> > when you want to make sure that your peering partner is realy only passing
> > you traffic he should).
> > 
> > To make as-set possible lets do some cleanup beforehands. This mainly
> > removes one element from the filter_as struct, uses as_min for unary
> > operations and changes the way we pass the and check the neighbor-as.
> > as_compare() and aspath_match() now take the neighbor-as as last argument
> > and will match against it if AS_FLAG_NEIGHBORAS is set. Simplifies the
> > rde_filter_match() a fair bit.
> > 
> > OK?
> 

OK denis@ if you patch bgpctl too.

> -- 
> :wq Claudio
>  
> 
> Index: bgpd.h
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
> retrieving revision 1.330
> diff -u -p -r1.330 bgpd.h
> --- bgpd.h9 Aug 2018 21:12:33 -   1.330
> +++ bgpd.h27 Aug 2018 10:03:55 -
> @@ -647,7 +647,6 @@ enum aslen_spec {
>  };
>  
>  struct filter_as {
> - u_int32_t   as;
>   u_int16_t   flags;
>   enum as_spectype;
>   u_int8_top;
> Index: parse.y
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
> retrieving revision 1.330
> diff -u -p -r1.330 parse.y
> --- parse.y   27 Aug 2018 09:49:00 -  1.330
> +++ parse.y   27 Aug 2018 10:03:56 -
> @@ -1902,7 +1902,7 @@ filter_as   : as4number_any {
>   if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
>   NULL)
>   fatal(NULL);
> - $$->a.as = $1;
> + $$->a.as_min = $1;
>   $$->a.op = OP_EQ;
>   }
>   | NEIGHBORAS{
> @@ -1916,7 +1916,7 @@ filter_as   : as4number_any {
>   NULL)
>   fatal(NULL);
>   $$->a.op = $1;
> - $$->a.as = $2;
> + $$->a.as_min = $2;
>   }
>   | as4number_any binaryop as4number_any {
>   if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
> Index: printconf.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/printconf.c,v
> retrieving revision 1.109
> diff -u -p -r1.109 printconf.c
> --- printconf.c   11 Jul 2018 14:08:46 -  1.109
> +++ printconf.c   27 Aug 2018 10:03:56 -
> @@ -619,10 +619,10 @@ void print_as(struct filter_rule *r)
>   printf("%s ", log_as(r->match.as.as_max));
>   break;
>   case OP_NE:
> - printf("!= %s ", log_as(r->match.as.as));
> + printf("!= %s ", log_as(r->match.as.as_min));
>   break;
>   default:
> - printf("%s ", log_as(r->match.as.as));
> + printf("%s ", log_as(r->match.as.as_min));
>   break;
>   }
>  }
> Index: rde.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
> retrieving revision 1.414
> diff -u -p -r1.414 rde.c
> --- rde.c 9 Aug 2018 12:54:06 -   1.414
> +++ rde.c 27 Aug 2018 10:03:57 -
> @@ -2149,7 +2149,7 @@ rde_dump_filter(struct prefix *p, struct
>   return;
>   if (req->type == IMSG_CTL_SHOW_RIB_AS &&
>   !aspath_match(asp->aspath->data, asp->aspath->len,
> - >as, req->as.as))
> + >as, 0))
>   return;
>   if (req->type == IMSG_CTL_SHOW_RIB_COMMUNITY &&
>   !community_match(asp, req->community.as,
> @@ -3769,5 +3769,4 @@ rde_mark_prefixsets_dirty(struct prefixs
>   }
>   }
>   }
> - return;
>  }
> Index: rde_filter.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/rde_filter.c,v
> retrieving revision 1.99
> diff -u -p -r1.99 rde_filter.c
> --- rde_filter.c  3 Aug 2018 16:31:22 -   1.99
> +++ rde_filter.c  27 Aug 2018 10:03:57 -
> @@ -340,7 +340,6 @@ int
>  rde_filter_match(struct filter_rule *f, struct rde_peer *peer,
>  struct filterstate *state, struct prefix *p)
>  {
> - u_int32_t   pas;
>   int cas, type;
>   int64_t las, ld1, ld2;
>   struct prefixset_item   *psi;
> @@ -349,20 +348,16 @@ rde_filter_match(struct filter_rule *f, 
>   if (state != NULL)
>   asp = >aspath;
>  
> - if (asp != NULL && f->match.as.type != AS_NONE) {
> - if (f->match.as.flags & AS_FLAG_NEIGHBORAS)
> - pas = peer->conf.remote_as;
> - else
> - pas = 

Re: 6.4-current fatal protection fault in supervisor mode (under qemu)

2018-09-04 Thread Mike Larkin
On Tue, Sep 04, 2018 at 12:31:11AM -0700, Greg Steuck wrote:
> I'm trying to build an OpenBSD image for deployment on GCE. Towards this
> end I'm running a script on Debian which runs OpenBSD-snapshot in qemu. The
> script worked a few times for 6.3 release and then failed once and worked
> once when I set it to use a snapshot. I would've reproduced this under
> OpenBSD had growisofs not complained about inability to allocate memory
> (quick ulimit hacking didn't prove fruitful). The kernel panic is at the
> very end.
> 
> $ git clone https://github.com/blackgnezdo/build.git
> $ cd ./build/env/openbsd-amd64/
> $ env MIRROR=cloudflare.cdn.openbsd.org bash ./make.bash
> ... works fine
> $ env RELNO=64 VERSION=snapshots MIRROR=cloudflare.cdn.openbsd.org bash -x
> ./make.bash
> % env RELNO=64 VERSION=snapshots MIRROR=cloudflare.cdn.openbsd.org bash -x
> ./make.bash
> + set -e
> + set -u
> + readonly VERSION=snapshots
> + VERSION=snapshots
> + readonly RELNO=64
> + RELNO=64
> + readonly ARCH=amd64
> + ARCH=amd64
> + readonly MIRROR=cloudflare.cdn.openbsd.org
> + MIRROR=cloudflare.cdn.openbsd.org
> + [[ amd64 != \a\m\d\6\4 ]]
> + readonly ISO=install64-amd64.iso
> + ISO=install64-amd64.iso
> + readonly ISO_PATCHED=install64-amd64-patched.iso
> + ISO_PATCHED=install64-amd64-patched.iso
> + [[ ! -f install64-amd64.iso ]]
> + curl -o install64-amd64.iso
> https://cloudflare.cdn.openbsd.org/pub/OpenBSD/snapshots/amd64/install64.iso
>   % Total% Received % Xferd  Average Speed   TimeTime Time
> Current
>  Dload  Upload   Total   SpentLeft
> Speed
> 100  343M  100  343M0 0  3825k  0  0:01:31  0:01:31 --:--:--
> 3922k
> + trap cleanup EXIT INT
> + mkdir -p etc
> + cat
> + cat
> + cat
> + chmod +x install.site
> + tar -zcvf site64.tgz install.site etc/installurl etc/rc.local
> install.site
> etc/installurl
> etc/rc.local
> + cat
> + cat
> + echo 'set tty com0'
> + dd if=/dev/urandom of=random.seed bs=4096 count=1
> 1+0 records in
> 1+0 records out
> 4096 bytes (4.1 kB, 4.0 KiB) copied, 8.8445e-05 s, 46.3 MB/s
> + cp install64-amd64.iso install64-amd64-patched.iso
> + growisofs -M install64-amd64-patched.iso -l -R -graft-points
> /snapshots/amd64/site64.tgz=site64.tgz /auto_install.conf=auto_install.conf
> /disklabel.template=disklabel.template /etc/boot.conf=boot.conf
> /etc/random.seed=random.seed
> Executing 'genisoimage -C 16,175680 -M /dev/fd/3 -l -R -graft-points
> /snapshots/amd64/site64.tgz=site64.tgz /auto_install.conf=auto_install.conf
> /disklabel.template=disklabel.template /etc/boot.conf=boot.conf
> /etc/random.seed=random.seed | builtin_dd of=install64-amd64-patched.iso
> obs=32k seek=10980'
> I: -input-charset not specified, using utf-8 (detected in locale settings)
> Rock Ridge signatures found
> Total translation table size: 0
> Total rockridge attributes bytes: 3117
> Total directory bytes: 12288
> Path table size(bytes): 80
> Max brk space used 0
> 175867 extents written (343 MB)
> builtin_dd: 192*2KB out @ average infx1352KBps
> install64-amd64-patched.iso: copying volume descriptor(s)
> + rm -f disk.raw
> + qemu-img create -f raw disk.raw 10G
> Formatting 'disk.raw', fmt=raw size=10737418240
> + expect
> spawn qemu-system-x86_64 -nographic -smp 2 -drive
> if=virtio,file=disk.raw,format=raw -cdrom install64-amd64-patched.iso -net
> nic,model=virtio -net user -boot once=d
> >> OpenBSD/amd64 CDBOOT 3.40
> boot>
> booting cd0a:/6.4/amd64/bsd.rd: 3507018+1496064+3887944+0+593920
> [371914+111+440232+292841]=0xa1c058
> entry point at 0x1000158
> Copyright (c) 1982, 1986, 1989, 1991, 1993
> The Regents of the University of California.  All rights reserved.
> Copyright (c) 1995-2018 OpenBSD. All rights reserved.
> https://www.OpenBSD.org
> 
> OpenBSD 6.4-beta (RAMDISK_CD) #271: Sat Sep  1 22:29:29 MDT 2018
> dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
> real mem = 117301248 (111MB)
> avail mem = 110112768 (105MB)
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xf68c0 (10 entries)
> bios0: vendor SeaBIOS version "1.10.2-1" date 04/01/2014
> bios0: QEMU Standard PC (i440FX + PIIX, 1996)
> acpi0 at bios0: rev 0
> acpi0: tables DSDT FACP APIC HPET
> acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: QEMU Virtual CPU version 2.5+, 2695.97 MHz, 06-06-03
> cpu0:
> FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,CX16,HV,NXE,LONG,LAHF,SVM
> cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB
> 64b/line 16-way L2 cache
> cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
> cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
> cpu0: apic clock running at 1010MHz
> cpu at mainbus0: not configured
> ioapic0 at mainbus0: apid 0 pa 0xfec0, version 20, 24 pins
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpicpu at acpi0 not configured
> "ACPI0006" at acpi0 not configured
> 

6.4-current fatal protection fault in supervisor mode (under qemu)

2018-09-04 Thread Greg Steuck
I'm trying to build an OpenBSD image for deployment on GCE. Towards this
end I'm running a script on Debian which runs OpenBSD-snapshot in qemu. The
script worked a few times for 6.3 release and then failed once and worked
once when I set it to use a snapshot. I would've reproduced this under
OpenBSD had growisofs not complained about inability to allocate memory
(quick ulimit hacking didn't prove fruitful). The kernel panic is at the
very end.

$ git clone https://github.com/blackgnezdo/build.git
$ cd ./build/env/openbsd-amd64/
$ env MIRROR=cloudflare.cdn.openbsd.org bash ./make.bash
... works fine
$ env RELNO=64 VERSION=snapshots MIRROR=cloudflare.cdn.openbsd.org bash -x
./make.bash
% env RELNO=64 VERSION=snapshots MIRROR=cloudflare.cdn.openbsd.org bash -x
./make.bash
+ set -e
+ set -u
+ readonly VERSION=snapshots
+ VERSION=snapshots
+ readonly RELNO=64
+ RELNO=64
+ readonly ARCH=amd64
+ ARCH=amd64
+ readonly MIRROR=cloudflare.cdn.openbsd.org
+ MIRROR=cloudflare.cdn.openbsd.org
+ [[ amd64 != \a\m\d\6\4 ]]
+ readonly ISO=install64-amd64.iso
+ ISO=install64-amd64.iso
+ readonly ISO_PATCHED=install64-amd64-patched.iso
+ ISO_PATCHED=install64-amd64-patched.iso
+ [[ ! -f install64-amd64.iso ]]
+ curl -o install64-amd64.iso
https://cloudflare.cdn.openbsd.org/pub/OpenBSD/snapshots/amd64/install64.iso
  % Total% Received % Xferd  Average Speed   TimeTime Time
Current
 Dload  Upload   Total   SpentLeft
Speed
100  343M  100  343M0 0  3825k  0  0:01:31  0:01:31 --:--:--
3922k
+ trap cleanup EXIT INT
+ mkdir -p etc
+ cat
+ cat
+ cat
+ chmod +x install.site
+ tar -zcvf site64.tgz install.site etc/installurl etc/rc.local
install.site
etc/installurl
etc/rc.local
+ cat
+ cat
+ echo 'set tty com0'
+ dd if=/dev/urandom of=random.seed bs=4096 count=1
1+0 records in
1+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 8.8445e-05 s, 46.3 MB/s
+ cp install64-amd64.iso install64-amd64-patched.iso
+ growisofs -M install64-amd64-patched.iso -l -R -graft-points
/snapshots/amd64/site64.tgz=site64.tgz /auto_install.conf=auto_install.conf
/disklabel.template=disklabel.template /etc/boot.conf=boot.conf
/etc/random.seed=random.seed
Executing 'genisoimage -C 16,175680 -M /dev/fd/3 -l -R -graft-points
/snapshots/amd64/site64.tgz=site64.tgz /auto_install.conf=auto_install.conf
/disklabel.template=disklabel.template /etc/boot.conf=boot.conf
/etc/random.seed=random.seed | builtin_dd of=install64-amd64-patched.iso
obs=32k seek=10980'
I: -input-charset not specified, using utf-8 (detected in locale settings)
Rock Ridge signatures found
Total translation table size: 0
Total rockridge attributes bytes: 3117
Total directory bytes: 12288
Path table size(bytes): 80
Max brk space used 0
175867 extents written (343 MB)
builtin_dd: 192*2KB out @ average infx1352KBps
install64-amd64-patched.iso: copying volume descriptor(s)
+ rm -f disk.raw
+ qemu-img create -f raw disk.raw 10G
Formatting 'disk.raw', fmt=raw size=10737418240
+ expect
spawn qemu-system-x86_64 -nographic -smp 2 -drive
if=virtio,file=disk.raw,format=raw -cdrom install64-amd64-patched.iso -net
nic,model=virtio -net user -boot once=d
>> OpenBSD/amd64 CDBOOT 3.40
boot>
booting cd0a:/6.4/amd64/bsd.rd: 3507018+1496064+3887944+0+593920
[371914+111+440232+292841]=0xa1c058
entry point at 0x1000158
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2018 OpenBSD. All rights reserved.
https://www.OpenBSD.org

OpenBSD 6.4-beta (RAMDISK_CD) #271: Sat Sep  1 22:29:29 MDT 2018
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
real mem = 117301248 (111MB)
avail mem = 110112768 (105MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xf68c0 (10 entries)
bios0: vendor SeaBIOS version "1.10.2-1" date 04/01/2014
bios0: QEMU Standard PC (i440FX + PIIX, 1996)
acpi0 at bios0: rev 0
acpi0: tables DSDT FACP APIC HPET
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: QEMU Virtual CPU version 2.5+, 2695.97 MHz, 06-06-03
cpu0:
FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,CX16,HV,NXE,LONG,LAHF,SVM
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB
64b/line 16-way L2 cache
cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu0: apic clock running at 1010MHz
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 0 pa 0xfec0, version 20, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpicpu at acpi0 not configured
"ACPI0006" at acpi0 not configured
"PNP0B00" at acpi0 not configured
"PNP0A06" at acpi0 not configured
"PNP0A06" at acpi0 not configured
"PNP0A06" at acpi0 not configured
"QEMU0002" at acpi0 not configured
"ACPI0010" at acpi0 not configured
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02
"Intel 82371SB 

Re: iostat: add "sp" column for CP_SPIN

2018-09-04 Thread Landry Breuil
On Tue, Sep 04, 2018 at 03:27:29PM +0200, Solene Rapenne wrote:
> Stuart Henderson  wrote:
> > On 2018/09/04 14:22, Solene Rapenne wrote:
> > > About munin I'm trying to get a diff accepted upstream to fix cpu plugin 
> > > and
> > > talk about this with kirby@. The cpu plugin uses sysctl kern.cp_time. 
> > > While
> > > it's not related, I prefer to announce it here so people don't waste time
> > > fixing it again by looking at the thread :)
> > 
> > Ah nice. When I worked on the initial munin port with mk I had intended
> > to try to get upstream to take the openbsd plugins separately (rather
> > than the current "copy similar OS and patch" approach), but I got fed up
> > with rrdtool performance on OpenBSD and stopped using munin before I got
> > round to it.. (and then I started using librenms and got fed up with
> > rrdtool performance once again ;)
> 
> Using rrdcached the performances are really good. But that certainly depend on
> the number of systems. It may not scale well with more than 50 systems, this 
> is
> also highly dependent on the number of plugins on each systems (as 1 value = 1
> rrd file).

Seconded, rrdcached really helps a lot until you have waaayyy too many rrds,
and then switch to a real tsdb (hint: influxdb is in ports)



Re: iostat: add "sp" column for CP_SPIN

2018-09-04 Thread Stuart Henderson
On 2018/09/04 15:27, Solene Rapenne wrote:
> Stuart Henderson  wrote:
> > On 2018/09/04 14:22, Solene Rapenne wrote:
> > > About munin I'm trying to get a diff accepted upstream to fix cpu plugin 
> > > and
> > > talk about this with kirby@. The cpu plugin uses sysctl kern.cp_time. 
> > > While
> > > it's not related, I prefer to announce it here so people don't waste time
> > > fixing it again by looking at the thread :)
> >
> > Ah nice. When I worked on the initial munin port with mk I had intended
> > to try to get upstream to take the openbsd plugins separately (rather
> > than the current "copy similar OS and patch" approach), but I got fed up
> > with rrdtool performance on OpenBSD and stopped using munin before I got
> > round to it.. (and then I started using librenms and got fed up with
> > rrdtool performance once again ;)
>
> Using rrdcached the performances are really good. But that certainly depend on
> the number of systems. It may not scale well with more than 50 systems, this 
> is
> also highly dependent on the number of plugins on each systems (as 1 value = 1
> rrd file).

Not sure if I tried rrdcached with munin but I am using it with librenms
and it's not really good here. In 9 days uptime, I have ~32h of cpu time
from rrdcached, and lots of spin while the threads are actively processing.
(Yes there are lots of RRDs ;)

159 threads: 2 running, 153 idle, 4 on processor
 up 9 days, 14:40
CPU0 states: 44.2% user,  0.0% nice, 24.5% sys, 31.3% spin,  0.0% intr,  0.0% 
idle
CPU1 states: 45.2% user,  0.0% nice, 25.5% sys, 29.3% spin,  0.0% intr,  0.0% 
idle
CPU2 states: 49.4% user,  0.0% nice, 24.1% sys, 26.5% spin,  0.0% intr,  0.0% 
idle
CPU3 states: 49.0% user,  0.0% nice, 20.1% sys, 30.9% spin,  0.0% intr,  0.0% 
idle
Memory: Real: 1847M/5197M act/tot Free: 2722M Cache: 2836M Swap: 0K/4098M



Re: Minor cal(1) man diff

2018-09-04 Thread Jason McIntyre
On Tue, Sep 04, 2018 at 03:14:46PM +0300, Lauri Tirkkonen wrote:
> On Tue, Sep 04 2018 14:08:23 +0200, Martijn van Duren wrote:
> > Month is only taken into account if year is also specified.
> > This is also how POSIX notates the format.[0]
> 
> that synopsis doesn't match this usage though:
> 
> Alternatively,
> a single parameter may be given specifying
> the name or abbreviated name of a month:
> in that case a calendar is displayed for that month of the current year.
> 
> -- 
> Lauri Tirkkonen | lotheac @ IRCnet
> 

yep, and that fact is also noted in STANDARDS as a deviation.
jmc



Re: iostat: add "sp" column for CP_SPIN

2018-09-04 Thread Solene Rapenne
Stuart Henderson  wrote:
> On 2018/09/04 14:22, Solene Rapenne wrote:
> > About munin I'm trying to get a diff accepted upstream to fix cpu plugin and
> > talk about this with kirby@. The cpu plugin uses sysctl kern.cp_time. While
> > it's not related, I prefer to announce it here so people don't waste time
> > fixing it again by looking at the thread :)
> 
> Ah nice. When I worked on the initial munin port with mk I had intended
> to try to get upstream to take the openbsd plugins separately (rather
> than the current "copy similar OS and patch" approach), but I got fed up
> with rrdtool performance on OpenBSD and stopped using munin before I got
> round to it.. (and then I started using librenms and got fed up with
> rrdtool performance once again ;)

Using rrdcached the performances are really good. But that certainly depend on
the number of systems. It may not scale well with more than 50 systems, this is
also highly dependent on the number of plugins on each systems (as 1 value = 1
rrd file).



bgpd - simplify prefixlen logic

2018-09-04 Thread Claudio Jeker
Currently a lot of different operations are implemented for prefix
matching. This is not really needed because most can be expressed with the
range expression (prefixlen A - B). The only exceptions are the != and ><
operators. Both of them are a bit excotic and may be removed at a later time. 

This diff replaces 10.0.0.0/8 prefixlen >= 8 internally with
10.0.0.0/8 prefixlen 8 - 32 but at the same time the prefix printing
changed to print the ranges more nicely.

The visible changes when using bgpd -nv are:
match from any prefix 12.0.0.0/8 prefixlen > 12
becomes match from any prefix 12.0.0.0/8 prefixlen >= 13 

match from any prefix 14.0.0.0/8 prefixlen 8 - 11 
becomes match from any prefix 14.0.0.0/8 prefixlen < 12

match from any prefix 15.0.0.0/8 prefixlen 8 - 12 
becomes match from any prefix 15.0.0.0/8 prefixlen <= 12

match from any prefix 18.0.0.0/8 prefixlen 8 - 32
becomes match from any prefix 18.0.0.0/8 or-longer 

There is no behavior change because of this but is is needed since fast
lookups in prefix-sets are limited to OP_RANGE lookups.
-- 
:wq Claudio

Index: parse.y
===
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.331
diff -u -p -r1.331 parse.y
--- parse.y 27 Aug 2018 19:32:37 -  1.331
+++ parse.y 4 Sep 2018 12:47:59 -
@@ -2086,21 +2086,49 @@ filter_elm  : filter_prefix_h   {
 prefixlenop: /* empty */   { bzero(&$$, sizeof($$)); }
| LONGER{
bzero(&$$, sizeof($$));
-   $$.op = OP_GE;
+   $$.op = OP_RANGE;
$$.len_min = -1;
+   $$.len_max = -1;
}
| PREFIXLEN unaryop NUMBER  {
+   int min, max;
+
bzero(&$$, sizeof($$));
if ($3 < 0 || $3 > 128) {
yyerror("prefixlen must be >= 0 and <= 128");
YYERROR;
}
-   if ($2 == OP_GT && $3 == 0) {
-   yyerror("prefixlen must be > 0");
-   YYERROR;
+   /*
+* convert the unary operation into the equivalent
+* range check
+*/
+   $$.op = OP_RANGE;
+
+   switch ($2) {
+   case OP_EQ:
+   case OP_NE:
+   min = max = $3;
+   $$.op = $2;
+   break;
+   case OP_LT:
+   if ($3 == 0) {
+   yyerror("prefixlen must be > 0");
+   YYERROR;
+   }
+   $3 -= 1;
+   case OP_LE:
+   min = -1;
+   max = $3;
+   break;
+   case OP_GT:
+   $3 += 1;
+   case OP_GE:
+   min = $3;
+   max = -1;
+   break;
}
-   $$.op = $2;
-   $$.len_min = $3;
+   $$.len_min = min;
+   $$.len_max = max;
}
| PREFIXLEN NUMBER binaryop NUMBER  {
bzero(&$$, sizeof($$));
@@ -2108,7 +2136,7 @@ prefixlenop   : /* empty */   { 
bzero(&$$,
yyerror("prefixlen must be < 128");
YYERROR;
}
-   if ($2 >= $4) {
+   if ($2 > $4) {
yyerror("start prefixlen is bigger than end");
YYERROR;
}
@@ -3696,60 +3724,35 @@ merge_prefixspec(struct filter_prefix_l 
break;
}
 
-   switch (pl->op) {
-   case OP_NONE:
+   if (pl->op == OP_NONE) {
+   p->p.len_min = p->p.len_max = p->p.len;
return (0);
-   case OP_RANGE:
-   case OP_XRANGE:
-   if (pl->len_min > max_len || pl->len_max > max_len) {
-   yyerror("prefixlen %d too big for AF, limit %d",
-   pl->len_min > max_len ? pl->len_min : pl->len_max,
-   max_len);
-   return (-1);
-   }
-   if (pl->len_min < p->p.len) {
-   yyerror("prefixlen %d smaller than prefix, limit %d",
-   

Re: iostat: add "sp" column for CP_SPIN

2018-09-04 Thread Stuart Henderson
On 2018/09/04 14:22, Solene Rapenne wrote:
> About munin I'm trying to get a diff accepted upstream to fix cpu plugin and
> talk about this with kirby@. The cpu plugin uses sysctl kern.cp_time. While
> it's not related, I prefer to announce it here so people don't waste time
> fixing it again by looking at the thread :)

Ah nice. When I worked on the initial munin port with mk I had intended
to try to get upstream to take the openbsd plugins separately (rather
than the current "copy similar OS and patch" approach), but I got fed up
with rrdtool performance on OpenBSD and stopped using munin before I got
round to it.. (and then I started using librenms and got fed up with
rrdtool performance once again ;)



Update to table(5) man page

2018-09-04 Thread Matt Schwartz
Below is a diff to clear up the description of the Userinfo table in
table(5). I also added an example of how it can be used with an Alias
table.

Thanks,
Matt

Index: table.5
===
RCS file: /cvs/src/usr.sbin/smtpd/table.5,v
retrieving revision 1.9
diff -u -p -u -r1.9 table.5
--- table.524 May 2018 20:40:21 -1.9
+++ table.54 Sep 2018 12:52:47 -
@@ -174,16 +174,12 @@ ipv6:::1
 192.168.1.0/24
 .Ed
 .Ss Userinfo tables
-User info tables are used to described virtual system users.
-They are used in rule context to specify an alternate user base, mapping
-virtual users to local system UID, GID and home directory.
+User info tables are used in rule context to specify an alternate user base,
+mapping virtual users to local system users by UID, GID and home directory.
 .Pp
 .D1 Ic action Ar name method Cm userbase Pf < Ar table Ns >
 .Pp
-The userinfo table is a mapping from virtual user names to a set of system user
-ID, group ID and path to home directory.
-.Pp
-A userinfo table looks as follows:
+An userinfo table looks as follows:
 .Bd -literal -offset indent
 joe1000:100:/home/virtual/joe
 jack1000:100:/home/virtual/jack
@@ -193,7 +189,15 @@ In this example, both joe and jack are v
 system user with UID 1000 and GID 100, but different home directories.
 These directories may contain a
 .Xr forward 5
-file.
+file. This can be used in conjunction with an
+.Cm Alias table
+that maps an email address or the domain part to the desired virtual
+username. For example:
+.Bd -literal -offset indent
+j...@example.orgjoe
+j...@example.comjack
+.Ed
+.Pp
 .Ss Source tables
 Source tables are lists of IPv4 and IPv6 addresses.
 They can only be used in the following context:



Re: iostat: add "sp" column for CP_SPIN

2018-09-04 Thread Solene Rapenne
Stuart Henderson  wrote:
> On 2018/09/04 12:07, Solene Rapenne wrote:
> > Naoki Fukaumi  wrote:
> > > hi tech@,
> > > 
> > > new cpu state, CP_SPIN, was added,
> > >  https://marc.info/?l=openbsd-cvs=152630109526317=2
> > > 
> > > but there is no column for it in the header of iostat,
> > > 
> > > $ iostat
> > >   tty  sd0 cpu
> > >  tin tout  KB/t  t/s  MB/s  us ni sy in id
> > >01 11.473  0.04   0  0  0  0  0100
> > > 
> > > this patch adds "sp" for CP_SPIN.
> > > 
> > > --
> > > FUKAUMI Naoki
> > > 
> > > Index: usr.sbin/iostat/iostat.c
> > > ===
> > > RCS file: /cvs/src/usr.sbin/iostat/iostat.c,v
> > > retrieving revision 1.40
> > > diff -u -p -u -p -r1.40 iostat.c
> > > --- usr.sbin/iostat/iostat.c  10 Feb 2018 19:49:50 -  1.40
> > > +++ usr.sbin/iostat/iostat.c  4 Sep 2018 04:19:14 -
> > > @@ -229,7 +229,7 @@ header(void)
> > >   printf(" %16.16s ", cur.dk_name[i]);
> > >  
> > >   if (ISSET(todo, SHOW_CPU))
> > > - printf("cpu");
> > > + printf("   cpu");
> > >   printf("\n");
> > >  
> > >   /* Sub-Headers. */
> > > @@ -254,7 +254,7 @@ header(void)
> > >   printf(" KB  xfr time ");
> > >  
> > >   if (ISSET(todo, SHOW_CPU))
> > > - printf(" us ni sy in id");
> > > + printf(" us ni sy sp in id");
> > >   printf("\n");
> > >  }
> > >  
> > 
> > ok solene@ for this, but the man page should be updated too, it contains the
> > list of columns displayed.
> > 
> 
> Is iostat(8) something where people are likely to parse output?
> 
> (I first thought of sysutils/munin, iostat parsing is not enabled
> there, but there might be others).

About munin I'm trying to get a diff accepted upstream to fix cpu plugin and
talk about this with kirby@. The cpu plugin uses sysctl kern.cp_time. While
it's not related, I prefer to announce it here so people don't waste time
fixing it again by looking at the thread :)



Re: Minor cal(1) man diff

2018-09-04 Thread Lauri Tirkkonen
On Tue, Sep 04 2018 14:08:23 +0200, Martijn van Duren wrote:
> Month is only taken into account if year is also specified.
> This is also how POSIX notates the format.[0]

that synopsis doesn't match this usage though:

Alternatively,
a single parameter may be given specifying
the name or abbreviated name of a month:
in that case a calendar is displayed for that month of the current year.

-- 
Lauri Tirkkonen | lotheac @ IRCnet



Re: iostat: add "sp" column for CP_SPIN

2018-09-04 Thread Stuart Henderson
On 2018/09/04 12:07, Solene Rapenne wrote:
> Naoki Fukaumi  wrote:
> > hi tech@,
> > 
> > new cpu state, CP_SPIN, was added,
> >  https://marc.info/?l=openbsd-cvs=152630109526317=2
> > 
> > but there is no column for it in the header of iostat,
> > 
> > $ iostat
> >   tty  sd0 cpu
> >  tin tout  KB/t  t/s  MB/s  us ni sy in id
> >01 11.473  0.04   0  0  0  0  0100
> > 
> > this patch adds "sp" for CP_SPIN.
> > 
> > --
> > FUKAUMI Naoki
> > 
> > Index: usr.sbin/iostat/iostat.c
> > ===
> > RCS file: /cvs/src/usr.sbin/iostat/iostat.c,v
> > retrieving revision 1.40
> > diff -u -p -u -p -r1.40 iostat.c
> > --- usr.sbin/iostat/iostat.c10 Feb 2018 19:49:50 -  1.40
> > +++ usr.sbin/iostat/iostat.c4 Sep 2018 04:19:14 -
> > @@ -229,7 +229,7 @@ header(void)
> > printf(" %16.16s ", cur.dk_name[i]);
> >  
> > if (ISSET(todo, SHOW_CPU))
> > -   printf("cpu");
> > +   printf("   cpu");
> > printf("\n");
> >  
> > /* Sub-Headers. */
> > @@ -254,7 +254,7 @@ header(void)
> > printf(" KB  xfr time ");
> >  
> > if (ISSET(todo, SHOW_CPU))
> > -   printf(" us ni sy in id");
> > +   printf(" us ni sy sp in id");
> > printf("\n");
> >  }
> >  
> 
> ok solene@ for this, but the man page should be updated too, it contains the
> list of columns displayed.
> 

Is iostat(8) something where people are likely to parse output?

(I first thought of sysutils/munin, iostat parsing is not enabled
there, but there might be others).



Re: xidle: launching program on timeout without active-area

2018-09-04 Thread Rob Pierce
On Tue, Sep 04, 2018 at 01:54:10PM +0200, Claudio Jeker wrote:
> On Mon, Sep 03, 2018 at 03:49:46PM +0200, Sebastien Marie wrote:
> > ping
> 
> I like it, OK claudio@ but I'm not really a X person.

I also like it and it works well for me. ok rob@ with the same caveat.

Rob

> > On Tue, Aug 14, 2018 at 06:15:08AM +0200, Sebastien Marie wrote:
> > > ping
> > > 
> > > On Wed, Jul 25, 2018 at 02:13:49PM +0200, Sebastien Marie wrote:
> > > > On Wed, Jul 25, 2018 at 12:55:48PM +0200, Claudio Jeker wrote:
> > > > > On Wed, Jul 25, 2018 at 12:27:29PM +0200, Sebastien Marie wrote:
> > > > > > On Mon, Jul 16, 2018 at 11:37:41AM +0200, Sebastien Marie wrote:
> > > > > > 
> > > > > > > xidle(1) seems great for such purpose. But I didn't found a way 
> > > > > > > to just
> > > > > > > use timeout and not also an active area (a corner where the 
> > > > > > > program is
> > > > > > > launched if pointer stays inside few seconds).
> > > > > > > 
> > > > > > > The following diff tries to implement a way to disable the active 
> > > > > > > area
> > > > > > > without being too intrusive.
> > > > > > > 
> > > > > > > For that, I used the `delay' parameter ("Specify the number of 
> > > > > > > seconds
> > > > > > > the pointer has to be in the given position before running the
> > > > > > > program."), to allow value -1, and make it to discard the event.
> > > > > > > 
> > > > > > > Does it make sens ? Or any proposition to more straighfull 
> > > > > > > approch ?
> > > > > > > 
> > > > > 
> > > > > I would love to be able to use xidle without active area but I have 
> > > > > to say
> > > > > that your approach with -1 as delay seems a bit like a hack. Wouldn't 
> > > > > it
> > > > > be better to add a -no option to disable the corners all together? 
> > > > > Maybe
> > > > > even make that the default instead of -nw?
> > > > > 
> > > > 
> > > > the "-delay -1" approch was taken to avoid too instrusive change that
> > > > would clash with upstream (but are we upstream ? I didn't found xidle 
> > > > under
> > > > www.x.org). Anyway, the approch with -no option seems to not be too
> > > > intrusive neither and it is better for user point of vue.
> > > > 
> > > > So below a new diff with -no option.
> > > > 
> > > > When used, the -no flag that sets `position' variable to `none'. The
> > > > active area window is still created (its avoid to manage a new case
> > > > where `xi->win' could be NULL), but the window isn't mapper and no
> > > > event asked for EnterWindow.
> > > > 
> > > > Sending USR1 still work as intented.
> > > > 
> > > > I didn't change the default value for the position, but it could be
> > > > easily done (one line change in xidle.c and xidle.1).
> > > > 
> > > > -- 
> > > > Sebastien Marie
> > > > 
> > > > Index: xidle.1
> > > > ===
> > > > RCS file: /cvs/xenocara/app/xidle/xidle.1,v
> > > > retrieving revision 1.4
> > > > diff -u -p -r1.4 xidle.1
> > > > --- xidle.1 9 Nov 2017 19:13:03 -   1.4
> > > > +++ xidle.1 25 Jul 2018 11:54:13 -
> > > > @@ -35,7 +35,7 @@
> > > >  .Op Fl area Ar pixels
> > > >  .Op Fl delay Ar secs
> > > >  .Op Fl display Ar display
> > > > -.Op Fl nw | ne | sw | se
> > > > +.Op Fl no | nw | ne | sw | se
> > > >  .Op Fl program Ar path
> > > >  .Op Fl timeout Ar secs
> > > >  .Ek
> > > > @@ -66,8 +66,8 @@ The default is 2 seconds.
> > > >  .It Fl display Ar display
> > > >  This argument allows you to specify the server to connect to; see
> > > >  .Xr X 7 .
> > > > -.It Fl nw | ne | sw | se
> > > > -Set the position to one of northwest, northeast, southwest, or 
> > > > southeast,
> > > > +.It Fl no | nw | ne | sw | se
> > > > +Set the position to one of none, northwest, northeast, southwest, or 
> > > > southeast,
> > > >  respectively.
> > > >  If no position is specified,
> > > >  the default is northwest.
> > > > @@ -100,7 +100,9 @@ Specify the number of seconds to wait be
> > > >  .Fl delay
> > > >  option.
> > > >  .It Sy position No (class Sy Position )
> > > > -Set the position to one of: "nw", "ne", "sw", or "se"; see 
> > > > descriptions of the
> > > > +Set the position to one of: "no", "nw", "ne", "sw", or "se"; see 
> > > > descriptions
> > > > +of the
> > > > +.Fl no ,
> > > >  .Fl nw ,
> > > >  .Fl ne ,
> > > >  .Fl sw ,
> > > > Index: xidle.c
> > > > ===
> > > > RCS file: /cvs/xenocara/app/xidle/xidle.c,v
> > > > retrieving revision 1.5
> > > > diff -u -p -r1.5 xidle.c
> > > > --- xidle.c 20 Aug 2017 16:43:25 -  1.5
> > > > +++ xidle.c 25 Jul 2018 11:59:40 -
> > > > @@ -53,7 +53,8 @@ enum {
> > > > north = 0x01,
> > > > south = 0x02,
> > > > east  = 0x04,
> > > > -   west  = 0x08
> > > > +   west  = 0x08,
> > > > +   none  = 0x10,
> > > >  };
> > > >  
> > > >  enum { XIDLE_LOCK = 1, XIDLE_DIE = 2 };
> > > > @@ -84,6 +85,7 @@ static XrmOptionDescRec opts[] = {

Minor cal(1) man diff

2018-09-04 Thread Martijn van Duren
Month is only taken into account if year is also specified.
This is also how POSIX notates the format.[0]

OK?

martijn@

[0] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cal.html

Index: cal.1
===
RCS file: /cvs/src/usr.bin/cal/cal.1,v
retrieving revision 1.31
diff -u -p -r1.31 cal.1
--- cal.1   27 Nov 2016 10:37:22 -  1.31
+++ cal.1   4 Sep 2018 12:05:54 -
@@ -42,8 +42,9 @@
 .Sh SYNOPSIS
 .Nm cal
 .Op Fl jmwy
-.Op Ar month
-.Op Ar year
+.Oo Op Ar month
+.Ar year
+.Oc
 .Sh DESCRIPTION
 .Nm
 displays a simple calendar.



Re: bgpd, streamline aspath matching

2018-09-04 Thread Claudio Jeker
On Mon, Aug 27, 2018 at 12:11:43PM +0200, Claudio Jeker wrote:
> This is in preparation for introducing as-sets (a fast lookup table for
> when you want to make sure that your peering partner is realy only passing
> you traffic he should).
> 
> To make as-set possible lets do some cleanup beforehands. This mainly
> removes one element from the filter_as struct, uses as_min for unary
> operations and changes the way we pass the and check the neighbor-as.
> as_compare() and aspath_match() now take the neighbor-as as last argument
> and will match against it if AS_FLAG_NEIGHBORAS is set. Simplifies the
> rde_filter_match() a fair bit.
> 
> OK?

Ping

-- 
:wq Claudio
 

Index: bgpd.h
===
RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
retrieving revision 1.330
diff -u -p -r1.330 bgpd.h
--- bgpd.h  9 Aug 2018 21:12:33 -   1.330
+++ bgpd.h  27 Aug 2018 10:03:55 -
@@ -647,7 +647,6 @@ enum aslen_spec {
 };
 
 struct filter_as {
-   u_int32_t   as;
u_int16_t   flags;
enum as_spectype;
u_int8_top;
Index: parse.y
===
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.330
diff -u -p -r1.330 parse.y
--- parse.y 27 Aug 2018 09:49:00 -  1.330
+++ parse.y 27 Aug 2018 10:03:56 -
@@ -1902,7 +1902,7 @@ filter_as : as4number_any {
if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
NULL)
fatal(NULL);
-   $$->a.as = $1;
+   $$->a.as_min = $1;
$$->a.op = OP_EQ;
}
| NEIGHBORAS{
@@ -1916,7 +1916,7 @@ filter_as : as4number_any {
NULL)
fatal(NULL);
$$->a.op = $1;
-   $$->a.as = $2;
+   $$->a.as_min = $2;
}
| as4number_any binaryop as4number_any {
if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
Index: printconf.c
===
RCS file: /cvs/src/usr.sbin/bgpd/printconf.c,v
retrieving revision 1.109
diff -u -p -r1.109 printconf.c
--- printconf.c 11 Jul 2018 14:08:46 -  1.109
+++ printconf.c 27 Aug 2018 10:03:56 -
@@ -619,10 +619,10 @@ void print_as(struct filter_rule *r)
printf("%s ", log_as(r->match.as.as_max));
break;
case OP_NE:
-   printf("!= %s ", log_as(r->match.as.as));
+   printf("!= %s ", log_as(r->match.as.as_min));
break;
default:
-   printf("%s ", log_as(r->match.as.as));
+   printf("%s ", log_as(r->match.as.as_min));
break;
}
 }
Index: rde.c
===
RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
retrieving revision 1.414
diff -u -p -r1.414 rde.c
--- rde.c   9 Aug 2018 12:54:06 -   1.414
+++ rde.c   27 Aug 2018 10:03:57 -
@@ -2149,7 +2149,7 @@ rde_dump_filter(struct prefix *p, struct
return;
if (req->type == IMSG_CTL_SHOW_RIB_AS &&
!aspath_match(asp->aspath->data, asp->aspath->len,
-   >as, req->as.as))
+   >as, 0))
return;
if (req->type == IMSG_CTL_SHOW_RIB_COMMUNITY &&
!community_match(asp, req->community.as,
@@ -3769,5 +3769,4 @@ rde_mark_prefixsets_dirty(struct prefixs
}
}
}
-   return;
 }
Index: rde_filter.c
===
RCS file: /cvs/src/usr.sbin/bgpd/rde_filter.c,v
retrieving revision 1.99
diff -u -p -r1.99 rde_filter.c
--- rde_filter.c3 Aug 2018 16:31:22 -   1.99
+++ rde_filter.c27 Aug 2018 10:03:57 -
@@ -340,7 +340,6 @@ int
 rde_filter_match(struct filter_rule *f, struct rde_peer *peer,
 struct filterstate *state, struct prefix *p)
 {
-   u_int32_t   pas;
int cas, type;
int64_t las, ld1, ld2;
struct prefixset_item   *psi;
@@ -349,20 +348,16 @@ rde_filter_match(struct filter_rule *f, 
if (state != NULL)
asp = >aspath;
 
-   if (asp != NULL && f->match.as.type != AS_NONE) {
-   if (f->match.as.flags & AS_FLAG_NEIGHBORAS)
-   pas = peer->conf.remote_as;
-   else
-   pas = f->match.as.as;
-   if (aspath_match(asp->aspath->data, asp->aspath->len,
-   >match.as, pas) == 0)
-   return (0);
-   }
-
if (f->peer.ebgp && !peer->conf.ebgp)
return 

Re: xidle: launching program on timeout without active-area

2018-09-04 Thread Claudio Jeker
On Mon, Sep 03, 2018 at 03:49:46PM +0200, Sebastien Marie wrote:
> ping

I like it, OK claudio@ but I'm not really a X person.
 
> On Tue, Aug 14, 2018 at 06:15:08AM +0200, Sebastien Marie wrote:
> > ping
> > 
> > On Wed, Jul 25, 2018 at 02:13:49PM +0200, Sebastien Marie wrote:
> > > On Wed, Jul 25, 2018 at 12:55:48PM +0200, Claudio Jeker wrote:
> > > > On Wed, Jul 25, 2018 at 12:27:29PM +0200, Sebastien Marie wrote:
> > > > > On Mon, Jul 16, 2018 at 11:37:41AM +0200, Sebastien Marie wrote:
> > > > > 
> > > > > > xidle(1) seems great for such purpose. But I didn't found a way to 
> > > > > > just
> > > > > > use timeout and not also an active area (a corner where the program 
> > > > > > is
> > > > > > launched if pointer stays inside few seconds).
> > > > > > 
> > > > > > The following diff tries to implement a way to disable the active 
> > > > > > area
> > > > > > without being too intrusive.
> > > > > > 
> > > > > > For that, I used the `delay' parameter ("Specify the number of 
> > > > > > seconds
> > > > > > the pointer has to be in the given position before running the
> > > > > > program."), to allow value -1, and make it to discard the event.
> > > > > > 
> > > > > > Does it make sens ? Or any proposition to more straighfull approch ?
> > > > > > 
> > > > 
> > > > I would love to be able to use xidle without active area but I have to 
> > > > say
> > > > that your approach with -1 as delay seems a bit like a hack. Wouldn't it
> > > > be better to add a -no option to disable the corners all together? Maybe
> > > > even make that the default instead of -nw?
> > > > 
> > > 
> > > the "-delay -1" approch was taken to avoid too instrusive change that
> > > would clash with upstream (but are we upstream ? I didn't found xidle 
> > > under
> > > www.x.org). Anyway, the approch with -no option seems to not be too
> > > intrusive neither and it is better for user point of vue.
> > > 
> > > So below a new diff with -no option.
> > > 
> > > When used, the -no flag that sets `position' variable to `none'. The
> > > active area window is still created (its avoid to manage a new case
> > > where `xi->win' could be NULL), but the window isn't mapper and no
> > > event asked for EnterWindow.
> > > 
> > > Sending USR1 still work as intented.
> > > 
> > > I didn't change the default value for the position, but it could be
> > > easily done (one line change in xidle.c and xidle.1).
> > > 
> > > -- 
> > > Sebastien Marie
> > > 
> > > Index: xidle.1
> > > ===
> > > RCS file: /cvs/xenocara/app/xidle/xidle.1,v
> > > retrieving revision 1.4
> > > diff -u -p -r1.4 xidle.1
> > > --- xidle.1   9 Nov 2017 19:13:03 -   1.4
> > > +++ xidle.1   25 Jul 2018 11:54:13 -
> > > @@ -35,7 +35,7 @@
> > >  .Op Fl area Ar pixels
> > >  .Op Fl delay Ar secs
> > >  .Op Fl display Ar display
> > > -.Op Fl nw | ne | sw | se
> > > +.Op Fl no | nw | ne | sw | se
> > >  .Op Fl program Ar path
> > >  .Op Fl timeout Ar secs
> > >  .Ek
> > > @@ -66,8 +66,8 @@ The default is 2 seconds.
> > >  .It Fl display Ar display
> > >  This argument allows you to specify the server to connect to; see
> > >  .Xr X 7 .
> > > -.It Fl nw | ne | sw | se
> > > -Set the position to one of northwest, northeast, southwest, or southeast,
> > > +.It Fl no | nw | ne | sw | se
> > > +Set the position to one of none, northwest, northeast, southwest, or 
> > > southeast,
> > >  respectively.
> > >  If no position is specified,
> > >  the default is northwest.
> > > @@ -100,7 +100,9 @@ Specify the number of seconds to wait be
> > >  .Fl delay
> > >  option.
> > >  .It Sy position No (class Sy Position )
> > > -Set the position to one of: "nw", "ne", "sw", or "se"; see descriptions 
> > > of the
> > > +Set the position to one of: "no", "nw", "ne", "sw", or "se"; see 
> > > descriptions
> > > +of the
> > > +.Fl no ,
> > >  .Fl nw ,
> > >  .Fl ne ,
> > >  .Fl sw ,
> > > Index: xidle.c
> > > ===
> > > RCS file: /cvs/xenocara/app/xidle/xidle.c,v
> > > retrieving revision 1.5
> > > diff -u -p -r1.5 xidle.c
> > > --- xidle.c   20 Aug 2017 16:43:25 -  1.5
> > > +++ xidle.c   25 Jul 2018 11:59:40 -
> > > @@ -53,7 +53,8 @@ enum {
> > >   north = 0x01,
> > >   south = 0x02,
> > >   east  = 0x04,
> > > - west  = 0x08
> > > + west  = 0x08,
> > > + none  = 0x10,
> > >  };
> > >  
> > >  enum { XIDLE_LOCK = 1, XIDLE_DIE = 2 };
> > > @@ -84,6 +85,7 @@ static XrmOptionDescRec opts[] = {
> > >   { "-program",   ".program", XrmoptionSepArg,(caddr_t)NULL },
> > >   { "-timeout",   ".timeout", XrmoptionSepArg,(caddr_t)NULL },
> > >  
> > > + { "-no",".position",XrmoptionNoArg, (caddr_t)"no" },
> > >   { "-ne",".position",XrmoptionNoArg, (caddr_t)"ne" },
> > >   { "-nw",".position",XrmoptionNoArg, (caddr_t)"nw" },
> > >   { "-se",

Re: usbd_close_pipe.9: usbd_abort_pipe is void

2018-09-04 Thread Jason McIntyre
On Sun, Sep 02, 2018 at 06:54:02PM +0300, Artturi Alm wrote:
> Hi,
> 
> spotted this while removing return value from usbd_close_pipe,
> following cleanup by pirofti@[0], which made usbd_abort_pipe void.
> 
> 
> -Artturi
> 
> [0]:
> https://github.com/openbsd/src/commit/1e087f7cf25ce711b6cef28d054ab4a68be213d2
> 

someone fix (or reject) this, please.
ta,

jmc

> 
> diff --git share/man/man9/usbd_close_pipe.9 share/man/man9/usbd_close_pipe.9
> index 650182d5284..3c2027c337e 100644
> --- share/man/man9/usbd_close_pipe.9
> +++ share/man/man9/usbd_close_pipe.9
> @@ -25,7 +25,7 @@
>  .In dev/usb/usbdi.h
>  .Ft usbd_status
>  .Fn usbd_close_pipe "struct usbd_pipe *pipe"
> -.Ft usbd_status
> +.Ft void
>  .Fn usbd_abort_pipe "struct usbd_pipe *pipe"
>  .Sh DESCRIPTION
>  The
> 



Re: bgpd diff

2018-09-04 Thread Denis Fondras
On Tue, Sep 04, 2018 at 12:56:52PM +0200, Claudio Jeker wrote:
> Yet another minor bgpd diff from a much bigger diff. This adds
> inet4applymask() similar to inet6applymask() and starts using it in a few
> places. This makes some of the INET vs INET6 cases more similar.
> 
> OK?

OK denis@

> -- 
> :wq Claudio
> 
> Index: bgpd.h
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
> retrieving revision 1.331
> diff -u -p -r1.331 bgpd.h
> --- bgpd.h29 Aug 2018 19:47:47 -  1.331
> +++ bgpd.h3 Sep 2018 14:29:39 -
> @@ -1174,6 +1177,7 @@ int  nlri_get_vpn4(u_char *, u_int16_t,
>  int   prefix_compare(const struct bgpd_addr *,
>   const struct bgpd_addr *, int);
>  in_addr_t prefixlen2mask(u_int8_t);
> +void  inet4applymask(struct in_addr *, const struct in_addr *, int);
>  void  inet6applymask(struct in6_addr *, const struct in6_addr *,
>   int);
>  const char   *aid2str(u_int8_t);
> Index: rde_prefix.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/rde_prefix.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 rde_prefix.c
> --- rde_prefix.c  24 Jan 2017 04:22:42 -  1.33
> +++ rde_prefix.c  4 Sep 2018 10:15:42 -
> @@ -101,7 +101,6 @@ pt_fill(struct bgpd_addr *prefix, int pr
>   static struct pt_entry4 pte4;
>   static struct pt_entry6 pte6;
>   static struct pt_entry_vpn4 pte_vpn4;
> - in_addr_t   addr_hbo;
>  
>   switch (prefix->aid) {
>   case AID_INET:
> @@ -109,9 +108,7 @@ pt_fill(struct bgpd_addr *prefix, int pr
>   pte4.aid = prefix->aid;
>   if (prefixlen > 32)
>   fatalx("pt_fill: bad IPv4 prefixlen");
> - addr_hbo = ntohl(prefix->v4.s_addr);
> - pte4.prefix4.s_addr = htonl(addr_hbo &
> - prefixlen2mask(prefixlen));
> + inet4applymask(, >v4, prefixlen);
>   pte4.prefixlen = prefixlen;
>   return ((struct pt_entry *));
>   case AID_INET6:
> @@ -119,17 +116,16 @@ pt_fill(struct bgpd_addr *prefix, int pr
>   pte6.aid = prefix->aid;
>   if (prefixlen > 128)
>   fatalx("pt_get: bad IPv6 prefixlen");
> - pte6.prefixlen = prefixlen;
>   inet6applymask(, >v6, prefixlen);
> + pte6.prefixlen = prefixlen;
>   return ((struct pt_entry *));
>   case AID_VPN_IPv4:
>   bzero(_vpn4, sizeof(pte_vpn4));
>   pte_vpn4.aid = prefix->aid;
>   if (prefixlen > 32)
>   fatalx("pt_fill: bad IPv4 prefixlen");
> - addr_hbo = ntohl(prefix->vpn4.addr.s_addr);
> - pte_vpn4.prefix4.s_addr = htonl(addr_hbo &
> - prefixlen2mask(prefixlen));
> + inet4applymask(_vpn4.prefix4, >vpn4.addr,
> + prefixlen);
>   pte_vpn4.prefixlen = prefixlen;
>   pte_vpn4.rd = prefix->vpn4.rd;
>   pte_vpn4.labellen = prefix->vpn4.labellen;
> Index: session.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
> retrieving revision 1.365
> diff -u -p -r1.365 session.c
> --- session.c 11 Jul 2018 16:34:36 -  1.365
> +++ session.c 4 Sep 2018 10:07:34 -
> @@ -3150,19 +3150,20 @@ session_template_clone(struct peer *p, s
>  int
>  session_match_mask(struct peer *p, struct bgpd_addr *a)
>  {
> - in_addr_tv4mask;
> - struct in6_addr  masked;
> + struct in_addr   v4masked;
> + struct in6_addr  v6masked;
>  
>   switch (p->conf.remote_addr.aid) {
>   case AID_INET:
> - v4mask = htonl(prefixlen2mask(p->conf.remote_masklen));
> - if (p->conf.remote_addr.v4.s_addr == (a->v4.s_addr & v4mask))
> + inet4applymask(, >v4, p->conf.remote_masklen);
> + if (p->conf.remote_addr.v4.s_addr == v4masked.s_addr)
>   return (1);
>   return (0);
>   case AID_INET6:
> - inet6applymask(, >v6, p->conf.remote_masklen);
> + inet6applymask(, >v6, p->conf.remote_masklen);
>  
> - if (!memcmp(, >conf.remote_addr.v6, sizeof(masked)))
> + if (memcmp(, >conf.remote_addr.v6,
> + sizeof(v6masked)) == 0)
>   return (1);
>   return (0);
>   }
> Index: util.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/util.c,v
> retrieving revision 1.31
> diff -u -p -r1.31 util.c
> --- util.c29 Aug 2018 11:43:15 -  1.31
> +++ util.c30 Aug 2018 12:12:05 -
> @@ -732,6 +732,15 @@ prefixlen2mask(u_int8_t prefixlen)
>  }
>  
>  void
> +inet4applymask(struct in_addr *dest, const struct in_addr 

bgpd diff

2018-09-04 Thread Claudio Jeker
Yet another minor bgpd diff from a much bigger diff. This adds
inet4applymask() similar to inet6applymask() and starts using it in a few
places. This makes some of the INET vs INET6 cases more similar.

OK?
-- 
:wq Claudio

Index: bgpd.h
===
RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
retrieving revision 1.331
diff -u -p -r1.331 bgpd.h
--- bgpd.h  29 Aug 2018 19:47:47 -  1.331
+++ bgpd.h  3 Sep 2018 14:29:39 -
@@ -1174,6 +1177,7 @@ intnlri_get_vpn4(u_char *, u_int16_t,
 int prefix_compare(const struct bgpd_addr *,
const struct bgpd_addr *, int);
 in_addr_t   prefixlen2mask(u_int8_t);
+voidinet4applymask(struct in_addr *, const struct in_addr *, int);
 voidinet6applymask(struct in6_addr *, const struct in6_addr *,
int);
 const char *aid2str(u_int8_t);
Index: rde_prefix.c
===
RCS file: /cvs/src/usr.sbin/bgpd/rde_prefix.c,v
retrieving revision 1.33
diff -u -p -r1.33 rde_prefix.c
--- rde_prefix.c24 Jan 2017 04:22:42 -  1.33
+++ rde_prefix.c4 Sep 2018 10:15:42 -
@@ -101,7 +101,6 @@ pt_fill(struct bgpd_addr *prefix, int pr
static struct pt_entry4 pte4;
static struct pt_entry6 pte6;
static struct pt_entry_vpn4 pte_vpn4;
-   in_addr_t   addr_hbo;
 
switch (prefix->aid) {
case AID_INET:
@@ -109,9 +108,7 @@ pt_fill(struct bgpd_addr *prefix, int pr
pte4.aid = prefix->aid;
if (prefixlen > 32)
fatalx("pt_fill: bad IPv4 prefixlen");
-   addr_hbo = ntohl(prefix->v4.s_addr);
-   pte4.prefix4.s_addr = htonl(addr_hbo &
-   prefixlen2mask(prefixlen));
+   inet4applymask(, >v4, prefixlen);
pte4.prefixlen = prefixlen;
return ((struct pt_entry *));
case AID_INET6:
@@ -119,17 +116,16 @@ pt_fill(struct bgpd_addr *prefix, int pr
pte6.aid = prefix->aid;
if (prefixlen > 128)
fatalx("pt_get: bad IPv6 prefixlen");
-   pte6.prefixlen = prefixlen;
inet6applymask(, >v6, prefixlen);
+   pte6.prefixlen = prefixlen;
return ((struct pt_entry *));
case AID_VPN_IPv4:
bzero(_vpn4, sizeof(pte_vpn4));
pte_vpn4.aid = prefix->aid;
if (prefixlen > 32)
fatalx("pt_fill: bad IPv4 prefixlen");
-   addr_hbo = ntohl(prefix->vpn4.addr.s_addr);
-   pte_vpn4.prefix4.s_addr = htonl(addr_hbo &
-   prefixlen2mask(prefixlen));
+   inet4applymask(_vpn4.prefix4, >vpn4.addr,
+   prefixlen);
pte_vpn4.prefixlen = prefixlen;
pte_vpn4.rd = prefix->vpn4.rd;
pte_vpn4.labellen = prefix->vpn4.labellen;
Index: session.c
===
RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
retrieving revision 1.365
diff -u -p -r1.365 session.c
--- session.c   11 Jul 2018 16:34:36 -  1.365
+++ session.c   4 Sep 2018 10:07:34 -
@@ -3150,19 +3150,20 @@ session_template_clone(struct peer *p, s
 int
 session_match_mask(struct peer *p, struct bgpd_addr *a)
 {
-   in_addr_tv4mask;
-   struct in6_addr  masked;
+   struct in_addr   v4masked;
+   struct in6_addr  v6masked;
 
switch (p->conf.remote_addr.aid) {
case AID_INET:
-   v4mask = htonl(prefixlen2mask(p->conf.remote_masklen));
-   if (p->conf.remote_addr.v4.s_addr == (a->v4.s_addr & v4mask))
+   inet4applymask(, >v4, p->conf.remote_masklen);
+   if (p->conf.remote_addr.v4.s_addr == v4masked.s_addr)
return (1);
return (0);
case AID_INET6:
-   inet6applymask(, >v6, p->conf.remote_masklen);
+   inet6applymask(, >v6, p->conf.remote_masklen);
 
-   if (!memcmp(, >conf.remote_addr.v6, sizeof(masked)))
+   if (memcmp(, >conf.remote_addr.v6,
+   sizeof(v6masked)) == 0)
return (1);
return (0);
}
Index: util.c
===
RCS file: /cvs/src/usr.sbin/bgpd/util.c,v
retrieving revision 1.31
diff -u -p -r1.31 util.c
--- util.c  29 Aug 2018 11:43:15 -  1.31
+++ util.c  30 Aug 2018 12:12:05 -
@@ -732,6 +732,15 @@ prefixlen2mask(u_int8_t prefixlen)
 }
 
 void
+inet4applymask(struct in_addr *dest, const struct in_addr *src, int prefixlen)
+{
+   struct in_addr mask;
+
+   mask.s_addr = htonl(prefixlen2mask(prefixlen));
+   dest->s_addr = src->s_addr & mask.s_addr;

Re: Add $daemon_nice to rc.subr

2018-09-04 Thread Craig Skinner
Hi Thomas,

This was previously discussed and rejected 5 years ago in thread:
"Alter daemon scheduling priority with renice for rc.d"

See: https://marc.info/?t=13874606661


Subsequently I found login.conf is perfect. Some examples:


daemon-cellar:\
:priority=18:\
:tc=daemon:

avahi_daemon:\
:tc=daemon-cellar:

cupsd:\
:setenv=:\
:priority=12:\
:tc=daemon:

cvsyncd:\
:tc=daemon-cellar:
  
dbus_daemon:\
:tc=daemon-cellar:

dhcp:\
:priority=15:\
:tc=daemon:

identd:\
:priority=7:\
:tc=daemon:

inetd:\
:priority=10:\
:tc=daemon:

nmbd:\
:tc=daemon-cellar:

smbd:\
:priority=9:\
:tc=daemon:

spamd:\
:priority=5:\
:tc=daemon:

spamlogd:\
:tc=spamd:

squid:\ 
:priority=1:\
:openfiles-cur=4096:\
:openfiles-max=8192:\
:tc=daemon:

sshd:\
:priority=-10:\
:tc=daemon:

unbound:\
:priority=-5:\
:openfiles-cur=512:\
:openfiles-max=718:\
:tc=daemon:

nsd:\   
:priority=-5:\
:tc=daemon:


etc. etc. etc.


Cheers,
-- 
Craig Skinner | http://linkd.in/yGqkv7



Re: iostat: add "sp" column for CP_SPIN

2018-09-04 Thread Solene Rapenne
Naoki Fukaumi  wrote:
> hi tech@,
> 
> new cpu state, CP_SPIN, was added,
>  https://marc.info/?l=openbsd-cvs=152630109526317=2
> 
> but there is no column for it in the header of iostat,
> 
> $ iostat
>   tty  sd0 cpu
>  tin tout  KB/t  t/s  MB/s  us ni sy in id
>01 11.473  0.04   0  0  0  0  0100
> 
> this patch adds "sp" for CP_SPIN.
> 
> --
> FUKAUMI Naoki
> 
> Index: usr.sbin/iostat/iostat.c
> ===
> RCS file: /cvs/src/usr.sbin/iostat/iostat.c,v
> retrieving revision 1.40
> diff -u -p -u -p -r1.40 iostat.c
> --- usr.sbin/iostat/iostat.c  10 Feb 2018 19:49:50 -  1.40
> +++ usr.sbin/iostat/iostat.c  4 Sep 2018 04:19:14 -
> @@ -229,7 +229,7 @@ header(void)
>   printf(" %16.16s ", cur.dk_name[i]);
>  
>   if (ISSET(todo, SHOW_CPU))
> - printf("cpu");
> + printf("   cpu");
>   printf("\n");
>  
>   /* Sub-Headers. */
> @@ -254,7 +254,7 @@ header(void)
>   printf(" KB  xfr time ");
>  
>   if (ISSET(todo, SHOW_CPU))
> - printf(" us ni sy in id");
> + printf(" us ni sy sp in id");
>   printf("\n");
>  }
>  

ok solene@ for this, but the man page should be updated too, it contains the
list of columns displayed.



Re: Add $daemon_nice to rc.subr

2018-09-04 Thread Stuart Henderson
On 2018/09/04 10:57, Thomas de Grivel wrote:
> plus it's really 6 new lines in rc.subr, no big deal.

6 lines in rc.subr, but add this and someone will want to add something
else (ulimit? setting environment variables?) and it's more, plus the
accompanying documentation (which I think reduces the chance of people
seeing things which are already possible..)

There's already a mechanism to do what you want (note you can set the
priority for "daemon" as well, to apply by default). While you might
not like login.conf, it's not so horrible that there needs to be a
duplicate mechanism..



Re: Add $daemon_nice to rc.subr

2018-09-04 Thread Solène Rapenne

Le 2018-09-04 10:56, Thomas de Grivel a écrit :

why ?


why ? well all interactive process get a quarter range nice priority
advance compared to all daemon tasks, at least for a laptop
environment it really makes sense. sndiod and ntpd are unaffected by
this change.

you're right to criticize in that I did not document my code, the
point of this new variable is that an amendment to daemon priority is
no more than putting one line in /etc/rc.conf.local eg.
sshd_nice=1

or in the rc.d/ file
daemon_nice=whatever

why, because it is a whole lot more readable and usable than
inheriting a whole new login class just to change one parameter, but
if you don't like it nobody foces you huh ?

--
Thomas de Grivel
http://kmx.io

Le mar. 4 sept. 2018 à 07:57, Alexandre Ratchov  a 
écrit :


On Tue, Sep 04, 2018 at 04:58:53AM +0200, Thomas de Grivel wrote:
>
> And I still feel the default nice priority of 10 is rather a good
> idea.

why?


The current system using login.conf requires one line too

echo "tor:priority=5:" >> /etc/login.conf

it's already there, no need duplicating ways to manage the nice level



Re: Add $daemon_nice to rc.subr

2018-09-04 Thread Thomas de Grivel
plus it's really 6 new lines in rc.subr, no big deal.
Le mar. 4 sept. 2018 à 10:53, Thomas de Grivel  a écrit :
>
> why ? well all interactive process get a quarter range nice priority
> advance compared to all daemon tasks, at least for a laptop
> environment it really makes sense. sndiod and ntpd are unaffected by
> this change.
>
> you're right to criticize in that I did not document my code, the
> point of this new variable is that an amendment to daemon priority is
> no more than putting one line in /etc/rc.conf.local eg.
> sshd_nice=1
>
> or in the rc.d/ file
> daemon_nice=whatever
>
> why, because it is a whole lot more readable and usable than
> inheriting a whole new login class just to change one parameter, but
> if you don't like it nobody foces you huh ?
>
> Le mar. 4 sept. 2018 à 07:57, Alexandre Ratchov  a écrit :
> >
> > On Tue, Sep 04, 2018 at 04:58:53AM +0200, Thomas de Grivel wrote:
> > >
> > > And I still feel the default nice priority of 10 is rather a good
> > > idea.
> >
> > why?
>
>
>
> --
>  Thomas de Grivel
>  http://b.lowh.net/billitch/



-- 
 Thomas de Grivel
 http://b.lowh.net/billitch/



Re: Add $daemon_nice to rc.subr

2018-09-04 Thread Thomas de Grivel
> why ?

why ? well all interactive process get a quarter range nice priority
advance compared to all daemon tasks, at least for a laptop
environment it really makes sense. sndiod and ntpd are unaffected by
this change.

you're right to criticize in that I did not document my code, the
point of this new variable is that an amendment to daemon priority is
no more than putting one line in /etc/rc.conf.local eg.
sshd_nice=1

or in the rc.d/ file
daemon_nice=whatever

why, because it is a whole lot more readable and usable than
inheriting a whole new login class just to change one parameter, but
if you don't like it nobody foces you huh ?

-- 
Thomas de Grivel
http://kmx.io

Le mar. 4 sept. 2018 à 07:57, Alexandre Ratchov  a écrit :
>
> On Tue, Sep 04, 2018 at 04:58:53AM +0200, Thomas de Grivel wrote:
> >
> > And I still feel the default nice priority of 10 is rather a good
> > idea.
>
> why?



-- 
 Thomas de Grivel
 http://b.lowh.net/billitch/



iostat: add "sp" column for CP_SPIN

2018-09-04 Thread Naoki Fukaumi
hi tech@,

new cpu state, CP_SPIN, was added,
 https://marc.info/?l=openbsd-cvs=152630109526317=2

but there is no column for it in the header of iostat,

$ iostat
  tty  sd0 cpu
 tin tout  KB/t  t/s  MB/s  us ni sy in id
   01 11.473  0.04   0  0  0  0  0100

this patch adds "sp" for CP_SPIN.

--
FUKAUMI Naoki

Index: usr.sbin/iostat/iostat.c
===
RCS file: /cvs/src/usr.sbin/iostat/iostat.c,v
retrieving revision 1.40
diff -u -p -u -p -r1.40 iostat.c
--- usr.sbin/iostat/iostat.c10 Feb 2018 19:49:50 -  1.40
+++ usr.sbin/iostat/iostat.c4 Sep 2018 04:19:14 -
@@ -229,7 +229,7 @@ header(void)
printf(" %16.16s ", cur.dk_name[i]);
 
if (ISSET(todo, SHOW_CPU))
-   printf("cpu");
+   printf("   cpu");
printf("\n");
 
/* Sub-Headers. */
@@ -254,7 +254,7 @@ header(void)
printf(" KB  xfr time ");
 
if (ISSET(todo, SHOW_CPU))
-   printf(" us ni sy in id");
+   printf(" us ni sy sp in id");
printf("\n");
 }
 



fix "_nfiles" references for crash dump

2018-09-04 Thread Naoki Fukaumi
hi tech@,

"_nfiles" was renamed to "_numfiles" by this commit,
 https://marc.info/?l=openbsd-cvs=147199491615345=2

then fstat/pstat put following errors,

 # fstat -M bsd.0.core -N bsd.0
 fstat: _nfiles: no such symbol

 # pstat -f -M bsd.0.core -N bsd.0
 pstat: kvm_getfiles: _nfiles: no such symbol

 # pstat -T -M bsd.0.core -N bsd.0
 pstat: cannot read nfile: invalid translation (invalid PTE)

this patch fixes the problem.

--
FUKAUMI Naoki

Index: lib/libkvm/kvm_file2.c
===
RCS file: /cvs/src/lib/libkvm/kvm_file2.c,v
retrieving revision 1.53
diff -u -p -u -p -r1.53 kvm_file2.c
--- lib/libkvm/kvm_file2.c  2 Jan 2018 06:38:45 -   1.53
+++ lib/libkvm/kvm_file2.c  4 Sep 2018 04:19:00 -
@@ -209,7 +209,7 @@ kvm_deadfile_byfile(kvm_t *kd, int op, i
int nfiles;
 
nl[0].n_name = "_filehead";
-   nl[1].n_name = "_nfiles";
+   nl[1].n_name = "_numfiles";
nl[2].n_name = 0;
 
if (kvm_nlist(kd, nl) != 0) {
@@ -280,7 +280,7 @@ kvm_deadfile_byid(kvm_t *kd, int op, int
int i, nfiles;
 
nl[0].n_name = "_filehead";
-   nl[1].n_name = "_nfiles";
+   nl[1].n_name = "_numfiles";
nl[2].n_name = "_allprocess";
nl[3].n_name = 0;
 
Index: usr.sbin/pstat/pstat.c
===
RCS file: /cvs/src/usr.sbin/pstat/pstat.c,v
retrieving revision 1.118
diff -u -p -u -p -r1.118 pstat.c
--- usr.sbin/pstat/pstat.c  3 Aug 2018 14:39:55 -   1.118
+++ usr.sbin/pstat/pstat.c  4 Sep 2018 04:19:00 -
@@ -69,7 +69,7 @@
 
 struct nlist vnodenl[] = {
 #defineFNL_NFILE   0   /* sysctl */
-   {"_nfiles"},
+   {"_numfiles"},
 #define FNL_MAXFILE1   /* sysctl */
{"_maxfiles"},
 #define TTY_NTTY   2   /* sysctl */