Re: sunfire v120 gem interfaces

2015-11-09 Thread Christian Weisgerber
Ryan Freeman:

> However, for some reason after sometimes mere hours -- othertimes days at a
> time,  the gem0 interface needs to be cycled: [...] starting to wonder
> if this machine is at its EOL and the network ports are dying :(

I see the same problem with the gem in my Blade 150.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



pledge(2) nohup(1)

2015-11-09 Thread Ricardo Mestre

Hi!

Simple pledge around nohup, it starts with "stdio rpath wpath cpath 
exec" and then after nohup.out file is open(2)'ed it can drop to "stdio 
exec" only:


Index: nohup.c
===
RCS file: /cvs/src/usr.bin/nohup/nohup.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 nohup.c
--- nohup.c 16 Jan 2015 06:40:10 -  1.15
+++ nohup.c 9 Nov 2015 12:55:08 -
@@ -73,6 +73,9 @@ main(int argc, char *argv[])
 {
int exit_status;

+   if (pledge("stdio rpath wpath cpath exec", NULL) == -1)
+   err(1, "pledge");
+
if (argc < 2)
usage();

@@ -116,6 +119,9 @@ dofile(void)
errx(EXIT_MISC, "can't open a nohup.out file");

 dupit:
+   if (pledge("stdio exec", NULL) == -1)
+   err(1, "pledge");
+
(void)lseek(fd, (off_t)0, SEEK_END);
if (dup2(fd, STDOUT_FILENO) == -1)
err(EXIT_MISC, NULL);


Best regards,
Ricardo Mestre



Re: Patch 1/3 - make DIOCRADDADDRS to accept on IP address per ioctl() call

2015-11-09 Thread Alexandr Nedvedicky
Hello,

> On Wed, Oct 28, 2015 at 06:19:48PM +0100, Alexandr Nedvedicky wrote:
> > The idea has been proposed by Claudio at Varazdin.
> 
> I guess the idea is to eliminate the workq.  Or is ther naother
> reason to change it?

the primary goal is to kill work queues.

> 
> Comments inline
> 
thank you very much for very good code review.

> > -   *nadd = io.pfrio_nadd;
> > -   return (0);
> > +   io.pfrio_size = 1;  /* TODO: check .pfrio_size is needed */
> > +   for (i = 0; (i < size) && (rv == 0); i++) {
> 
> rv is unitialized in the first interation

it's fixed by change below:

@@ -184,7 +184,8 @@
 int *nadd, int flags)
 {
struct pfioc_table io;
-   int i, rv, add = 0;
+   int i, add = 0;
+   int rv = 0; 
 
> 
> > +   io.pfrio_buffer = addr++;
> > +   rv = ioctl(dev, DIOCRADDADDR, );
> 
> I would suggest to return (-1) if ioctl fails...
I'll write my response in email answering your note on 'illusion of atomicity'

> 
> pfr_add_addr() handles exactly 1 address, don't pass io->pfrio_size.
> 

yes that's true...

error = pfr_add_addr(>pfrio_table, io->pfrio_buffer,
-   io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL);
+   io->pfrio_flags | PFR_FLAG_USERIOCTL);
break;

> >  
> >  int
> > +pfr_add_addr(struct pfr_table *tbl, struct pfr_addr *addr, int size, int 
> > flags)
> 
> Do not pass size.

-pfr_add_addr(struct pfr_table *tbl, struct pfr_addr *addr, int size, int flags)
+pfr_add_addr(struct pfr_table *tbl, struct pfr_addr *addr, int flags)

> 
> Should you check for !(flags & PFR_FLAG_DUMMY) here?  It was done
> in the old code before pfr_insert_kentries().
> 
> > +   rv = pfr_insert_kentry(kt, , tzero);
> 
> The old code ignored wether pfr_insert_kentries() succeeded.
> 

thanks for catching this.

@@ -288,20 +288,20 @@
senderr(EINVAL);
p = pfr_lookup_addr(kt, , 1);
if (p == NULL) {
-   rv = pfr_insert_kentry(kt, , tzero);
+   if (!(flags & PFR_FLAG_DUMMY))
+   rv = pfr_insert_kentry(kt, , tzero);
+   else
+   rv = 0;
}

> 
> No { } for one line if block.

there is no longer one line if block after fixing  PFR_FLAG_DUMMY flag.

> 
> PFR_FB_DUPLICATE was used when there were two identical addresses
> in the passed list.  This cannot happen anymore.  It should be
> PFR_FB_NONE in this case.
> 
> > +   } else if (rv != 0) {
> > +   ad.pfra_fback = PFR_FB_NONE;
> > +   } else {
> > +   ad.pfra_fback = PFR_FB_ADDED;
> > +   }
> 
> Perhaps write this block as
> 
>   if (p == NULL)
>   ad.pfra_fback = PFR_FB_ADDED;
>   else if ((p->pfrke_flags & PFRKE_FLAG_NOT) != ad.pfra_not))
>   ad.pfra_fback = PFR_FB_CONFLICT;
>   else
>   ad.pfra_fback = PFR_FB_NONE;
> 

I thinks we still must check rv coming from pfr_insert_kentry():

