better return type for usqrt() in factor(6)
In factor(6), there is the line 216 stop = usqrt(val) + 1; where the u_int64_t stop is the upper bound for the sieve of Eratosthenes (I cautiously added 1 to be sure to be on the safe side). Unfortunately, the right hand side may now overflow for large enough val because my brilliant former self chose usqrt() to be of type u_int32_t usqrt(u_sqrt64_t); ... Example from http://cvsweb.netbsd.org/bsdweb.cgi/src/games/primes/pattern.c $ printf "%u\n" $((139646831 * 132095686967)) 18446744073709551577 $ factor 18446744073709551577 18446744073709551577 With the patch below: $ obj/factor 18446744073709551577: 139646831 132095686967 as it should be. Index: factor.c === RCS file: /var/cvs/src/games/factor/factor.c,v retrieving revision 1.29 diff -u -p -r1.29 factor.c --- factor.c14 Aug 2016 18:34:48 - 1.29 +++ factor.c1 Sep 2016 04:56:00 - @@ -75,7 +75,7 @@ extern const int pattern_size; static voidpr_fact(u_int64_t); /* print factors of a value */ static voidpr_bigfact(u_int64_t); -static u_int32_t usqrt(u_int64_t); +static u_int64_t usqrt(u_int64_t); static void __dead usage(void); int @@ -284,7 +284,7 @@ pr_bigfact(u_int64_t val) /* Factor this } /* Code taken from ping.c */ -static u_int32_t +static u_int64_t usqrt(u_int64_t n) { u_int64_t y, x = 1; @@ -299,7 +299,7 @@ usqrt(u_int64_t n) x /= 2; } while (((y < x) && (x - y) > 1) || (y - x) > 1); - return (u_int32_t)x; + return x; } static void __dead
Re: ifconfig baudrate
> Whatever, you know what you're talking about but I guess the MCS table is to= > tally uninteresting for most users like me. For them, it is "utterly meaning= > less" to have some code and acronym instead of the actual calculated speed. I= > t's a blinkenlight but it will probably stay where it is. Except it is exactly like ethernet negotiating 100baseTX or 1000baseT and calling that "media", and also why if_media.h contains a seperate ifmedia_baudrate / IFM_BAUDRATE_DESCRIPTIONS which provides the "speed".
Re: remove ntfs write code
Yes, ok beck@ to be shortly followed by the ntfs code - don't we have a fuse version of this? On Wed, Aug 31, 2016 at 3:34 PM, Martin Natanowrote: > mount_ntfs forces the mount point to be MNT_RDONLY, so the write parts > in ntfs are never used. OK to remove? > > natano > > > Index: ntfs/ntfs_subr.c > === > RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v > retrieving revision 1.47 > diff -u -p -r1.47 ntfs_subr.c > --- ntfs/ntfs_subr.c31 Aug 2016 15:13:57 - 1.47 > +++ ntfs/ntfs_subr.c31 Aug 2016 19:58:31 - > @@ -1336,152 +1336,6 @@ ntfs_filesize(struct ntfsmount *ntmp, st > } > > /* > - * This is one of the write routines. > - */ > -int > -ntfs_writeattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, > -u_int32_t attrnum, char *attrname, off_t roff, size_t rsize, void > *rdata, > -size_t *initp, struct uio *uio) > -{ > - size_t init; > - int error = 0; > - off_t off = roff; > - size_t left = rsize, towrite; > - caddr_t data = rdata; > - struct ntvattr *vap; > - *initp = 0; > - > - while (left) { > - error = ntfs_ntvattrget(ntmp, ip, attrnum, attrname, > - ntfs_btocn(off), ); > - if (error) > - return (error); > - towrite = MIN(left, ntfs_cntob(vap->va_vcnend + 1) - off); > - DDPRINTF("ntfs_writeattr_plain: o: %lld, s: %zu " > - "(%llu - %llu)\n", off, towrite, > - vap->va_vcnstart, vap->va_vcnend); > - error = ntfs_writentvattr_plain(ntmp, ip, vap, > -off - > ntfs_cntob(vap->va_vcnstart), > -towrite, data, , uio); > - if (error) { > - DPRINTF("ntfs_writeattr_plain: > ntfs_writentvattr_plain " > - "failed: o: %lld, s: %zu\n", off, towrite); > - DPRINTF("ntfs_writeattr_plain: attrib: %llu - > %llu\n", > - vap->va_vcnstart, vap->va_vcnend); > - ntfs_ntvattrrele(vap); > - break; > - } > - ntfs_ntvattrrele(vap); > - left -= towrite; > - off += towrite; > - data = data + towrite; > - *initp += init; > - } > - > - return (error); > -} > - > -/* > - * This is one of the write routines. > - * > - * ntnode should be locked. > - */ > -int > -ntfs_writentvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, > -struct ntvattr *vap, off_t roff, size_t rsize, void *rdata, size_t > *initp, > -struct uio *uio) > -{ > - int error = 0; > - off_t off; > - int cnt; > - cn_tccn, ccl, cn, cl; > - caddr_t data = rdata; > - struct buf *bp; > - size_t left, tocopy; > - > - *initp = 0; > - > - if ((vap->va_flag & NTFS_AF_INRUN) == 0) { > - DPRINTF("ntfs_writevattr_plain: CAN'T WRITE RES. > ATTRIBUTE\n"); > - return ENOTTY; > - } > - > - DDPRINTF("ntfs_writentvattr_plain: data in run: %lu chains\n", > - vap->va_vruncnt); > - > - off = roff; > - left = rsize; > - > - for (cnt = 0; left && (cnt < vap->va_vruncnt); cnt++) { > - ccn = vap->va_vruncn[cnt]; > - ccl = vap->va_vruncl[cnt]; > - > - DDPRINTF("ntfs_writentvattr_plain: left %zu, cn: 0x%llx, " > - "cl: %llu, off: %lld\n", left, ccn, ccl, off); > - > - if (ntfs_cntob(ccl) < off) { > - off -= ntfs_cntob(ccl); > - cnt++; > - continue; > - } > - if (!ccn && ip->i_number != NTFS_BOOTINO) > - continue; /* XXX */ > - > - ccl -= ntfs_btocn(off); > - cn = ccn + ntfs_btocn(off); > - off = ntfs_btocnoff(off); > - > - while (left && ccl) { > - /* > -* Always read and write single clusters at a time > - > -* we need to avoid requesting differently-sized > -* blocks at the same disk offsets to avoid > -* confusing the buffer cache. > -*/ > - tocopy = MIN(left, ntfs_cntob(1) - off); > - cl = ntfs_btocl(tocopy + off); > - KASSERT(cl == 1 && tocopy <= ntfs_cntob(1)); > - DDPRINTF("ntfs_writentvattr_plain: write: cn: > 0x%llx " > - "cl: %llu, off: %lld len: %zu, left: %zu\n", > - cn, cl,
encrypt(1) readpassphrase
Hi, encrypt(1) updated to use readpassphrase(3) instead of getpass(3). Thought I would grep the tree after the recent commit to passwd(1) by tedu. Index: encrypt.c === RCS file: /cvs/src/usr.bin/encrypt/encrypt.c,v retrieving revision 1.42 diff -u -p -r1.42 encrypt.c --- encrypt.c 10 Oct 2015 18:14:20 - 1.42 +++ encrypt.c 31 Aug 2016 23:05:17 - @@ -36,6 +36,7 @@ #include #include #include +#include /* * Very simple little program, for encrypting passwords from the command @@ -123,11 +124,13 @@ main(int argc, char **argv) } if (((argc - optind) < 1)) { - char line[BUFSIZ], *string; + char line[BUFSIZ]; + char string[_PASSWORD_LEN + 1]; if (prompt) { - if ((string = getpass("Enter string: ")) == NULL) - err(1, "getpass"); + if (readpassphrase("Enter string: ", string, + sizeof(string), RPP_ECHO_OFF) == NULL) + err(1, "readpassphrase"); print_passwd(string, operation, extra); (void)fputc('\n', stdout); } else {
Re: remove ntfs write code
as far as i'm concerned ok benno@ btw i have incresingly problems with mounting ntfs partions (read-only) with this and use the ntfs_3g fuse port. Martin Natano(nat...@natano.net) on 2016.08.31 23:34:43 +0200: > mount_ntfs forces the mount point to be MNT_RDONLY, so the write parts > in ntfs are never used. OK to remove? > > natano > > > Index: ntfs/ntfs_subr.c > === > RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v > retrieving revision 1.47 > diff -u -p -r1.47 ntfs_subr.c > --- ntfs/ntfs_subr.c 31 Aug 2016 15:13:57 - 1.47 > +++ ntfs/ntfs_subr.c 31 Aug 2016 19:58:31 - > @@ -1336,152 +1336,6 @@ ntfs_filesize(struct ntfsmount *ntmp, st > } > > /* > - * This is one of the write routines. > - */ > -int > -ntfs_writeattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, > -u_int32_t attrnum, char *attrname, off_t roff, size_t rsize, void *rdata, > -size_t *initp, struct uio *uio) > -{ > - size_t init; > - int error = 0; > - off_t off = roff; > - size_t left = rsize, towrite; > - caddr_t data = rdata; > - struct ntvattr *vap; > - *initp = 0; > - > - while (left) { > - error = ntfs_ntvattrget(ntmp, ip, attrnum, attrname, > - ntfs_btocn(off), ); > - if (error) > - return (error); > - towrite = MIN(left, ntfs_cntob(vap->va_vcnend + 1) - off); > - DDPRINTF("ntfs_writeattr_plain: o: %lld, s: %zu " > - "(%llu - %llu)\n", off, towrite, > - vap->va_vcnstart, vap->va_vcnend); > - error = ntfs_writentvattr_plain(ntmp, ip, vap, > - off - ntfs_cntob(vap->va_vcnstart), > - towrite, data, , uio); > - if (error) { > - DPRINTF("ntfs_writeattr_plain: ntfs_writentvattr_plain " > - "failed: o: %lld, s: %zu\n", off, towrite); > - DPRINTF("ntfs_writeattr_plain: attrib: %llu - %llu\n", > - vap->va_vcnstart, vap->va_vcnend); > - ntfs_ntvattrrele(vap); > - break; > - } > - ntfs_ntvattrrele(vap); > - left -= towrite; > - off += towrite; > - data = data + towrite; > - *initp += init; > - } > - > - return (error); > -} > - > -/* > - * This is one of the write routines. > - * > - * ntnode should be locked. > - */ > -int > -ntfs_writentvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, > -struct ntvattr *vap, off_t roff, size_t rsize, void *rdata, size_t > *initp, > -struct uio *uio) > -{ > - int error = 0; > - off_t off; > - int cnt; > - cn_tccn, ccl, cn, cl; > - caddr_t data = rdata; > - struct buf *bp; > - size_t left, tocopy; > - > - *initp = 0; > - > - if ((vap->va_flag & NTFS_AF_INRUN) == 0) { > - DPRINTF("ntfs_writevattr_plain: CAN'T WRITE RES. ATTRIBUTE\n"); > - return ENOTTY; > - } > - > - DDPRINTF("ntfs_writentvattr_plain: data in run: %lu chains\n", > - vap->va_vruncnt); > - > - off = roff; > - left = rsize; > - > - for (cnt = 0; left && (cnt < vap->va_vruncnt); cnt++) { > - ccn = vap->va_vruncn[cnt]; > - ccl = vap->va_vruncl[cnt]; > - > - DDPRINTF("ntfs_writentvattr_plain: left %zu, cn: 0x%llx, " > - "cl: %llu, off: %lld\n", left, ccn, ccl, off); > - > - if (ntfs_cntob(ccl) < off) { > - off -= ntfs_cntob(ccl); > - cnt++; > - continue; > - } > - if (!ccn && ip->i_number != NTFS_BOOTINO) > - continue; /* XXX */ > - > - ccl -= ntfs_btocn(off); > - cn = ccn + ntfs_btocn(off); > - off = ntfs_btocnoff(off); > - > - while (left && ccl) { > - /* > - * Always read and write single clusters at a time - > - * we need to avoid requesting differently-sized > - * blocks at the same disk offsets to avoid > - * confusing the buffer cache. > - */ > - tocopy = MIN(left, ntfs_cntob(1) - off); > - cl = ntfs_btocl(tocopy + off); > - KASSERT(cl == 1 && tocopy <= ntfs_cntob(1)); > - DDPRINTF("ntfs_writentvattr_plain: write: cn: 0x%llx " > - "cl: %llu, off: %lld len: %zu, left: %zu\n", > - cn, cl, off, tocopy, left); > - if ((off == 0) && (tocopy == ntfs_cntob(cl))) > - { > -
Re: ifconfig baudrate
> Am 31.08.2016 um 21:29 schrieb Chris Cappuccio: > > Reyk Floeter [r...@openbsd.org] wrote: >> >> Ok, it makes some sense to have this information for Ethernet. > > I am strongly opposed to this change on wired or wireless. Why the > push for having less information? > >> For 11n and all these new wireless rates it doesn't provide any useful >> information, what does "HT-MCS0" mean? Or "HT-MCS70"? In this case >> it would be much more useful to have the actual speed and not some >> obscure technical details from 802.11. > > This is a standard. On 11n, everything from MCS0 to MCS7 is > the single stream version of MCS8 to MCS15. The PHY rate can't tell > you which is in effect alone. We don't support >MCS7 yet so maybe > this is less obvious. > > You want to go away from having to know anything about the 11n > MCS table to figure out your expected baud rate? You should > display both. > > I'd much rather know what modulation and error coding scheme is in > effect, than know only what the physical data rate is. It's utterly > meaningless by itself. > Whatever, you know what you're talking about but I guess the MCS table is totally uninteresting for most users like me. For them, it is "utterly meaningless" to have some code and acronym instead of the actual calculated speed. It's a blinkenlight but it will probably stay where it is. Reyk
remove ntfs write code
mount_ntfs forces the mount point to be MNT_RDONLY, so the write parts in ntfs are never used. OK to remove? natano Index: ntfs/ntfs_subr.c === RCS file: /cvs/src/sys/ntfs/ntfs_subr.c,v retrieving revision 1.47 diff -u -p -r1.47 ntfs_subr.c --- ntfs/ntfs_subr.c31 Aug 2016 15:13:57 - 1.47 +++ ntfs/ntfs_subr.c31 Aug 2016 19:58:31 - @@ -1336,152 +1336,6 @@ ntfs_filesize(struct ntfsmount *ntmp, st } /* - * This is one of the write routines. - */ -int -ntfs_writeattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, -u_int32_t attrnum, char *attrname, off_t roff, size_t rsize, void *rdata, -size_t *initp, struct uio *uio) -{ - size_t init; - int error = 0; - off_t off = roff; - size_t left = rsize, towrite; - caddr_t data = rdata; - struct ntvattr *vap; - *initp = 0; - - while (left) { - error = ntfs_ntvattrget(ntmp, ip, attrnum, attrname, - ntfs_btocn(off), ); - if (error) - return (error); - towrite = MIN(left, ntfs_cntob(vap->va_vcnend + 1) - off); - DDPRINTF("ntfs_writeattr_plain: o: %lld, s: %zu " - "(%llu - %llu)\n", off, towrite, - vap->va_vcnstart, vap->va_vcnend); - error = ntfs_writentvattr_plain(ntmp, ip, vap, -off - ntfs_cntob(vap->va_vcnstart), -towrite, data, , uio); - if (error) { - DPRINTF("ntfs_writeattr_plain: ntfs_writentvattr_plain " - "failed: o: %lld, s: %zu\n", off, towrite); - DPRINTF("ntfs_writeattr_plain: attrib: %llu - %llu\n", - vap->va_vcnstart, vap->va_vcnend); - ntfs_ntvattrrele(vap); - break; - } - ntfs_ntvattrrele(vap); - left -= towrite; - off += towrite; - data = data + towrite; - *initp += init; - } - - return (error); -} - -/* - * This is one of the write routines. - * - * ntnode should be locked. - */ -int -ntfs_writentvattr_plain(struct ntfsmount *ntmp, struct ntnode *ip, -struct ntvattr *vap, off_t roff, size_t rsize, void *rdata, size_t *initp, -struct uio *uio) -{ - int error = 0; - off_t off; - int cnt; - cn_tccn, ccl, cn, cl; - caddr_t data = rdata; - struct buf *bp; - size_t left, tocopy; - - *initp = 0; - - if ((vap->va_flag & NTFS_AF_INRUN) == 0) { - DPRINTF("ntfs_writevattr_plain: CAN'T WRITE RES. ATTRIBUTE\n"); - return ENOTTY; - } - - DDPRINTF("ntfs_writentvattr_plain: data in run: %lu chains\n", - vap->va_vruncnt); - - off = roff; - left = rsize; - - for (cnt = 0; left && (cnt < vap->va_vruncnt); cnt++) { - ccn = vap->va_vruncn[cnt]; - ccl = vap->va_vruncl[cnt]; - - DDPRINTF("ntfs_writentvattr_plain: left %zu, cn: 0x%llx, " - "cl: %llu, off: %lld\n", left, ccn, ccl, off); - - if (ntfs_cntob(ccl) < off) { - off -= ntfs_cntob(ccl); - cnt++; - continue; - } - if (!ccn && ip->i_number != NTFS_BOOTINO) - continue; /* XXX */ - - ccl -= ntfs_btocn(off); - cn = ccn + ntfs_btocn(off); - off = ntfs_btocnoff(off); - - while (left && ccl) { - /* -* Always read and write single clusters at a time - -* we need to avoid requesting differently-sized -* blocks at the same disk offsets to avoid -* confusing the buffer cache. -*/ - tocopy = MIN(left, ntfs_cntob(1) - off); - cl = ntfs_btocl(tocopy + off); - KASSERT(cl == 1 && tocopy <= ntfs_cntob(1)); - DDPRINTF("ntfs_writentvattr_plain: write: cn: 0x%llx " - "cl: %llu, off: %lld len: %zu, left: %zu\n", - cn, cl, off, tocopy, left); - if ((off == 0) && (tocopy == ntfs_cntob(cl))) - { - bp = getblk(ntmp->ntm_devvp, ntfs_cntobn(cn), - ntfs_cntob(cl), 0, 0); - clrbuf(bp); - } else { - error = bread(ntmp->ntm_devvp, ntfs_cntobn(cn), -
Re: ifconfig baudrate
Reyk Floeter [r...@openbsd.org] wrote: > > Ok, it makes some sense to have this information for Ethernet. > I am strongly opposed to this change on wired or wireless. Why the push for having less information? > For 11n and all these new wireless rates it doesn't provide any useful > information, what does "HT-MCS0" mean? Or "HT-MCS70"? In this case > it would be much more useful to have the actual speed and not some > obscure technical details from 802.11. > This is a standard. On 11n, everything from MCS0 to MCS7 is the single stream version of MCS8 to MCS15. The PHY rate can't tell you which is in effect alone. We don't support >MCS7 yet so maybe this is less obvious. You want to go away from having to know anything about the 11n MCS table to figure out your expected baud rate? You should display both. I'd much rather know what modulation and error coding scheme is in effect, than know only what the physical data rate is. It's utterly meaningless by itself. Chris
rewrite column(1)
Hello tech@, Here's a complete restructuring of the column(1) utility. It's aim is to ease the implementation of UTF-8 support, which will come in a separate patch, but also fixes a few bugs while here: - Fix the width-calculation of a tab-character - Correct treatment of files without trailing newlines. - Repair "-xc 7" - Overflow protection for the number of rows and columns This patch already had loads of feedback from, and is OK by schwarze@. Without any objections I'd like to commit this by the end of the hackathon. Extra OKs welcome. martijn@ Index: column.c === RCS file: /cvs/src/usr.bin/column/column.c,v retrieving revision 1.23 diff -u -p -r1.23 column.c --- column.c17 Mar 2016 05:27:10 - 1.23 +++ column.c31 Aug 2016 19:52:47 - @@ -48,14 +48,18 @@ void input(FILE *); void maketbl(void); void print(void); void r_columnate(void); -void usage(void); +__dead void usage(void); -int termwidth; /* default terminal width */ +struct field { + char *content; + int width; +}; +int termwidth; /* default terminal width */ int entries; /* number of records */ int eval; /* exit value */ -int maxlength; /* longest record */ -char **list; /* array of pointers to records */ +int *maxwidths;/* longest record per column */ +struct field **table; /* one array of pointers per line */ char *separator = "\t "; /* field separator for table option */ int @@ -80,7 +84,7 @@ main(int argc, char *argv[]) err(1, "pledge"); tflag = xflag = 0; - while ((ch = getopt(argc, argv, "c:s:tx")) != -1) + while ((ch = getopt(argc, argv, "c:s:tx")) != -1) { switch(ch) { case 'c': termwidth = strtonum(optarg, 1, INT_MAX, ); @@ -96,14 +100,16 @@ main(int argc, char *argv[]) case 'x': xflag = 1; break; - case '?': default: usage(); } - argc -= optind; + } + + if (!tflag) + separator = ""; argv += optind; - if (!*argv) { + if (*argv == NULL) { input(stdin); } else { for (; *argv; ++argv) { @@ -121,73 +127,63 @@ main(int argc, char *argv[]) err(1, "pledge"); if (!entries) - exit(eval); + return eval; if (tflag) maketbl(); - else if (maxlength >= termwidth) + else if (*maxwidths >= termwidth) print(); else if (xflag) c_columnate(); else r_columnate(); - exit(eval); + return eval; } -#defineTAB 8 +#defineINCR_NEXTTAB(x) (x = (x + 8) & ~7) void c_columnate(void) { - int chcnt, col, cnt, endcol, numcols; - char **lp; + int col, numcols; + struct field **row; - maxlength = (maxlength + TAB) & ~(TAB - 1); - numcols = termwidth / maxlength; - endcol = maxlength; - for (chcnt = col = 0, lp = list;; ++lp) { - chcnt += printf("%s", *lp); + INCR_NEXTTAB(*maxwidths); + if ((numcols = termwidth / *maxwidths) == 0) + numcols = 1; + for (col = 0, row = table;; ++row) { + fputs((*row)->content, stdout); if (!--entries) break; if (++col == numcols) { - chcnt = col = 0; - endcol = maxlength; + col = 0; putchar('\n'); } else { - while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol) { - (void)putchar('\t'); - chcnt = cnt; - } - endcol += maxlength; + while (INCR_NEXTTAB((*row)->width) <= *maxwidths) + putchar('\t'); } } - if (chcnt) - putchar('\n'); + putchar('\n'); } void r_columnate(void) { - int base, chcnt, cnt, col, endcol, numcols, numrows, row; + int base, col, numcols, numrows, row; - maxlength = (maxlength + TAB) & ~(TAB - 1); - numcols = termwidth / maxlength; - if (numcols == 0) + INCR_NEXTTAB(*maxwidths); + if ((numcols = termwidth / *maxwidths) == 0) numcols = 1; numrows = entries / numcols; if (entries % numcols) ++numrows; - for (row = 0; row < numrows; ++row) { - endcol = maxlength; - for (base = row, chcnt = col = 0; col < numcols; ++col) { -
iwm(4): Fix off-by-one error in a range check in iwm_read_firmware().
This fixes an off-by-one error in the "if (idx > howmany(IWM_NUM_UCODE_TLV_CAPA, 32))" range check. Since IWM_NUM_UCODE_TLV_CAPA is defined as 128, for an idx value of 4, we would potentially try to set bits 159..128 in the sc->sc_enabled_capa bitmap (which is just IWM_NUM_UCODE_TLV_CAPA bits long). Index: sys/dev/pci/if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.99 diff -u -r1.99 if_iwm.c --- sys/dev/pci/if_iwm.c17 Aug 2016 09:39:38 - 1.99 +++ sys/dev/pci/if_iwm.c31 Aug 2016 19:41:12 - @@ -758,7 +758,7 @@ } capa = (struct iwm_ucode_capa *)tlv_data; idx = le32toh(capa->api_index); - if (idx > howmany(IWM_NUM_UCODE_TLV_CAPA, 32)) { + if (idx >= howmany(IWM_NUM_UCODE_TLV_CAPA, 32)) { DPRINTF(("%s: unsupported API index %d\n", DEVNAME(sc), idx)); goto parse_out;
iwm(4): Use htole16 for policy field in iwm_time_event_cmd_v2 struct.
Hi, The policy field in struct iwm_time_event_cmd_v2 is just a 16bit integer, so we should use htole16() when setting it, instead of htole32(). Index: sys/dev/pci/if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.99 diff -u -r1.99 if_iwm.c --- sys/dev/pci/if_iwm.c17 Aug 2016 09:39:38 - 1.99 +++ sys/dev/pci/if_iwm.c31 Aug 2016 19:37:05 - @@ -2379,7 +2379,7 @@ time_cmd.duration = htole32(duration); time_cmd.repeat = 1; time_cmd.policy - = htole32(IWM_TE_V2_NOTIF_HOST_EVENT_START | + = htole16(IWM_TE_V2_NOTIF_HOST_EVENT_START | IWM_TE_V2_NOTIF_HOST_EVENT_END | IWM_T2_V2_START_IMMEDIATELY);
iwm(4): Use uint32_t instead of enum type in __packed struct iwm_sf_cfg_cmd.
Hi, Although this doesn't seem to cause any issue at the moment, using an enum type in a __packed struct should be avoided: Index: sys/dev/pci/if_iwmreg.h === RCS file: /cvs/src/sys/dev/pci/if_iwmreg.h,v retrieving revision 1.14 diff -u -r1.14 if_iwmreg.h --- sys/dev/pci/if_iwmreg.h 20 Jul 2016 18:24:38 - 1.14 +++ sys/dev/pci/if_iwmreg.h 31 Aug 2016 18:53:25 - @@ -3225,14 +3225,14 @@ /** * Smart Fifo configuration command. - * @state: smart fifo state, types listed in iwm_sf_sate. + * @state: smart fifo state, types listed in enum %iwm_sf_state. * @watermark: Minimum allowed availabe free space in RXF for transient state. * @long_delay_timeouts: aging and idle timer values for each scenario * in long delay state. * @full_on_timeouts: timer values for each scenario in full on state. */ struct iwm_sf_cfg_cmd { - enum iwm_sf_state state; + uint32_t state; uint32_t watermark[IWM_SF_TRANSIENT_STATES_NUMBER]; uint32_t long_delay_timeouts[IWM_SF_NUM_SCENARIO][IWM_SF_NUM_TIMEOUT_TYPES]; uint32_t full_on_timeouts[IWM_SF_NUM_SCENARIO][IWM_SF_NUM_TIMEOUT_TYPES];
iwm(4): gc struct iwm_rbuf and the wantresp field in struct iwm_rx_data.
Hi, The struct iwm_rbuf definition, and the wantresp field in struct iwm_rx_data aren't used anywhere and can be removed: Index: sys/dev/pci/if_iwmvar.h === RCS file: /cvs/src/sys/dev/pci/if_iwmvar.h,v retrieving revision 1.19 diff -u -r1.19 if_iwmvar.h --- sys/dev/pci/if_iwmvar.h 15 Aug 2016 12:59:53 - 1.19 +++ sys/dev/pci/if_iwmvar.h 31 Aug 2016 18:53:25 - @@ -264,17 +264,9 @@ /* Linux driver optionally uses 8k buffer */ #define IWM_RBUF_SIZE 4096 -struct iwm_softc; -struct iwm_rbuf { - struct iwm_softc*sc; - void*vaddr; - bus_addr_t paddr; -}; - struct iwm_rx_data { struct mbuf *m; bus_dmamap_tmap; - int wantresp; }; struct iwm_rx_ring {
sdmmc locking
When a sdmmc device driver currently calls sdmmc_io_function_enable() in its attach routine it will cause a 'locking against myself' panic since the lock already has been set in the sdmmc attach path. Therefore just check if the lock already has been set in sdmmc_io_function_enable() fixes this. ok? Index: sdmmc_io.c === RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_io.c,v retrieving revision 1.26 diff -u -p -r1.26 sdmmc_io.c --- sdmmc_io.c 12 May 2016 15:26:42 - 1.26 +++ sdmmc_io.c 31 Aug 2016 18:08:38 - @@ -223,14 +223,14 @@ sdmmc_io_function_enable(struct sdmmc_fu u_int8_t rv; int retry = 5; + rw_assert_wrlock(>sc_lock); + if (sf->number == 0) return 0; /* FN0 is always enabled */ - rw_enter_write(>sc_lock); rv = sdmmc_io_read_1(sf0, SD_IO_CCCR_FN_ENABLE); rv |= (1sc_lock); while (!sdmmc_io_function_ready(sf) && retry-- > 0) tsleep(, PPAUSE, "pause", 0);
Re: ifconfig baudrate
Wed, 31 Aug 2016 09:42:07 -0600 "Theo de Raadt"> > I'd rather have this as an extra rather than replacing the more > > specific information. > > I agree... > Wed, 31 Aug 2016 17:17:26 +0200 Peter Hessler > On 2016 Aug 31 (Wed) at 17:04:38 +0200 (+0200), Stefan Sperling wrote: > :This makes ifconfig display baudrates defined in ifmedia.h tables. > : > :Before (prints media subtype): > : > :$ ifconfig iwn0 | grep media: > :media: IEEE802.11 autoselect (OFDM6 mode 11a) > :$ ifconfig em0 | grep media: > :media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) > : > :After (prints corresponding baudrate): > : > :$ ifconfig iwn0 | grep media: > :media: IEEE802.11 autoselect (6Mbps mode 11a) > :$ ifconfig em0 | grep media: > :media: Ethernet autoselect (100Mbps full-duplex,rxpause,txpause) > > For wifi, I have no opinion. > > For wired ethernet, NO! > > We _need_ that information for fiber interfaces. For some of our IXP > connected switches, that is how we can tell which is external, and which > is internal. Hi tech@, Absolutely! The same applies for wireless devices with multiple antennas respective to modulation type choices (many interfaces). Kind regards, Anton
Re: Let iked specify its source address when sending
On Wed, 31 Aug 2016 16:09:30 +0200 Reyk Floeterwrote: > On Wed, Aug 31, 2016 at 03:26:53PM +0200, Vincent Gross wrote: > > On Thu, 11 Aug 2016 16:57:27 +0100 > > Stuart Henderson wrote: > > > > > On 2016/06/27 13:00, J?r?mie Courr?ges-Anglas wrote: > > [...] > > > > > > > > I also gave my ok to vgross by IM. > > > > > > > > I know that some concerns have been exposed privately, I was not > > > > Cc'd, thus I have no idea what is the current status of that > > > > discussion. To the people concerned, please keep me / us > > > > updated about that discussion and Cc us. > > > > > > How are things looking with IN_SENDSRCADDR now, are there any > > > remaining concerns that need fixing before it could be committed? > > > (Also if anyone has a share-able diff to use this with iked it > > > would be quite handy..) > > > > > > > Tested locally with two iked on two distinct rdomains plus a bit of > > LD_PRELOAD goop. Unfortunately I couldn't ping from one rdom to the > > other, but I also have this problem without my patch, so I am > > confident this ping problem is unrelated. > > > > I would be very grateful if someone could test this. > > > > I don't know why you need LD_PRELOAD. > I wanted to use different key sets for each iked instance. > When testing iked with two different rdomains, you have to create an > enc(4) device per rdomain, or no ipsec traffic will flow. enc0 is for > rdomain 0 only. > > # ifconfig enc1 rdomain up > # ifconfig enc2 rdomain up > # route -T 1 exec iked -ddvvf /etc/iked.conf.1 > # route -T 2 exec iked -ddvvf /etc/iked.conf.2 Well, look at what you did, I understood why my pings wouldn't go through ! Hm, turns out I can send esp'ed data, when using the not-default address, but I can't receive yet. This is my test bench : -- A side: $ doas ifconfig pair10 rdomain 10 10.124.0.10/24 up $ doas ifconfig enc10 rdomain 10 up $ doas ifconfig vether10 rdomain 10 10.123.10.1/24 up $ doas route -T 10 add 10.123.11.0/24 10.124.0.11 $ cat iked.a.conf ikev2 active esp from 10.123.10.0/24 to 10.124.0.11 \ local 10.123.10.1 peer 10.124.0.11 \ srcid a.test dstid b.test "route -T 10 exec ipsecctl -s all" output : FLOWS: flow esp in from 10.124.0.11 to 10.123.10.0/24 peer 10.124.0.11 srcid FQDN/a.test dstid FQDN/b.test type use flow esp out from 10.123.10.0/24 to 10.124.0.11 peer 10.124.0.11 srcid FQDN/a.test dstid FQDN/b.test type require flow esp out from ::/0 to ::/0 type deny SAD: esp tunnel from 10.124.0.11 to 10.124.0.10 spi 0x2ebe4b1b auth hmac-sha2-256 enc aes-256 esp tunnel from 10.124.0.10 to 10.124.0.11 spi 0x3c4b29c3 auth hmac-sha2-256 enc aes-256 -- B side: $ doas ifconfig pair11 rdomain 11 10.124.0.11/24 up $ doas ifconfig enc11 rdomain 11 up $ doas ifconfig vether11 rdomain 11 10.123.11.1/24 up $ doas route -T 11 add 10.123.10.0/24 10.124.0.10 $ cat iked.b.conf ikev2 active esp from 10.124.0.11 to 10.123.10.0/24 \ local 10.124.0.11 peer 10.123.10.1 \ srcid b.test dstid a.test "route -T 11 exec ipsecctl -s all" output : FLOWS: flow esp in from 10.123.10.0/24 to 10.124.0.11 peer 10.124.0.10 srcid FQDN/b.test dstid FQDN/a.test type use flow esp out from 10.124.0.11 to 10.123.10.0/24 peer 10.124.0.10 srcid FQDN/b.test dstid FQDN/a.test type require flow esp out from ::/0 to ::/0 type deny SAD: esp tunnel from 10.124.0.11 to 10.124.0.10 spi 0x2ebe4b1b auth hmac-sha2-256 enc aes-256 esp tunnel from 10.124.0.10 to 10.124.0.11 spi 0x3c4b29c3 auth hmac-sha2-256 enc aes-256 -- The fun part: run "tcpdump -ni pair10", then "route -T 10 exec ping -I 10.123.10.1 10.124.0.11" : ... 17:26:24.185391 esp 10.124.0.10 > 10.124.0.11 spi 0x3c4b29c3 seq 36 len 136 17:26:24.185797 10.124.0.11.4500 > 10.124.0.10.4500:udpencap: esp 10.124.0.11 > 10.124.0.10 spi 0x2ebe4b1b seq 36 len 136 17:26:25.190350 esp 10.124.0.10 > 10.124.0.11 spi 0x3c4b29c3 seq 37 len 136 17:26:25.190680 10.124.0.11.4500 > 10.124.0.10.4500:udpencap: esp 10.124.0.11 > 10.124.0.10 spi 0x2ebe4b1b seq 37 len 136 17:26:26.190344 esp 10.124.0.10 > 10.124.0.11 spi 0x3c4b29c3 seq 38 len 136 17:26:26.190701 10.124.0.11.4500 > 10.124.0.10.4500:udpencap: esp 10.124.0.11 > 10.124.0.10 spi 0x2ebe4b1b seq 38 len 136 ... The udpencap'd return traffic is not picked up by enc10, so your ping replies are lost ...
Re: ifconfig baudrate
On 2016/08/31 17:04, Stefan Sperling wrote: > This makes ifconfig display baudrates defined in ifmedia.h tables. > > Before (prints media subtype): > > $ ifconfig iwn0 | grep media: > media: IEEE802.11 autoselect (OFDM6 mode 11a) > $ ifconfig em0 | grep media: > media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) > > After (prints corresponding baudrate): > > $ ifconfig iwn0 | grep media: > media: IEEE802.11 autoselect (6Mbps mode 11a) > $ ifconfig em0 | grep media: > media: Ethernet autoselect (100Mbps full-duplex,rxpause,txpause) > > The output of 'ifconfig media' (which prints command syntax) is unchanged > and we fall back to printing the media subtype if no baudrate is found. > > I've kept this disabled in the ramdisk for now. > The baudrate table will grow when more 11n features are implemented. I'd rather have this as an extra rather than replacing the more specific information.
Re: ifconfig baudrate
> I'd rather have this as an extra rather than replacing the more > specific information. I agree...
ftpd and IPv6 traffic class
Like in nc(1) IPTOS_* (supposedly IPv4) values are used for the IPv6 path. That's not a concern in practice. Index: ftpd.c === RCS file: /cvs/src/libexec/ftpd/ftpd.c,v retrieving revision 1.221 diff -u -p -p -u -r1.221 ftpd.c --- ftpd.c 31 Aug 2016 13:43:36 - 1.221 +++ ftpd.c 31 Aug 2016 15:35:27 - @@ -531,11 +531,18 @@ main(int argc, char *argv[]) reply(530, "System not available."); exit(1); } - if (his_addr.su_family == AF_INET) { - tos = IPTOS_LOWDELAY; + tos = IPTOS_LOWDELAY; + switch (his_addr.su_family) { + case AF_INET: if (setsockopt(0, IPPROTO_IP, IP_TOS, , sizeof(int)) < 0) syslog(LOG_WARNING, "setsockopt (IP_TOS): %m"); + break; + case AF_INET6: + if (setsockopt(0, IPPROTO_IPV6, IPV6_TCLASS, , + sizeof(int)) < 0) + syslog(LOG_WARNING, "setsockopt (IPV6_TCLASS): %m"); + break; } data_source.su_port = htons(ntohs(ctrl_addr.su_port) - 1); @@ -1269,7 +1276,7 @@ done: static FILE * getdatasock(char *mode) { - int on = 1, s, t, tries; + int on = 1, s, t, tos, tries; if (data >= 0) return (fdopen(data, mode)); @@ -1293,11 +1300,18 @@ getdatasock(char *mode) } sigprocmask (SIG_UNBLOCK, , NULL); - if (ctrl_addr.su_family == AF_INET) { - on = IPTOS_THROUGHPUT; - if (setsockopt(s, IPPROTO_IP, IP_TOS, , + tos = IPTOS_THROUGHPUT; + switch (ctrl_addr.su_family) { + case AF_INET: + if (setsockopt(s, IPPROTO_IP, IP_TOS, , sizeof(int)) < 0) syslog(LOG_WARNING, "setsockopt (IP_TOS): %m"); + break; + case AF_INET6: + if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, , + sizeof(int)) < 0) + syslog(LOG_WARNING, "setsockopt (IPV6_TCLASS): %m"); + break; } /* * Turn off push flag to keep sender TCP from sending short packets -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: ifconfig baudrate
> From: "Theo de Raadt"> Date: Wed, 31 Aug 2016 09:12:30 -0600 > > > This makes ifconfig display baudrates defined in ifmedia.h tables. > > > > Before (prints media subtype): > > > > $ ifconfig iwn0 | grep media: > > media: IEEE802.11 autoselect (OFDM6 mode 11a) > > $ ifconfig em0 | grep media: > > media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) > > > > After (prints corresponding baudrate): > > > > $ ifconfig iwn0 | grep media: > > media: IEEE802.11 autoselect (6Mbps mode 11a) > > $ ifconfig em0 | grep media: > > media: Ethernet autoselect (100Mbps full-duplex,rxpause,txpause) > > > > The output of 'ifconfig media' (which prints command syntax) is unchanged > > and we fall back to printing the media subtype if no baudrate is found. > > It makes no sense to change ethernet. > > The values it prints now is intended to match what you pass as > parameters for the 'media' and 'mediaopt' subcommands. That's why the > line is prefixed with the word "media", not "speed". There are legacy > options at the 100mbit level: > > if_media.h: { IFM_ETHER|IFM_100_TX, "100baseTX" }, > \ > if_media.h: { IFM_ETHER|IFM_100_FX, "100baseFX" }, > \ > if_media.h: { IFM_ETHER|IFM_100_T4, "100baseT4" }, > \ > if_media.h: { IFM_ETHER|IFM_100_VG, "100baseVG" }, > \ > if_media.h: { IFM_ETHER|IFM_100_T2, "100baseT2" }, > \ > > Now they all become the opaque "100Mbps"? Sure many of those don't > exist at the moment, or are not used. > > But look at gig: > > if_media.h: { IFM_ETHER|IFM_1000_SX,"1000baseSX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_SX,"1000SX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_LX,"1000baseLX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_LX,"1000LX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_CX,"1000baseCX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_CX,"1000CX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_T, "1000baseT" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_T, "1000T" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_T, "1000baseTX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_T, "1000TX" }, > \ > > this is on cvs: > > media: Ethernet autoselect (10GSFP+Cu full-duplex) > > That is information, you'd replace that with a speed? No thanks, > it does not make sense. +1 And I'm actually not sure about the wireless devices either. Those baudrates are fairly meaningless. And aren't they going to be ambiguous if we start to support antenna diversity?
Re: ifconfig baudrate
Il 31 agosto 2016 17:19:36 CEST, Reyk Floeterha scritto: >On Wed, Aug 31, 2016 at 09:12:30AM -0600, Theo de Raadt wrote: >> > This makes ifconfig display baudrates defined in ifmedia.h tables. >> > >> > Before (prints media subtype): >> > >> > $ ifconfig iwn0 | grep media: >> > media: IEEE802.11 autoselect (OFDM6 mode 11a) >> > $ ifconfig em0 | grep media: >> > media: Ethernet autoselect (100baseTX >full-duplex,rxpause,txpause) >> > >> > After (prints corresponding baudrate): >> > >> > $ ifconfig iwn0 | grep media: >> > media: IEEE802.11 autoselect (6Mbps mode 11a) >> > $ ifconfig em0 | grep media: >> > media: Ethernet autoselect (100Mbps >full-duplex,rxpause,txpause) >> > >> > The output of 'ifconfig media' (which prints command syntax) is >unchanged >> > and we fall back to printing the media subtype if no baudrate is >found. >> >> It makes no sense to change ethernet. >> >> The values it prints now is intended to match what you pass as >> parameters for the 'media' and 'mediaopt' subcommands. That's why >the >> line is prefixed with the word "media", not "speed". There are >legacy >> options at the 100mbit level: >> >> if_media.h: { IFM_ETHER|IFM_100_TX, "100baseTX" }, > \ >> if_media.h: { IFM_ETHER|IFM_100_FX, "100baseFX" }, > \ >> if_media.h: { IFM_ETHER|IFM_100_T4, "100baseT4" }, > \ >> if_media.h: { IFM_ETHER|IFM_100_VG, "100baseVG" }, > \ >> if_media.h: { IFM_ETHER|IFM_100_T2, "100baseT2" }, > \ >> >> Now they all become the opaque "100Mbps"? Sure many of those don't >> exist at the moment, or are not used. >> >> But look at gig: >> >> if_media.h: { IFM_ETHER|IFM_1000_SX,"1000baseSX" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_SX,"1000SX" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_LX,"1000baseLX" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_LX,"1000LX" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_CX,"1000baseCX" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_CX,"1000CX" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_T, "1000baseT" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_T, "1000T" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_T, "1000baseTX" }, > \ >> if_media.h: { IFM_ETHER|IFM_1000_T, "1000TX" }, > \ >> >> this is on cvs: >> >> media: Ethernet autoselect (10GSFP+Cu full-duplex) >> >> That is information, you'd replace that with a speed? No thanks, >> it does not make sense. >> > >Ok, it makes some sense to have this information for Ethernet. > >For 11n and all these new wireless rates it doesn't provide any useful >information, what does "HT-MCS0" mean? Or "HT-MCS70"? In this case >it would be much more useful to have the actual speed and not some >obscure technical details from 802.11. I also am in the "ok-for-wifi-but-not-for-wired" camp. Ciao! David
Re: ifconfig baudrate
On Wed, Aug 31, 2016 at 09:12:30AM -0600, Theo de Raadt wrote: > > This makes ifconfig display baudrates defined in ifmedia.h tables. > > > > Before (prints media subtype): > > > > $ ifconfig iwn0 | grep media: > > media: IEEE802.11 autoselect (OFDM6 mode 11a) > > $ ifconfig em0 | grep media: > > media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) > > > > After (prints corresponding baudrate): > > > > $ ifconfig iwn0 | grep media: > > media: IEEE802.11 autoselect (6Mbps mode 11a) > > $ ifconfig em0 | grep media: > > media: Ethernet autoselect (100Mbps full-duplex,rxpause,txpause) > > > > The output of 'ifconfig media' (which prints command syntax) is unchanged > > and we fall back to printing the media subtype if no baudrate is found. > > It makes no sense to change ethernet. > > The values it prints now is intended to match what you pass as > parameters for the 'media' and 'mediaopt' subcommands. That's why the > line is prefixed with the word "media", not "speed". There are legacy > options at the 100mbit level: > > if_media.h: { IFM_ETHER|IFM_100_TX, "100baseTX" }, > \ > if_media.h: { IFM_ETHER|IFM_100_FX, "100baseFX" }, > \ > if_media.h: { IFM_ETHER|IFM_100_T4, "100baseT4" }, > \ > if_media.h: { IFM_ETHER|IFM_100_VG, "100baseVG" }, > \ > if_media.h: { IFM_ETHER|IFM_100_T2, "100baseT2" }, > \ > > Now they all become the opaque "100Mbps"? Sure many of those don't > exist at the moment, or are not used. > > But look at gig: > > if_media.h: { IFM_ETHER|IFM_1000_SX,"1000baseSX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_SX,"1000SX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_LX,"1000baseLX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_LX,"1000LX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_CX,"1000baseCX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_CX,"1000CX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_T, "1000baseT" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_T, "1000T" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_T, "1000baseTX" }, > \ > if_media.h: { IFM_ETHER|IFM_1000_T, "1000TX" }, > \ > > this is on cvs: > > media: Ethernet autoselect (10GSFP+Cu full-duplex) > > That is information, you'd replace that with a speed? No thanks, > it does not make sense. > Ok, it makes some sense to have this information for Ethernet. For 11n and all these new wireless rates it doesn't provide any useful information, what does "HT-MCS0" mean? Or "HT-MCS70"? In this case it would be much more useful to have the actual speed and not some obscure technical details from 802.11. Reyk
Re: ifconfig baudrate
On Wed, Aug 31, 2016 at 05:04:38PM +0200, Stefan Sperling wrote: > This makes ifconfig display baudrates defined in ifmedia.h tables. > > Before (prints media subtype): > > $ ifconfig iwn0 | grep media: > media: IEEE802.11 autoselect (OFDM6 mode 11a) > $ ifconfig em0 | grep media: > media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) > > After (prints corresponding baudrate): > > $ ifconfig iwn0 | grep media: > media: IEEE802.11 autoselect (6Mbps mode 11a) > $ ifconfig em0 | grep media: > media: Ethernet autoselect (100Mbps full-duplex,rxpause,txpause) > > The output of 'ifconfig media' (which prints command syntax) is unchanged > and we fall back to printing the media subtype if no baudrate is found. > > I've kept this disabled in the ramdisk for now. > The baudrate table will grow when more 11n features are implemented. > I find it much more useful to have the actual speed ("baudrate") displayed instead of the mode or rate name - especially with these non-obvious MCS rates from 11n. OK reyk@ > Index: ifconfig.c > === > RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v > retrieving revision 1.328 > diff -u -p -r1.328 ifconfig.c > --- ifconfig.c31 Aug 2016 13:32:27 - 1.328 > +++ ifconfig.c31 Aug 2016 14:51:36 - > @@ -2715,6 +2715,11 @@ const struct ifmedia_description ifm_typ > const struct ifmedia_description ifm_subtype_descriptions[] = > IFM_SUBTYPE_DESCRIPTIONS; > > +#ifndef SMALL > +const struct ifmedia_baudrate ifm_baudrate_descriptions[] = > +IFM_BAUDRATE_DESCRIPTIONS; > +#endif > + > struct ifmedia_description ifm_mode_descriptions[] = > IFM_MODE_DESCRIPTIONS; > > @@ -2748,6 +2753,39 @@ get_media_subtype_string(uint64_t mword) > return (""); > } > > +#ifndef SMALL > +char * > +get_media_baudrate_string(uint64_t mword) > +{ > + const struct ifmedia_baudrate *ifmb; > + char *str; > + int ret = -1; > + > + for (ifmb = ifm_baudrate_descriptions; ifmb->ifmb_word != 0; ifmb++) { > + if (!IFM_TYPE_MATCH(ifmb->ifmb_word, mword) || > + IFM_SUBTYPE(ifmb->ifmb_word) != IFM_SUBTYPE(mword)) > + continue; > + > + if (ifmb->ifmb_baudrate >= IF_Gbps(1)) > + ret = asprintf(, > + "%lluGbps", ifmb->ifmb_baudrate / IF_Gbps(1)); > + else if (ifmb->ifmb_baudrate >= IF_Mbps(1)) > + ret = asprintf(, > + "%lluMbps", ifmb->ifmb_baudrate / IF_Mbps(1)); > + else if (ifmb->ifmb_baudrate >= IF_Kbps(1)) > + ret = asprintf(, > + "%lluKbps", ifmb->ifmb_baudrate / IF_Kbps(1)); > + else > + ret = asprintf(, "%llubps", ifmb->ifmb_baudrate); > + > + break; > + } > + if (ret == -1) > + str = NULL; > + return str; > +} > +#endif > + > uint64_t > get_media_subtype(uint64_t type, const char *val) > { > @@ -2818,11 +2856,18 @@ print_media_word(uint64_t ifmw, int prin > { > const struct ifmedia_description *desc; > uint64_t seen_option = 0; > + char *baudrate = NULL; > + > +#ifndef SMALL > + baudrate = as_syntax ? NULL : get_media_baudrate_string(ifmw); > +#endif > > if (print_type) > printf("%s ", get_media_type_string(ifmw)); > printf("%s%s", as_syntax ? "media " : "", > - get_media_subtype_string(ifmw)); > + baudrate ? baudrate : get_media_subtype_string(ifmw)); > + > + free(baudrate); > > /* Find mode. */ > if (IFM_MODE(ifmw) != 0) { > --
Re: ifconfig baudrate
> This makes ifconfig display baudrates defined in ifmedia.h tables. > > Before (prints media subtype): > > $ ifconfig iwn0 | grep media: > media: IEEE802.11 autoselect (OFDM6 mode 11a) > $ ifconfig em0 | grep media: > media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) > > After (prints corresponding baudrate): > > $ ifconfig iwn0 | grep media: > media: IEEE802.11 autoselect (6Mbps mode 11a) > $ ifconfig em0 | grep media: > media: Ethernet autoselect (100Mbps full-duplex,rxpause,txpause) > > The output of 'ifconfig media' (which prints command syntax) is unchanged > and we fall back to printing the media subtype if no baudrate is found. It makes no sense to change ethernet. The values it prints now is intended to match what you pass as parameters for the 'media' and 'mediaopt' subcommands. That's why the line is prefixed with the word "media", not "speed". There are legacy options at the 100mbit level: if_media.h: { IFM_ETHER|IFM_100_TX, "100baseTX" }, \ if_media.h: { IFM_ETHER|IFM_100_FX, "100baseFX" }, \ if_media.h: { IFM_ETHER|IFM_100_T4, "100baseT4" }, \ if_media.h: { IFM_ETHER|IFM_100_VG, "100baseVG" }, \ if_media.h: { IFM_ETHER|IFM_100_T2, "100baseT2" }, \ Now they all become the opaque "100Mbps"? Sure many of those don't exist at the moment, or are not used. But look at gig: if_media.h: { IFM_ETHER|IFM_1000_SX,"1000baseSX" }, \ if_media.h: { IFM_ETHER|IFM_1000_SX,"1000SX" }, \ if_media.h: { IFM_ETHER|IFM_1000_LX,"1000baseLX" }, \ if_media.h: { IFM_ETHER|IFM_1000_LX,"1000LX" }, \ if_media.h: { IFM_ETHER|IFM_1000_CX,"1000baseCX" }, \ if_media.h: { IFM_ETHER|IFM_1000_CX,"1000CX" }, \ if_media.h: { IFM_ETHER|IFM_1000_T, "1000baseT" }, \ if_media.h: { IFM_ETHER|IFM_1000_T, "1000T" }, \ if_media.h: { IFM_ETHER|IFM_1000_T, "1000baseTX" }, \ if_media.h: { IFM_ETHER|IFM_1000_T, "1000TX" }, \ this is on cvs: media: Ethernet autoselect (10GSFP+Cu full-duplex) That is information, you'd replace that with a speed? No thanks, it does not make sense.
ifconfig baudrate
This makes ifconfig display baudrates defined in ifmedia.h tables. Before (prints media subtype): $ ifconfig iwn0 | grep media: media: IEEE802.11 autoselect (OFDM6 mode 11a) $ ifconfig em0 | grep media: media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause) After (prints corresponding baudrate): $ ifconfig iwn0 | grep media: media: IEEE802.11 autoselect (6Mbps mode 11a) $ ifconfig em0 | grep media: media: Ethernet autoselect (100Mbps full-duplex,rxpause,txpause) The output of 'ifconfig media' (which prints command syntax) is unchanged and we fall back to printing the media subtype if no baudrate is found. I've kept this disabled in the ramdisk for now. The baudrate table will grow when more 11n features are implemented. Index: ifconfig.c === RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.328 diff -u -p -r1.328 ifconfig.c --- ifconfig.c 31 Aug 2016 13:32:27 - 1.328 +++ ifconfig.c 31 Aug 2016 14:51:36 - @@ -2715,6 +2715,11 @@ const struct ifmedia_description ifm_typ const struct ifmedia_description ifm_subtype_descriptions[] = IFM_SUBTYPE_DESCRIPTIONS; +#ifndef SMALL +const struct ifmedia_baudrate ifm_baudrate_descriptions[] = +IFM_BAUDRATE_DESCRIPTIONS; +#endif + struct ifmedia_description ifm_mode_descriptions[] = IFM_MODE_DESCRIPTIONS; @@ -2748,6 +2753,39 @@ get_media_subtype_string(uint64_t mword) return (""); } +#ifndef SMALL +char * +get_media_baudrate_string(uint64_t mword) +{ + const struct ifmedia_baudrate *ifmb; + char *str; + int ret = -1; + + for (ifmb = ifm_baudrate_descriptions; ifmb->ifmb_word != 0; ifmb++) { + if (!IFM_TYPE_MATCH(ifmb->ifmb_word, mword) || + IFM_SUBTYPE(ifmb->ifmb_word) != IFM_SUBTYPE(mword)) + continue; + + if (ifmb->ifmb_baudrate >= IF_Gbps(1)) + ret = asprintf(, + "%lluGbps", ifmb->ifmb_baudrate / IF_Gbps(1)); + else if (ifmb->ifmb_baudrate >= IF_Mbps(1)) + ret = asprintf(, + "%lluMbps", ifmb->ifmb_baudrate / IF_Mbps(1)); + else if (ifmb->ifmb_baudrate >= IF_Kbps(1)) + ret = asprintf(, + "%lluKbps", ifmb->ifmb_baudrate / IF_Kbps(1)); + else + ret = asprintf(, "%llubps", ifmb->ifmb_baudrate); + + break; + } + if (ret == -1) + str = NULL; + return str; +} +#endif + uint64_t get_media_subtype(uint64_t type, const char *val) { @@ -2818,11 +2856,18 @@ print_media_word(uint64_t ifmw, int prin { const struct ifmedia_description *desc; uint64_t seen_option = 0; + char *baudrate = NULL; + +#ifndef SMALL + baudrate = as_syntax ? NULL : get_media_baudrate_string(ifmw); +#endif if (print_type) printf("%s ", get_media_type_string(ifmw)); printf("%s%s", as_syntax ? "media " : "", - get_media_subtype_string(ifmw)); + baudrate ? baudrate : get_media_subtype_string(ifmw)); + + free(baudrate); /* Find mode. */ if (IFM_MODE(ifmw) != 0) {
passwd(1) - use explicit_bzero(3)
after recents passwd(1) changes, We should use explicit_bzero(3) for clearing these sensitive strings. OK? Index: local_passwd.c === RCS file: /cvs/src/usr.bin/passwd/local_passwd.c,v retrieving revision 1.50 diff -u -p -r1.50 local_passwd.c --- local_passwd.c 31 Aug 2016 12:41:19 - 1.50 +++ local_passwd.c 31 Aug 2016 14:17:40 - @@ -174,8 +174,10 @@ getnewpasswd(struct passwd *pw, login_ca } if (crypt_checkpass(p, pw->pw_passwd) != 0) { errno = EACCES; + explicit_bzero(oldpass, sizeof(oldpass)); pw_error(NULL, 1, 1); } + explicit_bzero(oldpass, sizeof(oldpass)); } } @@ -204,6 +206,7 @@ getnewpasswd(struct passwd *pw, login_ca if (p != NULL && strcmp(newpass, p) == 0) break; (void)printf("Mismatch; try again, EOF to quit.\n"); + explicit_bzero(newpass, sizeof(newpass)); } (void)signal(SIGINT, saveint); @@ -212,8 +215,10 @@ getnewpasswd(struct passwd *pw, login_ca pref = login_getcapstr(lc, "localcipher", NULL, NULL); if (crypt_newhash(newpass, pref, hash, sizeof(hash)) != 0) { (void)printf("Couldn't generate hash.\n"); + explicit_bzero(newpass, sizeof(newpass)); pw_error(NULL, 0, 0); } + explicit_bzero(newpass, sizeof(newpass)); free(pref); return hash; }
Re: Let iked specify its source address when sending
On Wed, Aug 31, 2016 at 04:09:30PM +0200, Reyk Floeter wrote: > On Wed, Aug 31, 2016 at 03:26:53PM +0200, Vincent Gross wrote: > > On Thu, 11 Aug 2016 16:57:27 +0100 > > Stuart Hendersonwrote: > > > > > On 2016/06/27 13:00, J?r?mie Courr?ges-Anglas wrote: > > [...] > > > > > > > > I also gave my ok to vgross by IM. > > > > > > > > I know that some concerns have been exposed privately, I was not > > > > Cc'd, thus I have no idea what is the current status of that > > > > discussion. To the people concerned, please keep me / us updated > > > > about that discussion and Cc us. > > > > > > How are things looking with IN_SENDSRCADDR now, are there any > > > remaining concerns that need fixing before it could be committed? > > > (Also if anyone has a share-able diff to use this with iked it > > > would be quite handy..) > > > > > > > Tested locally with two iked on two distinct rdomains plus a bit of > > LD_PRELOAD goop. Unfortunately I couldn't ping from one rdom to the > > other, but I also have this problem without my patch, so I am confident > > this ping problem is unrelated. > > > > I would be very grateful if someone could test this. > > > > I don't know why you need LD_PRELOAD. > > When testing iked with two different rdomains, you have to create an > enc(4) device per rdomain, or no ipsec traffic will flow. enc0 is for > rdomain 0 only. > > # ifconfig enc1 rdomain up > # ifconfig enc2 rdomain up > # route -T 1 exec iked -ddvvf /etc/iked.conf.1 > # route -T 2 exec iked -ddvvf /etc/iked.conf.2 > > I like the idea of finally using IN_SENDSRCADDR in iked, but I didn't > look at the diff yet. > ... and you connect the two rdomains with pair(4). I used it to test iked locally many times. Reyk > > > > Index: sbin/iked/iked.h > > === > > RCS file: /cvs/src/sbin/iked/iked.h,v > > retrieving revision 1.96 > > diff -u -p -r1.96 iked.h > > --- sbin/iked/iked.h1 Jun 2016 11:16:41 - 1.96 > > +++ sbin/iked/iked.h31 Aug 2016 13:19:10 - > > @@ -898,6 +898,8 @@ int socket_setport(struct sockaddr *, i > > int socket_getaddr(int, struct sockaddr_storage *); > > int socket_bypass(int, struct sockaddr *); > > int udp_bind(struct sockaddr *, in_port_t); > > +ssize_t sendtofrom(int, void *, size_t, int, struct sockaddr *, > > + socklen_t, struct sockaddr *, socklen_t); > > ssize_t recvfromto(int, void *, size_t, int, struct sockaddr *, > > socklen_t *, struct sockaddr *, socklen_t *); > > const char * > > Index: sbin/iked/ikev2_msg.c > > === > > RCS file: /cvs/src/sbin/iked/ikev2_msg.c,v > > retrieving revision 1.45 > > diff -u -p -r1.45 ikev2_msg.c > > --- sbin/iked/ikev2_msg.c 19 Oct 2015 11:25:35 - 1.45 > > +++ sbin/iked/ikev2_msg.c 31 Aug 2016 13:19:10 - > > @@ -319,9 +319,11 @@ ikev2_msg_send(struct iked *env, struct > > msg->msg_offset += sizeof(natt); > > } > > > > - if ((sendto(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0, > > - (struct sockaddr *)>msg_peer, msg->msg_peerlen)) == > > -1) { > > - log_warn("%s: sendto", __func__); > > + if (sendtofrom(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0, > > + (struct sockaddr *)>msg_peer, msg->msg_peerlen, > > + (struct sockaddr *)>msg_local, msg->msg_locallen) < > > + ibuf_size(buf)) { > > + log_warn("%s: sendtofrom", __func__); > > return (-1); > > } > > > > @@ -969,10 +971,12 @@ int > > ikev2_msg_retransmit_response(struct iked *env, struct iked_sa *sa, > > struct iked_message *msg) > > { > > - if ((sendto(msg->msg_fd, ibuf_data(msg->msg_data), > > - ibuf_size(msg->msg_data), 0, (struct sockaddr > > *)>msg_peer, > > - msg->msg_peerlen)) == -1) { > > - log_warn("%s: sendto", __func__); > > + if (sendtofrom(msg->msg_fd, ibuf_data(msg->msg_data), > > + ibuf_size(msg->msg_data), 0, > > + (struct sockaddr *)>msg_peer, msg->msg_peerlen, > > + (struct sockaddr *)>msg_local, msg->msg_locallen) < > > + ibuf_size(msg->msg_data)) { > > + log_warn("%s: sendtofrom", __func__); > > return (-1); > > } > > > > @@ -996,11 +1000,12 @@ ikev2_msg_retransmit_timeout(struct iked > > struct iked_sa *sa = msg->msg_sa; > > > > if (msg->msg_tries < IKED_RETRANSMIT_TRIES) { > > - if ((sendto(msg->msg_fd, ibuf_data(msg->msg_data), > > + if (sendtofrom(msg->msg_fd, ibuf_data(msg->msg_data), > > ibuf_size(msg->msg_data), 0, > > - (struct sockaddr *)>msg_peer, > > - msg->msg_peerlen)) == -1) { > > - log_warn("%s: sendto", __func__); > > + (struct sockaddr *)>msg_peer, > > msg->msg_peerlen, > > + (struct sockaddr *)>msg_local, > >
Re: Let iked specify its source address when sending
On Wed, Aug 31, 2016 at 03:26:53PM +0200, Vincent Gross wrote: > On Thu, 11 Aug 2016 16:57:27 +0100 > Stuart Hendersonwrote: > > > On 2016/06/27 13:00, J?r?mie Courr?ges-Anglas wrote: > [...] > > > > > > I also gave my ok to vgross by IM. > > > > > > I know that some concerns have been exposed privately, I was not > > > Cc'd, thus I have no idea what is the current status of that > > > discussion. To the people concerned, please keep me / us updated > > > about that discussion and Cc us. > > > > How are things looking with IN_SENDSRCADDR now, are there any > > remaining concerns that need fixing before it could be committed? > > (Also if anyone has a share-able diff to use this with iked it > > would be quite handy..) > > > > Tested locally with two iked on two distinct rdomains plus a bit of > LD_PRELOAD goop. Unfortunately I couldn't ping from one rdom to the > other, but I also have this problem without my patch, so I am confident > this ping problem is unrelated. > > I would be very grateful if someone could test this. > I don't know why you need LD_PRELOAD. When testing iked with two different rdomains, you have to create an enc(4) device per rdomain, or no ipsec traffic will flow. enc0 is for rdomain 0 only. # ifconfig enc1 rdomain up # ifconfig enc2 rdomain up # route -T 1 exec iked -ddvvf /etc/iked.conf.1 # route -T 2 exec iked -ddvvf /etc/iked.conf.2 I like the idea of finally using IN_SENDSRCADDR in iked, but I didn't look at the diff yet. Reyk > > Index: sbin/iked/iked.h > === > RCS file: /cvs/src/sbin/iked/iked.h,v > retrieving revision 1.96 > diff -u -p -r1.96 iked.h > --- sbin/iked/iked.h 1 Jun 2016 11:16:41 - 1.96 > +++ sbin/iked/iked.h 31 Aug 2016 13:19:10 - > @@ -898,6 +898,8 @@ intsocket_setport(struct sockaddr *, i > int socket_getaddr(int, struct sockaddr_storage *); > int socket_bypass(int, struct sockaddr *); > int udp_bind(struct sockaddr *, in_port_t); > +ssize_t sendtofrom(int, void *, size_t, int, struct sockaddr *, > + socklen_t, struct sockaddr *, socklen_t); > ssize_t recvfromto(int, void *, size_t, int, struct sockaddr *, > socklen_t *, struct sockaddr *, socklen_t *); > const char * > Index: sbin/iked/ikev2_msg.c > === > RCS file: /cvs/src/sbin/iked/ikev2_msg.c,v > retrieving revision 1.45 > diff -u -p -r1.45 ikev2_msg.c > --- sbin/iked/ikev2_msg.c 19 Oct 2015 11:25:35 - 1.45 > +++ sbin/iked/ikev2_msg.c 31 Aug 2016 13:19:10 - > @@ -319,9 +319,11 @@ ikev2_msg_send(struct iked *env, struct > msg->msg_offset += sizeof(natt); > } > > - if ((sendto(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0, > - (struct sockaddr *)>msg_peer, msg->msg_peerlen)) == > -1) { > - log_warn("%s: sendto", __func__); > + if (sendtofrom(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0, > + (struct sockaddr *)>msg_peer, msg->msg_peerlen, > + (struct sockaddr *)>msg_local, msg->msg_locallen) < > + ibuf_size(buf)) { > + log_warn("%s: sendtofrom", __func__); > return (-1); > } > > @@ -969,10 +971,12 @@ int > ikev2_msg_retransmit_response(struct iked *env, struct iked_sa *sa, > struct iked_message *msg) > { > - if ((sendto(msg->msg_fd, ibuf_data(msg->msg_data), > - ibuf_size(msg->msg_data), 0, (struct sockaddr > *)>msg_peer, > - msg->msg_peerlen)) == -1) { > - log_warn("%s: sendto", __func__); > + if (sendtofrom(msg->msg_fd, ibuf_data(msg->msg_data), > + ibuf_size(msg->msg_data), 0, > + (struct sockaddr *)>msg_peer, msg->msg_peerlen, > + (struct sockaddr *)>msg_local, msg->msg_locallen) < > + ibuf_size(msg->msg_data)) { > + log_warn("%s: sendtofrom", __func__); > return (-1); > } > > @@ -996,11 +1000,12 @@ ikev2_msg_retransmit_timeout(struct iked > struct iked_sa *sa = msg->msg_sa; > > if (msg->msg_tries < IKED_RETRANSMIT_TRIES) { > - if ((sendto(msg->msg_fd, ibuf_data(msg->msg_data), > + if (sendtofrom(msg->msg_fd, ibuf_data(msg->msg_data), > ibuf_size(msg->msg_data), 0, > - (struct sockaddr *)>msg_peer, > - msg->msg_peerlen)) == -1) { > - log_warn("%s: sendto", __func__); > + (struct sockaddr *)>msg_peer, > msg->msg_peerlen, > + (struct sockaddr *)>msg_local, > msg->msg_locallen) < > + ibuf_size(msg->msg_data)) { > + log_warn("%s: sendtofrom", __func__); > sa_free(env, sa); > return; > } > Index: sbin/iked/util.c > === > RCS file:
Re: Let iked specify its source address when sending
On Wed, 31 Aug 2016 15:26:53 +0200 Vincent Grosswrote: > On Thu, 11 Aug 2016 16:57:27 +0100 > Stuart Henderson wrote: > > > On 2016/06/27 13:00, Jérémie Courrèges-Anglas wrote: > [...] > > > > > > I also gave my ok to vgross by IM. > > > > > > I know that some concerns have been exposed privately, I was not > > > Cc'd, thus I have no idea what is the current status of that > > > discussion. To the people concerned, please keep me / us updated > > > about that discussion and Cc us. > > > > How are things looking with IN_SENDSRCADDR now, are there any > > remaining concerns that need fixing before it could be committed? > > (Also if anyone has a share-able diff to use this with iked it > > would be quite handy..) > > > > Tested locally with two iked on two distinct rdomains plus a bit of > LD_PRELOAD goop. Unfortunately I couldn't ping from one rdom to the > other, but I also have this problem without my patch, so I am > confident this ping problem is unrelated. > > I would be very grateful if someone could test this. > Take two, unmangled version : Index: sbin/iked/iked.h === RCS file: /cvs/src/sbin/iked/iked.h,v retrieving revision 1.96 diff -u -p -r1.96 iked.h --- sbin/iked/iked.h1 Jun 2016 11:16:41 - 1.96 +++ sbin/iked/iked.h31 Aug 2016 13:19:10 - @@ -898,6 +898,8 @@ int socket_setport(struct sockaddr *, i int socket_getaddr(int, struct sockaddr_storage *); int socket_bypass(int, struct sockaddr *); int udp_bind(struct sockaddr *, in_port_t); +ssize_t sendtofrom(int, void *, size_t, int, struct sockaddr *, + socklen_t, struct sockaddr *, socklen_t); ssize_t recvfromto(int, void *, size_t, int, struct sockaddr *, socklen_t *, struct sockaddr *, socklen_t *); const char * Index: sbin/iked/ikev2_msg.c === RCS file: /cvs/src/sbin/iked/ikev2_msg.c,v retrieving revision 1.45 diff -u -p -r1.45 ikev2_msg.c --- sbin/iked/ikev2_msg.c 19 Oct 2015 11:25:35 - 1.45 +++ sbin/iked/ikev2_msg.c 31 Aug 2016 13:19:10 - @@ -319,9 +319,11 @@ ikev2_msg_send(struct iked *env, struct msg->msg_offset += sizeof(natt); } - if ((sendto(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0, - (struct sockaddr *)>msg_peer, msg->msg_peerlen)) == -1) { - log_warn("%s: sendto", __func__); + if (sendtofrom(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0, + (struct sockaddr *)>msg_peer, msg->msg_peerlen, + (struct sockaddr *)>msg_local, msg->msg_locallen) < + ibuf_size(buf)) { + log_warn("%s: sendtofrom", __func__); return (-1); } @@ -969,10 +971,12 @@ int ikev2_msg_retransmit_response(struct iked *env, struct iked_sa *sa, struct iked_message *msg) { - if ((sendto(msg->msg_fd, ibuf_data(msg->msg_data), - ibuf_size(msg->msg_data), 0, (struct sockaddr *)>msg_peer, - msg->msg_peerlen)) == -1) { - log_warn("%s: sendto", __func__); + if (sendtofrom(msg->msg_fd, ibuf_data(msg->msg_data), + ibuf_size(msg->msg_data), 0, + (struct sockaddr *)>msg_peer, msg->msg_peerlen, + (struct sockaddr *)>msg_local, msg->msg_locallen) < + ibuf_size(msg->msg_data)) { + log_warn("%s: sendtofrom", __func__); return (-1); } @@ -996,11 +1000,12 @@ ikev2_msg_retransmit_timeout(struct iked struct iked_sa *sa = msg->msg_sa; if (msg->msg_tries < IKED_RETRANSMIT_TRIES) { - if ((sendto(msg->msg_fd, ibuf_data(msg->msg_data), + if (sendtofrom(msg->msg_fd, ibuf_data(msg->msg_data), ibuf_size(msg->msg_data), 0, - (struct sockaddr *)>msg_peer, - msg->msg_peerlen)) == -1) { - log_warn("%s: sendto", __func__); + (struct sockaddr *)>msg_peer, msg->msg_peerlen, + (struct sockaddr *)>msg_local, msg->msg_locallen) < + ibuf_size(msg->msg_data)) { + log_warn("%s: sendtofrom", __func__); sa_free(env, sa); return; } Index: sbin/iked/util.c === RCS file: /cvs/src/sbin/iked/util.c,v retrieving revision 1.30 diff -u -p -r1.30 util.c --- sbin/iked/util.c23 Nov 2015 19:28:34 - 1.30 +++ sbin/iked/util.c31 Aug 2016 13:19:10 - @@ -287,6 +287,57 @@ sockaddr_cmp(struct sockaddr *a, struct } ssize_t +sendtofrom(int s, void *buf, size_t len, int flags, struct sockaddr *to, +socklen_t tolen, struct sockaddr *from, socklen_t fromlen) +{ + struct iovec iov; + struct msghdr
regression tests and patch for calendar(1)
Hello, While writing a set of regression tests for calendar(1) I discovered a bug introduced by my last patch. The following patch fixes that and all regression tests in the attachment of tests passes. Thanks, Andy Index: day.c === RCS file: /home/cvs/src/usr.bin/calendar/day.c,v retrieving revision 1.33 diff -u -p -r1.33 day.c --- day.c 13 Jul 2016 21:32:01 - 1.33 +++ day.c 31 Aug 2016 13:40:01 - @@ -543,7 +543,9 @@ isnow(char *endp, int bodun) tdiff = difftime(ttmp, f_time)/ SECSPERDAY; if (tdiff <= offset + f_dayAfter || (bodun && tdiff == -1)) { - if ((tmtmp.tm_mon == month) && + if (((tmtmp.tm_mon == month) || +(flags & F_SPECIAL) || +(interval == WEEKLY)) && (tdiff >= 0 || (bodun && tdiff == -1))) { if ((tmp = malloc(sizeof(struct match))) == NULL) calendar-regress.tar.gz Description: calendar-regress.tar.gz
Re: switch the cubie miniroot to cubieboard2
Speaking as a Cubieboard owner here ;-) Would it be too much hassle to provide both images? (and a pony!) -- Marco Bonetti
dhclient: Kill 'ifi' global
In order to properly separate some of dhclient's components I'd like to make clear which functions depend on the state of an interface. So the diff attached removes the 'ifi' global and passes it as an argument where necessary. One interesting place to look at are the timeouts that are now getting a "void *" just like in kernel. ok? Index: dhclient.c === RCS file: /cvs/src/sbin/dhclient/dhclient.c,v retrieving revision 1.382 diff -u -p -r1.382 dhclient.c --- dhclient.c 31 Aug 2016 12:57:31 - 1.382 +++ dhclient.c 31 Aug 2016 13:21:10 - @@ -111,7 +111,6 @@ struct in_addr adding; const struct in_addr inaddr_any = { INADDR_ANY }; const struct in_addr inaddr_broadcast = { INADDR_BROADCAST }; -struct interface_info *ifi; struct client_config *config; struct imsgbuf *unpriv_ibuf; @@ -121,12 +120,13 @@ struct sockaddr *get_ifa(char *, int); void usage(void); int res_hnok(const char *dn); int res_hnok_list(const char *dn); -int addressinuse(struct in_addr, char *); +int addressinuse(struct interface_info *, struct in_addr, char *); -void fork_privchld(int, int); -void get_ifname(char *); -char *resolv_conf_contents(struct option_data *, - struct option_data *, struct option_data *); +void fork_privchld(struct interface_info *, int, int); +void get_ifname(struct interface_info *, char *); +char *resolv_conf_contents(struct interface_info *ifi, + struct option_data *, struct option_data *, + struct option_data *); void write_resolv_conf(u_int8_t *, size_t); void write_option_db(u_int8_t *, size_t); @@ -142,28 +142,30 @@ void add_classless_static_routes(struct int compare_lease(struct client_lease *, struct client_lease *); void set_lease_times(struct client_lease *); -void state_preboot(void); -void state_reboot(void); -void state_init(void); -void state_selecting(void); -void state_bound(void); -void state_panic(void); - -void send_discover(void); -void send_request(void); -void send_decline(void); - -void bind_lease(void); - -void make_discover(struct client_lease *); -void make_request(struct client_lease *); -void make_decline(struct client_lease *); - -void rewrite_client_leases(void); -void rewrite_option_db(struct client_lease *, struct client_lease *); -char *lease_as_string(char *, struct client_lease *); +void state_preboot(void *); +void state_reboot(void *); +void state_init(void *); +void state_selecting(void *); +void state_bound(void *); +void state_panic(void *); + +void send_discover(void *); +void send_request(void *); +void send_decline(void *); + +void bind_lease(struct interface_info *); + +void make_discover(struct interface_info *, struct client_lease *); +void make_request(struct interface_info *, struct client_lease *); +void make_decline(struct interface_info *, struct client_lease *); + +void rewrite_client_leases(struct interface_info *); +void rewrite_option_db(struct interface_info *, struct client_lease *, +struct client_lease *); +char *lease_as_string(struct interface_info *, char *, struct client_lease *); -struct client_lease *packet_to_lease(struct in_addr, struct option_data *); +struct client_lease *packet_to_lease(struct interface_info *, struct in_addr, +struct option_data *); void go_daemon(void); #define ROUNDUP(a) \ @@ -228,7 +230,7 @@ get_ifa(char *cp, int n) } void -routehandler(void) +routehandler(struct interface_info *ifi) { struct client_state *client = ifi->client; char ntoabuf[INET_ADDRSTRLEN]; @@ -378,11 +380,11 @@ routehandler(void) ifi->linkstat = linkstat; if (ifi->linkstat) { if (client->state == S_PREBOOT) { - state_preboot(); + state_preboot(ifi); get_hw_address(ifi); } else { client->state = S_REBOOTING; - state_reboot(); + state_reboot(ifi); } } else { /* Let monitoring programs see link loss. */ @@ -426,6 +428,7 @@ char **saved_argv; int main(int argc, char *argv[]) { + struct interface_info *ifi; struct ifreq ifr; struct ieee80211_nwid nwid; struct stat sb; @@ -496,7 +499,7 @@ main(int argc, char *argv[]) ifi = calloc(1, sizeof(struct interface_info)); if (ifi == NULL) error("ifi calloc"); - get_ifname(argv[0]); + get_ifname(ifi, argv[0]); ifi->index = if_nametoindex(ifi->name); if (ifi->index == 0) error("%s: no such interface", ifi->name); @@ -526,7 +529,7 @@ main(int argc, char *argv[]) PF_UNSPEC, socket_fd) == -1) error("socketpair: %s", strerror(errno)); - fork_privchld(socket_fd[0], socket_fd[1]); + fork_privchld(ifi, socket_fd[0], socket_fd[1]); close(socket_fd[0]); if ((unpriv_ibuf = malloc(sizeof(struct imsgbuf))) == NULL) @@ -594,7 +597,7 @@ main(int argc, char *argv[]) read_client_leases(ifi); if ((leaseFile = fopen(path_dhclient_db, "w")) == NULL) error("can't open %s: %s", path_dhclient_db, strerror(errno)); - rewrite_client_leases(); + rewrite_client_leases(ifi);
Let iked specify its source address when sending
On Thu, 11 Aug 2016 16:57:27 +0100 Stuart Hendersonwrote: > On 2016/06/27 13:00, Jérémie Courrèges-Anglas wrote: [...] > > > > I also gave my ok to vgross by IM. > > > > I know that some concerns have been exposed privately, I was not > > Cc'd, thus I have no idea what is the current status of that > > discussion. To the people concerned, please keep me / us updated > > about that discussion and Cc us. > > How are things looking with IN_SENDSRCADDR now, are there any > remaining concerns that need fixing before it could be committed? > (Also if anyone has a share-able diff to use this with iked it > would be quite handy..) > Tested locally with two iked on two distinct rdomains plus a bit of LD_PRELOAD goop. Unfortunately I couldn't ping from one rdom to the other, but I also have this problem without my patch, so I am confident this ping problem is unrelated. I would be very grateful if someone could test this. Index: sbin/iked/iked.h === RCS file: /cvs/src/sbin/iked/iked.h,v retrieving revision 1.96 diff -u -p -r1.96 iked.h --- sbin/iked/iked.h1 Jun 2016 11:16:41 - 1.96 +++ sbin/iked/iked.h31 Aug 2016 13:19:10 - @@ -898,6 +898,8 @@ int socket_setport(struct sockaddr *, i int socket_getaddr(int, struct sockaddr_storage *); int socket_bypass(int, struct sockaddr *); int udp_bind(struct sockaddr *, in_port_t); +ssize_t sendtofrom(int, void *, size_t, int, struct sockaddr *, + socklen_t, struct sockaddr *, socklen_t); ssize_t recvfromto(int, void *, size_t, int, struct sockaddr *, socklen_t *, struct sockaddr *, socklen_t *); const char * Index: sbin/iked/ikev2_msg.c === RCS file: /cvs/src/sbin/iked/ikev2_msg.c,v retrieving revision 1.45 diff -u -p -r1.45 ikev2_msg.c --- sbin/iked/ikev2_msg.c 19 Oct 2015 11:25:35 - 1.45 +++ sbin/iked/ikev2_msg.c 31 Aug 2016 13:19:10 - @@ -319,9 +319,11 @@ ikev2_msg_send(struct iked *env, struct msg->msg_offset += sizeof(natt); } - if ((sendto(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0, - (struct sockaddr *)>msg_peer, msg->msg_peerlen)) == -1) { - log_warn("%s: sendto", __func__); + if (sendtofrom(msg->msg_fd, ibuf_data(buf), ibuf_size(buf), 0, + (struct sockaddr *)>msg_peer, msg->msg_peerlen, + (struct sockaddr *)>msg_local, msg->msg_locallen) < + ibuf_size(buf)) { + log_warn("%s: sendtofrom", __func__); return (-1); } @@ -969,10 +971,12 @@ int ikev2_msg_retransmit_response(struct iked *env, struct iked_sa *sa, struct iked_message *msg) { - if ((sendto(msg->msg_fd, ibuf_data(msg->msg_data), - ibuf_size(msg->msg_data), 0, (struct sockaddr *)>msg_peer, - msg->msg_peerlen)) == -1) { - log_warn("%s: sendto", __func__); + if (sendtofrom(msg->msg_fd, ibuf_data(msg->msg_data), + ibuf_size(msg->msg_data), 0, + (struct sockaddr *)>msg_peer, msg->msg_peerlen, + (struct sockaddr *)>msg_local, msg->msg_locallen) < + ibuf_size(msg->msg_data)) { + log_warn("%s: sendtofrom", __func__); return (-1); } @@ -996,11 +1000,12 @@ ikev2_msg_retransmit_timeout(struct iked struct iked_sa *sa = msg->msg_sa; if (msg->msg_tries < IKED_RETRANSMIT_TRIES) { - if ((sendto(msg->msg_fd, ibuf_data(msg->msg_data), + if (sendtofrom(msg->msg_fd, ibuf_data(msg->msg_data), ibuf_size(msg->msg_data), 0, - (struct sockaddr *)>msg_peer, - msg->msg_peerlen)) == -1) { - log_warn("%s: sendto", __func__); + (struct sockaddr *)>msg_peer, msg->msg_peerlen, + (struct sockaddr *)>msg_local, msg->msg_locallen) < + ibuf_size(msg->msg_data)) { + log_warn("%s: sendtofrom", __func__); sa_free(env, sa); return; } Index: sbin/iked/util.c === RCS file: /cvs/src/sbin/iked/util.c,v retrieving revision 1.30 diff -u -p -r1.30 util.c --- sbin/iked/util.c23 Nov 2015 19:28:34 - 1.30 +++ sbin/iked/util.c31 Aug 2016 13:19:10 - @@ -287,6 +287,57 @@ sockaddr_cmp(struct sockaddr *a, struct } ssize_t +sendtofrom(int s, void *buf, size_t len, int flags, struct sockaddr *to, +socklen_t tolen, struct sockaddr *from, socklen_t fromlen) +{ + struct iovec iov; + struct msghdrmsg; + struct cmsghdr *cmsg; + struct in6_pktinfo *pkt6; + struct sockaddr_in *in; + struct sockaddr_in6
Re: ksh cd two args
On Wed, Aug 31, 2016 at 01:53:30PM +0100, Theo Buehler wrote: > On Wed, Aug 31, 2016 at 08:39:51AM -0400, Ted Unangst wrote: > > About ten times a day I do something like this: > > $ cd cd tedu > > ksh: cd: bad substitution > > > > What does that even mean? According to the source, but not the manual, there > > is some two argument cd syntax which substitutes something. I have never > > once > > tried to do this on purpose. > > > > Thus, I think the error message should be changed to be more appropriate. > > Those few power users who try to substitute paths can probably deal with the > > error message better than I can. > > But the error message "too many arguments" doesn't make sense for the > two-argument cd. The two-argument cd is documented: > > cd [-LP] old new > The string new is substituted for old in the current > directory, > and the shell attempts to change to the new directory. I agree. Feel free to improve the error message, but please keep it accurate. As for how I (albeit rarely) have used it: $ pwd /usr/src/usr.bin/ssh $ cd src src/regress /usr/src/regress/usr.bin/ssh $ pwd /usr/src/regress/usr.bin/ssh /Alexander
Array of TAILQs in kern_synch.c
There is what appears to be a sensless hash in kern_synch.c. It's an array of 128 TAILQs which are hashed according to the high bits of the wchan. It's possible to write a program that adds kern.maxthread entries to one of those TAILQs. Just running chrome with 11 tabs open adds 35 entries to one TAILQ, while leaving others empty. If it doesn't matter that a user program can make a TAILQ very long, then the hash is senseless (diff below). If it does matter, then it's broken, and a different data structure needs to be used. Currently RB trees require all element values to be unique, but a version of RB trees with non-unique element values is possible. Any thoughts? Index: sys/kern/kern_synch.c === RCS file: /cvs/src/sys/kern/kern_synch.c,v retrieving revision 1.133 diff -u -p -r1.133 kern_synch.c --- sys/kern/kern_synch.c 6 Jul 2016 15:53:01 - 1.133 +++ sys/kern/kern_synch.c 31 Aug 2016 12:54:40 - @@ -61,22 +61,12 @@ intthrsleep(struct proc *, struct sys___thrsleep_args *); intthrsleep_unlock(void *, int); -/* - * We're only looking at 7 bits of the address; everything is - * aligned to 4, lots of things are aligned to greater powers - * of 2. Shift right by 8, i.e. drop the bottom 256 worth. - */ -#define TABLESIZE 128 -#define LOOKUP(x) (((long)(x) >> 8) & (TABLESIZE - 1)) -TAILQ_HEAD(slpque,proc) slpque[TABLESIZE]; +TAILQ_HEAD(slpque,proc) slpque; void sleep_queue_init(void) { - int i; - - for (i = 0; i < TABLESIZE; i++) - TAILQ_INIT([i]); + TAILQ_INIT(); } @@ -251,7 +241,7 @@ sleep_setup(struct sleep_state *sls, con p->p_wmesg = wmesg; p->p_slptime = 0; p->p_priority = prio & PRIMASK; - TAILQ_INSERT_TAIL([LOOKUP(ident)], p, p_runq); + TAILQ_INSERT_TAIL(, p, p_runq); } void @@ -385,7 +375,7 @@ unsleep(struct proc *p) SCHED_ASSERT_LOCKED(); if (p->p_wchan) { - TAILQ_REMOVE([LOOKUP(p->p_wchan)], p, p_runq); + TAILQ_REMOVE(, p, p_runq); p->p_wchan = NULL; } } @@ -396,14 +386,12 @@ unsleep(struct proc *p) void wakeup_n(const volatile void *ident, int n) { - struct slpque *qp; struct proc *p; struct proc *pnext; int s; SCHED_LOCK(s); - qp = [LOOKUP(ident)]; - for (p = TAILQ_FIRST(qp); p != NULL && n != 0; p = pnext) { + for (p = TAILQ_FIRST(); p != NULL && n != 0; p = pnext) { pnext = TAILQ_NEXT(p, p_runq); #ifdef DIAGNOSTIC if (p->p_stat != SSLEEP && p->p_stat != SSTOP) @@ -412,7 +400,7 @@ wakeup_n(const volatile void *ident, int if (p->p_wchan == ident) { --n; p->p_wchan = 0; - TAILQ_REMOVE(qp, p, p_runq); + TAILQ_REMOVE(, p, p_runq); if (p->p_stat == SSLEEP) setrunnable(p); } -- Michal Mazurek
Re: ksh cd two args
On Wed, Aug 31, 2016 at 08:39:51AM -0400, Ted Unangst wrote: > About ten times a day I do something like this: > $ cd cd tedu > ksh: cd: bad substitution > > What does that even mean? According to the source, but not the manual, there > is some two argument cd syntax which substitutes something. I have never once > tried to do this on purpose. > > Thus, I think the error message should be changed to be more appropriate. > Those few power users who try to substitute paths can probably deal with the > error message better than I can. But the error message "too many arguments" doesn't make sense for the two-argument cd. The two-argument cd is documented: cd [-LP] old new The string new is substituted for old in the current directory, and the shell attempts to change to the new directory.
Re: remove ifdef from ftpd
Jeremie Courreges-Anglas wrote: > > As discussed I prefer this direction, but: > - the fgets code will make the server hang > - it's not the ftp user's business to know that IPv4 mapped addresses > aren't supported. I'd rather log something to syslog. yeah, ok
Re: vmd: cleaning up virtio.c
On Wed, Aug 31, 2016 at 06:04:22AM -0600, nayden wrote: > Addressing "this function needs a cleanup block, lots of free(blah); return > (0)" > comment for vioblk_notifyq() and doing the same for vionet_enq_rx(). > go for it, thanks. > Index: virtio.c > === > RCS file: /home/nayden/cvsync/src/usr.sbin/vmd/virtio.c,v > retrieving revision 1.17 > diff -u -p -r1.17 virtio.c > --- virtio.c 17 Aug 2016 05:07:13 - 1.17 > +++ virtio.c 31 Aug 2016 10:35:55 - > @@ -353,8 +353,7 @@ vioblk_do_write(struct vioblk_dev *dev, > } > > /* > - * XXX this function needs a cleanup block, lots of free(blah); return (0) > - * in various cases, ds should be set to VIRTIO_BLK_S_IOERR, if we can > + * XXX in various cases, ds should be set to VIRTIO_BLK_S_IOERR, if we can > * XXX cant trust ring data from VM, be extra cautious. > */ > int > @@ -390,8 +389,7 @@ vioblk_notifyq(struct vioblk_dev *dev) > > if (read_mem(q_gpa, vr, vr_sz)) { > log_warnx("error reading gpa 0x%llx", q_gpa); > - free(vr); > - return (0); > + goto out; > } > > /* Compute offsets in ring of descriptors, avail ring, and used ring */ > @@ -406,8 +404,7 @@ vioblk_notifyq(struct vioblk_dev *dev) > > if ((avail->idx & VIOBLK_QUEUE_MASK) == idx) { > log_warnx("vioblk queue notify - nothing to do?"); > - free(vr); > - return (0); > + goto out; > } > > cmd_desc_idx = avail->ring[idx] & VIOBLK_QUEUE_MASK; > @@ -416,16 +413,14 @@ vioblk_notifyq(struct vioblk_dev *dev) > if ((cmd_desc->flags & VRING_DESC_F_NEXT) == 0) { > log_warnx("unchained vioblk cmd descriptor received " > "(idx %d)", cmd_desc_idx); > - free(vr); > - return (0); > + goto out; > } > > /* Read command from descriptor ring */ > if (read_mem(cmd_desc->addr, , cmd_desc->len)) { > log_warnx("vioblk: command read_mem error @ 0x%llx", > cmd_desc->addr); > - free(vr); > - return (0); > + goto out; > } > > switch (cmd.type) { > @@ -437,8 +432,7 @@ vioblk_notifyq(struct vioblk_dev *dev) > if ((secdata_desc->flags & VRING_DESC_F_NEXT) == 0) { > log_warnx("unchained vioblk data descriptor " > "received (idx %d)", cmd_desc_idx); > - free(vr); > - return (0); > + goto out; > } > > secbias = 0; > @@ -453,8 +447,7 @@ vioblk_notifyq(struct vioblk_dev *dev) > if (secdata == NULL) { > log_warnx("vioblk: block read error, " > "sector %lld", cmd.sector); > - free(vr); > - return (0); > + goto out; > } > > if (write_mem(secdata_desc->addr, secdata, > @@ -463,9 +456,8 @@ vioblk_notifyq(struct vioblk_dev *dev) > "data to gpa @ 0x%llx", > secdata_desc->addr); > dump_descriptor_chain(desc, cmd_desc_idx); > - free(vr); > free(secdata); > - return (0); > + goto out; > } > > free(secdata); > @@ -484,8 +476,7 @@ vioblk_notifyq(struct vioblk_dev *dev) > log_warnx("can't write device status data @ " > "0x%llx", ds_desc->addr); > dump_descriptor_chain(desc, cmd_desc_idx); > - free(vr); > - return (0); > + goto out; > } > > > @@ -509,16 +500,14 @@ vioblk_notifyq(struct vioblk_dev *dev) > if ((secdata_desc->flags & VRING_DESC_F_NEXT) == 0) { > log_warnx("wr vioblk: unchained vioblk data " > "descriptor received (idx %d)", cmd_desc_idx); > - free(vr); > - return (0); > + goto out; > } > > secdata = malloc(MAXPHYS); > if (secdata == NULL) { > log_warn("wr vioblk: malloc error, len %d", > secdata_desc->len); > - free(vr); > - return (0); > + goto out; > } > > secbias = 0; > @@ -529,17 +518,15 @@ vioblk_notifyq(struct vioblk_dev *dev) > "sector data @ 0x%llx", > secdata_desc->addr); >
ksh cd two args
About ten times a day I do something like this: $ cd cd tedu ksh: cd: bad substitution What does that even mean? According to the source, but not the manual, there is some two argument cd syntax which substitutes something. I have never once tried to do this on purpose. Thus, I think the error message should be changed to be more appropriate. Those few power users who try to substitute paths can probably deal with the error message better than I can. Index: c_ksh.c === RCS file: /cvs/src/bin/ksh/c_ksh.c,v retrieving revision 1.50 diff -u -p -r1.50 c_ksh.c --- c_ksh.c 21 Mar 2016 13:35:00 - 1.50 +++ c_ksh.c 31 Aug 2016 12:36:53 - @@ -82,7 +82,7 @@ c_cd(char **wp) * we don't */ if ((cp = strstr(current_wd, wp[0])) == NULL) { - bi_errorf("bad substitution"); + bi_errorf("too many arguments"); return 1; } ilen = cp - current_wd;
Re: ifconfig setinstance -> setrdomain
Stefan Sperlingwrites: > 'instance' is the name of an ifconfig subcommand related to ifmedia > so the name of the setinstance() function is slightly confusing. ok -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: RSSI values
Stefan Sperlingwrites: > ifconfig scan displays RSSI (received signal strength indicator) values. > > If the driver sets ic->ic_max_rssi the value is displayed as a percentage > of ic_max_rssi. Otherwise ifconfig displays the value as dBm. > > The problem in the dBm case is that many drivers end up reporting a positive > value. The range for 802.11 networks is -10dBm to -100dBm (wikipedia has a > table at https://en.wikipedia.org/wiki/DBm). > > In January 2016 sthen@ fixed this problem for some drivers by converting > from an unsigned value to a signed value at the ioctl boundary. > This approach works for drivers which report values in the (unsigned) range > 128 - 255. But there are some drivers which report RSSI values in the 20 to > 100 range. These are fixed by the diff below. Makes sense, ok jca@. Nit below. > A few drivers report bogus values altogether, and some always report the > same value. I'm not going to bother fixing those. > > Index: ieee80211_ioctl.c > === > RCS file: /cvs/src/sys/net80211/ieee80211_ioctl.c,v > retrieving revision 1.42 > diff -u -p -r1.42 ieee80211_ioctl.c > --- ieee80211_ioctl.c 15 Aug 2016 22:14:19 - 1.42 > +++ ieee80211_ioctl.c 30 Aug 2016 15:36:50 - > @@ -60,6 +60,8 @@ void > ieee80211_node2req(struct ieee80211com *ic, const struct ieee80211_node *ni, > struct ieee80211_nodereq *nr) > { > + uint8_t rssi; > + > /* Node address and name information */ > IEEE80211_ADDR_COPY(nr->nr_macaddr, ni->ni_macaddr); > IEEE80211_ADDR_COPY(nr->nr_bssid, ni->ni_bssid); > @@ -73,7 +75,19 @@ ieee80211_node2req(struct ieee80211com * > bcopy(ni->ni_rates.rs_rates, nr->nr_rates, IEEE80211_RATE_MAXSIZE); > > /* Node status information */ > - nr->nr_rssi = (*ic->ic_node_getrssi)(ic, ni); > + rssi = (*ic->ic_node_getrssi)(ic, ni); > + if (ic->ic_max_rssi) { > + /* Driver reports RSSI relative to ic_max_rssi. */ > + nr->nr_rssi = rssi; > + } else { > + /* trailing space > + * Driver reports RSSI value in dBm. > + * Convert from unsigned to signed. > + * Some drivers report a negative value, some don't. > + * Reasonable range is -20dBm to -80dBm. > + */ > + nr->nr_rssi = (rssi < 128) ? -rssi : rssi; > + } > nr->nr_max_rssi = ic->ic_max_rssi; > bcopy(ni->ni_tstamp, nr->nr_tstamp, sizeof(nr->nr_tstamp)); > nr->nr_intval = ni->ni_intval; > -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: ifconfig setinstance -> setrdomain
On Wed, Aug 31, 2016 at 02:23:00PM +0200, Stefan Sperling wrote: > 'instance' is the name of an ifconfig subcommand related to ifmedia > so the name of the setinstance() function is slightly confusing. OK > Index: ifconfig.c > === > RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v > retrieving revision 1.327 > diff -u -p -r1.327 ifconfig.c > --- ifconfig.c19 Aug 2016 09:06:24 - 1.327 > +++ ifconfig.c31 Aug 2016 12:19:48 - > @@ -218,7 +218,7 @@ void unsetvlandev(const char *, int); > void mpe_status(void); > void mpw_status(void); > void vlan_status(void); > -void setinstance(const char *, int); > +void setrdomain(const char *, int); > int main(int, char *[]); > int prefix(void *val, int); > void getifgroups(void); > @@ -392,7 +392,7 @@ const struct cmd { > { "priority", NEXTARG,0, setifpriority }, > { "rtlabel",NEXTARG,0, setifrtlabel }, > { "-rtlabel", -1, 0, setifrtlabel }, > - { "rdomain",NEXTARG,0, setinstance }, > + { "rdomain",NEXTARG,0, setrdomain }, > { "mpls", IFXF_MPLS, 0, setifxflags }, > { "-mpls", -IFXF_MPLS, 0, setifxflags }, > { "mplslabel", NEXTARG,0, setmpelabel }, > @@ -5675,7 +5675,7 @@ setiflladdr(const char *addr, int param) > > #ifndef SMALL > void > -setinstance(const char *id, int param) > +setrdomain(const char *id, int param) > { > const char *errmsg = NULL; > int rdomainid; > -- :wq Claudio
Re: hashfree: sizes for free(9) when using hashinit.
Mathieu - wrote: > Hello list, > > I'm introducing hashfree, a counterpart to hashinit in order to pass the > size to free(9) while hiding the implementation details. > Most of the api users are converted in the patch below, those not > included just simply do not free the memory (pid hash table etc). All, > except for one case, the input hashtbl in in_pcb, because at free time > the size is really not known, so it needs more moving of things around > and is out the scope of this patch. > > Manpage diff courtesy of natano@ on an old version of the diff! looks good
Re: remove ifdef from ftpd
"Ted Unangst"writes: > Jeremie Courreges-Anglas wrote: >> I think that's a better choice. >> >> > >> >> >> >> > -#else >> >> > - while (fgets(line, sizeof(line), fd) != NULL) { >> >> > - line[strcspn(line, "\n")] = '\0'; >> >> > - lreply(530, "%s", line); >> >> > - } >> >> > - (void) fflush(stdout); >> >> > - (void) close(fd); >> >> No need for the two lines above. > > this flips the code. to make the changes easier to read, left the old code in > place for a bit. that'll then be deleted. As discussed I prefer this direction, but: - the fgets code will make the server hang - it's not the ftp user's business to know that IPv4 mapped addresses aren't supported. I'd rather log something to syslog. Here's the diff I've just tried, obviously not intended for commit as-is. user POV ritchie ~$ ftp ::1 Connected to ::1. 530 System not available. xferlog Aug 31 13:17:29 ritchie ftpd[44886]: Connection from IPv4 mapped address is not supported. Index: ftpd.c === RCS file: /cvs/src/libexec/ftpd/ftpd.c,v retrieving revision 1.220 diff -u -p -p -u -r1.220 ftpd.c --- ftpd.c 30 Aug 2016 14:56:39 - 1.220 +++ ftpd.c 31 Aug 2016 12:18:41 - @@ -524,9 +524,10 @@ main(int argc, char *argv[]) syslog(LOG_ERR, "getsockname: %m"); exit(1); } - if (his_addr.su_family == AF_INET6 && - IN6_IS_ADDR_V4MAPPED(_addr.su_sin6.sin6_addr)) { -#if 1 +// if (his_addr.su_family == AF_INET6 && +// IN6_IS_ADDR_V4MAPPED(_addr.su_sin6.sin6_addr)) { + if (his_addr.su_family == AF_INET6) { +#if 0 /* * IPv4 control connection arrived to AF_INET6 socket. * I hate to do this, but this is the easiest solution. @@ -552,15 +553,10 @@ main(int argc, char *argv[]) sizeof(ctrl_addr.su_sin.sin_addr)); ctrl_addr.su_sin.sin_port = tmp_addr.su_sin6.sin6_port; #else - while (fgets(line, sizeof(line), fd) != NULL) { - line[strcspn(line, "\n")] = '\0'; - lreply(530, "%s", line); - } - (void) fflush(stdout); - (void) close(fd); - reply(530, - "Connection from IPv4 mapped address is not supported."); - exit(0); + syslog(LOG_WARNING, + "Connection from IPv4 mapped address is not supported."); + reply(530, "System not available."); + exit(1); #endif } if (his_addr.su_family == AF_INET) { -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
ifconfig setinstance -> setrdomain
'instance' is the name of an ifconfig subcommand related to ifmedia so the name of the setinstance() function is slightly confusing. Index: ifconfig.c === RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.327 diff -u -p -r1.327 ifconfig.c --- ifconfig.c 19 Aug 2016 09:06:24 - 1.327 +++ ifconfig.c 31 Aug 2016 12:19:48 - @@ -218,7 +218,7 @@ voidunsetvlandev(const char *, int); void mpe_status(void); void mpw_status(void); void vlan_status(void); -void setinstance(const char *, int); +void setrdomain(const char *, int); intmain(int, char *[]); intprefix(void *val, int); void getifgroups(void); @@ -392,7 +392,7 @@ const structcmd { { "priority", NEXTARG,0, setifpriority }, { "rtlabel",NEXTARG,0, setifrtlabel }, { "-rtlabel", -1, 0, setifrtlabel }, - { "rdomain",NEXTARG,0, setinstance }, + { "rdomain",NEXTARG,0, setrdomain }, { "mpls", IFXF_MPLS, 0, setifxflags }, { "-mpls", -IFXF_MPLS, 0, setifxflags }, { "mplslabel", NEXTARG,0, setmpelabel }, @@ -5675,7 +5675,7 @@ setiflladdr(const char *addr, int param) #ifndef SMALL void -setinstance(const char *id, int param) +setrdomain(const char *id, int param) { const char *errmsg = NULL; int rdomainid;
fusefs lookup/reclaim bug
Watch this: $ doas fuse-zip ~/Downloads/foo.zip /mnt $ ls /mnt openbsd-www $ grep -IR foo /usr/src > /dev/null # force vfs to reclaim vnodes $ ls /mnt ls: /mnt: No such file or directory $ Currently fusefs nodes in the kernel remember the parent inode number for ".." lookups. This only works until the kernel starts to reuse vnodes and the parent's vnode is reclaimed and the ino to path mapping is removed from the userland process by libfuse. I suggest to fix this by using reference counting in libfuse, so that parent mapping are retained as long as a child uses them. Also, the root node should never be freed. Ok? natano Index: lib/libfuse/fuse_ops.c === RCS file: /cvs/src/lib/libfuse/fuse_ops.c,v retrieving revision 1.25 diff -u -p -r1.25 fuse_ops.c --- lib/libfuse/fuse_ops.c 30 Aug 2016 16:45:54 - 1.25 +++ lib/libfuse/fuse_ops.c 31 Aug 2016 10:14:58 - @@ -432,15 +432,28 @@ ifuse_ops_lookup(struct fuse *f, struct DPRINTF("Inode:\t%llu\n", (unsigned long long)fbuf->fb_ino); DPRINTF("For file %s\n", fbuf->fb_dat); - vn = get_vn_by_name_and_parent(f, fbuf->fb_dat, fbuf->fb_ino); - if (vn == NULL) { - vn = alloc_vn(f, (const char *)fbuf->fb_dat, -1, fbuf->fb_ino); - if (vn == NULL) { - fbuf->fb_err = -errno; - free(fbuf->fb_dat); + if (strcmp((const char *)fbuf->fb_dat, "..") == 0) { + vn = tree_get(>vnode_tree, fbuf->fb_ino); + if (vn == NULL || vn->parent == NULL) { + fbuf->fb_err = -ENOENT; return (0); } - set_vn(f, vn); /*XXX*/ + vn = vn->parent; + if (vn->ino != FUSE_ROOT_INO) + ref_vn(vn); + } else { + vn = get_vn_by_name_and_parent(f, fbuf->fb_dat, fbuf->fb_ino); + if (vn == NULL) { + vn = alloc_vn(f, (const char *)fbuf->fb_dat, -1, + fbuf->fb_ino); + if (vn == NULL) { + fbuf->fb_err = -errno; + free(fbuf->fb_dat); + return (0); + } + set_vn(f, vn); /*XXX*/ + } else if (vn->ino != FUSE_ROOT_INO) + ref_vn(vn); } DPRINTF("new ino %llu\n", (unsigned long long)vn->ino); @@ -991,11 +1004,9 @@ ifuse_ops_reclaim(struct fuse *f, struct { struct fuse_vnode *vn; - vn = tree_pop(>vnode_tree, fbuf->fb_ino); - if (vn) { - remove_vnode_from_name_tree(f, vn); - free(vn); - } + vn = tree_get(>vnode_tree, fbuf->fb_ino); + if (vn != NULL) + unref_vn(f, vn); return (0); } Index: lib/libfuse/fuse_private.h === RCS file: /cvs/src/lib/libfuse/fuse_private.h,v retrieving revision 1.13 diff -u -p -r1.13 fuse_private.h --- lib/libfuse/fuse_private.h 30 Aug 2016 16:45:54 - 1.13 +++ lib/libfuse/fuse_private.h 30 Aug 2016 17:06:27 - @@ -34,7 +34,8 @@ struct fuse_args; struct fuse_vnode { ino_t ino; - ino_t parent; + struct fuse_vnode *parent; + unsigned int ref; char path[NAME_MAX + 1]; struct fuse_dirhandle *fd; @@ -99,6 +100,8 @@ int ifuse_exec_opcode(struct fuse *, str /* fuse_subr.c */ struct fuse_vnode *alloc_vn(struct fuse *, const char *, ino_t, ino_t); +voidref_vn(struct fuse_vnode *); +voidunref_vn(struct fuse *, struct fuse_vnode *); struct fuse_vnode *get_vn_by_name_and_parent(struct fuse *, uint8_t *, ino_t); void remove_vnode_from_name_tree(struct fuse *, Index: lib/libfuse/fuse_subr.c === RCS file: /cvs/src/lib/libfuse/fuse_subr.c,v retrieving revision 1.10 diff -u -p -r1.10 fuse_subr.c --- lib/libfuse/fuse_subr.c 24 May 2016 19:24:46 - 1.10 +++ lib/libfuse/fuse_subr.c 31 Aug 2016 10:15:36 - @@ -24,7 +24,7 @@ #include "debug.h" struct fuse_vnode * -alloc_vn(struct fuse *f, const char *path, ino_t ino, ino_t parent) +alloc_vn(struct fuse *f, const char *path, ino_t ino, ino_t pino) { struct fuse_vnode *vn; @@ -34,13 +34,26 @@ alloc_vn(struct fuse *f, const char *pat } vn->ino = ino; - vn->parent = parent; + vn->ref = 1; if (strlcpy(vn->path, path, sizeof(vn->path)) >= sizeof(vn->path)) { DPRINTF("%s: strlcpy name too long\n", __func__); free(vn); return (NULL); } + if (pino == (ino_t)0) + vn->parent = NULL; + else { + if ((vn->parent =
vmd: cleaning up virtio.c
Addressing "this function needs a cleanup block, lots of free(blah); return (0)" comment for vioblk_notifyq() and doing the same for vionet_enq_rx(). Index: virtio.c === RCS file: /home/nayden/cvsync/src/usr.sbin/vmd/virtio.c,v retrieving revision 1.17 diff -u -p -r1.17 virtio.c --- virtio.c17 Aug 2016 05:07:13 - 1.17 +++ virtio.c31 Aug 2016 10:35:55 - @@ -353,8 +353,7 @@ vioblk_do_write(struct vioblk_dev *dev, } /* - * XXX this function needs a cleanup block, lots of free(blah); return (0) - * in various cases, ds should be set to VIRTIO_BLK_S_IOERR, if we can + * XXX in various cases, ds should be set to VIRTIO_BLK_S_IOERR, if we can * XXX cant trust ring data from VM, be extra cautious. */ int @@ -390,8 +389,7 @@ vioblk_notifyq(struct vioblk_dev *dev) if (read_mem(q_gpa, vr, vr_sz)) { log_warnx("error reading gpa 0x%llx", q_gpa); - free(vr); - return (0); + goto out; } /* Compute offsets in ring of descriptors, avail ring, and used ring */ @@ -406,8 +404,7 @@ vioblk_notifyq(struct vioblk_dev *dev) if ((avail->idx & VIOBLK_QUEUE_MASK) == idx) { log_warnx("vioblk queue notify - nothing to do?"); - free(vr); - return (0); + goto out; } cmd_desc_idx = avail->ring[idx] & VIOBLK_QUEUE_MASK; @@ -416,16 +413,14 @@ vioblk_notifyq(struct vioblk_dev *dev) if ((cmd_desc->flags & VRING_DESC_F_NEXT) == 0) { log_warnx("unchained vioblk cmd descriptor received " "(idx %d)", cmd_desc_idx); - free(vr); - return (0); + goto out; } /* Read command from descriptor ring */ if (read_mem(cmd_desc->addr, , cmd_desc->len)) { log_warnx("vioblk: command read_mem error @ 0x%llx", cmd_desc->addr); - free(vr); - return (0); + goto out; } switch (cmd.type) { @@ -437,8 +432,7 @@ vioblk_notifyq(struct vioblk_dev *dev) if ((secdata_desc->flags & VRING_DESC_F_NEXT) == 0) { log_warnx("unchained vioblk data descriptor " "received (idx %d)", cmd_desc_idx); - free(vr); - return (0); + goto out; } secbias = 0; @@ -453,8 +447,7 @@ vioblk_notifyq(struct vioblk_dev *dev) if (secdata == NULL) { log_warnx("vioblk: block read error, " "sector %lld", cmd.sector); - free(vr); - return (0); + goto out; } if (write_mem(secdata_desc->addr, secdata, @@ -463,9 +456,8 @@ vioblk_notifyq(struct vioblk_dev *dev) "data to gpa @ 0x%llx", secdata_desc->addr); dump_descriptor_chain(desc, cmd_desc_idx); - free(vr); free(secdata); - return (0); + goto out; } free(secdata); @@ -484,8 +476,7 @@ vioblk_notifyq(struct vioblk_dev *dev) log_warnx("can't write device status data @ " "0x%llx", ds_desc->addr); dump_descriptor_chain(desc, cmd_desc_idx); - free(vr); - return (0); + goto out; } @@ -509,16 +500,14 @@ vioblk_notifyq(struct vioblk_dev *dev) if ((secdata_desc->flags & VRING_DESC_F_NEXT) == 0) { log_warnx("wr vioblk: unchained vioblk data " "descriptor received (idx %d)", cmd_desc_idx); - free(vr); - return (0); + goto out; } secdata = malloc(MAXPHYS); if (secdata == NULL) { log_warn("wr vioblk: malloc error, len %d", secdata_desc->len); - free(vr); - return (0); + goto out; } secbias = 0; @@ -529,17 +518,15 @@ vioblk_notifyq(struct vioblk_dev *dev) "sector data @ 0x%llx", secdata_desc->addr); dump_descriptor_chain(desc, cmd_desc_idx); - free(vr); free(secdata); -
www/60.html: too many nbsp
Trivial, but too many nbsp and too little comma in 60.html... Thanks, Michael Index: 60.html === RCS file: /cvs/www/60.html,v retrieving revision 1.71 diff -u -p -r1.71 60.html --- 60.html 25 Aug 2016 15:21:15 - 1.71 +++ 60.html 31 Aug 2016 08:19:22 - @@ -27,17 +27,10 @@ Copyright 1997-2016, Theo de Raadt. 6.0 Songs: "Another Smash of the Stack", "Black Hat", -"Money" - - - +"Money", "Comfortably Dumb (the misc song)", - - - -"Mother", +"Mother", (plus 1 more...) - Order a CDROM from our https://openbsdstore.com;>ordering system. See the information on the FTP page for
hashfree: sizes for free(9) when using hashinit.
Hello list, I'm introducing hashfree, a counterpart to hashinit in order to pass the size to free(9) while hiding the implementation details. Most of the api users are converted in the patch below, those not included just simply do not free the memory (pid hash table etc). All, except for one case, the input hashtbl in in_pcb, because at free time the size is really not known, so it needs more moving of things around and is out the scope of this patch. Manpage diff courtesy of natano@ on an old version of the diff! Anyway here is the patch. Index: share/man/man9/hashinit.9 === RCS file: /cvs/src/share/man/man9/hashinit.9,v retrieving revision 1.5 diff -u -p -r1.5 hashinit.9 --- share/man/man9/hashinit.9 4 Jun 2013 19:27:07 - 1.5 +++ share/man/man9/hashinit.9 31 Aug 2016 10:30:13 - @@ -29,14 +29,15 @@ .Dt HASHINIT 9 .Os .Sh NAME -.Nm hashinit -.\" This should be ported from netbsd as well... -.\" .Nm hashdone +.Nm hashinit , +.Nm hashfree .Nd kernel hashtable functions .Sh SYNOPSIS .In sys/systm.h .Ft void * .Fn hashinit "int num" "int type" "int flags" "u_long *mask" +.Ft void +.Fn hashfree "void *hash" "int num" "int type" .Sh DESCRIPTION The .Fn hashinit @@ -60,6 +61,17 @@ argument is used to pass back the mask f hashing table. For an example of its use, see .Xr hash 9 . +.Pp +The +.Fn hashfree +function causes memory allocated by the +.Fn hashinit +function to be released. +The +.Fa num +and +.Fa type +arguments of related calls must match. .Sh RETURN VALUES The .Fn hashinit Index: sys/isofs/udf/udf_vfsops.c === RCS file: /cvs/src/sys/isofs/udf/udf_vfsops.c,v retrieving revision 1.54 diff -u -p -r1.54 udf_vfsops.c --- sys/isofs/udf/udf_vfsops.c 25 Aug 2016 00:06:44 - 1.54 +++ sys/isofs/udf/udf_vfsops.c 31 Aug 2016 10:30:22 - @@ -444,8 +444,7 @@ udf_mountfs(struct vnode *devvp, struct return (0); bail: - if (ump->um_hashtbl != NULL) - free(ump->um_hashtbl, M_UDFMOUNT, 0); + hashfree(ump->um_hashtbl, UDF_HASHTBLSIZE, M_UDFMOUNT); if (ump != NULL) { free(ump, M_UDFMOUNT, 0); @@ -494,9 +493,7 @@ udf_unmount(struct mount *mp, int mntfla if (ump->um_stbl != NULL) free(ump->um_stbl, M_UDFMOUNT, 0); - if (ump->um_hashtbl != NULL) - free(ump->um_hashtbl, M_UDFMOUNT, 0); - + hashfree(ump->um_hashtbl, UDF_HASHTBLSIZE, M_UDFMOUNT); free(ump, M_UDFMOUNT, 0); mp->mnt_data = NULL; Index: sys/kern/kern_descrip.c === RCS file: /cvs/src/sys/kern/kern_descrip.c,v retrieving revision 1.134 diff -u -p -r1.134 kern_descrip.c --- sys/kern/kern_descrip.c 25 Aug 2016 00:00:02 - 1.134 +++ sys/kern/kern_descrip.c 31 Aug 2016 10:30:22 - @@ -1098,7 +1098,7 @@ fdfree(struct proc *p) if (fdp->fd_rdir) vrele(fdp->fd_rdir); free(fdp->fd_knlist, M_TEMP, fdp->fd_knlistsize * sizeof(struct klist)); - free(fdp->fd_knhash, M_TEMP, 0); + hashfree(fdp->fd_knhash, KN_HASHSIZE, M_TEMP); pool_put(_pool, fdp); } Index: sys/kern/kern_event.c === RCS file: /cvs/src/sys/kern/kern_event.c,v retrieving revision 1.75 diff -u -p -r1.75 kern_event.c --- sys/kern/kern_event.c 25 Aug 2016 00:00:02 - 1.75 +++ sys/kern/kern_event.c 31 Aug 2016 10:30:23 - @@ -119,7 +119,6 @@ int kq_timeoutmax = (4 * 1024); knote_enqueue(kn); \ } while(0) -#defineKN_HASHSIZE 64 /* XXX should be tunable */ #define KN_HASH(val, mask) (((val) ^ (val >> 8)) & (mask)) extern struct filterops sig_filtops; Index: sys/kern/kern_subr.c === RCS file: /cvs/src/sys/kern/kern_subr.c,v retrieving revision 1.47 diff -u -p -r1.47 kern_subr.c --- sys/kern/kern_subr.c15 Mar 2016 04:19:26 - 1.47 +++ sys/kern/kern_subr.c31 Aug 2016 10:30:23 - @@ -176,6 +176,20 @@ hashinit(int elements, int type, int fla return (hashtbl); } +void +hashfree(void *hash, int elements, int type) +{ + u_long hashsize; + LIST_HEAD(generic, generic) *hashtbl = hash; + + if (elements <= 0) + panic("hashfree: bad cnt"); + for (hashsize = 1; hashsize < elements; hashsize <<= 1) + continue; + + free(hashtbl, type, sizeof(*hashtbl) * hashsize); +} + /* * "startup hook" types, functions, and variables. */ Index: sys/netinet/ip_mroute.c === RCS file: /cvs/src/sys/netinet/ip_mroute.c,v retrieving revision 1.90 diff -u -p -r1.90 ip_mroute.c --- sys/netinet/ip_mroute.c
Re: switch the cubie miniroot to cubieboard2
On Wed, Aug 31, 2016 at 07:26:27AM -0400, Ted Unangst wrote: > Jonathan Gray wrote: > > Now that the A20 works it likely makes sense to switch > > the cubie miniroot from the A10 based cubieboard1 to the A20 > > based cubieboard2 which more people seem to have? > > forgive the insane question, but does this imply that it > doesn't work on the a10 board? The u-boot and dtb images are in most cases only for a single board. So we either need to create board specific miniroots or require people to add u-boot and dtb before booting install images and after install. With u-boot being either at a raw offset or on the fat fs depending on the board type. This is because these machines don't have firmware in a rom in most cases, so we can't create a single install image. So yes, switching the miniroot to use the cubieboard2 specific u-boot will result in it not working on cubieboard1.
Re: squeeze some isa drivers
> Time to play whack i386/conf/GENERIC with a bat and see what pops out. > > Extensive research in the archives indicates that these devices are extinct. You'll need to remove out the commented wss line in alpha GENERIC as well.
Re: per-ifp input task
On Mon, Aug 29, 2016 at 03:28:34PM +0200, Martin Pieuchot wrote: > Comments? Oks? OK bluhm@ > -if_input_process(void *xmq) > +if_input_process(void *xifidx) > { > - struct mbuf_queue *mq = xmq; > + unsigned int ifidx = (unsigned long)xifidx; > struct mbuf_list ml; > - struct mbuf *m; > struct ifnet *ifp; > + struct mbuf *m; > struct ifih *ifih; > struct srp_ref sr; > int s; Moving struct mbuf definition looks useless.
Re: switch the cubie miniroot to cubieboard2
Jonathan Gray wrote: > Now that the A20 works it likely makes sense to switch > the cubie miniroot from the A10 based cubieboard1 to the A20 > based cubieboard2 which more people seem to have? forgive the insane question, but does this imply that it doesn't work on the a10 board?
switch the cubie miniroot to cubieboard2
Now that the A20 works it likely makes sense to switch the cubie miniroot from the A10 based cubieboard1 to the A20 based cubieboard2 which more people seem to have? Index: distrib/armv7/miniroot/cubie/Makefile === RCS file: /cvs/src/distrib/armv7/miniroot/cubie/Makefile,v retrieving revision 1.3 diff -u -p -r1.3 Makefile --- distrib/armv7/miniroot/cubie/Makefile 5 Jun 2016 14:53:23 - 1.3 +++ distrib/armv7/miniroot/cubie/Makefile 31 Aug 2016 10:30:14 - @@ -1,7 +1,7 @@ BOARD= cubie PLATFORM=SUNXI -UBOOT= Cubieboard +UBOOT= Cubieboard2 DTBS=\ - sun4i-a10-cubieboard.dtb + sun7i-a20-cubieboard2.dtb .include "${.CURDIR}/../Makefile.inc" Index: distrib/armv7/ramdisk/install.md === RCS file: /cvs/src/distrib/armv7/ramdisk/install.md,v retrieving revision 1.40 diff -u -p -r1.40 install.md --- distrib/armv7/ramdisk/install.md5 Jun 2016 15:35:38 - 1.40 +++ distrib/armv7/ramdisk/install.md31 Aug 2016 10:30:14 - @@ -46,7 +46,7 @@ md_installboot() { *AM335x*) _plat=am335x;; *'OMAP3 BeagleBoard'*) _plat=beagle;; *OMAP4*)_plat=panda;; - *Cubieboard*) _plat=cubie;; + *'Cubietech Cubieboard2'*) _plat=cubie;; *Cubox-i*|*HummingBoard*) _plat=cubox;; *Wandboard*)_plat=wandboard;; *Nitrogen6*|*'SABRE Lite'*) _plat=nitrogen;; Index: distrib/armv7/ramdisk/list === RCS file: /cvs/src/distrib/armv7/ramdisk/list,v retrieving revision 1.21 diff -u -p -r1.21 list --- distrib/armv7/ramdisk/list 5 Jun 2016 15:12:56 - 1.21 +++ distrib/armv7/ramdisk/list 31 Aug 2016 10:30:14 - @@ -129,8 +129,8 @@ COPY/usr/local/share/dtb/arm/omap3-beag COPY /usr/local/share/dtb/arm/omap3-beagle-xm.dtb /usr/mdec/beagle/omap3-beagle-xm.dtb COPY /usr/local/share/dtb/arm/omap3-beagle.dtb /usr/mdec/beagle/omap3-beagle.dtb -COPY /usr/local/share/u-boot/Cubieboard/u-boot-sunxi-with-spl.bin /usr/mdec/cubie/u-boot-sunxi-with-spl.bin -COPY /usr/local/share/dtb/arm/sun4i-a10-cubieboard.dtb /usr/mdec/cubie/sun4i-a10-cubieboard.dtb +COPY /usr/local/share/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin /usr/mdec/cubie/u-boot-sunxi-with-spl.bin +COPY /usr/local/share/dtb/arm/sun7i-a20-cubieboard2.dtb /usr/mdec/cubie/sun7i-a20-cubieboard2.dtb COPY /usr/local/share/u-boot/omap4_panda/MLO /usr/mdec/panda/MLO COPY /usr/local/share/u-boot/omap4_panda/u-boot.img /usr/mdec/panda/u-boot.img Index: distrib/notes/armv7/contents === RCS file: /cvs/src/distrib/notes/armv7/contents,v retrieving revision 1.10 diff -u -p -r1.10 contents --- distrib/notes/armv7/contents30 Dec 2015 23:48:59 - 1.10 +++ distrib/notes/armv7/contents31 Aug 2016 10:30:14 - @@ -11,7 +11,7 @@ TopPart miniroot-cubie-{:--:}OSrev.fs A miniroot filesystem to be used for - installation; Cubieboard1 version. + installation; Cubieboard2 version. miniroot-cubox-{:--:}OSrev.fs A miniroot filesystem to be used for
Re: Estonian keymap
On 08/30/16 21:14, Mart Tõnso wrote: This should be ok now: ok mpi@ Index: sys/dev/pckbc/wskbdmap_mfii.c === RCS file: /cvs/src/sys/dev/pckbc/wskbdmap_mfii.c,v retrieving revision 1.43 diff -u -p -r1.43 wskbdmap_mfii.c --- sys/dev/pckbc/wskbdmap_mfii.c 14 Apr 2013 19:32:52 - 1.43 +++ sys/dev/pckbc/wskbdmap_mfii.c 30 Aug 2016 15:59:25 - @@ -1071,6 +1071,40 @@ static const keysym_t pckbd_keydesc_is_n KC(40), KS_acute, KS_diaeresis, KS_asciicircum, }; +static const keysym_t pckbd_keydesc_ee[] = { +/* pos normalshifted altgr shift-altgr */ +KC(3), KS_2, KS_quotedbl,KS_at, +KC(4), KS_3, KS_numbersign, KS_sterling, +KC(5), KS_4, KS_currency,KS_dollar, +KC(7), KS_6, KS_ampersand, +KC(8), KS_7, KS_slash, KS_braceleft, +KC(9), KS_8, KS_parenleft, KS_bracketleft, +KC(10), KS_9, KS_parenright, KS_bracketright, +KC(11), KS_0, KS_equal, KS_braceright, +KC(12), KS_plus, KS_question,KS_backslash, +KC(13), KS_dead_acute,KS_dead_grave, +KC(26), KS_udiaeresis, +KC(27), KS_otilde,KS_Otilde, KS_section, +KC(31), KS_s, KS_S, KS_L2_scaron, KS_L2_Scaron, +KC(39), KS_odiaeresis, +KC(40), KS_adiaeresis,KS_Adiaeresis, KS_dead_circumflex, +KC(41), KS_dead_caron,KS_dead_tilde, +KC(43), KS_apostrophe,KS_asterisk,KS_onehalf, +KC(44), KS_z, KS_Z, KS_L2_zcaron, KS_L2_Zcaron, +KC(51), KS_comma, KS_semicolon, +KC(52), KS_period,KS_colon, +KC(53), KS_minus, KS_underscore, +KC(86), KS_less, KS_greater, KS_bar, KS_brokenbar, +KC(184), KS_Mode_switch, KS_Multi_key, +}; + +static const keysym_t pckbd_keydesc_ee_nodead[] = { +/* pos normalshifted altgr shift-altgr */ +KC(13), KS_apostrophe,KS_grave, +KC(40), KS_adiaeresis,KS_Adiaeresis, KS_asciicircum, +KC(41), KS_L2_caron, KS_asciitilde, +}; + #endif /* WSKBD_NO_INTL_LAYOUTS */ #define KBD_MAP(name, base, map) \ @@ -1130,6 +1164,8 @@ const struct wscons_keydesc pckbd_keydes KBD_MAP(KB_NL | KB_NODEAD, KB_NL, pckbd_keydesc_nl_nodead), KBD_MAP(KB_IS, KB_US, pckbd_keydesc_is), KBD_MAP(KB_IS | KB_NODEAD, KB_IS, pckbd_keydesc_is_nodead), + KBD_MAP(KB_EE, KB_US, pckbd_keydesc_ee), + KBD_MAP(KB_EE | KB_NODEAD, KB_EE, pckbd_keydesc_ee_nodead), #endif /* WSKBD_NO_INTL_LAYOUTS */ {0, 0, 0, 0} }; Index: sys/dev/wscons/wskbdutil.c === RCS file: /cvs/src/sys/dev/wscons/wskbdutil.c,v retrieving revision 1.14 diff -u -p -r1.14 wskbdutil.c --- sys/dev/wscons/wskbdutil.c 9 Dec 2014 07:05:06 - 1.14 +++ sys/dev/wscons/wskbdutil.c 30 Aug 2016 15:59:25 - @@ -170,7 +170,12 @@ static struct compose_tab_s { { { KS_acute, KS_u }, KS_uacute }, { { KS_asciicircum, KS_u }, KS_ucircumflex }, { { KS_grave, KS_u }, KS_ugrave }, - { { KS_acute, KS_y }, KS_yacute } + { { KS_acute, KS_y }, KS_yacute }, + { { KS_dead_caron, KS_space }, KS_L2_caron }, + { { KS_dead_caron, KS_S }, KS_L2_Scaron }, + { { KS_dead_caron, KS_Z }, KS_L2_Zcaron }, + { { KS_dead_caron, KS_s }, KS_L2_scaron }, + { { KS_dead_caron, KS_z }, KS_L2_zcaron } }; #define COMPOSE_SIZE nitems(compose_tab) Index: sys/dev/wscons/wsksymdef.h === RCS file: /cvs/src/sys/dev/wscons/wsksymdef.h,v retrieving revision 1.36 diff -u -p -r1.36 wsksymdef.h --- sys/dev/wscons/wsksymdef.h 26 Jan 2014 17:48:08 - 1.36 +++ sys/dev/wscons/wsksymdef.h 30 Aug 2016 15:59:25 - @@ -266,6 +266,7 @@ #defineKS_dead_diaeresis 0x0308 #defineKS_dead_abovering 0x030a #defineKS_dead_cedilla 0x0327 +#defineKS_dead_caron 0x0328 /* * Group Cyrillic @@ -734,6 +735,7 @@ #define KB_CF 0x1a00 #define KB_LV 0x1b00 #define KB_IS 0x1c00 +#define KB_EE 0x1d00 #define KB_NODEAD 0x0001 /* disable dead accents */ #define KB_DECLK 0x0002 /* DEC LKnnn layout */ @@ -774,7 +776,8 @@ { KB_SI,"si"
squeeze some isa drivers
Time to play whack i386/conf/GENERIC with a bat and see what pops out. Extensive research in the archives indicates that these devices are extinct. Index: arch/i386/conf/GENERIC === RCS file: /cvs/src/sys/arch/i386/conf/GENERIC,v retrieving revision 1.817 diff -u -p -r1.817 GENERIC --- arch/i386/conf/GENERIC 28 Jun 2016 04:41:37 - 1.817 +++ arch/i386/conf/GENERIC 31 Aug 2016 10:17:04 - @@ -467,7 +467,6 @@ siop* at pci? # NCR 538XX SCSI control adv* at pci? # AdvanSys 1200A/B and ULTRA SCSI adw* at pci? # AdvanSys ULTRA WIDE SCSI pcscp* at pci? # AMD 53c974 PCscsi-PCI SCSI -sea0 at isa? disable iomem 0xc8000 irq 5 # Seagate ST0[12] SCSI controllers trm* at pci? # Tekram DC-3x5U SCSI Controllers uha0 at isa? port 0x330 # UltraStor [13]4f SCSI controllers uha1 at isa? disable port 0x334 # UltraStor [13]4f SCSI controllers @@ -691,18 +690,14 @@ envy* at pci? # VIA Envy24 (aka ICE17 sb0at isa? port 0x220 irq 5 drq 1 # SoundBlaster sb*at isapnp? ess* at isapnp? # ESS Tech ES188[78], ES888 -wss0 at isa? port 0x530 irq 10 drq 0 # Windows Sound System -wss* at isapnp? pas0 at isa? port 0x220 irq 7 drq 1 # ProAudio Spectrum gus0 at isa? port 0x220 irq 7 drq 1 drq2 6 # Gravis (drq2 is record drq) gus* at isapnp? -ym*at isapnp? mpu* at isapnp? mpu* at isa? port 0x300 # generic MPU, Yamaha SW60XG # MIDI support midi* at sb? # SB MPU401 port -midi* at ym? midi* at mpu? midi* at autri? midi* at eap? @@ -715,8 +710,6 @@ audio* at sb? audio* at gus? audio* at pas? audio* at ess? -audio* at wss? -audio* at ym? audio* at eap? audio* at envy? audio* at eso? Index: dev/isa/files.isa === RCS file: /cvs/src/sys/dev/isa/files.isa,v retrieving revision 1.119 diff -u -p -r1.119 files.isa --- dev/isa/files.isa 30 Sep 2015 12:15:12 - 1.119 +++ dev/isa/files.isa 31 Aug 2016 10:16:27 - @@ -109,11 +109,6 @@ device aha: scsi, isa_dma attach aha at isa with aha_isa file dev/isa/aha.c aha needs-flag -# Seagate ST0[12] ICs -device sea: scsi -attach sea at isa -file dev/isa/seagate.c sea - # UltraStor UHA-[13]4f boards # device declaration in sys/conf/files attach uha at isa with uha_isa: isa_dma @@ -247,14 +242,6 @@ file dev/isa/ad1848.cad1848 # ICS2101 mixer chip support; used by other drivers define ics2101 file dev/isa/ics2101.c ics2101 - - -# Microsoft Windows Sound System -device wss: audio, isa_dma, ad1848 -file dev/isa/wss.c wss - -attach wss at isa with wss_isa -file dev/isa/wss_isa.c wss & (wss_isa | wss_isapnp) # ESS Technology ES1887/ES888/ES1888 device ess {} : audio, isa_dma, midibus Index: dev/isa/files.isapnp === RCS file: /cvs/src/sys/dev/isa/files.isapnp,v retrieving revision 1.33 diff -u -p -r1.33 files.isapnp --- dev/isa/files.isapnp11 May 2015 06:46:21 - 1.33 +++ dev/isa/files.isapnp31 Aug 2016 10:19:15 - @@ -34,8 +34,6 @@ file dev/isa/aic_isapnp.caic_isapnp attach sb at isapnp with sb_isapnp file dev/isa/sb_isapnp.c sb_isapnp -attach wss at isapnp with wss_isapnp -file dev/isa/wss_isapnp.cwss_isapnp attach ess at isapnp with ess_isapnp file dev/isa/ess_isapnp.cess_isapnp attach gus at isapnp with gus_isapnp @@ -63,8 +61,3 @@ attachwe at isapnp with we_isapnp attach rt at isapnp with rt_isapnp file dev/isa/rt_isapnp.c rt_isapnp -# Yamaha OPL3-SA3 -device ym: audio, isa_dma, ad1848, midibus -attach ym at isapnp with ym_isapnp -file dev/isa/ym.cym_isapnp -file dev/isa/ym_isapnp.c ym_isapnp
RSSI values
ifconfig scan displays RSSI (received signal strength indicator) values. If the driver sets ic->ic_max_rssi the value is displayed as a percentage of ic_max_rssi. Otherwise ifconfig displays the value as dBm. The problem in the dBm case is that many drivers end up reporting a positive value. The range for 802.11 networks is -10dBm to -100dBm (wikipedia has a table at https://en.wikipedia.org/wiki/DBm). In January 2016 sthen@ fixed this problem for some drivers by converting from an unsigned value to a signed value at the ioctl boundary. This approach works for drivers which report values in the (unsigned) range 128 - 255. But there are some drivers which report RSSI values in the 20 to 100 range. These are fixed by the diff below. A few drivers report bogus values altogether, and some always report the same value. I'm not going to bother fixing those. Index: ieee80211_ioctl.c === RCS file: /cvs/src/sys/net80211/ieee80211_ioctl.c,v retrieving revision 1.42 diff -u -p -r1.42 ieee80211_ioctl.c --- ieee80211_ioctl.c 15 Aug 2016 22:14:19 - 1.42 +++ ieee80211_ioctl.c 30 Aug 2016 15:36:50 - @@ -60,6 +60,8 @@ void ieee80211_node2req(struct ieee80211com *ic, const struct ieee80211_node *ni, struct ieee80211_nodereq *nr) { + uint8_t rssi; + /* Node address and name information */ IEEE80211_ADDR_COPY(nr->nr_macaddr, ni->ni_macaddr); IEEE80211_ADDR_COPY(nr->nr_bssid, ni->ni_bssid); @@ -73,7 +75,19 @@ ieee80211_node2req(struct ieee80211com * bcopy(ni->ni_rates.rs_rates, nr->nr_rates, IEEE80211_RATE_MAXSIZE); /* Node status information */ - nr->nr_rssi = (*ic->ic_node_getrssi)(ic, ni); + rssi = (*ic->ic_node_getrssi)(ic, ni); + if (ic->ic_max_rssi) { + /* Driver reports RSSI relative to ic_max_rssi. */ + nr->nr_rssi = rssi; + } else { + /* +* Driver reports RSSI value in dBm. +* Convert from unsigned to signed. +* Some drivers report a negative value, some don't. +* Reasonable range is -20dBm to -80dBm. +*/ + nr->nr_rssi = (rssi < 128) ? -rssi : rssi; + } nr->nr_max_rssi = ic->ic_max_rssi; bcopy(ni->ni_tstamp, nr->nr_tstamp, sizeof(nr->nr_tstamp)); nr->nr_intval = ni->ni_intval;
Re: Undefined behaviour in subr_hibernate.c
On Wed, Aug 31, 2016 at 10:47:50AM +0200, Michal Mazurek wrote: > Section "J.2 Undefined behavior" of n1570 includes: > * Pointers that do not point to the same aggregate or union (nor just > beyond the same array object) are compared using relational > operators (6.5.8). > > I think that's what's happening when using RB trees in subr_hibernate.c. > subr_pool.c fixes this issue by casting the address to vaddr_t. Diff > to do the same in subr_hibernate.c below. > If this passes a couple ZZZ/resume cycles, go for it. > Index: sys/kern/subr_hibernate.c > === > RCS file: /cvs/src/sys/kern/subr_hibernate.c,v > retrieving revision 1.116 > diff -u -p -r1.116 subr_hibernate.c > --- sys/kern/subr_hibernate.c 4 May 2015 02:18:05 - 1.116 > +++ sys/kern/subr_hibernate.c 31 Aug 2016 08:35:53 - > @@ -156,7 +156,10 @@ hibernate_sort_ranges(union hibernate_in > static __inline int > hibe_cmp(struct hiballoc_entry *l, struct hiballoc_entry *r) > { > - return l < r ? -1 : (l > r); > + vaddr_t vl = (vaddr_t)l; > + vaddr_t vr = (vaddr_t)r; > + > + return vl < vr ? -1 : (vl > vr); > } > > RB_PROTOTYPE(hiballoc_addr, hiballoc_entry, hibe_entry, hibe_cmp) > > -- > Michal Mazurek >
Undefined behaviour in subr_hibernate.c
Section "J.2 Undefined behavior" of n1570 includes: * Pointers that do not point to the same aggregate or union (nor just beyond the same array object) are compared using relational operators (6.5.8). I think that's what's happening when using RB trees in subr_hibernate.c. subr_pool.c fixes this issue by casting the address to vaddr_t. Diff to do the same in subr_hibernate.c below. Index: sys/kern/subr_hibernate.c === RCS file: /cvs/src/sys/kern/subr_hibernate.c,v retrieving revision 1.116 diff -u -p -r1.116 subr_hibernate.c --- sys/kern/subr_hibernate.c 4 May 2015 02:18:05 - 1.116 +++ sys/kern/subr_hibernate.c 31 Aug 2016 08:35:53 - @@ -156,7 +156,10 @@ hibernate_sort_ranges(union hibernate_in static __inline int hibe_cmp(struct hiballoc_entry *l, struct hiballoc_entry *r) { - return l < r ? -1 : (l > r); + vaddr_t vl = (vaddr_t)l; + vaddr_t vr = (vaddr_t)r; + + return vl < vr ? -1 : (vl > vr); } RB_PROTOTYPE(hiballoc_addr, hiballoc_entry, hibe_entry, hibe_cmp) -- Michal Mazurek
Re: bridge: drop gif(4) support
ok > On 31 Aug 2016, at 02:09, Martin Pieuchotwrote: > >