if (flags & PFR_FLAG_FEEDBACK) {
-   if (p != NULL) {
-   if ((p->pfrke_flags & PFRKE_FLAG_NOT) != ad.pfra_not)
-   ad.pfra_fback = PFR_FB_CONFLICT;
-   else
-   ad.pfra_fback = PFR_FB_DUPLICATE;
-   } else if (rv != 0) {
+   if (p == NULL)
+   ad.pfra_fback = (rv == 0) ? PFR_FB_ADDED : PFR_FB_NONE;
+   else if ((p->pfrke_flags & PFRKE_FLAG_NOT) != ad.pfra_not)
+   ad.pfra_fback = PFR_FB_CONFLICT;
+   else
ad.pfra_fback = PFR_FB_NONE;
-   } else {
-   ad.pfra_fback = PFR_FB_ADDED;
-   }

 
> > +_bad:
> > +   if (flags & PFR_FLAG_FEEDBACK)
> > +   pfr_reset_feedback(addr, size, flags);
> 
> Don't use size, it must be 1.

the size argument got dropped.

> 
> > +   return (rv);
> 
> rv may be unitialized

thanks for catching that.

> 
> pfr_add_addrs() is not used anymore, remove it.

pfr_add_addrs() is gone in new patch.

thanks and
regards
sasha

8<---8<-8<

Index: sbin/pfctl/pfctl_radix.c
===
RCS file: /cvs/src/sbin/pfctl/pfctl_radix.c,v
retrieving revision 1.32
diff -u -p -r1.32 pfctl_radix.c
--- sbin/pfctl/pfctl_radix.c21 Jan 2015 21:50:33 -  1.32
+++ sbin/pfctl/pfctl_radix.c9 Nov 2015 20:43:52 -
@@ -184,6 +184,8 @@ pfr_add_addrs(struct pfr_table *tbl, str
 int *nadd, int flags)
 {
struct pfioc_table io;
+   int i, add = 0;
+   int rv = 0; 
 
if (tbl == NULL || size < 0 || (size && addr == NULL)) {
errno = EINVAL;
@@ -192,14 +194,19 @@ pfr_add_addrs(struct pfr_table *tbl, str
bzero(, sizeof io);
io.pfrio_flags = 

at(1): avoid chdir

2015-11-09 Thread Todd C. Miller
Use the *at system calls instead of changing directories.

 - todd

Index: usr.bin/at/at.c
===
RCS file: /cvs/src/usr.bin/at/at.c,v
retrieving revision 1.70
diff -u -p -u -r1.70 at.c
--- usr.bin/at/at.c 9 Nov 2015 15:57:39 -   1.70
+++ usr.bin/at/at.c 9 Nov 2015 21:48:05 -
@@ -214,8 +214,8 @@ writefile(const char *cwd, time_t runtim
act.sa_flags = 0;
sigaction(SIGINT, , NULL);
 
-   if ((lockdes = open(AT_SPOOL, O_RDONLY, 0)) < 0)
-   perr("Cannot open jobs dir");
+   if ((lockdes = open(AT_SPOOL, O_RDONLY|O_DIRECTORY, 0)) < 0)
+   perr2("Cannot open ", AT_SPOOL);
 
/*
 * Lock the jobs dir so we don't have to worry about someone
@@ -479,7 +479,7 @@ list_jobs(int argc, char **argv, int cou
uid_t *uids;
char queue, *ep;
DIR *spool;
-   int i, shortformat;
+   int dfd, i, shortformat;
size_t numjobs, maxjobs;
 
if (argc) {
@@ -498,13 +498,11 @@ list_jobs(int argc, char **argv, int cou
 
shortformat = strcmp(__progname, "at") == 0;
 
-   if (chdir(AT_SPOOL) != 0)
-   perr2("Cannot change to ", AT_SPOOL);
-
-   if ((spool = opendir(".")) == NULL)
+   if ((dfd = open(AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1 ||
+   (spool = fdopendir(dfd)) == NULL)
perr2("Cannot open ", AT_SPOOL);
 
-   if (fstat(dirfd(spool), ) != 0)
+   if (fstat(dfd, ) != 0)
perr2("Cannot stat ", AT_SPOOL);
 
/*
@@ -520,8 +518,8 @@ list_jobs(int argc, char **argv, int cou
 
/* Loop over every file in the directory. */
while ((dirent = readdir(spool)) != NULL) {
-   if (stat(dirent->d_name, ) != 0)
-   perr2("Cannot stat in ", AT_SPOOL);
+   if (fstatat(dfd, dirent->d_name, , AT_SYMLINK_NOFOLLOW) 
!= 0)
+   perr2("Cannot stat ", dirent->d_name);
 
/*
 * See it's a regular file and has its x bit turned on and
@@ -632,12 +630,10 @@ process_jobs(int argc, char **argv, int 
FILE *fp;
DIR *spool;
int job_matches, jobs_len, uids_len;
-   int error, i, ch, changed;
-
-   if (chdir(AT_SPOOL) != 0)
-   perr2("Cannot change to ", AT_SPOOL);
+   int error, i, ch, changed, dfd;
 
-   if ((spool = opendir(".")) == NULL)
+   if ((dfd = open(AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1 ||
+   (spool = fdopendir(dfd)) == NULL)
perr2("Cannot open ", AT_SPOOL);
 
/* Convert argv into a list of jobs and uids. */
@@ -671,8 +667,8 @@ process_jobs(int argc, char **argv, int 
/* Loop over every file in the directory */
changed = 0;
while ((dirent = readdir(spool)) != NULL) {
-   if (stat(dirent->d_name, ) != 0)
-   perr2("Cannot stat in ", AT_SPOOL);
+   if (fstatat(dfd, dirent->d_name, , AT_SYMLINK_NOFOLLOW) 
!= 0)
+   perr2("Cannot stat ", dirent->d_name);
 
if (stbuf.st_uid != user_uid && user_uid != 0)
continue;
@@ -709,7 +705,7 @@ process_jobs(int argc, char **argv, int 
case ATRM:
if (!interactive ||
(interactive && rmok(runtimer))) {
-   if (unlink(dirent->d_name) == 0)
+   if (unlinkat(dfd, dirent->d_name, 0) == 
0)
changed = 1;
else
perr(dirent->d_name);
@@ -721,9 +717,10 @@ process_jobs(int argc, char **argv, int 
break;
 
case CAT:
-   fp = fopen(dirent->d_name, "r");
-   if (!fp)
-   perr("Cannot open file");
+   i = openat(dfd, dirent->d_name,
+   O_RDONLY|O_NOFOLLOW);
+   if (i == -1 || (fp = fdopen(i, "r")) == NULL)
+   perr2("Cannot open ", dirent->d_name);
 
while ((ch = getc(fp)) != EOF)
putchar(ch);
@@ -751,12 +748,8 @@ process_jobs(int argc, char **argv, int 
free(uids);
 
/* If we modied the spool, poke cron so it knows to reload. */
-   if (changed) {
-   if (chdir(CRONDIR) != 0)
-   perror(CRONDIR);
-   else
-   poke_daemon(AT_SPOOL, RELOAD_AT);
-   }
+   if (changed)
+   poke_daemon(AT_SPOOL, RELOAD_AT);
 
return (error);
 }



Re: Patch 1/3 - make DIOCRADDADDRS to accept on IP address per ioctl() call

2015-11-09 Thread Alexandr Nedvedicky
On Sun, Nov 08, 2015 at 01:18:22PM +0100, Alexander Bluhm wrote:
> On Sun, Nov 08, 2015 at 02:37:58AM +0100, Alexander Bluhm wrote:
> > > + for (i = 0; (i < size) && (rv == 0); i++) {
> > 
> > rv is unitialized in the first interation
> > 
> > > + io.pfrio_buffer = addr++;
> > > + rv = ioctl(dev, DIOCRADDADDR, );
> > 
> > I would suggest to return (-1) if ioctl fails...
> > 
> > > + add++;
> > > + }
> 
> To keep the illusion of an atomic operation, we could remove the
> addresses we just added before the one add failed.
> 

actually pfctl_radix.c is just tip of the iceberg,  there are other tools than
pfctl, which manipulate with PF-tables:
authpf
bgpd
pfutils

The more I'm thinking about s/SIOCADDADDRS/SIOCADDADDR the less I like it.  I
feel good about s/pfr_add_addrs/pfr_add_addr. The pfr_add_addr() should be a
back end for SIOCADDADDRS ioctl operation, which I think should go back.  The
ioctl in kernel will iterate over the array of addresses coming from userland.
It seems to me as more convenient approach. I'm working on prototype, I
hope I'll send updated patches soon.

thanks and
regards
sasha



Re: Patch 1/3 - make DIOCRADDADDRS to accept on IP address per ioctl() call

2015-11-09 Thread Reyk Floeter

> On 09.11.2015, at 22:21, Alexandr Nedvedicky  
> wrote:
> 
> On Sun, Nov 08, 2015 at 01:18:22PM +0100, Alexander Bluhm wrote:
>> On Sun, Nov 08, 2015 at 02:37:58AM +0100, Alexander Bluhm wrote:
 +  for (i = 0; (i < size) && (rv == 0); i++) {
>>> 
>>> rv is unitialized in the first interation
>>> 
 +  io.pfrio_buffer = addr++;
 +  rv = ioctl(dev, DIOCRADDADDR, );
>>> 
>>> I would suggest to return (-1) if ioctl fails...
>>> 
 +  add++;
 +  }
>> 
>> To keep the illusion of an atomic operation, we could remove the
>> addresses we just added before the one add failed.
>> 
> 
> actually pfctl_radix.c is just tip of the iceberg,  there are other tools than
> pfctl, which manipulate with PF-tables:
>   authpf
>   bgpd
>   pfutils
> 
> The more I'm thinking about s/SIOCADDADDRS/SIOCADDADDR the less I like it.  I
> feel good about s/pfr_add_addrs/pfr_add_addr. The pfr_add_addr() should be a
> back end for SIOCADDADDRS ioctl operation, which I think should go back.  The
> ioctl in kernel will iterate over the array of addresses coming from userland.
> It seems to me as more convenient approach. I'm working on prototype, I
> hope I'll send updated patches soon.
> 

I'm wondering - how does it affect tools that load several thousands of IPs 
into a table?
Like spamd, bgpd (for spam lists etc.), or pfctl for IP black lists (as 
distributed by ET).

There are valid use cases with HUGE tables, but I have to admit that I didn't 
test your
diff yet. Just a concern that loading IPs one after another might take forever.

Reyk



less(1): fix implicit declaration

2015-11-09 Thread Michael Reed
Index: main.c
===
RCS file: /cvs/src/usr.bin/less/main.c,v
retrieving revision 1.26
diff -u -p -r1.26 main.c
--- main.c  9 Nov 2015 18:41:46 -   1.26
+++ main.c  9 Nov 2015 21:09:46 -
@@ -13,6 +13,7 @@
  * Entry point, initialization, miscellaneous routines.
  */
 
+#include 
 #include 
 #include 
 #include 



Re: at(1): avoid chdir

2015-11-09 Thread Philip Guenther
On Mon, Nov 9, 2015 at 2:57 PM, Todd C. Miller
 wrote:
> On Mon, 09 Nov 2015 14:52:53 -0800, Philip Guenther wrote:
>
>> If fdopendir() fails, dfd needs to be closed.
>
> Since perr() exits like err() does we don't need to close dfd.

Ah, in that case, ok guenther@



Re: [patch] dc: array_free usage

2015-11-09 Thread Michael McConville
Michael W. Bombardieri wrote:
> Hi tech@,
> 
> In dc(1) the function array_free() knows how to skip a null pointer so
> calling code doesn't need to avoid passing null.
> Also, minor style (braces) clean-up.

ok mmcc@

It may also be a good idea to change the allocation names in the form
bmalloc -> xmalloc. It'd make it more obvious what they do. Just
nitpicking, though.

> Index: bcode.c
> ===
> RCS file: /cvs/src/usr.bin/dc/bcode.c,v
> retrieving revision 1.48
> diff -u -p -u -r1.48 bcode.c
> --- bcode.c   3 Oct 2015 16:24:53 -   1.48
> +++ bcode.c   10 Nov 2015 03:50:43 -
> @@ -937,9 +937,8 @@ badd(void)
>   struct number   *r;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -965,9 +964,8 @@ bsub(void)
>   struct number   *r;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -1014,9 +1012,8 @@ bmul(void)
>   struct number   *r;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -1040,9 +1037,8 @@ bdiv(void)
>   BN_CTX  *ctx;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -1078,9 +1074,8 @@ bmod(void)
>   BN_CTX  *ctx;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -1116,9 +,8 @@ bdivmod(void)
>   BN_CTX  *ctx;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -1158,9 +1152,8 @@ bexp(void)
>   u_int   rscale;
>  
>   p = pop_number();
> - if (p == NULL) {
> + if (p == NULL)
>   return;
> - }
>   a = pop_number();
>   if (a == NULL) {
>   push_number(p);
> @@ -1282,9 +1275,8 @@ bsqrt(void)
>  
>   onecount = 0;
>   n = pop_number();
> - if (n == NULL) {
> + if (n == NULL)
>   return;
> - }
>   if (BN_is_zero(n->number)) {
>   r = new_number();
>   push_number(r);
> @@ -1325,9 +1317,8 @@ not(void)
>   struct number   *a;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   a->scale = 0;
>   bn_check(BN_set_word(a->number, BN_get_word(a->number) ? 0 : 1));
>   push_number(a);
> @@ -1345,9 +1336,8 @@ equal_numbers(void)
>   struct number *a, *b, *r;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -1365,9 +1355,8 @@ less_numbers(void)
>   struct number *a, *b, *r;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -1385,9 +1374,8 @@ lesseq_numbers(void)
>   struct number *a, *b, *r;
>  
>   a = pop_number();
> - if (a == NULL) {
> + if (a == NULL)
>   return;
> - }
>   b = pop_number();
>   if (b == NULL) {
>   push_number(a);
> @@ -1711,9 +1699,8 @@ eval_tos(void)
>   char *p;
>  
>   p = pop_string();
> - if (p == NULL)
> - return;
> - eval_string(p);
> + if (p != NULL)
> + eval_string(p);
>  }
>  
>  void
> Index: stack.c
> ===
> RCS file: /cvs/src/usr.bin/dc/stack.c,v
> retrieving revision 1.13
> diff -u -p -u -r1.13 stack.c
> --- stack.c   1 Dec 2014 13:13:00 -   1.13
> +++ stack.c   10 Nov 2015 03:50:43 -
> @@ -62,10 +62,8 @@ stack_free_value(struct value *v)
>   free(v->u.string);
>   break;
>   }
> - if (v->array != NULL) {
> - array_free(v->array);
> - v->array = NULL;
> - }
> + array_free(v->array);
> + v->array = NULL;
>  }
>  
>  /* Copy number or string content into already allocated target */
> @@ -210,10 +208,8 @@ stack_popnumber(struct stack *stack)
>  {
>   if (stack_empty(stack))
>   return NULL;
> - if (stack->stack[stack->sp].array != NULL) {
> - array_free(stack->stack[stack->sp].array);
> - 

[patch] tsec(4): enable TX interrupt coalescing

2015-11-09 Thread Richard Procter
Hi, 

This reduces tsec(4) TX interrupts by over a factor of four per interface,
boosting throughput by a couple of percent for

$ dd if=/dev/zero bs=4096 | nc ${host} ${port}

It does this by reducing TX interrupts notifications to one per frame, from
one per mbuf fragment, and by enabling TX interrupt coalescing.

I've chosen conservative coalescing parameters. The card now interrupts every
four tx frames, leaving the tx ring fuller on average. But ample room remains
on the card's tx ring of 256 descriptors, which can hold 16 frames in the 
worst case of 16 mbuf fragments per frame. Testing showed descriptor use 
peaking at 13 descriptors under load.

The hold-off timer, ensuring stale frames are not left on the tx ring 
indefinitely, is not crucial for tx: as the frame has already been transmitted, 
latency isn't a concern. It need only last longer than the time to transmit the 
coalesced frames, and I've set it much longer, roughly 2ms for 1000baseT, 
to give the stack some slack when feeding the card.

While here, also makes tsec_encap() error handling a tad more robust.

Tested on RB600A.

best, 
Richard. 

Index: if_tsec.c
===
RCS file: /cvs/src/sys/arch/socppc/dev/if_tsec.c,v
retrieving revision 1.39
diff -u -p -u -r1.39 if_tsec.c
--- if_tsec.c   6 Nov 2015 11:35:48 -   1.39
+++ if_tsec.c   10 Nov 2015 01:32:31 -
@@ -121,6 +121,8 @@ extern void myetheraddr(u_char *);
 #define TSEC_TCTRL 0x100
 #define TSEC_TSTAT 0x104
 #define  TSEC_TSTAT_THLT   0x8000
+#define TSEC_TXIC  0x110
+#define  TSEC_TXIC_ICEN0x8000
 #define TSEC_TBPTR 0x184
 #define TSEC_TBASE 0x204
 
@@ -536,7 +538,7 @@ tsec_start(struct ifnet *ifp)
ifp->if_flags |= IFF_OACTIVE;
break;
} 
-   if (error == EFBIG) {
+   if (error) {
IFQ_DEQUEUE(>if_snd, m);
m_freem(m); /* give up: drop it */
ifp->if_oerrors++;
@@ -1020,6 +1022,9 @@ tsec_up(struct tsec_softc *sc)
attr |= TSEC_ATTR_RBDSEN;
tsec_write(sc, TSEC_ATTR, attr);
 
+   /* TX interrupts every 4 TSEC_TX_I with ~2ms hold-off @ 1000baseT */
+   tsec_write(sc, TSEC_TXIC, (TSEC_TXIC_ICEN | (0x4 << 21) | 0x1000));
+
tsec_write(sc, TSEC_TSTAT, TSEC_TSTAT_THLT);
tsec_write(sc, TSEC_RSTAT, TSEC_RSTAT_QHLT);
 
@@ -1158,12 +1163,14 @@ tsec_encap(struct tsec_softc *sc, struct
for (i = 0; i < map->dm_nsegs; i++) {
status = txd->td_status & TSEC_TX_W;
status |= TSEC_TX_TO1;
+   status |= TSEC_TX_TC;
if (i == (map->dm_nsegs - 1))
-   status |= TSEC_TX_L;
+   status |= TSEC_TX_L | TSEC_TX_I;
+
txd->td_len = map->dm_segs[i].ds_len;
txd->td_addr = map->dm_segs[i].ds_addr;
__asm volatile("eieio" ::: "memory");
-   txd->td_status = status | TSEC_TX_R | TSEC_TX_I | TSEC_TX_TC;
+   txd->td_status = status | TSEC_TX_R;
 
bus_dmamap_sync(sc->sc_dmat, TSEC_DMA_MAP(sc->sc_txring),
frag * sizeof(*txd), sizeof(*txd), BUS_DMASYNC_PREWRITE);



fix segfault in rs(1)

2015-11-09 Thread Ingo Schwarze
Hi,

  schwarze@isnote $ cat rs.c | rs -H
  61 line 1
  [...]
  25 line 50
  26 line 12338
  Segmentation fault (core dumped) 

rs(1) -H always segfaults for input larger than 4 KB.
The reason is that, in get_line(),

 * Initially, (irows == 0), curline gets set to the static buffer ibuf.
 * -H sets DETAILSHAPE sets putlength.
 * curline keeps getting advanced by "curline += curlen + 1;".
 * Due to putlength, we never get to malloc, curline just grows until boom.

We could summarize this as follows:

  /* don't waste storage, better overrun the static buffer */

Rather than figuring out how the hand-rolled parsing loop was
intended, i decided to use the standard getline(3) interface,
making the code much more readable and eight lines shorter.
This requires switching curlen and maxlen to ssize_t, which is the
natural data type for line lengths, anyway.

While here, also add the missing error handling when the input
ends prematurely.  That caused bogus blank lines on output for

  schwarze@isnote $ echo -n | rs -K 10
  [ ten blank lines ]

It is OK to just return from getfile() because the next function,
prepfile(), will exit right away if !nelem.

OK?
  Ingo


Index: rs.c
===
RCS file: /cvs/src/usr.bin/rs/rs.c,v
retrieving revision 1.27
diff -u -p -r1.27 rs.c
--- rs.c9 Oct 2015 01:37:08 -   1.27
+++ rs.c10 Nov 2015 02:29:28 -
@@ -67,10 +67,10 @@ char**elem;
 char   **endelem;
 char   *curline;
 intallocsize = BUFSIZ;
-intcurlen;
+ssize_tcurlen;
 intirows, icols;
 intorows, ocols;
-intmaxlen;
+ssize_tmaxlen;
 intskip;
 intpropgutter;
 char   isep = ' ', osep = ' ';
@@ -118,11 +118,13 @@ getfile(void)
char **padto;
 
while (skip--) {
-   get_line();
+   if (get_line() == EOF)
+   return;
if (flags & SKIPPRINT)
puts(curline);
}
-   get_line();
+   if (get_line() == EOF)
+   return;
if (flags & NOARGS && curlen < owidth)
flags |= ONEPERLINE;
if (flags & ONEPERLINE)
@@ -303,37 +305,29 @@ prepfile(void)
nelem = n;
 }
 
-#defineBSIZE   2048
-char   ibuf[BSIZE];/* two screenfuls should do */
-
 int
 get_line(void) /* get line; maintain curline, curlen; manage storage */
 {
-   static  int putlength;
-   static  char *endblock = ibuf + BSIZE;
-   char *p;
-   int c, i;
+   static  char*ibuf = NULL;
+   static  size_t   ibufsz = 0;
 
-   if (!irows) {
-   curline = ibuf;
-   putlength = flags & DETAILSHAPE;
-   }
-   else if (skip <= 0) {   /* don't waste storage */
-   curline += curlen + 1;
-   if (putlength)  /* print length, recycle storage */
-   printf(" %d line %d\n", curlen, irows);
-   }
-   if (!putlength && endblock - curline < BUFSIZ) {   /* need storage */
-   if (!(curline = malloc(BSIZE)))
-   errx(1, "File too large");
-   endblock = curline + BSIZE;
+   if (irows > 0 && flags & DETAILSHAPE)
+   printf(" %zd line %d\n", curlen, irows);
+
+   if ((curlen = getline(, , stdin)) == EOF) {
+   if (ferror(stdin))
+   err(1, NULL);
+   return EOF;
}
-   for (p = curline, i = 1; i < BUFSIZ; *p++ = c, i++)
-   if ((c = getchar()) == EOF || c == '\n')
-   break;
-   *p = '\0';
-   curlen = i - 1;
-   return(c);
+   if (curlen > 0 && ibuf[curlen - 1] == '\n')
+   ibuf[--curlen] = '\0';
+
+   if (skip >= 0 || flags & SHAPEONLY)
+   curline = ibuf;
+   else if ((curline = strdup(ibuf)) == NULL)
+   err(1, NULL);
+
+   return 0;
 }
 
 char **



Re: tls_init.3 add small info

2015-11-09 Thread Jason McIntyre
On Thu, Nov 05, 2015 at 02:11:06PM +0100, Jan Klemkow wrote:
> Hi,
> 
> I'm playing around with client-side certificates[1] and saw that the
> manpage of tls_init.3 recommend to uses the functions:
> tls_config_set_ca_{file,path,mem} only in client context.
> 
> But to check client-side certificates its also useful in server context.
> 
> bye,
> Jan
> 
> [1]: https://github.com/younix/ucspi/blob/master/tests.mk
> 

fixed, thanks.
jmc

> Index: tls_init.3
> ===
> RCS file: /cvs/src/lib/libtls/tls_init.3,v
> retrieving revision 1.53
> diff -u -p -r1.53 tls_init.3
> --- tls_init.316 Oct 2015 13:49:53 -  1.53
> +++ tls_init.35 Nov 2015 12:48:17 -
> @@ -289,16 +289,16 @@ Configuration options may apply to only 
>  .Fn tls_config_set_ca_file
>  sets the filename used to load a file
>  containing the root certificates.
> -.Em (Client)
> +.Em (Client and Server)
>  .It
>  .Fn tls_config_set_ca_path
>  sets the path (directory) which should be searched for root
>  certificates.
> -.Em (Client)
> +.Em (Client and Server)
>  .It
>  .Fn tls_config_set_ca_mem
>  sets the root certificates directly from memory.
> -.Em (Client)
> +.Em (Client and Server)
>  .It
>  .Fn tls_config_set_cert_file
>  sets file from which the public certificate will be read.
> 



Re: Call for Testing: rtalloc(9) change

2015-11-09 Thread Alexander Bluhm
On Wed, Nov 04, 2015 at 12:33:23PM +0100, Martin Pieuchot wrote:
> On 12/08/15(Wed) 17:03, Martin Pieuchot wrote:
> > I'm currently working on the routing table interface to make is safe
> > to use by multiple CPUs at the same time.  The diff below is a big
> > step in this direction and I'd really appreciate if people could test
> > it with their usual network setup and report back.
> 
> Below is an updated version of the diff now that bluhm@ fixed the
> potential loop with RTF_GATEWAY routes.
> 
> Note that regression tests will fail because we no longer call
> rtalloc(9) inside rt_setgate().  In other words we do not cache
> a next-hop route before using it.
> 
> Ok?

OK bluhm@

> 
> Index: net/route.c
> ===
> RCS file: /cvs/src/sys/net/route.c,v
> retrieving revision 1.268
> diff -u -p -r1.268 route.c
> --- net/route.c   4 Nov 2015 10:13:55 -   1.268
> +++ net/route.c   4 Nov 2015 11:15:00 -
> @@ -151,6 +151,7 @@ void  rt_timer_init(void);
>  int  rtflushclone1(struct rtentry *, void *, u_int);
>  void rtflushclone(unsigned int, struct rtentry *);
>  int  rt_if_remove_rtdelete(struct rtentry *, void *, u_int);
> +struct rtentry *rt_match(struct sockaddr *, int, unsigned int);
>  
>  struct   ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr 
> *,
>   u_int);
> @@ -194,6 +195,12 @@ rtisvalid(struct rtentry *rt)
>   if (rt == NULL)
>   return (0);
>  
> +#ifdef DIAGNOSTIC
> + if (ISSET(rt->rt_flags, RTF_GATEWAY) && (rt->rt_gwroute != NULL) &&
> + ISSET(rt->rt_gwroute->rt_flags, RTF_GATEWAY))
> + panic("next hop must be directly reachable");
> +#endif
> +
>   if ((rt->rt_flags & RTF_UP) == 0)
>   return (0);
>  
> @@ -201,11 +208,27 @@ rtisvalid(struct rtentry *rt)
>   if (rt->rt_ifa == NULL || rt->rt_ifa->ifa_ifp == NULL)
>   return (0);
>  
> + if (ISSET(rt->rt_flags, RTF_GATEWAY) && !rtisvalid(rt->rt_gwroute))
> + return (0);
> +
>   return (1);
>  }
>  
> +/*
> + * Do the actual lookup for rtalloc(9), do not use directly!
> + *
> + * Return the best matching entry for the destination ``dst''.
> + *
> + * "RT_RESOLVE" means that a corresponding L2 entry should
> + *   be added to the routing table and resolved (via ARP or
> + *   NDP), if it does not exist.
> + *
> + * "RT_REPORT" indicates that a message should be sent to
> + *   userland if no matching route has been found or if an
> + *   error occured while adding a L2 entry.
> + */
>  struct rtentry *
> -rtalloc(struct sockaddr *dst, int flags, unsigned int tableid)
> +rt_match(struct sockaddr *dst, int flags, unsigned int tableid)
>  {
>   struct rtentry  *rt0, *rt = NULL;
>   struct rt_addrinfo   info;
> @@ -336,6 +359,76 @@ rtalloc_mpath(struct sockaddr *dst, uint
>  }
>  #endif /* SMALL_KERNEL */
>  
> +/*
> + * Look in the routing table for the best matching entry for
> + * ``dst''.
> + *
> + * If a route with a gateway is found and its next hop is no
> + * longer valid, try to cache it.
> + */
> +struct rtentry *
> +rtalloc(struct sockaddr *dst, int flags, unsigned int rtableid)
> +{
> + struct rtentry *rt, *nhrt;
> +
> + rt = rt_match(dst, flags, rtableid);
> +
> + /* No match or route to host?  We're done. */
> + if (rt == NULL || !ISSET(rt->rt_flags, RTF_GATEWAY))
> + return (rt);
> +
> + /* Nothing to do if the next hop is valid. */
> + if (rtisvalid(rt->rt_gwroute))
> + return (rt);
> +
> + rtfree(rt->rt_gwroute);
> + rt->rt_gwroute = NULL;
> +
> + /*
> +  * If we cannot find a valid next hop, return the route
> +  * with a gateway.
> +  *
> +  * XXX Some dragons hiding in the tree certainly depends on
> +  * this behavior.  But it is safe since rt_checkgate() wont
> +  * allow us to us this route later on.
> +  */
> + nhrt = rt_match(rt->rt_gateway, flags | RT_RESOLVE, rtableid);
> + if (nhrt == NULL)
> + return (rt);
> +
> + /*
> +  * Next hop must be reachable, this also prevents rtentry
> +  * loops for example when rt->rt_gwroute points to rt.
> +  */
> + if (ISSET(nhrt->rt_flags, RTF_CLONING|RTF_GATEWAY)) {
> + rtfree(nhrt);
> + return (rt);
> + }
> +
> + /*
> +  * Next hop entry must be UP and on the same interface.
> +  */
> + if (!ISSET(nhrt->rt_flags, RTF_UP) || nhrt->rt_ifidx != rt->rt_ifidx) {
> + rtfree(nhrt);
> + return (rt);
> + }
> +
> + /*
> +  * If the MTU of next hop is 0, this will reset the MTU of the
> +  * route to run PMTUD again from scratch.
> +  */
> + if (!ISSET(rt->rt_locks, RTV_MTU) && (rt->rt_mtu > nhrt->rt_mtu))
> + rt->rt_mtu = nhrt->rt_mtu;
> +
> + /*
> +  * Do not return the cached next-hop route, rt_checkgate() will
> +  * do the 

Re: [PATCH] add F13-F24 and colour support to console terminfo

2015-11-09 Thread Nicholas Marriott
Perhaps it should go in FAQ section 7, or somewhere else, I don't know
where. Note pccon is only for some platforms.


On Mon, Nov 09, 2015 at 08:50:12AM +, Tati Chevron wrote:
> On Mon, Nov 09, 2015 at 08:23:08AM +, Nicholas Marriott wrote:
> >On Sun, Nov 08, 2015 at 09:01:52PM +, Tati Chevron wrote:
> >>Is there any reason why the OpenBSD installer still defaults to a
> >>terminal type of vt-220 for the VGA framebuffer console, and doesn't
> >>even suggest pccon as an alternative?
> >
> >In the installer itself? vt220 works fine and reliably and - importantly
> >- is small and fits on the ramdisks. Who needs to press F13 in the
> >installer?
> 
> Agreed, I didn't mean the installer itself, that does work fine with vt220.
> 
> >If you mean in /etc/ttys, this has been discussed before and mostly the
> >reason it has stayed is that terminfo entries propagate very slowly and
> >vt220 is available everywhere, no matter if the user ssh to some ancient
> >OS. It's easy to change anyway.
> 
> Ah, then this is a documentation issue - I always assumed that the terminal 
> type specified in the installer was propogated to /etc/ttys during the 
> install, and used as a default for the console.
> 
> It is indeed easy to change, but the existance of pccon isn't exactly widely 
> documented.  To be honest, I knew about it, but seeing that it was broken and 
> not used by default in the installer, nor on the console after installation, 
> I assumed that it was abandoned and unmaintained.
> 
> -- 
> Tati Chevron
> Perl and FORTRAN specialist.
> SWABSIT development and migration department.
> http://www.swabsit.com



Re: PC Engines APU2 coming soon - how is OpenBSD's support so far?

2015-11-09 Thread Chris Cappuccio
Brian Conway [bcon...@rcesoftware.com] wrote:
> I meant positioning the whole case bottom-up (i.e. but the hot surface
> at the top).

Oh I see!

I just got a beta unit. I was late to the party. I used some of this
ZM-STG1 thermal grease (comes with a paint applicator type brush) and
the integrated memtest goes between 46 and 47 C. With intel ethernet,
four cores and usb3, this is a pretty nice unit!

I wonder if these are four discrete cores or if AMD is playing games
(like the bulldozer lawsuit as of late.)

Chris



Re: pledge(2) spamdb(8)

2015-11-09 Thread Ricardo Mestre

Ping?

On 27/10/2015 12:33, Ricardo Mestre wrote:

Hi!

I have been running this on my "production" server, for a few days 
now, without any apparent issues (I also tested manual interactions 
adding/removing SPAMTRAP and TRAPPED entries).


Any comments? :)

Best regards,
Ricardo Mestre

On 24/10/2015 21:37, Ricardo Mestre wrote:

Hi tech@,

spamdb(8) can pledge(2) for "stdio rpath wpath flock" and "flock" 
permission can be dropped after "/var/db/spamd" is opened with 
dbopen(3).


Index: spamdb.c
===
RCS file: /cvs/src/usr.sbin/spamdb/spamdb.c,v
retrieving revision 1.29
diff -u -p -u -r1.29 spamdb.c
--- spamdb.c24 Nov 2013 01:06:19 -  1.29
+++ spamdb.c24 Oct 2015 20:23:24 -
@@ -276,6 +276,9 @@ main(int argc, char **argv)
HASHINFOhashinfo;
DB  *db;

+   if (pledge("stdio rpath wpath flock", NULL) == -1)
+   err(1, "pledge");
+
while ((ch = getopt(argc, argv, "adtT")) != -1) {
switch (ch) {
case 'a':
@@ -307,6 +310,9 @@ main(int argc, char **argv)
err(1, "cannot open %s for %s", PATH_SPAMD_DB,
action ? "writing" : "reading");
}
+
+   if (pledge("stdio rpath wpath", NULL) == -1)
+   err(1, "pledge");

switch (action) {
case 0:

Best regards,
Ricardo Mestre






restore typo

2015-11-09 Thread Manuel Giraud
Hi,

Here is a typo in the verbose mode of restore:

Index: tape.c
===
RCS file: /cvs/src/sbin/restore/tape.c,v
retrieving revision 1.46
diff -u -p -r1.46 tape.c
--- tape.c  25 Aug 2015 04:18:43 -  1.46
+++ tape.c  9 Nov 2015 16:01:27 -
@@ -547,7 +547,7 @@ extractfile(char *name)
skipfile();
return (GOOD);
}
-   Vprintf(stdout, "extract file %s\n", name);
+   Vprintf(stdout, "extract directory %s\n", name);
return (genliteraldir(name, curfile.ino));
 
case IFLNK: {

-- 
Manuel Giraud



Re: restore typo

2015-11-09 Thread Michael McConville
Manuel Giraud wrote:
> Hi,
> 
> Here is a typo in the verbose mode of restore:

ok mmcc@

> Index: tape.c
> ===
> RCS file: /cvs/src/sbin/restore/tape.c,v
> retrieving revision 1.46
> diff -u -p -r1.46 tape.c
> --- tape.c25 Aug 2015 04:18:43 -  1.46
> +++ tape.c9 Nov 2015 16:01:27 -
> @@ -547,7 +547,7 @@ extractfile(char *name)
>   skipfile();
>   return (GOOD);
>   }
> - Vprintf(stdout, "extract file %s\n", name);
> + Vprintf(stdout, "extract directory %s\n", name);
>   return (genliteraldir(name, curfile.ino));
>  
>   case IFLNK: {



Re: [PATCH] add F13-F24 and colour support to console terminfo

2015-11-09 Thread Alexei Malinin
On 11/09/15 11:50, Tati Chevron wrote:
> On Mon, Nov 09, 2015 at 08:23:08AM +, Nicholas Marriott wrote:
>> On Sun, Nov 08, 2015 at 09:01:52PM +, Tati Chevron wrote:
>>> Is there any reason why the OpenBSD installer still defaults to a
>>> terminal type of vt-220 for the VGA framebuffer console, and doesn't
>>> even suggest pccon as an alternative?
>>
>> In the installer itself? vt220 works fine and reliably and - importantly
>> - is small and fits on the ramdisks. Who needs to press F13 in the
>> installer?
>
> Agreed, I didn't mean the installer itself, that does work fine with
> vt220.
>
>> If you mean in /etc/ttys, this has been discussed before and mostly the
>> reason it has stayed is that terminfo entries propagate very slowly and
>> vt220 is available everywhere, no matter if the user ssh to some ancient
>> OS. It's easy to change anyway.
>
> Ah, then this is a documentation issue - I always assumed that the
> terminal type specified in the installer was propogated to /etc/ttys
> during the install, and used as a default for the console.
>
> It is indeed easy to change, but the existance of pccon isn't exactly
> widely documented.  To be honest, I knew about it, but seeing that it
> was broken and not used by default in the installer, nor on the
> console after installation, I assumed that it was abandoned and
> unmaintained.

It's not broken. It is stable :) I use it every day.I'm waiting for
worldwide distribution of the pccon* terminfo entries :))


--
Alexei Malinin



Re: PC Engines APU2 coming soon - how is OpenBSD's support so far?

2015-11-09 Thread Brian Conway
I meant positioning the whole case bottom-up (i.e. but the hot surface
at the top).

Brian Conway

On Mon, Nov 9, 2015 at 9:28 AM, Chris Cappuccio  wrote:
> Brian Conway [bcon...@rcesoftware.com] wrote:
>>
>> Taking into account Mr. Cappuccio's advice on using thermal paste
>> between the CPU and heat spreader, and also positioning it bottom-up,
>> this one stabilized at 51 C at idle. I haven't had a chance to do much
>> benchmarking for higher temps yet, other than a run of `openssl speed`
>> to warm it up.
>
> If you put the heat speader upside down, the sticky pad would be against
> the cpu heatsink contact area?? There's only one way to put that device in.



Re: PC Engines APU2 coming soon - how is OpenBSD's support so far?

2015-11-09 Thread Chris Cappuccio
Brian Conway [bcon...@rcesoftware.com] wrote:
> 
> Taking into account Mr. Cappuccio's advice on using thermal paste
> between the CPU and heat spreader, and also positioning it bottom-up,
> this one stabilized at 51 C at idle. I haven't had a chance to do much
> benchmarking for higher temps yet, other than a run of `openssl speed`
> to warm it up.

If you put the heat speader upside down, the sticky pad would be against
the cpu heatsink contact area?? There's only one way to put that device in.



Re: [patch] cwm: Honour size hints when resizing using keyboard

2015-11-09 Thread Okan Demirmen
On Mon 2015.11.09 at 00:14 +0100, Vadim Vygonets wrote:
> Dear daemonfishes,
> 
> After using evilwm for a decade, I'm quite impressed with cwm's
> codebase and functionality.  (I just couldn't understand one
> feature: what's the use of ptrmove* if you cannot click?  (...Mr.
> Andersen?))

I've never used this, but maybe someone else cares? The only rationale
is that one can move the pointer with the keyboard, then create a new
window with a keyboard action.

Who knows how much this is used, I could go either way.

> This tiny preliminary patch makes keyboard-based window resizing
> honour size hints, which mouse-based one already does, to let you
> resize xterm character by character.  Specifically:
> 
> - If resize increments are set, multiply the resize deltas by the
>   increments.  I.e., resize* commands use (moveamount * incw) for
>   width and the obvious for height, and bigresize* ten times
>   that.
> - If minimum size is set, don't resize below it.
> 
> Are you interested in something like this?  Would you modify the
> behaviour somehow (e.g., with respect to moveamount)?  Is it OK
> to use the same MAX() macro twice and let the compiler optimize
> it out?

It was excluded from keyboard-based resizing because back then people
wanted micro adjustments to windows - something much easier to do with a
keyboard than mouse.

Personally, I believe (and you might have seen changes to this effect),
that keyboard and mouse actions should result in the same behaviour.
That said, I've lived with the current state since the beginning, so I
don't really care one way or another.

If there are objections, no; else, sure, why not. Though I will state
now that I don't think it warrants a configuration button.

> If you like thie modification, I can try to explain the new
> behaviour in less technical prose and write a man page patch.

No need; we get it :)

Thanks,
Okan

> Vadik.
> 
> -- 
> A friend is someone you call to help you move.  A real friend is
> someone you call to help you move a body.

> ? cwm-incsize.diff
> Index: kbfunc.c
> ===
> RCS file: /cvs/xenocara/app/cwm/kbfunc.c,v
> retrieving revision 1.118
> diff -u -r1.118 kbfunc.c
> --- kbfunc.c  16 Sep 2015 17:58:25 -  1.118
> +++ kbfunc.c  8 Nov 2015 13:18:28 -
> @@ -118,10 +118,10 @@
>   client_ptrwarp(cc);
>   break;
>   case CWM_RESIZE:
> - if ((cc->geom.w += mx) < 1)
> - cc->geom.w = 1;
> - if ((cc->geom.h += my) < 1)
> - cc->geom.h = 1;
> + if ((cc->geom.w += mx * cc->hint.incw) < MAX(1, cc->hint.minw))
> + cc->geom.w = MAX(1, cc->hint.minw);
> + if ((cc->geom.h += my * cc->hint.inch) < MAX(1, cc->hint.minh))
> + cc->geom.h = MAX(1, cc->hint.minh);
>   client_resize(cc, 1);
>  
>   /* Make sure the pointer stays within the window. */



New erratas released today: 5.8 errata #8, 5.7 errata #20

2015-11-09 Thread Stefan Sperling
There is a remotely triggerable panic in the wireless subsystem
involving WPA (a.k.a RSN).

RSN element parsing in the input path lacks validation of the group
cipher and group management cipher values. If a bad value is received
it is stored without validation, which will trigger a panic when the
value is used while sending a reply.

This can be used by malicious access points to crash OpenBSD clients,
or by malicious clients to crash OpenBSD access points.

Thanks to Franz Bettag for highlighting this problem.

Links to patches below. Please follow the instructions within.

5.8: http://ftp.openbsd.org/pub/OpenBSD/patches/5.8/common/008_rsn.patch.sig
5.7: http://ftp.openbsd.org/pub/OpenBSD/patches/5.7/common/020_rsn.patch.sig



Re: patch saves some cycles by extending pfr_walktree() a bit

2015-11-09 Thread Alexandr Nedvedicky
Hello,

> 
> For now the code gets more as we have two ways to iterate over the
> tree.  When you remove the additional work queues I expect many -
> diffs.  So if this code dupliation is temporary, this aproach is
> fine for me.

yes code duplication is temporary, I'd like to kill work queues.

> >  #define pfrw_dyn   pfrw_1.pfrw1_dyn
> > +#definepfrw_tzero  pfrw_1.pfrw1_clstat.tzero
> > +#definepfrw_negchange  pfrw_1.pfrw1_clstat.negchange
> >  #define pfrw_cnt   pfrw_free
> 
> Use space instead of tab after the define.  Otherwise it is incosistent
> and the diff looks ugly.
thanks for catching that.

I will postpone commit for few more days. Just to give a chance other folks
to give OK / !OK

I also would like to finish prototype of pfr_set_addrs(), which still prevents
me from removing work queues in my OpenBSD branch.

thanks and
regards
sasha

8<---8<---8<--8<
Index: pf_table.c
===
RCS file: /cvs/src/sys/net/pf_table.c,v
retrieving revision 1.116
diff -u -p -r1.116 pf_table.c
--- pf_table.c  3 Nov 2015 22:10:33 -   1.116
+++ pf_table.c  9 Nov 2015 19:24:52 -
@@ -107,7 +107,9 @@ struct pfr_walktree {
PFRW_GET_ADDRS,
PFRW_GET_ASTATS,
PFRW_POOL_GET,
-   PFRW_DYNADDR_UPDATE
+   PFRW_DYNADDR_UPDATE,
+   PFRW_WININFO_UPDATE,
+   PFRW_CLSTAT
}pfrw_op;
union {
struct pfr_addr *pfrw1_addr;
@@ -115,15 +117,22 @@ struct pfr_walktree {
struct pfr_kentryworkq  *pfrw1_workq;
struct pfr_kentry   *pfrw1_kentry;
struct pfi_dynaddr  *pfrw1_dyn;
+   struct {
+   time_t  tzero;
+   int negchange;
+   }pfrw1_clstat;
}pfrw_1;
int  pfrw_free;
int  pfrw_flags;
+   struct pfr_ktable   *pfrw_kt;
 };
 #define pfrw_addr  pfrw_1.pfrw1_addr
 #define pfrw_astatspfrw_1.pfrw1_astats
 #define pfrw_workq pfrw_1.pfrw1_workq
 #define pfrw_kentrypfrw_1.pfrw1_kentry
 #define pfrw_dyn   pfrw_1.pfrw1_dyn
+#define pfrw_tzero pfrw_1.pfrw1_clstat.tzero
+#define pfrw_negchange pfrw_1.pfrw1_clstat.negchange
 #define pfrw_cnt   pfrw_free
 
 #define senderr(e) do { rv = (e); goto _bad; } while (0)
@@ -156,6 +165,8 @@ void pfr_remove_kentries(struct 
pfr_k
struct pfr_kentryworkq *);
 voidpfr_clstats_kentries(struct pfr_kentryworkq *, time_t,
int);
+voidpfr_clstats_kentries_pfrw(struct pfr_ktable *, time_t,
+   int);
 voidpfr_reset_feedback(struct pfr_addr *, int, int);
 voidpfr_prepare_network(union sockaddr_union *, int, int);
 int pfr_route_kentry(struct pfr_ktable *,
@@ -181,6 +192,7 @@ int  pfr_ktable_compare(struct pfr_kta
struct pfr_ktable *);
 voidpfr_ktable_winfo_update(struct pfr_ktable *,
struct pfr_kentry *);
+voidpfr_ktable_winfo_update_sum(struct pfr_ktable *);
 struct pfr_ktable  *pfr_lookup_table(struct pfr_table *);
 voidpfr_clean_node_mask(struct pfr_ktable *,
struct pfr_kentryworkq *);
@@ -189,6 +201,8 @@ int  pfr_skip_table(struct pfr_table *
struct pfr_ktable *, int);
 struct pfr_kentry  *pfr_kentry_byidx(struct pfr_ktable *, int, int);
 int pfr_islinklocal(sa_family_t, struct pf_addr *);
+voidpfr_walk(struct pfr_ktable *, struct pfr_walktree *,
+   const char *);
 
 RB_PROTOTYPE(pfr_ktablehead, pfr_ktable, pfrkt_tree, pfr_ktable_compare);
 RB_GENERATE(pfr_ktablehead, pfr_ktable, pfrkt_tree, pfr_ktable_compare);
@@ -631,7 +645,6 @@ pfr_get_astats(struct pfr_table *tbl, st
 {
struct pfr_ktable   *kt;
struct pfr_walktree  w;
-   struct pfr_kentryworkq   workq;
int  rv;
time_t   tzero = time_second;
 
@@ -653,10 +666,8 @@ pfr_get_astats(struct pfr_table *tbl, st
rv = rn_walktree(kt->pfrkt_ip4, pfr_walktree, );
if (!rv)
rv = rn_walktree(kt->pfrkt_ip6, pfr_walktree, );
-   if (!rv && (flags & PFR_FLAG_CLSTATS)) {
-   pfr_enqueue_addrs(kt, , NULL, 0);
-   pfr_clstats_kentries(, tzero, 0);
-   }
+   if (!rv && (flags & PFR_FLAG_CLSTATS))
+   pfr_clstats_kentries_pfrw(kt, tzero, 0);
if (rv)
return (rv);
 
@@ -954,7 +965,6 @@ pfr_remove_kentries(struct pfr_ktable *k
 struct 

Re: radioctl slight error

2015-11-09 Thread Ricardo Mestre

Hi tech@,

I tried the code from radioctl(1) on a test program, since I don't have 
a radio tuner, and cannot reproduce this problem, nevertheless like 
Douglas mentioned below shouldn't strtod(3) be used instead of atof(3) 
since it has overflow/underflow checks for free?


Also are there any merits in changing the rest of tree looking for 
atoi(3) and atol(3)? Not worth the time? Not enough portable?


Index: radioctl.c
===
RCS file: /cvs/src/usr.bin/radioctl/radioctl.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 radioctl.c
--- radioctl.c  21 Dec 2013 06:54:53 -  1.19
+++ radioctl.c  9 Nov 2015 20:45:25 -
@@ -389,7 +389,7 @@ str_to_int(char *str, int optval)
return VALUE_NONE;

if (optval == OPTION_FREQUENCY)
-   val = (int)(1000 * atof(str));
+   val = (int)(1000 * strtod(str, (char **)NULL));
else
val = (int)strtol(str, (char **)NULL, 10);


Best regards,
Ricardo Mestre

On 07/11/2015 22:02, Douglas Maus wrote:

on my system
# radioctl frequency=99.3
frequency: 99.25MHz -> 99.25MHz

Not a big deal, but frequencies of 99.3 being interpreted as slightly lower
at 99.25
is not ideal for some applications
This happens for other floats ending in '.3', '.1', etc

I tracked this down in radioctl.c to the function str_to_int():
if (optval == OPTION_FREQUENCY)
val = (int)(1000 * atof(str))
with the str="99.3", the integer val generated is 99299
because of integer truncation with the cast

a version that generates more expected values for me is something like:
val = lrint(1000*strtod(str, NULL));

at the cost of lrint() requiring the  header, and math library
and strtod() instead of the (deprecated) atof()

just FYI if someone wanted to update it




[patch] dc: array_free usage

2015-11-09 Thread Michael W. Bombardieri
Hi tech@,

In dc(1) the function array_free() knows how to skip a null pointer
so calling code doesn't need to avoid passing null.
Also, minor style (braces) clean-up.

- Michael
 

Index: bcode.c
===
RCS file: /cvs/src/usr.bin/dc/bcode.c,v
retrieving revision 1.48
diff -u -p -u -r1.48 bcode.c
--- bcode.c 3 Oct 2015 16:24:53 -   1.48
+++ bcode.c 10 Nov 2015 03:50:43 -
@@ -937,9 +937,8 @@ badd(void)
struct number   *r;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -965,9 +964,8 @@ bsub(void)
struct number   *r;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1014,9 +1012,8 @@ bmul(void)
struct number   *r;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1040,9 +1037,8 @@ bdiv(void)
BN_CTX  *ctx;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1078,9 +1074,8 @@ bmod(void)
BN_CTX  *ctx;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1116,9 +,8 @@ bdivmod(void)
BN_CTX  *ctx;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1158,9 +1152,8 @@ bexp(void)
u_int   rscale;
 
p = pop_number();
-   if (p == NULL) {
+   if (p == NULL)
return;
-   }
a = pop_number();
if (a == NULL) {
push_number(p);
@@ -1282,9 +1275,8 @@ bsqrt(void)
 
onecount = 0;
n = pop_number();
-   if (n == NULL) {
+   if (n == NULL)
return;
-   }
if (BN_is_zero(n->number)) {
r = new_number();
push_number(r);
@@ -1325,9 +1317,8 @@ not(void)
struct number   *a;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
a->scale = 0;
bn_check(BN_set_word(a->number, BN_get_word(a->number) ? 0 : 1));
push_number(a);
@@ -1345,9 +1336,8 @@ equal_numbers(void)
struct number *a, *b, *r;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1365,9 +1355,8 @@ less_numbers(void)
struct number *a, *b, *r;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1385,9 +1374,8 @@ lesseq_numbers(void)
struct number *a, *b, *r;
 
a = pop_number();
-   if (a == NULL) {
+   if (a == NULL)
return;
-   }
b = pop_number();
if (b == NULL) {
push_number(a);
@@ -1711,9 +1699,8 @@ eval_tos(void)
char *p;
 
p = pop_string();
-   if (p == NULL)
-   return;
-   eval_string(p);
+   if (p != NULL)
+   eval_string(p);
 }
 
 void
Index: stack.c
===
RCS file: /cvs/src/usr.bin/dc/stack.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 stack.c
--- stack.c 1 Dec 2014 13:13:00 -   1.13
+++ stack.c 10 Nov 2015 03:50:43 -
@@ -62,10 +62,8 @@ stack_free_value(struct value *v)
free(v->u.string);
break;
}
-   if (v->array != NULL) {
-   array_free(v->array);
-   v->array = NULL;
-   }
+   array_free(v->array);
+   v->array = NULL;
 }
 
 /* Copy number or string content into already allocated target */
@@ -210,10 +208,8 @@ stack_popnumber(struct stack *stack)
 {
if (stack_empty(stack))
return NULL;
-   if (stack->stack[stack->sp].array != NULL) {
-   array_free(stack->stack[stack->sp].array);
-   stack->stack[stack->sp].array = NULL;
-   }
+   array_free(stack->stack[stack->sp].array);
+   stack->stack[stack->sp].array = NULL;
if (stack->stack[stack->sp].type != BCODE_NUMBER) {
warnx("not a number"); /* XXX remove */
return 

Re: Periodically sync RTC

2015-11-09 Thread Mark Kettenis
> Date: Sun, 8 Nov 2015 22:57:24 +0100
> From: Christian Weisgerber 
> 
> I would like to sync the system time periodically back to the RTC.
> 
> Currently we update the RTC
> (1) when the time is set with clock_settime() or settimeofday(), which
> never happens for a typical ntpd setup,
> (2) before suspend,
> (3) when the system is properly shut down.
> 
> This means if a machine has been running for a few months and it
> loses power, it may come back up with the time, say, 200 seconds
> off because of RTC drift, and then your SixXS tunnel won't come up
> and you can no longer reach your home network on the last day of
> u2k15.  For example.
> 
> FreeBSD uses a period of 30 minutes.  I have no idea what a good
> number would be so I went with that.  (Maybe a prime number of
> seconds?)  FreeBSD also has a sysctl knob to change the period,
> which is silly.
> 
> The patch below, inspired by FreeBSD, "seems to work for me", but
> I don't really know what I'm doing and if it's okay to just use a
> timeout(9) like that.

No.  Some of the implementattions of resettodr() may sleep.

> Do I need a task?

Probably.

> Any locking?

Kernel lock should be good enough.

> I'm also uncertain where to put the hook to kick off the initial
> timeout_add().

Most logical place would be inittodr() but that's MD code.  Unifying
that code (and therefore unifying the checks for silly times and
falling back to the filesystem time) would be good, but probably too
much to ask from you.  It's a serious can of worms!

You should also delete the timeout and task before rebooting.  And
across suspend/resume.


> Index: kern/init_main.c
> ===
> RCS file: /cvs/src/sys/kern/init_main.c,v
> retrieving revision 1.246
> diff -u -p -r1.246 init_main.c
> --- kern/init_main.c  8 Nov 2015 20:45:57 -   1.246
> +++ kern/init_main.c  8 Nov 2015 21:06:47 -
> @@ -118,6 +118,8 @@ structsigacts sigacts0;
>  struct   process *initprocess;
>  struct   proc *reaperproc;
>  
> +void start_periodic_resettodr(void);
> +
>  extern   struct user *proc0paddr;
>  
>  struct   vnode *rootvp, *swapdev_vp;
> @@ -550,6 +552,8 @@ main(void *framep)
>  #if !(defined(__m88k__) && defined(MULTIPROCESSOR))  /* XXX */
>   pool_gc_pages(NULL);
>  #endif
> +
> + start_periodic_resettodr();
>  
>  /*
>   * proc0: nothing to do, back to sleep
> Index: kern/kern_time.c
> ===
> RCS file: /cvs/src/sys/kern/kern_time.c,v
> retrieving revision 1.95
> diff -u -p -r1.95 kern_time.c
> --- kern/kern_time.c  1 Nov 2015 19:03:33 -   1.95
> +++ kern/kern_time.c  8 Nov 2015 16:46:46 -
> @@ -41,6 +41,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -792,3 +793,21 @@ ppsratecheck(struct timeval *lasttime, i
>   return (rv);
>  }
>  
> +
> +#define RESETTODR_PERIOD 1800
> +
> +void periodic_resettodr(void *);
> +struct timeout resettodr_to = TIMEOUT_INITIALIZER(periodic_resettodr, NULL);
> +
> +void
> +periodic_resettodr(void *arg __unused)
> +{
> + resettodr();
> + timeout_add_sec(_to, RESETTODR_PERIOD);
> +}
> +
> +void
> +start_periodic_resettodr(void)
> +{
> + timeout_add_sec(_to, RESETTODR_PERIOD);
> +}
> -- 
> Christian "naddy" Weisgerber  na...@mips.inka.de
> 
> 



Re: Patch 1/3 - make DIOCRADDADDRS to accept on IP address per ioctl() call

2015-11-09 Thread Alexandr Nedvedicky
> 
> I'm wondering - how does it affect tools that load several thousands of IPs
> into a table?  Like spamd, bgpd (for spam lists etc.), or pfctl for IP black
> lists (as distributed by ET).
> 
> There are valid use cases with HUGE tables, but I have to admit that I didn't
> test your diff yet. Just a concern that loading IPs one after another might
> take forever.
> 

I could measure no difference on sample of 1 unique IPv4 addresses.
Both (pfr_add_addrs/pfr_add_addr) could load them within 1sec.

pfr_add_addrs:
# wc -l test.table.pf ; date ; pfctl -t test -T add -f test.table.pf ; date
10 test.table.pf
Mon Nov  9 18:21:18 CET 2015
1 table created.
10/10 addresses added.
Mon Nov  9 18:21:19 CET 2015


pfr_add_addr:
Mon Nov  9 18:31:27 CET 2015
# wc -l test.table.pf ; date ; pfctl -t test -T add -f test.table.pf ; date
10 test.table.pf
Mon Nov  9 18:31:27 CET 2015
1 table created.  10/10 addresses added.
Mon Nov  9 18:31:28 CET 2015

My test machine is Toshiba Tecra with Centrino 2.

regards
sasha



Re: at(1): avoid chdir

2015-11-09 Thread Philip Guenther
On Mon, Nov 9, 2015 at 1:48 PM, Todd C. Miller
 wrote:
> Use the *at system calls instead of changing directories.
...
> +   if ((dfd = open(AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1 ||
> +   (spool = fdopendir(dfd)) == NULL)
> perr2("Cannot open ", AT_SPOOL);

If fdopendir() fails, dfd needs to be closed.

> +   i = openat(dfd, dirent->d_name,
> +   O_RDONLY|O_NOFOLLOW);
> +   if (i == -1 || (fp = fdopen(i, "r")) == NULL)
> +   perr2("Cannot open ", dirent->d_name);

Similarly, if fdopen() fails, i needs to be closed.


Philip Guenther



Re: at(1): avoid chdir

2015-11-09 Thread Todd C. Miller
On Mon, 09 Nov 2015 14:52:53 -0800, Philip Guenther wrote:

> If fdopendir() fails, dfd needs to be closed.

Since perr() exits like err() does we don't need to close dfd.

 - todd



Re: unify xmalloc (was Re: [patch] cvs: retire xfree())

2015-11-09 Thread Tobias Stöckmann
> On November 9, 2015 at 5:04 AM Michael McConville  wrote:
> Tobias, could you split your latest diff into separate diffs for each
> function type (xmalloc, xcalloc, etc.)? It'd make it easier to zero in
> on the problematic hunks and fast-track the rest.

I don't really see the point splitting it up.
The scope of the diff is "merge xmalloc.{c,h} files".

If you still see problematic hunks, tell me. I don't know one.
In fact, I'm just waiting for feedback from djm.



Re: [patch] tcpdump print-atalk segfaults

2015-11-09 Thread Mike Belopuhov
On 9 November 2015 at 01:27, Kevin Reay  wrote:
> On Sun, Nov 8, 2015 at 4:58 PM, Mike Belopuhov  wrote:
>> Do you have a library of pcaps available somewhere?
>
> Just a small local set that I've built up for testing.
>
> Is there interest in having them online somewhere?

Well, we have no other way of testing Appletalk or DECnet...



Re: Driver for Attansic Technology E2200.

2015-11-09 Thread Martin Pieuchot
Hello Guillermo,

On 08/11/15(Sun) 17:06, Guillermo Bernaldo de Quiros Maraver wrote:
> Hi, good afternoon.
> 
> I don't know if this is the correct list to post the next email so, I'm
> sorry if this isn't the correct place.
> 
> My laptop computer wich is an MSI GE70 2QE has a network interface which
> currently it seems to be not supported by -current so I tried to port the
> device driver to OpenBSD based on the driver from FreeBSD which is similar
> and now the network interface is working correctly. Next I paste some
> information about the hardware and the device driver:
> 
> 1º Dmesg:
> alc0 at pci4 dev 0 function 0 "Attansic Technology E2200" rev 0x13: msi,
> address d8:cb:8a:84:db:cc
> atphy0 at alc0 phy 0: F1 10/100/1000 PHY, rev. 9
> 
> 2º Output of ifconfig alc0
>  alc0: flags=8843 mtu 1500
> lladdr d8:cb:8a:84:db:cc
> priority: 0
> groups: egress
> media: Ethernet autoselect (1000baseT full-duplex,rxpause,txpause)
> status: active
> inet 192.168.1.7 netmask 0xff00 broadcast 192.168.1.255
> 3º full dmesg in the attachment
> 4º cvs diff if_alc.c and cvs diff in the attachments.
> 
> I don't know if you're interested to apply the diff's into base but I think
> that could be a good idea.

Some comments inline.

> alc0: could not disable Rx/Tx MAC(0x40009e00)!

Did you investigate what does that mean?

> Index: if_alc.c
> ===
> RCS file: /cvs/src/sys/dev/pci/if_alc.c,v
> retrieving revision 1.35
> diff -u -p -r1.35 if_alc.c
> --- if_alc.c  25 Oct 2015 13:04:28 -  1.35
> +++ if_alc.c  8 Nov 2015 16:02:09 -
> @@ -120,7 +120,8 @@ const struct pci_matchid alc_devices[] =
>   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L1D },
>   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L1D_1 },
>   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_1 },
> - { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_2 }
> + { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_L2C_2 },
> + { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_E2200 }
>  };
>  
>  struct cfattach alc_ca = {
> @@ -525,6 +526,7 @@ alc_phy_down(struct alc_softc *sc)
>   switch (sc->sc_product) {
>   case PCI_PRODUCT_ATTANSIC_L1D:
>   case PCI_PRODUCT_ATTANSIC_L1D_1:
> + case PCI_PRODUCT_ATTANSIC_E2200:
>   /*
>* GPHY power down caused more problems on AR8151 v2.0.
>* When driver is reloaded after GPHY power down,
> @@ -783,10 +785,14 @@ alc_attach(struct device *parent, struct
>   case PCI_PRODUCT_ATTANSIC_L1D_1:
>   sc->alc_flags |= ALC_FLAG_APS;
>   /* FALLTHROUGH */
> + case PCI_PRODUCT_ATTANSIC_E2200:
> + sc->alc_flags |= ALC_FLAG_AR816X_FAMILY;
> + break;
>   default:
>   break;
>   }
> - sc->alc_flags |= ALC_FLAG_ASPM_MON | ALC_FLAG_JUMBO;
> + //sc->alc_flags |= ALC_FLAG_ASPM_MON | ALC_FLAG_JUMBO;
> + sc->alc_flags |= ALC_FLAG_JUMBO;

Why did you change this flag?  This cannot be committed as-is if this is
really needed then you could add a conditional statement based on the
product ID.


> @@ -797,6 +803,7 @@ alc_attach(struct device *parent, struct
>   case PCI_PRODUCT_ATTANSIC_L1D_1:
>   case PCI_PRODUCT_ATTANSIC_L2C_1:
>   case PCI_PRODUCT_ATTANSIC_L2C_2:
> + case PCI_PRODUCT_ATTANSIC_E2200:
>   sc->alc_max_framelen = 6 * 1024;
>   break;
>   }
> @@ -2035,7 +2042,9 @@ alc_reset(struct alc_softc *sc)
>   printf("%s: master reset timeout!\n", sc->sc_dev.dv_xname);
>  
>   for (i = ALC_RESET_TIMEOUT; i > 0; i--) {
> - if ((reg = CSR_READ_4(sc, ALC_IDLE_STATUS)) == 0)
> + reg = CSR_READ_4(sc,ALC_IDLE_STATUS);   
> + if ((reg & (IDLE_STATUS_RXMAC | IDLE_STATUS_TXMAC | 
> + IDLE_STATUS_RXQ | IDLE_STATUS_TXQ)) == 0)

Isn't this related to the message in your dmesg?

>   break;
>   DELAY(10);
>   }
> @@ -2485,6 +2494,7 @@ alc_stop_queue(struct alc_softc *sc)
>   reg &= ~TXQ_CFG_ENB;
>   CSR_WRITE_4(sc, ALC_TXQ_CFG, reg);
>   }
> + DELAY(40);
>   for (i = ALC_TIMEOUT; i > 0; i--) {
>   reg = CSR_READ_4(sc, ALC_IDLE_STATUS);
>   if ((reg & (IDLE_STATUS_RXQ | IDLE_STATUS_TXQ)) == 0)

> Index: if_alcreg.h
> ===
> RCS file: /cvs/src/sys/dev/pci/if_alcreg.h,v
> retrieving revision 1.5
> diff -u -p -r1.5 if_alcreg.h
> --- if_alcreg.h   27 Nov 2014 14:52:04 -  1.5
> +++ if_alcreg.h   8 Nov 2015 16:05:42 -
> @@ -1164,6 +1164,7 @@ struct alc_softc {
>  #define  ALC_FLAG_L0S0x0400
>  #define  ALC_FLAG_L1S0x0800
>  #define  ALC_FLAG_APS0x1000
> +#define ALC_FLAG_AR816X_FAMILY 0x2000

Please use a tab here, to be coherent with the rest of the 

Re: [patch] cwm: Honour size hints when resizing using keyboard

2015-11-09 Thread Vadim Vygonets
Quoth Okan Demirmen on Mon, Nov 09, 2015:
> On Mon 2015.11.09 at 00:14 +0100, Vadim Vygonets wrote:
> > Dear daemonfishes,
> > 
> > After using evilwm for a decade, I'm quite impressed with cwm's
> > codebase and functionality.  (I just couldn't understand one
> > feature: what's the use of ptrmove* if you cannot click?  (...Mr.
> > Andersen?))
> 
> I've never used this, but maybe someone else cares? The only rationale
> is that one can move the pointer with the keyboard, then create a new
> window with a keyboard action.

Oh.  I just create a window and then move it.

> Who knows how much this is used, I could go either way.

Oh no, I'm not proposing to remove anything.

> It was excluded from keyboard-based resizing because back then people
> wanted micro adjustments to windows - something much easier to do with a
> keyboard than mouse.

I too want that, though not for xterm.

> If there are objections, no; else, sure, why not.

Fair enough, thanks!

> Though I will state
> now that I don't think it warrants a configuration button.

I agree.

> > If you like thie modification, I can try to explain the new
> > behaviour in less technical prose and write a man page patch.
> 
> No need; we get it :)

You sure do, but the users demand explanation!

Vadik.

-- 
Show respect for age.  Drink good Scotch for a change.



Re: [PATCH] add F13-F24 and colour support to console terminfo

2015-11-09 Thread Tati Chevron

On Mon, Nov 09, 2015 at 08:23:08AM +, Nicholas Marriott wrote:

On Sun, Nov 08, 2015 at 09:01:52PM +, Tati Chevron wrote:

Is there any reason why the OpenBSD installer still defaults to a
terminal type of vt-220 for the VGA framebuffer console, and doesn't
even suggest pccon as an alternative?


In the installer itself? vt220 works fine and reliably and - importantly
- is small and fits on the ramdisks. Who needs to press F13 in the
installer?


Agreed, I didn't mean the installer itself, that does work fine with vt220.


If you mean in /etc/ttys, this has been discussed before and mostly the
reason it has stayed is that terminfo entries propagate very slowly and
vt220 is available everywhere, no matter if the user ssh to some ancient
OS. It's easy to change anyway.


Ah, then this is a documentation issue - I always assumed that the terminal 
type specified in the installer was propogated to /etc/ttys during the install, 
and used as a default for the console.

It is indeed easy to change, but the existance of pccon isn't exactly widely 
documented.  To be honest, I knew about it, but seeing that it was broken and 
not used by default in the installer, nor on the console after installation, I 
assumed that it was abandoned and unmaintained.

--
Tati Chevron
Perl and FORTRAN specialist.
SWABSIT development and migration department.
http://www.swabsit.com



Re: [PATCH] add F13-F24 and colour support to console terminfo

2015-11-09 Thread Nicholas Marriott
On Sun, Nov 08, 2015 at 09:01:52PM +, Tati Chevron wrote:
> Hi,
> 
> On Sun, Nov 08, 2015 at 08:18:55PM +, Nicholas Marriott wrote:
> >Hi
> >
> >I think it should be Shift-F1 etc, but since this is a general problem
> >with the xterm entry not just on OpenBSD, I suggest you discuss it with
> >upstream. The terminfo database is maintained as part of ncurses.
> 
> OK, I'll look into that, and maintain a local patch here for X for the time 
> being.
> 
> Is there any reason why the OpenBSD installer still defaults to a
> terminal type of vt-220 for the VGA framebuffer console, and doesn't
> even suggest pccon as an alternative?

In the installer itself? vt220 works fine and reliably and - importantly
- is small and fits on the ramdisks. Who needs to press F13 in the
installer?

If you mean in /etc/ttys, this has been discussed before and mostly the
reason it has stayed is that terminfo entries propagate very slowly and
vt220 is available everywhere, no matter if the user ssh to some ancient
OS. It's easy to change anyway.



Re: less(1) cleanup

2015-11-09 Thread Nicholas Marriott

ok nicm



On Sun, Nov 08, 2015 at 11:42:27PM -0500, Michael McConville wrote:
> Here, I:
> 
>  1) remove a useless comment
>  2) remove a needless void* cast
>  3) remove a bunch of NULL-checks for free()
>  4) simplify a little associated logic
> 
> Call me a one trick pony. 
> 
> ok?
> 
> 
> Index: cmdbuf.c
> ===
> RCS file: /cvs/src/usr.bin/less/cmdbuf.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 cmdbuf.c
> --- cmdbuf.c  9 Nov 2015 04:10:57 -   1.11
> +++ cmdbuf.c  9 Nov 2015 04:38:23 -
> @@ -918,13 +918,8 @@ init_compl(void)
>   char *word;
>   char c;
>  
> - /*
> -  * Get rid of any previous tk_text.
> -  */
> - if (tk_text != NULL) {
> - free(tk_text);
> - tk_text = NULL;
> - }
> + free(tk_text);
> + tk_text = NULL;
>   /*
>* Find the original (uncompleted) word in the command buffer.
>*/
> @@ -939,8 +934,7 @@ init_compl(void)
>   /*
>* Save the original (uncompleted) word
>*/
> - if (tk_original != NULL)
> - free(tk_original);
> + free(tk_original);
>   tk_original = ecalloc(cp-word+1, sizeof (char));
>   (void) strncpy(tk_original, word, cp-word);
>   /*
> @@ -954,12 +948,11 @@ init_compl(void)
>   tk_text = fcomplete(word);
>   } else {
>   char *qword = shell_quote(word+1);
> - if (qword == NULL) {
> + if (qword == NULL)
>   tk_text = fcomplete(word+1);
> - } else {
> + else
>   tk_text = fcomplete(qword);
> - free(qword);
> - }
> + free(qword);
>   }
>   *cp = c;
>  }
> Index: command.c
> ===
> RCS file: /cvs/src/usr.bin/less/command.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 command.c
> --- command.c 7 Nov 2015 18:07:44 -   1.22
> +++ command.c 9 Nov 2015 04:38:23 -
> @@ -198,8 +198,7 @@ exec_mca(void)
>*/
>   while (*cbuf == '+' || *cbuf == ' ')
>   cbuf++;
> - if (every_first_cmd != NULL)
> - free(every_first_cmd);
> + free(every_first_cmd);
>   if (*cbuf == '\0')
>   every_first_cmd = NULL;
>   else
> Index: line.c
> ===
> RCS file: /cvs/src/usr.bin/less/line.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 line.c
> --- line.c6 Nov 2015 15:50:33 -   1.14
> +++ line.c9 Nov 2015 04:38:23 -
> @@ -98,10 +98,8 @@ expand_linebuf(void)
>   char *new_buf = realloc(linebuf, new_size);
>   char *new_attr = realloc(attr, new_size);
>   if (new_buf == NULL || new_attr == NULL) {
> - if (new_attr != NULL)
> - free(new_attr);
> - if (new_buf != NULL)
> - free(new_buf);
> + free(new_attr);
> + free(new_buf);
>   return (1);
>   }
>   linebuf = new_buf;
> Index: option.c
> ===
> RCS file: /cvs/src/usr.bin/less/option.c,v
> retrieving revision 1.12
> diff -u -p -r1.12 option.c
> --- option.c  7 Nov 2015 18:07:44 -   1.12
> +++ option.c  9 Nov 2015 04:38:23 -
> @@ -307,8 +307,7 @@ scan_option(char *s)
>*/
>   if (o->ofunc != NULL)
>   (*o->ofunc)(INIT, str);
> - if (str != NULL)
> - free(str);
> + free(str);
>   }
>  }
>  
> Index: search.c
> ===
> RCS file: /cvs/src/usr.bin/less/search.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 search.c
> --- search.c  6 Nov 2015 15:50:33 -   1.11
> +++ search.c  9 Nov 2015 04:38:23 -
> @@ -97,12 +97,10 @@ set_pattern(struct pattern_info *info, c
>   else if (compile_pattern(pattern, search_type, >compiled) < 0)
>   return (-1);
>   /* Pattern compiled successfully; save the text too. */
> - if (info->text != NULL)
> - free(info->text);
> + free(info->text);
>   info->text = NULL;
> - if (pattern != NULL) {
> + if (pattern != NULL)
>   info->text = estrdup(pattern);
> - }
>   info->search_type = search_type;
>  
>   /*
> @@ -291,7 +289,7 @@ clr_hlist(struct hilite *anchor)
>  
>   for (hl = anchor->hl_first; hl != NULL; hl = nexthl) {
>   nexthl = hl->hl_next;
> - free((void*)hl);
> + free(hl);
>   }
>   anchor->hl_first = NULL;
>   prep_startpos = prep_endpos = -1;
> 



Re: unify xmalloc (was Re: [patch] cvs: retire xfree())

2015-11-09 Thread Alexandre Ratchov
On Sun, Nov 08, 2015 at 07:43:10PM -0500, Michael McConville wrote:
> Maybe we should pick this off in smaller chunks so that we don't get
> immobilized by a few scattered issues.
> 
> ok for removing xfree from aucat?
> 

yes, ok ratchov; if later this causes me merges i'll find another
solution.  Feel free to do the same in usr.bin/sndiod, as it's
almost the same.



Re: [patch] tail(1) follow multiple files

2015-11-09 Thread Martijn van Duren

ping

On 11/04/15 23:29, Martijn van Duren wrote:

Hello tech@,

I got somewhat annoyed by the fact that OpenBSD's tail can't follow
multiple files and since the last attempt at it was from 2008 I thought
I'd give it a shot. I already sent an earlier version of this diff to
Landry who called it "a welcomed addition", but doesn't have time to
review my patch.

I've field tested this patch for a couple of days now and I didn't
experienced any problems. I also run it through
/usr/src/regress/usr.bin/tail/ both on UFS and NFS (v3), so it should
not suffer from the same issues as before.

The patch isn't based on any other follow implementation (at least not
by intent) and leans fully on kqueue for reading, deletion/renaming, and
truncation. When a file gets deleted I set a timeout to kevent(2) of 1
second and poll for the files individually, since the parent directory
might not always be available for kqueue monitoring.

Sincerely,

Martijn van Duren
Index: extern.h
===
--- extern.h	(revision 1)
+++ extern.h	(revision 34)
@@ -36,17 +36,23 @@
 	if (write(STDOUT_FILENO, p, size) != size) \
 		oerr();
 
+struct tailfile {
+	char		*fname;
+	FILE		*fp;
+	struct stat	 sb;
+};
+
 enum STYLE { NOTSET = 0, FBYTES, FLINES, RBYTES, RLINES, REVERSE };
 
-void forward(FILE *, enum STYLE, off_t, struct stat *);
-void reverse(FILE *, enum STYLE, off_t, struct stat *);
+void forward(struct tailfile *, int, enum STYLE, off_t);
+void reverse(struct tailfile *, int, enum STYLE, off_t);
 
-int bytes(FILE *, off_t);
-int lines(FILE *, off_t);
+int bytes(struct tailfile *, off_t);
+int lines(struct tailfile *, off_t);
 
-void ierr(void);
+void ierr(const char *);
 void oerr(void);
+void printfname(const char *);
 
 extern int fflag, rflag, rval;
-extern char *fname;
 extern int is_stdin;
Index: misc.c
===
--- misc.c	(revision 1)
+++ misc.c	(revision 34)
@@ -41,7 +41,7 @@
 #include "extern.h"
 
 void
-ierr(void)
+ierr(const char *fname)
 {
 	warn("%s", fname);
 	rval = 1;
@@ -52,3 +52,11 @@
 {
 	err(1, "stdout");
 }
+
+void printfname(const char *fname)
+{
+	static int first = 1;
+	(void)printf("%s==> %s <==\n", first ? "" : "\n", fname);
+	first = 0;
+	(void)fflush(stdout);
+}
Index: read.c
===
--- read.c	(revision 1)
+++ read.c	(revision 34)
@@ -59,7 +59,7 @@
  *
  */
 int
-bytes(FILE *fp, off_t off)
+bytes(struct tailfile *tf, off_t off)
 {
 	int ch;
 	size_t len, tlen;
@@ -73,7 +73,7 @@
 	if ((sp = p = malloc(off)) == NULL)
 		err(1, NULL);
 
-	for (wrap = 0, ep = p + off; (ch = getc(fp)) != EOF;) {
+	for (wrap = 0, ep = p + off; (ch = getc(tf->fp)) != EOF;) {
 		*p = ch;
 		if (++p == ep) {
 			wrap = 1;
@@ -80,8 +80,8 @@
 			p = sp;
 		}
 	}
-	if (ferror(fp)) {
-		ierr();
+	if (ferror(tf->fp)) {
+		ierr(tf->fname);
 		free(sp);
 		return(1);
 	}
@@ -135,7 +135,7 @@
  *
  */
 int
-lines(FILE *fp, off_t off)
+lines(struct tailfile *tf, off_t off)
 {
 	struct {
 		size_t blen;
@@ -156,7 +156,7 @@
 
 	blen = cnt = recno = wrap = 0;
 
-	while ((ch = getc(fp)) != EOF) {
+	while ((ch = getc(tf->fp)) != EOF) {
 		if (++cnt > blen) {
 			newsize = blen + 1024;
 			if ((newp = realloc(sp, newsize)) == NULL)
@@ -184,8 +184,8 @@
 			}
 		}
 	}
-	if (ferror(fp)) {
-		ierr();
+	if (ferror(tf->fp)) {
+		ierr(tf->fname);
 		rc = 1;
 		goto done;
 	}
Index: reverse.c
===
--- reverse.c	(revision 1)
+++ reverse.c	(revision 34)
@@ -43,12 +43,12 @@
 #include "extern.h"
 
 static void r_buf(FILE *);
-static int r_reg(FILE *, enum STYLE, off_t, struct stat *);
+static int r_reg(struct tailfile *, enum STYLE, off_t);
 
-#define COPYCHAR(fp, ch)\
+#define COPYCHAR(tf, ch)\
 	do {		\
-		if ((ch = getc(fp)) == EOF) {		\
-			ierr();\
+		if ((ch = getc(tf->fp)) == EOF) {	\
+			ierr(tf->fname);		\
 			return (0);			\
 		}	\
 		if (putchar(ch) == EOF) {		\
@@ -76,25 +76,35 @@
  *	NOREG	cyclically read input into a linked list of buffers
  */
 void
-reverse(FILE *fp, enum STYLE style, off_t off, struct stat *sbp)
+reverse(struct tailfile *tf, int nfiles, enum STYLE style, off_t off)
 {
+	int i;
+
 	if (style != REVERSE && off == 0)
 		return;
 
-	if (!S_ISREG(sbp->st_mode) || r_reg(fp, style, off, sbp) != 0)
-		switch(style) {
-		case FBYTES:
-		case RBYTES:
-			(void)bytes(fp, off);
-			break;
-		case FLINES:
-		case RLINES:
-			(void)lines(fp, off);
-			break;
-		case REVERSE:
-			r_buf(fp);
-			break;
+	for (i = 0; i < nfiles; i++) {
+		if (nfiles > 1)
+			printfname(tf[i].fname);
+		if (!S_ISREG(tf[i].sb.st_mode) ||
+		r_reg(&(tf[i]), style, off) != 0) {
+			switch(style) {
+			case FBYTES:
+			case RBYTES:
+(void)bytes(&(tf[i]), off);
+break;
+			case FLINES:
+			case RLINES:
+(void)lines(&(tf[i]), off);
+break;
+			case REVERSE:
+r_buf(tf[i].fp);
+