Re: fix clang types on arm
On Fri, Sep 16, 2016 at 09:04:58PM +0200, Mark Kettenis wrote: > On OpenBSD we use a consistent set of typedefs across platforms for > the types specified by the C standard. In some cases these deviate > from what the processor-specific ABI says. The diff below fixes the > ones relevant for arm, pretty much by following NetBSD. > > ok? ok jsg@ > > Oh, and how do we handle upstreaming these kind of diffs? For the tools/clang parts send patches to cfe-commits and hope they don't get ignored. http://cfe.llvm.org/get_involved.html I think they have a preference for patches as attachments rather than inline as well. > > > Index: gnu/llvm/tools/clang/lib/Basic/Targets.cpp > === > RCS file: /cvs/src/gnu/llvm/tools/clang/lib/Basic/Targets.cpp,v > retrieving revision 1.1.1.1 > diff -u -p -r1.1.1.1 Targets.cpp > --- gnu/llvm/tools/clang/lib/Basic/Targets.cpp3 Sep 2016 22:46:57 > - 1.1.1.1 > +++ gnu/llvm/tools/clang/lib/Basic/Targets.cpp16 Sep 2016 18:58:59 > - > @@ -4275,8 +4275,10 @@ class ARMTargetInfo : public TargetInfo > DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64; > const llvm::Triple &T = getTriple(); > > -// size_t is unsigned long on MachO-derived environments, NetBSD and > Bitrig. > +// size_t is unsigned long on MachO-derived environments, NetBSD, > +// OpenBSD and Bitrig. > if (T.isOSBinFormatMachO() || T.getOS() == llvm::Triple::NetBSD || > +T.getOS() == llvm::Triple::OpenBSD || > T.getOS() == llvm::Triple::Bitrig) >SizeType = UnsignedLong; > else > @@ -4284,6 +4286,7 @@ class ARMTargetInfo : public TargetInfo > > switch (T.getOS()) { > case llvm::Triple::NetBSD: > +case llvm::Triple::OpenBSD: >WCharType = SignedInt; >break; > case llvm::Triple::Win32: > @@ -4475,6 +4478,7 @@ public: > > switch (getTriple().getOS()) { > case llvm::Triple::NetBSD: > +case llvm::Triple::OpenBSD: >PtrDiffType = SignedLong; >break; > default: >
Re: little simpler ssh code
On Fri, Sep 16, 2016 at 09:19:40PM -0400, Ted Unangst wrote: > no change, but makes the code a little shorter. Reads fine to me. arc4random() is already used in other places in ssh, so this shouldn't be an issue for portable. > > > Index: clientloop.c > === > RCS file: /cvs/src/usr.bin/ssh/clientloop.c,v > retrieving revision 1.287 > diff -u -p -r1.287 clientloop.c > --- clientloop.c 12 Sep 2016 01:22:38 - 1.287 > +++ clientloop.c 17 Sep 2016 01:16:46 - > @@ -303,7 +303,7 @@ client_x11_get_proto(const char *display > char xauthfile[PATH_MAX], xauthdir[PATH_MAX]; > static char proto[512], data[512]; > FILE *f; > - int got_data = 0, generated = 0, do_unlink = 0, i, r; > + int got_data = 0, generated = 0, do_unlink = 0, r; > struct stat st; > u_int now, x11_timeout_real; > > @@ -430,17 +430,16 @@ client_x11_get_proto(const char *display >* for the local connection. >*/ > if (!got_data) { > - u_int32_t rnd = 0; > + u_int8_t rnd[16]; > + u_int i; > > logit("Warning: No xauth data; " > "using fake authentication data for X11 forwarding."); > strlcpy(proto, SSH_X11_PROTO, sizeof proto); > - for (i = 0; i < 16; i++) { > - if (i % 4 == 0) > - rnd = arc4random(); > + arc4random_buf(rnd, sizeof(rnd)); > + for (i = 0; i < sizeof(rnd); i++) { > snprintf(data + 2 * i, sizeof data - 2 * i, "%02x", > - rnd & 0xff); > - rnd >>= 8; > + rnd[i]); > } > } > >
Re: clang makefiles for arm
On Fri, Sep 16, 2016 at 08:23:27PM +0200, Mark Kettenis wrote: > I'm working on arm support for the in-tree llvm. I've got it working > well enough to build "Hello, World", but I still have some exception > handling issues. > > As a first step, this adds the build infrastructure. > > ok? ok jsg@
Re: random malloc junk
On Fri, Sep 16, 2016 at 09:30:15PM +0200, Otto Moerbeek wrote: > On Thu, Sep 15, 2016 at 10:08:26AM -0400, Ted Unangst wrote: > > > Otto Moerbeek wrote: > > > On Wed, Sep 14, 2016 at 12:53:05PM -0400, Ted Unangst wrote: > > > > > > > Daniel Micay wrote: > > > > > > > > > > The current OpenBSD code only wipes up to MALLOC_MAXCHUNK with junk @ > > > > > 1, > > > > > and it similarly doesn't wipe at all with 'U' (even though > > > > > junk-on-free > > > > > also serves the purpose of preventing information leaks, not just > > > > > mitigating use-after-free). IMO, optimizing large allocation perf like > > > > > this isn't worthwhile. > > > > > > > > this requires some analysis of what programs do in the wild. some > > > > programs > > > > preemptively malloc large buffers, but don't touch them. it would be a > > > > serious > > > > reqression for free to fault in new pages, just to ditry them, then turn > > > > around and unmap them. some of this is because i believe the code is > > > > doing > > > > things at the wrong time. if you want to dirty whole pages, it should > > > > be when > > > > they go on the freelist, not immediately. > > > > > > Something like this? > > > > didn't look too closely, but looks good from a distance. :) > > > > Sligtly better diff: it gets rid of a PAGEROUND(sz) call, since sz == > PAGEROUND(sz) in unmap(). Actually, I think the - mopts.malloc_guard can go as well. We're dealing with unguarded regions at this spot. > > -Otto > > Index: malloc.c > === > RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v > retrieving revision 1.195 > diff -u -p -r1.195 malloc.c > --- malloc.c 1 Sep 2016 10:41:02 - 1.195 > +++ malloc.c 16 Sep 2016 19:26:34 - > @@ -376,6 +376,11 @@ unmap(struct dir_info *d, void *p, size_ > for (i = 0; i < mopts.malloc_cache; i++) { > r = &d->free_regions[(i + offset) & (mopts.malloc_cache - 1)]; > if (r->p == NULL) { > + if (mopts.malloc_junk && !mopts.malloc_freeunmap) { > + size_t amt = mopts.malloc_junk == 1 ? > + MALLOC_MAXCHUNK : sz - mopts.malloc_guard; > + memset(p, SOME_FREEJUNK, amt); > + } > if (mopts.malloc_hint) > madvise(p, sz, MADV_FREE); > if (mopts.malloc_freeunmap) > @@ -1335,11 +1340,6 @@ ofree(struct dir_info *argpool, void *p) > wrterror(pool, "mprotect", NULL); > } > STATS_SUB(pool->malloc_guarded, mopts.malloc_guard); > - } > - if (mopts.malloc_junk && !mopts.malloc_freeunmap) { > - size_t amt = mopts.malloc_junk == 1 ? MALLOC_MAXCHUNK : > - PAGEROUND(sz) - mopts.malloc_guard; > - memset(p, SOME_FREEJUNK, amt); > } > unmap(pool, p, PAGEROUND(sz)); > delete(pool, r);
alignment error rtadvd/armv7
On a PandaBoard (armv7) running -current, when I run rtadvd, it crashes with a bus error shortly after printing (received a routing message). I can reproduce by sending SIGHUP to a dhclient running on the same interface. I have traced this down to the following block of code in rtadvd.c. static void rtmsg_input(void) { int n, type, ifindex = 0, plen; size_t len; char msg[2048], *next, *lim; u_char ifname[IF_NAMESIZE]; struct prefix *prefix; struct rainfo *rai; struct in6_addr *addr; char addrbuf[INET6_ADDRSTRLEN]; So msg is not 32-bit aligned, presumably because INET6_ADDRSTRLEN is 46. I can fix the bus error by hardcoding 48, but of course that's not right. Then msg is passed to get_next_msg (as next) where the expression rtm->rtm_hdrlen (rtm is the not-aligned msg) is the first dereference and thus the point where it crashes. I'm at the point now where I think I've found the root of the problem but don't know enough to fix it. Any thoughts? Martin
little simpler ssh code
no change, but makes the code a little shorter. Index: clientloop.c === RCS file: /cvs/src/usr.bin/ssh/clientloop.c,v retrieving revision 1.287 diff -u -p -r1.287 clientloop.c --- clientloop.c12 Sep 2016 01:22:38 - 1.287 +++ clientloop.c17 Sep 2016 01:16:46 - @@ -303,7 +303,7 @@ client_x11_get_proto(const char *display char xauthfile[PATH_MAX], xauthdir[PATH_MAX]; static char proto[512], data[512]; FILE *f; - int got_data = 0, generated = 0, do_unlink = 0, i, r; + int got_data = 0, generated = 0, do_unlink = 0, r; struct stat st; u_int now, x11_timeout_real; @@ -430,17 +430,16 @@ client_x11_get_proto(const char *display * for the local connection. */ if (!got_data) { - u_int32_t rnd = 0; + u_int8_t rnd[16]; + u_int i; logit("Warning: No xauth data; " "using fake authentication data for X11 forwarding."); strlcpy(proto, SSH_X11_PROTO, sizeof proto); - for (i = 0; i < 16; i++) { - if (i % 4 == 0) - rnd = arc4random(); + arc4random_buf(rnd, sizeof(rnd)); + for (i = 0; i < sizeof(rnd); i++) { snprintf(data + 2 * i, sizeof data - 2 * i, "%02x", - rnd & 0xff); - rnd >>= 8; + rnd[i]); } }
Re: define ELF_CTF in exec_elf.h
On Fri, Sep 16, 2016 at 12:19 PM, Jasper Lievisse Adriaanse wrote: > This moves the definition of ELF_CTF into exec_elf.h and adjusts the > loadfile_elf.c copies accordingly. > > OK? ok except for one bit: > --- share/man/man5/elf.57 Sep 2016 18:42:01 - 1.32 > +++ share/man/man5/elf.516 Sep 2016 19:16:37 - > @@ -877,6 +877,13 @@ fixed-size entries. > .Pp > Various sections hold program and control information: > .Bl -tag -width ".shstrtab" > +.It .SUNW_ctf > +This section contains the (un)compressed Compact C-Type Format data > +describing the object's types and symbols. > +This section is of type > +.Dv SHT_NOBITS . > +The attribute used is > +.Dv SHF_ALLOC . It's of type SHT_NOBITS and therefore occupies no space in the file? Really? I mean, I knew it was compressed, but infinite compression? Philip Guenther
Re: random malloc junk
On Thu, Sep 15, 2016 at 10:08:26AM -0400, Ted Unangst wrote: > Otto Moerbeek wrote: > > On Wed, Sep 14, 2016 at 12:53:05PM -0400, Ted Unangst wrote: > > > > > Daniel Micay wrote: > > > > > > > > The current OpenBSD code only wipes up to MALLOC_MAXCHUNK with junk @ 1, > > > > and it similarly doesn't wipe at all with 'U' (even though junk-on-free > > > > also serves the purpose of preventing information leaks, not just > > > > mitigating use-after-free). IMO, optimizing large allocation perf like > > > > this isn't worthwhile. > > > > > > this requires some analysis of what programs do in the wild. some programs > > > preemptively malloc large buffers, but don't touch them. it would be a > > > serious > > > reqression for free to fault in new pages, just to ditry them, then turn > > > around and unmap them. some of this is because i believe the code is doing > > > things at the wrong time. if you want to dirty whole pages, it should be > > > when > > > they go on the freelist, not immediately. > > > > Something like this? > > didn't look too closely, but looks good from a distance. :) > Sligtly better diff: it gets rid of a PAGEROUND(sz) call, since sz == PAGEROUND(sz) in unmap(). -Otto Index: malloc.c === RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.195 diff -u -p -r1.195 malloc.c --- malloc.c1 Sep 2016 10:41:02 - 1.195 +++ malloc.c16 Sep 2016 19:26:34 - @@ -376,6 +376,11 @@ unmap(struct dir_info *d, void *p, size_ for (i = 0; i < mopts.malloc_cache; i++) { r = &d->free_regions[(i + offset) & (mopts.malloc_cache - 1)]; if (r->p == NULL) { + if (mopts.malloc_junk && !mopts.malloc_freeunmap) { + size_t amt = mopts.malloc_junk == 1 ? + MALLOC_MAXCHUNK : sz - mopts.malloc_guard; + memset(p, SOME_FREEJUNK, amt); + } if (mopts.malloc_hint) madvise(p, sz, MADV_FREE); if (mopts.malloc_freeunmap) @@ -1335,11 +1340,6 @@ ofree(struct dir_info *argpool, void *p) wrterror(pool, "mprotect", NULL); } STATS_SUB(pool->malloc_guarded, mopts.malloc_guard); - } - if (mopts.malloc_junk && !mopts.malloc_freeunmap) { - size_t amt = mopts.malloc_junk == 1 ? MALLOC_MAXCHUNK : - PAGEROUND(sz) - mopts.malloc_guard; - memset(p, SOME_FREEJUNK, amt); } unmap(pool, p, PAGEROUND(sz)); delete(pool, r);
define ELF_CTF in exec_elf.h
Hi, This moves the definition of ELF_CTF into exec_elf.h and adjusts the loadfile_elf.c copies accordingly. OK? Index: share/man/man5/elf.5 === RCS file: /cvs/src/share/man/man5/elf.5,v retrieving revision 1.32 diff -u -p -r1.32 elf.5 --- share/man/man5/elf.57 Sep 2016 18:42:01 - 1.32 +++ share/man/man5/elf.516 Sep 2016 19:16:37 - @@ -877,6 +877,13 @@ fixed-size entries. .Pp Various sections hold program and control information: .Bl -tag -width ".shstrtab" +.It .SUNW_ctf +This section contains the (un)compressed Compact C-Type Format data +describing the object's types and symbols. +This section is of type +.Dv SHT_NOBITS . +The attribute used is +.Dv SHF_ALLOC . .It .bss This section holds uninitialized data that contribute to the program's memory image. Index: sys/ddb/db_ctf.c === RCS file: /cvs/src/sys/ddb/db_ctf.c,v retrieving revision 1.1 diff -u -p -r1.1 db_ctf.c --- sys/ddb/db_ctf.c16 Sep 2016 19:13:17 - 1.1 +++ sys/ddb/db_ctf.c16 Sep 2016 19:16:37 - @@ -56,8 +56,6 @@ static char *db_ctf_decompress(const ch static int db_ctf_print_functions(); static int db_ctf_nsyms(void); -#defineELF_CTF ".SUNW_ctf" - /* * Entrypoint to verify CTF presence, initialize the header, decompress * the data, etc. Index: sys/lib/libsa/loadfile_elf.c === RCS file: /cvs/src/sys/lib/libsa/loadfile_elf.c,v retrieving revision 1.12 diff -u -p -r1.12 loadfile_elf.c --- sys/lib/libsa/loadfile_elf.c13 Sep 2016 18:09:14 - 1.12 +++ sys/lib/libsa/loadfile_elf.c16 Sep 2016 19:16:37 - @@ -234,7 +234,7 @@ ELFNAME(exec)(int fd, Elf_Ehdr *elf, u_l if (shp[i].sh_type == SHT_SYMTAB || shp[i].sh_type == SHT_STRTAB || !strcmp(shstr + shp[i].sh_name, ".debug_line") || - !strcmp(shstr + shp[i].sh_name, ".SUNW_ctf")) { + !strcmp(shstr + shp[i].sh_name, ELF_CTF)) { if (havesyms && (flags & LOAD_SYM)) { PROGRESS(("%s%ld", first ? " [" : "+", (u_long)shp[i].sh_size)); Index: sys/sys/exec_elf.h === RCS file: /cvs/src/sys/sys/exec_elf.h,v retrieving revision 1.63 diff -u -p -r1.63 exec_elf.h --- sys/sys/exec_elf.h 7 Sep 2016 20:12:42 - 1.63 +++ sys/sys/exec_elf.h 16 Sep 2016 19:16:36 - @@ -264,6 +264,7 @@ typedef struct { /* Section names */ #define ELF_BSS ".bss" /* uninitialized data */ #define ELF_DATA".data"/* initialized data */ +#defineELF_CTF ".SUNW_ctf" /* CTF data */ #define ELF_DEBUG ".debug" /* debug */ #define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ #define ELF_DYNSTR ".dynstr" /* dynamic string table */ Index: usr.sbin/vmd/loadfile_elf.c === RCS file: /cvs/src/usr.sbin/vmd/loadfile_elf.c,v retrieving revision 1.18 diff -u -p -r1.18 loadfile_elf.c --- usr.sbin/vmd/loadfile_elf.c 13 Sep 2016 19:07:47 - 1.18 +++ usr.sbin/vmd/loadfile_elf.c 16 Sep 2016 19:16:37 - @@ -779,7 +779,7 @@ elf64_exec(int fd, Elf64_Ehdr *elf, u_lo if (shp[i].sh_type == SHT_SYMTAB || shp[i].sh_type == SHT_STRTAB || !strcmp(shstr + shp[i].sh_name, ".debug_line") || - !strcmp(shstr + shp[i].sh_name, ".SUNW_ctf")) { + !strcmp(shstr + shp[i].sh_name, ELF_CTF)) { if (havesyms && (flags & LOAD_SYM)) { if (lseek(fd, (off_t)shp[i].sh_offset, SEEK_SET) == -1) { Cheers, -- jasper
Re: [RFC] domain name matching support for rebound(8)
On 2016/09/16 11:40, Ted Unangst wrote: > Dimitris Papastamos wrote: > > By the way, what do you think about TCP caching support? I could send > > a patch to do just that. Caching sounds complicated, DNS is a bit of a minefield to handle, you have to cope with things like compression - not that it's all that hard to do, but it's been responsible for various crashes and worse bugs over the years, it doesn't really sound like something that's part of rebound's remit. Do you mean just persistent TCP connections? That sounds simpler and potentially quite handy. > It seems unnecessary. tcp proxy support is there because it's necessary, but > not because i think it's likely to be used. i'm pretty sure i never use it, > except when i deliberately test that it's still working. TCP for DNS is useful, not least because it's very easy to forward over ssh. If you're stuck on a network that forcibly redirects DNS requests to a broken local resolver, ssh-forwarding is about the simplest way to point at a non-broken nameserver. It can also get through certain types of packet loss (bad wifi networks..) a lot better than UDP. > rebound isn't meant to be a replacement for unbound. it's just a piece of libc > that lives somewhere else.
fix clang types on arm
On OpenBSD we use a consistent set of typedefs across platforms for the types specified by the C standard. In some cases these deviate from what the processor-specific ABI says. The diff below fixes the ones relevant for arm, pretty much by following NetBSD. ok? Oh, and how do we handle upstreaming these kind of diffs? Index: gnu/llvm/tools/clang/lib/Basic/Targets.cpp === RCS file: /cvs/src/gnu/llvm/tools/clang/lib/Basic/Targets.cpp,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 Targets.cpp --- gnu/llvm/tools/clang/lib/Basic/Targets.cpp 3 Sep 2016 22:46:57 - 1.1.1.1 +++ gnu/llvm/tools/clang/lib/Basic/Targets.cpp 16 Sep 2016 18:58:59 - @@ -4275,8 +4275,10 @@ class ARMTargetInfo : public TargetInfo DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64; const llvm::Triple &T = getTriple(); -// size_t is unsigned long on MachO-derived environments, NetBSD and Bitrig. +// size_t is unsigned long on MachO-derived environments, NetBSD, +// OpenBSD and Bitrig. if (T.isOSBinFormatMachO() || T.getOS() == llvm::Triple::NetBSD || +T.getOS() == llvm::Triple::OpenBSD || T.getOS() == llvm::Triple::Bitrig) SizeType = UnsignedLong; else @@ -4284,6 +4286,7 @@ class ARMTargetInfo : public TargetInfo switch (T.getOS()) { case llvm::Triple::NetBSD: +case llvm::Triple::OpenBSD: WCharType = SignedInt; break; case llvm::Triple::Win32: @@ -4475,6 +4478,7 @@ public: switch (getTriple().getOS()) { case llvm::Triple::NetBSD: +case llvm::Triple::OpenBSD: PtrDiffType = SignedLong; break; default:
Re: teach BFD how to send route messages
On 2016 Sep 15 (Thu) at 16:30:50 +0200 (+0200), Peter Hessler wrote: :Based on the above, and a few private comments, I will change the name :away from bfd_softc. Here is a diff doing a massive rename. It is mostly mechanical, functional changes will come later. I can still establish and bring down a BFD session as normal. bfd_msghdr, with a prefix of 'bm_' for BFD Message. This is for route messages. bfd_state -> bfd_neighbor, with a prefix of 'bn_' for BFD Neighbor. This is the state machine per neighbor. bfd_softc -> bfd_config, with a prefix of 'bc_' for BFD Config. This holds the entire configuration for each configured neighboring system. bfd_rtalloc() -> bfdset(). rtalloc was a bad name, and we shouldn't emulate it, and we aren't actually allocating a route. bfd_rtfree() -> bfdclear(). Same. move bfd_neighbor into bfd.h, because it is directly used by bfd_config. OK? Index: sys/net/bfd.c === RCS file: /cvs/openbsd/src/sys/net/bfd.c,v retrieving revision 1.26 diff -u -p -u -p -r1.26 bfd.c --- sys/net/bfd.c 15 Sep 2016 08:39:44 - 1.26 +++ sys/net/bfd.c 16 Sep 2016 18:49:07 - @@ -140,36 +140,19 @@ struct bfd_auth_header { #define BFD_MINIMUM1 /* 10,000 us == 10 ms */ -/* These spellings and capitalizations match RFC 5880 6.8.1*/ -/* Do not change */ -struct bfd_state { - uint32_tSessionState; - uint32_tRemoteSessionState; - uint32_tLocalDiscr; /* Unique identifier */ - uint32_tRemoteDiscr;/* Unique identifier */ - uint32_tLocalDiag; - uint32_tRemoteDiag; - uint32_tDesiredMinTxInterval; - uint32_tRequiredMinRxInterval; - uint32_tRemoteMinRxInterval; - uint32_tDemandMode; - uint32_tRemoteDemandMode; - uint32_tDetectMult; /* Detection Time Multiplier*/ - uint32_tAuthType; - uint32_tRcvAuthSeq; - uint32_tXmitAuthSeq; - uint32_tAuthSeqKnown; -}; - -struct pool bfd_pool, bfd_pool_peer, bfd_pool_time; +struct pool bfd_pool, bfd_pool_neigh, bfd_pool_time; struct taskq *bfdtq; -struct socket *bfd_listener(struct bfd_softc *, unsigned int); -struct socket *bfd_sender(struct bfd_softc *, unsigned int); -voidbfd_input(struct bfd_softc *, struct mbuf *); -voidbfd_set_state(struct bfd_softc *, int); -int bfd_send(struct bfd_softc *, struct mbuf *); +struct bfd_config *bfd_lookup(struct rtentry *); +voidbfddestroy(void); + +struct socket *bfd_listener(struct bfd_config *, unsigned int); +struct socket *bfd_sender(struct bfd_config *, unsigned int); +voidbfd_input(struct bfd_config *, struct mbuf *); +voidbfd_set_state(struct bfd_config *, int); + +int bfd_send(struct bfd_config *, struct mbuf *); voidbfd_send_control(void *); voidbfd_start_task(void *); @@ -178,21 +161,21 @@ void bfd_timeout_rx(void *); voidbfd_timeout_tx(void *); voidbfd_upcall(struct socket *, caddr_t, int); -voidbfd_senddown(struct bfd_softc *); -voidbfd_reset(struct bfd_softc *); -voidbfd_set_uptime(struct bfd_softc *); +voidbfd_senddown(struct bfd_config *); +voidbfd_reset(struct bfd_config *); +voidbfd_set_uptime(struct bfd_config *); -voidbfd_debug(struct bfd_softc *); +voidbfd_debug(struct bfd_config *); -TAILQ_HEAD(bfd_queue, bfd_softc) bfd_queue; +TAILQ_HEAD(bfd_queue, bfd_config) bfd_queue; /* * allocate a new bfd session */ int -bfd_rtalloc(struct rtentry *rt) +bfdset(struct rtentry *rt) { - struct bfd_softc*sc; + struct bfd_config *bfd; /* at the moment it is not allowed to run BFD on indirect routes */ if (ISSET(rt->rt_flags, RTF_GATEWAY) || !ISSET(rt->rt_flags, RTF_HOST)) @@ -203,26 +186,26 @@ bfd_rtalloc(struct rtentry *rt) return (EADDRINUSE); /* Do our necessary memory allocations upfront */ - sc = pool_get(&bfd_pool, PR_WAITOK | PR_ZERO); - sc->sc_peer = pool_get(&bfd_pool_peer, PR_WAITOK | PR_ZERO); - sc->sc_time = pool_get(&bfd_pool_time, PR_WAITOK | PR_ZERO); - - sc->sc_rt = rt; - rtref(sc->sc_rt); /* we depend on this route not going away */ - - microtime(sc->sc_time); - bfd_reset(sc); - sc->sc_peer->LocalDiscr = arc4random(); /* XXX - MUST be globally unique */ - - if (!timeout_initialized(&sc->sc_timo_rx)) - timeout_set(&sc->sc_timo_rx, bfd_timeout_rx, sc); - if (!timeout_initialized(&sc->sc_timo_tx)) - timeout_set(&sc->sc_timo_tx, bfd_timeout_tx, sc); + bfd = pool_get(&bfd_pool, PR_WAITOK | PR_ZERO); + bfd->bc_neighbor = pool_get(&bfd_pool_neigh, PR_WAITOK | PR_ZERO); + bfd->bc_time = pool_get(&bfd_pool_time, PR_WAI
Re: PT_ARM_EXIDX
On Fri, Sep 16, 2016 at 11:14 AM, Mark Kettenis wrote: > The ARM EABI exception handling support introduced a new program > header entry type. This adds it to the appropriate header file. I'm > working on some code that uses this. > > ok? Matches what binutils-2.17 says and that's the right file to put it in; ok guenther@
clang makefiles for arm
I'm working on arm support for the in-tree llvm. I've got it working well enough to build "Hello, World", but I still have some exception handling issues. As a first step, this adds the build infrastructure. ok? Index: include/llvm/ARM/Makefile === RCS file: include/llvm/ARM/Makefile diff -N include/llvm/ARM/Makefile --- /dev/null 1 Jan 1970 00:00:00 - +++ include/llvm/ARM/Makefile 16 Sep 2016 18:18:50 - @@ -0,0 +1,85 @@ +# $OpenBSD: Makefile,v 1.1 2016/09/05 10:56:48 pascal Exp $ + +.include + +LLVM_SRCS= ${.CURDIR}/../../../../../llvm + +HDRS= ARMGenAsmMatcher.inc ARMGenAsmWriter.inc \ + ARMGenCallingConv.inc ARMGenDAGISel.inc ARMGenDisassemblerTables.inc \ + ARMGenFastISel.inc ARMGenInstrInfo.inc ARMGenRegisterInfo.inc \ + ARMGenSubtargetInfo.inc \ + ARMGenMCCodeEmitter.inc ARMGenMCPseudoLowering.inc \ + ARMGenDisassemblerTables.inc + +all: ${HDRS} + +install: + # Nothing here so far ... + +depend: + # Nothing here so far ... + +clean: + rm -f ${HDRS} + +ARMGenRegisterInfo.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-register-info \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenDisassemblerTables.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-disassembler \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenInstrInfo.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-instr-info \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenAsmWriter.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-asm-writer \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenAsmMatcher.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-asm-matcher \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenDAGISel.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-dag-isel \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenFastISel.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-fast-isel \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenCallingConv.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-callingconv \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenSubtargetInfo.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-subtarget \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenMCCodeEmitter.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-emitter \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenMCPseudoLowering.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-pseudo-lowering \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +ARMGenDisassemblerTables.inc: ${LLVM_SRCS}/lib/Target/ARM/ARM.td + ${.OBJDIR}/../../../llvm-tblgen/llvm-tblgen -gen-disassembler \ + -I${LLVM_SRCS}/include -I${LLVM_SRCS}/lib/Target/ARM \ + -o ${.TARGET} ${.ALLSRC} + +.include Index: libLLVMARMAsmParser/Makefile === RCS file: libLLVMARMAsmParser/Makefile diff -N libLLVMARMAsmParser/Makefile --- /dev/null 1 Jan 1970 00:00:00 - +++ libLLVMARMAsmParser/Makefile16 Sep 2016 18:18:50 - @@ -0,0 +1,20 @@ +# $OpenBSD: Makefile,v 1.1 2016/09/05 10:56:50 pascal Exp $ + +LIB= LLVMARMAsmParser +NOPIC= +NOPROFILE= + +CPPFLAGS+= -I${.OBJDIR}/../include/llvm/ARM -I${LLVM_SRCS}/lib/Target/ARM + +.include +SRCS= ARMAsmParser.cpp + +.PATH: ${.CURDIR}/../../../llvm/lib/Target/ARM/AsmParser + +depend: + # Nothing here so far ... + +install: + # Nothing here so far ... + +.include Index: libLLVMARMAsmPrinter/Makefile === RCS file: libLLVMARMAsmPrinter/Makefile diff -N libLLVMARMAsmPrinter/Makefile --- /dev/null 1 Jan 1970 00:00:00 - +++ libLLVMARMAsmPrinter/
PT_ARM_EXIDX
The ARM EABI exception handling support introduced a new program header entry type. This adds it to the appropriate header file. I'm working on some code that uses this. ok? Index: arch/arm/include/exec.h === RCS file: /cvs/src/sys/arch/arm/include/exec.h,v retrieving revision 1.4 diff -u -p -r1.4 exec.h --- arch/arm/include/exec.h 29 Aug 2015 01:58:39 - 1.4 +++ arch/arm/include/exec.h 16 Sep 2016 18:11:24 - @@ -41,4 +41,6 @@ #define _KERN_DO_ELF +#define PT_ARM_EXIDX 0x7001 + #endif /* _ARM_EXEC_H_ */
crypto/ bcopy->memcpy
Hello - Here are a few bcopy to memcpy conversions for crypto/ Index: crypto/crypto.c === RCS file: /cvs/src/sys/crypto/crypto.c,v retrieving revision 1.77 diff -u -p -r1.77 crypto.c --- crypto/crypto.c 15 Sep 2016 02:00:17 - 1.77 +++ crypto/crypto.c 16 Sep 2016 17:40:04 - @@ -254,7 +254,7 @@ crypto_get_driverid(u_int8_t flags) return -1; } - bcopy(crypto_drivers, newdrv, + memcpy(newdrv, crypto_drivers, crypto_drivers_num * sizeof(struct cryptocap)); bzero(&newdrv[crypto_drivers_num], crypto_drivers_num * sizeof(struct cryptocap)); Index: crypto/gmac.c === RCS file: /cvs/src/sys/crypto/gmac.c,v retrieving revision 1.8 diff -u -p -r1.8 gmac.c --- crypto/gmac.c 7 Nov 2015 17:46:49 - 1.8 +++ crypto/gmac.c 16 Sep 2016 17:40:04 - @@ -144,7 +144,7 @@ AES_GMAC_Update(void *xctx, const uint8_ (*ghash_update)(&ctx->ghash, (uint8_t *)data, len - plen); if (plen) { - bcopy((uint8_t *)data + (len - plen), (uint8_t *)blk, + memcpy((uint8_t *)blk, (uint8_t *)data + (len - plen), plen); (*ghash_update)(&ctx->ghash, (uint8_t *)blk, GMAC_BLOCK_LEN); Index: crypto/hmac.c === RCS file: /cvs/src/sys/crypto/hmac.c,v retrieving revision 1.3 diff -u -p -r1.3 hmac.c --- crypto/hmac.c 11 Jan 2011 15:42:05 - 1.3 +++ crypto/hmac.c 16 Sep 2016 17:40:04 - @@ -46,7 +46,7 @@ HMAC_MD5_Init(HMAC_MD5_CTX *ctx, const u } bzero(k_ipad, MD5_BLOCK_LENGTH); - bcopy(ctx->key, k_ipad, ctx->key_len); + memcpy(k_ipad, ctx->key, ctx->key_len); for (i = 0; i < MD5_BLOCK_LENGTH; i++) k_ipad[i] ^= 0x36; @@ -71,7 +71,7 @@ HMAC_MD5_Final(u_int8_t digest[MD5_DIGES MD5Final(digest, &ctx->ctx); bzero(k_opad, MD5_BLOCK_LENGTH); - bcopy(ctx->key, k_opad, ctx->key_len); + memcpy(k_opad, ctx->key, ctx->key_len); for (i = 0; i < MD5_BLOCK_LENGTH; i++) k_opad[i] ^= 0x5c; @@ -100,7 +100,7 @@ HMAC_SHA1_Init(HMAC_SHA1_CTX *ctx, const } bzero(k_ipad, SHA1_BLOCK_LENGTH); - bcopy(ctx->key, k_ipad, ctx->key_len); + memcpy(k_ipad, ctx->key, ctx->key_len); for (i = 0; i < SHA1_BLOCK_LENGTH; i++) k_ipad[i] ^= 0x36; @@ -125,7 +125,7 @@ HMAC_SHA1_Final(u_int8_t digest[SHA1_DIG SHA1Final(digest, &ctx->ctx); bzero(k_opad, SHA1_BLOCK_LENGTH); - bcopy(ctx->key, k_opad, ctx->key_len); + memcpy(k_opad, ctx->key, ctx->key_len); for (i = 0; i < SHA1_BLOCK_LENGTH; i++) k_opad[i] ^= 0x5c; @@ -154,7 +154,7 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, c } bzero(k_ipad, SHA256_BLOCK_LENGTH); - bcopy(ctx->key, k_ipad, ctx->key_len); + memcpy(k_ipad, ctx->key, ctx->key_len); for (i = 0; i < SHA256_BLOCK_LENGTH; i++) k_ipad[i] ^= 0x36; @@ -179,7 +179,7 @@ HMAC_SHA256_Final(u_int8_t digest[SHA256 SHA256Final(digest, &ctx->ctx); bzero(k_opad, SHA256_BLOCK_LENGTH); - bcopy(ctx->key, k_opad, ctx->key_len); + memcpy(k_opad, ctx->key, ctx->key_len); for (i = 0; i < SHA256_BLOCK_LENGTH; i++) k_opad[i] ^= 0x5c; Index: crypto/xform.c === RCS file: /cvs/src/sys/crypto/xform.c,v retrieving revision 1.54 diff -u -p -r1.54 xform.c --- crypto/xform.c 10 Dec 2015 21:00:51 - 1.54 +++ crypto/xform.c 16 Sep 2016 17:40:04 - @@ -491,7 +491,7 @@ aes_xts_reinit(caddr_t key, u_int8_t *iv * Prepare tweak as E_k2(IV). IV is specified as LE representation * of a 64-bit block number which we allow to be passed in directly. */ - bcopy(iv, &blocknum, AES_XTS_IVSIZE); + memcpy(&blocknum, iv, AES_XTS_IVSIZE); for (i = 0; i < AES_XTS_IVSIZE; i++) { ctx->tweak[i] = blocknum & 0xff; blocknum >>= 8;
make sv(4) use the trigger_{intput,output}() interface
This makes sv(4) use the "modern" audio interface. Basically, this blindly concatenates the init_xxx() and start_xxx() functions into a single trigger_xxx() function. OK? Index: sv.c === RCS file: /cvs/src/sys/dev/pci/sv.c,v retrieving revision 1.33 diff -u -p -u -p -r1.33 sv.c --- sv.c14 Sep 2016 06:12:19 - 1.33 +++ sv.c16 Sep 2016 17:03:31 - @@ -139,10 +139,10 @@ int sv_open(void *, int); void sv_close(void *); intsv_set_params(void *, int, int, struct audio_params *, struct audio_params *); intsv_round_blocksize(void *, int); -intsv_dma_init_output(void *, void *, int); -intsv_dma_init_input(void *, void *, int); -intsv_dma_output(void *, void *, int, void (*)(void *), void *); -intsv_dma_input(void *, void *, int, void (*)(void *), void *); +intsv_trigger_output(void *, void *, void *, int, +void (*)(void *), void *, struct audio_params *); +intsv_trigger_input(void *, void *, void *, int, +void (*)(void *), void *, struct audio_params *); intsv_halt_in_dma(void *); intsv_halt_out_dma(void *); intsv_getdev(void *, struct audio_device *); @@ -161,10 +161,10 @@ struct audio_hw_if sv_hw_if = { sv_set_params, sv_round_blocksize, NULL, - sv_dma_init_output, - sv_dma_init_input, - sv_dma_output, - sv_dma_input, + NULL, + NULL, + NULL, + NULL, sv_halt_out_dma, sv_halt_in_dma, NULL, @@ -177,8 +177,8 @@ struct audio_hw_if sv_hw_if = { sv_free, NULL, sv_get_props, - NULL, - NULL + sv_trigger_output, + sv_trigger_input }; @@ -687,106 +687,78 @@ sv_round_blocksize(void *addr, int blk) } int -sv_dma_init_input(void *addr, void *buf, int cc) +sv_trigger_output(void *addr, void *start, void *end, int blksize, +void (*intr)(void *), void *arg, struct audio_params *param) { struct sv_softc *sc = addr; struct sv_dma *p; - int dma_count; + int mode, dma_count; - DPRINTF(("sv_dma_init_input: dma start loop input addr=%p cc=%d\n", -buf, cc)); -for (p = sc->sc_dmas; p && KERNADDR(p) != buf; p = p->next) +for (p = sc->sc_dmas; p && KERNADDR(p) != start; p = p->next) ; if (!p) { - printf("sv_dma_init_input: bad addr %p\n", buf); + printf("sv_trigger_output: bad addr %p\n", start); return (EINVAL); } - dma_count = (cc >> 1) - 1; - - bus_space_write_4(sc->sc_iot, sc->sc_dmac_ioh, SV_DMA_ADDR0, + dma_count = (char *)end - (char *)start - 1; + bus_space_write_4(sc->sc_iot, sc->sc_dmaa_ioh, SV_DMA_ADDR0, DMAADDR(p)); - bus_space_write_4(sc->sc_iot, sc->sc_dmac_ioh, SV_DMA_COUNT0, + bus_space_write_4(sc->sc_iot, sc->sc_dmaa_ioh, SV_DMA_COUNT0, dma_count); - bus_space_write_1(sc->sc_iot, sc->sc_dmac_ioh, SV_DMA_MODE, - DMA37MD_WRITE | DMA37MD_LOOP); + bus_space_write_1(sc->sc_iot, sc->sc_dmaa_ioh, SV_DMA_MODE, + DMA37MD_READ | DMA37MD_LOOP); - return (0); + sc->sc_pintr = intr; + sc->sc_parg = arg; + + dma_count = blksize - 1; + sv_write_indirect(sc, SV_DMAA_COUNT1, dma_count >> 8); + sv_write_indirect(sc, SV_DMAA_COUNT0, (dma_count & 0xFF)); + + mode = sv_read_indirect(sc, SV_PLAY_RECORD_ENABLE); + mode |= SV_PLAY_ENABLE; + sv_write_indirect(sc, SV_PLAY_RECORD_ENABLE, mode); + sc->sc_enable |= SV_PLAY_ENABLE; +return (0); } + int -sv_dma_init_output(void *addr, void *buf, int cc) +sv_trigger_input(void *handle, void *start, void *end, int blksize, +void (*intr)(void *), void *arg, struct audio_params *param) { struct sv_softc *sc = addr; struct sv_dma *p; - int dma_count; + int mode, dma_count; - DPRINTF(("sv: dma start loop output buf=%p cc=%d\n", buf, cc)); -for (p = sc->sc_dmas; p && KERNADDR(p) != buf; p = p->next) +for (p = sc->sc_dmas; p && KERNADDR(p) != start; p = p->next) ; if (!p) { - printf("sv_dma_init_output: bad addr %p\n", buf); + printf("sv_trigger_input: bad addr %p\n", start); return (EINVAL); } - dma_count = cc - 1; - - bus_space_write_4(sc->sc_iot, sc->sc_dmaa_ioh, SV_DMA_ADDR0, + dma_count = (((char *)end - (char *)start) >> 1) - 1; + bus_space_write_4(sc->sc_iot, sc->sc_dmac_ioh, SV_DMA_ADDR0, DMAADDR(p)); - bus_space_write_4(sc->sc_iot, sc->sc_dmaa_ioh, SV_DMA_COUNT0, + bus_space_write_4(sc->sc_iot, sc->sc_dmac_ioh, SV_DMA_COUNT0, dma_count); - bus_space_write_1(sc->sc_iot, sc->sc_dmaa_ioh, SV_DMA_MODE, -
Re: [RFC] domain name matching support for rebound(8)
Dimitris Papastamos wrote: > By the way, what do you think about TCP caching support? I could send > a patch to do just that. It seems unnecessary. tcp proxy support is there because it's necessary, but not because i think it's likely to be used. i'm pretty sure i never use it, except when i deliberately test that it's still working. rebound isn't meant to be a replacement for unbound. it's just a piece of libc that lives somewhere else.
Re: timeout_set_proc(9)
> Date: Thu, 15 Sep 2016 16:29:45 +0200 > From: Martin Pieuchot > > After discussing with a few people about a new "timed task" API I came > to the conclusion that mixing timeouts and tasks will result in: > > - always including a 'struct timeout' in a 'struct task', or the other > the way around > or > > - introducing a new data structure, hence API. > > Since I'd like to keep the change as small as possible when converting > existing timeout_set(9), neither option seem a good fit. So I decided > to add a new kernel thread, curiously named "softclock", that will > offer his stack to the poor timeout handlers that need one. > > With this approach, converting a timeout is just a matter of doing: > > s/timeout_set/timeout_set_proc/ > > > Diff below includes the conversions I need for the "netlock". I'm > waiting for feedbacks and a better name to document the new function. > > Comments? I like how minimal this is. Would like to see a few more people that are familliar with the timeout code chime in, but it looks mostly correct to me as well. One question though: > Index: kern/kern_timeout.c > === > RCS file: /cvs/src/sys/kern/kern_timeout.c,v > retrieving revision 1.48 > diff -u -p -r1.48 kern_timeout.c > --- kern/kern_timeout.c 6 Jul 2016 15:53:01 - 1.48 > +++ kern/kern_timeout.c 15 Sep 2016 14:19:10 - > @@ -27,7 +27,7 @@ > > #include > #include > -#include > +#include > #include > #include > #include > @@ -54,6 +54,7 @@ > > struct circq timeout_wheel[BUCKETS]; /* Queues of timeouts */ > struct circq timeout_todo; /* Worklist */ > +struct circq timeout_proc; /* Due timeouts needing proc. context */ > > #define MASKWHEEL(wheel, time) (((time) >> ((wheel)*WHEELBITS)) & WHEELMASK) > > @@ -127,6 +128,9 @@ struct mutex timeout_mutex = MUTEX_INITI > > #define CIRCQ_EMPTY(elem) (CIRCQ_FIRST(elem) == (elem)) > > +void softclock_thread(void *); > +void softclock_create_thread(void *); > + > /* > * Some of the "math" in here is a bit tricky. > * > @@ -147,11 +151,18 @@ timeout_startup(void) > int b; > > CIRCQ_INIT(&timeout_todo); > + CIRCQ_INIT(&timeout_proc); > for (b = 0; b < nitems(timeout_wheel); b++) > CIRCQ_INIT(&timeout_wheel[b]); > } > > void > +timeout_proc_init(void) > +{ > + kthread_create_deferred(softclock_create_thread, curcpu()); > +} > + > +void > timeout_set(struct timeout *new, void (*fn)(void *), void *arg) > { > new->to_func = fn; > @@ -159,6 +170,12 @@ timeout_set(struct timeout *new, void (* > new->to_flags = TIMEOUT_INITIALIZED; > } > > +void > +timeout_set_proc(struct timeout *new, void (*fn)(void *), void *arg) > +{ > + timeout_set(new, fn, arg); > + new->to_flags |= TIMEOUT_NEEDPROCCTX; > +} > > int > timeout_add(struct timeout *new, int to_ticks) > @@ -334,38 +351,84 @@ timeout_hardclock_update(void) > } > > void > +timeout_run(struct timeout *to) > +{ > + void (*fn)(void *); > + void *arg; > + > + MUTEX_ASSERT_LOCKED(&timeout_mutex); > + > + to->to_flags &= ~TIMEOUT_ONQUEUE; > + to->to_flags |= TIMEOUT_TRIGGERED; > + > + fn = to->to_func; > + arg = to->to_arg; > + > + mtx_leave(&timeout_mutex); > + fn(arg); > + mtx_enter(&timeout_mutex); > +} > + > +void > softclock(void *arg) > { > int delta; > struct circq *bucket; > struct timeout *to; > - void (*fn)(void *); > > mtx_enter(&timeout_mutex); > while (!CIRCQ_EMPTY(&timeout_todo)) { > to = timeout_from_circq(CIRCQ_FIRST(&timeout_todo)); > CIRCQ_REMOVE(&to->to_list); > > - /* If due run it, otherwise insert it into the right bucket. */ > + /* > + * If due run it or defer execution to the thread, > + * otherwise insert it into the right bucket. > + */ > delta = to->to_time - ticks; > if (delta > 0) { > bucket = &BUCKET(delta, to->to_time); > CIRCQ_INSERT(&to->to_list, bucket); > + } else if (to->to_flags & TIMEOUT_NEEDPROCCTX) { > + CIRCQ_INSERT(&to->to_list, &timeout_proc); > + wakeup(&timeout_proc); > } else { > #ifdef DEBUG > if (delta < 0) > printf("timeout delayed %d\n", delta); > #endif > - to->to_flags &= ~TIMEOUT_ONQUEUE; > - to->to_flags |= TIMEOUT_TRIGGERED; > + timeout_run(to); > + } > + } > + mtx_leave(&timeout_mutex); > +} > > - fn = to->to_func; > - arg = to->to_arg; > +void > +softclock_create_thread(void *xci) > +{ > + if (kthread_create(softclock_thread, xci, NULL, "softclock")) > + p
Re: timeout_set_proc(9)
> Date: Fri, 16 Sep 2016 16:03:50 +0200 > From: Vincent Gross > > On Thu, 15 Sep 2016 16:29:45 +0200 > Martin Pieuchot wrote: > > > After discussing with a few people about a new "timed task" API I came > > to the conclusion that mixing timeouts and tasks will result in: > > > > - always including a 'struct timeout' in a 'struct task', or the > > other the way around > > or > > > > - introducing a new data structure, hence API. > > > > Since I'd like to keep the change as small as possible when converting > > existing timeout_set(9), neither option seem a good fit. So I decided > > to add a new kernel thread, curiously named "softclock", that will > > offer his stack to the poor timeout handlers that need one. > > > > With this approach, converting a timeout is just a matter of doing: > > > > s/timeout_set/timeout_set_proc/ > > > > > > Diff below includes the conversions I need for the "netlock". I'm > > waiting for feedbacks and a better name to document the new function. > > > > Comments? > > Reads OK; I like the simple renaming. > > The "softclock" thread name will be confusing, the timeouts are indeed > driven by the softclock interrupt, but the tasks have nothing to do > with softclock. Maybe "timeothread" ? Naming things is always hard. The :"thread" in the name is a bit redundant. Probably just "timeout" would be fine. The nice thing about "sofclock" is that it is nicely symmetric with the "softnet" thread. Although that one is a taskq.
Re: timeout_set_proc(9)
On Thu, 15 Sep 2016 16:29:45 +0200 Martin Pieuchot wrote: > After discussing with a few people about a new "timed task" API I came > to the conclusion that mixing timeouts and tasks will result in: > > - always including a 'struct timeout' in a 'struct task', or the > other the way around > or > > - introducing a new data structure, hence API. > > Since I'd like to keep the change as small as possible when converting > existing timeout_set(9), neither option seem a good fit. So I decided > to add a new kernel thread, curiously named "softclock", that will > offer his stack to the poor timeout handlers that need one. > > With this approach, converting a timeout is just a matter of doing: > > s/timeout_set/timeout_set_proc/ > > > Diff below includes the conversions I need for the "netlock". I'm > waiting for feedbacks and a better name to document the new function. > > Comments? Reads OK; I like the simple renaming. The "softclock" thread name will be confusing, the timeouts are indeed driven by the softclock interrupt, but the tasks have nothing to do with softclock. Maybe "timeothread" ? Will this new thread stay, or is it only to ease the transition to MP networking ? > > Index: net/if_pflow.c > === > RCS file: /cvs/src/sys/net/if_pflow.c,v > retrieving revision 1.61 > diff -u -p -r1.61 if_pflow.c > --- net/if_pflow.c29 Apr 2016 08:55:03 - 1.61 > +++ net/if_pflow.c15 Sep 2016 14:19:10 - > @@ -548,15 +548,16 @@ pflow_init_timeouts(struct pflow_softc * > if (timeout_initialized(&sc->sc_tmo_tmpl)) > timeout_del(&sc->sc_tmo_tmpl); > if (!timeout_initialized(&sc->sc_tmo)) > - timeout_set(&sc->sc_tmo, pflow_timeout, sc); > + timeout_set_proc(&sc->sc_tmo, pflow_timeout, > sc); break; > case PFLOW_PROTO_10: > if (!timeout_initialized(&sc->sc_tmo_tmpl)) > - timeout_set(&sc->sc_tmo_tmpl, > pflow_timeout_tmpl, sc); > + timeout_set_proc(&sc->sc_tmo_tmpl, > pflow_timeout_tmpl, > + sc); > if (!timeout_initialized(&sc->sc_tmo)) > - timeout_set(&sc->sc_tmo, pflow_timeout, sc); > + timeout_set_proc(&sc->sc_tmo, pflow_timeout, > sc); if (!timeout_initialized(&sc->sc_tmo6)) > - timeout_set(&sc->sc_tmo6, pflow_timeout6, > sc); > + timeout_set_proc(&sc->sc_tmo6, > pflow_timeout6, sc); > timeout_add_sec(&sc->sc_tmo_tmpl, > PFLOW_TMPL_TIMEOUT); break; > Index: net/if_pfsync.c > === > RCS file: /cvs/src/sys/net/if_pfsync.c,v > retrieving revision 1.231 > diff -u -p -r1.231 if_pfsync.c > --- net/if_pfsync.c 15 Sep 2016 02:00:18 - 1.231 > +++ net/if_pfsync.c 15 Sep 2016 14:19:10 - > @@ -328,9 +328,9 @@ pfsync_clone_create(struct if_clone *ifc > IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); > ifp->if_hdrlen = sizeof(struct pfsync_header); > ifp->if_mtu = ETHERMTU; > - timeout_set(&sc->sc_tmo, pfsync_timeout, sc); > - timeout_set(&sc->sc_bulk_tmo, pfsync_bulk_update, sc); > - timeout_set(&sc->sc_bulkfail_tmo, pfsync_bulk_fail, sc); > + timeout_set_proc(&sc->sc_tmo, pfsync_timeout, sc); > + timeout_set_proc(&sc->sc_bulk_tmo, pfsync_bulk_update, sc); > + timeout_set_proc(&sc->sc_bulkfail_tmo, pfsync_bulk_fail, sc); > > if_attach(ifp); > if_alloc_sadl(ifp); > @@ -1723,7 +1723,7 @@ pfsync_defer(struct pf_state *st, struct > sc->sc_deferred++; > TAILQ_INSERT_TAIL(&sc->sc_deferrals, pd, pd_entry); > > - timeout_set(&pd->pd_tmo, pfsync_defer_tmo, pd); > + timeout_set_proc(&pd->pd_tmo, pfsync_defer_tmo, pd); > timeout_add_msec(&pd->pd_tmo, 20); > > schednetisr(NETISR_PFSYNC); > Index: netinet/ip_carp.c > === > RCS file: /cvs/src/sys/netinet/ip_carp.c,v > retrieving revision 1.293 > diff -u -p -r1.293 ip_carp.c > --- netinet/ip_carp.c 25 Jul 2016 16:44:04 - 1.293 > +++ netinet/ip_carp.c 15 Sep 2016 14:19:11 - > @@ -831,9 +831,9 @@ carp_new_vhost(struct carp_softc *sc, in > vhe->vhid = vhid; > vhe->advskew = advskew; > vhe->state = INIT; > - timeout_set(&vhe->ad_tmo, carp_send_ad, vhe); > - timeout_set(&vhe->md_tmo, carp_master_down, vhe); > - timeout_set(&vhe->md6_tmo, carp_master_down, vhe); > + timeout_set_proc(&vhe->ad_tmo, carp_send_ad, vhe); > + timeout_set_proc(&vhe->md_tmo, carp_master_down, vhe); > + timeout_set_proc(&vhe->md6_tmo, carp_master_down, vhe); > > KERNEL_ASSERT_LOCKED(); /* touching carp_vhosts */ > > Index: netinet/tcp_timer.h > === > RCS file: /cvs/src/sys/netinet/tcp_timer.
Re: [RFC] domain name matching support for rebound(8)
On Fri, Sep 16, 2016 at 09:09:44AM -0400, Ted Unangst wrote: > Dimitris Papastamos wrote: > > Hi everyone, > > > > I've put together a patch for 6.0-stable that adds domain name > > matching support to rebound(8). The patch is quite rough at the > > moment. > > > > The config is as follows: > > > > match "local." 10.0.0.53 > > match "." 8.8.8.8 > > So this is taking rebound in a rather different direction than planned. It's > not supposed to do anything complicated. Also, the plan is to remove its > config file entirely. > > But I think I know why you want this. I have this pf.conf rule on my firewall. > > pass in on cnmac1 proto { udp , tcp } from any to any port 53 rdr-to 10.1.1.1 > port 53 Yes that works for me then. By the way, what do you think about TCP caching support? I could send a patch to do just that.
Re: [RFC] domain name matching support for rebound(8)
Dimitris Papastamos wrote: > Hi everyone, > > I've put together a patch for 6.0-stable that adds domain name > matching support to rebound(8). The patch is quite rough at the > moment. > > The config is as follows: > > match "local." 10.0.0.53 > match "." 8.8.8.8 So this is taking rebound in a rather different direction than planned. It's not supposed to do anything complicated. Also, the plan is to remove its config file entirely. But I think I know why you want this. I have this pf.conf rule on my firewall. pass in on cnmac1 proto { udp , tcp } from any to any port 53 rdr-to 10.1.1.1 port 53
Re: rebound quantum entanglement
On 2016-09-15, "Ted Unangst" wrote: > Particular edge case: if resolv.conf has no nameservers, then the localhost > default is not prepended. So libc won't try talking to rebound if it's > specifically configured not to (chroot). Huh? If resolv.conf has no nameservers, libc already falls back to the localhost. -- Christian "naddy" Weisgerber na...@mips.inka.de
[RFC] domain name matching support for rebound(8)
Hi everyone, I've put together a patch for 6.0-stable that adds domain name matching support to rebound(8). The patch is quite rough at the moment. The config is as follows: match "local." 10.0.0.53 match "." 8.8.8.8 Requests to foo.local. are sent over to 10.0.0.53, all other requests go to 8.8.8.8. In my implementation, the first match wins. General drawbacks: - rebound has to parse DNS requests. I tried to keep the parsing code as small as possible to avoid security problems. Drawbacks in current implementation: - No caching for DNS requests over TCP. I am planning to implement this via a unified cache that works for both UDP and TCP. - non-blocking connect(2) support for TCP. The original code handled that but I reworked it because I wanted to get it working first. What do you think? === RCS file: /cvs/src/usr.sbin/rebound/rebound.c,v retrieving revision 1.65 diff -u -p -r1.65 rebound.c --- rebound.c 2 Jul 2016 17:09:09 - 1.65 +++ rebound.c 16 Sep 2016 12:29:39 - @@ -37,6 +37,8 @@ #include #include +#define LEN(x) (sizeof (x) / sizeof *(x)) + uint16_t randomid(void); static struct timespec now; @@ -100,6 +102,13 @@ struct request { }; static TAILQ_HEAD(, request) reqfifo; +struct match { + char pat[256]; + struct sockaddr_storage to; + TAILQ_ENTRY(match) entry; +}; +static TAILQ_HEAD(, match) matches; + static int conncount; static int connmax; static uint64_t conntotal; @@ -215,10 +224,94 @@ servfail(int ud, uint16_t id, struct soc sendto(ud, &pkt, sizeof(pkt), 0, fromaddr, fromlen); } +static size_t +readn(int fd, void *buf, size_t n) +{ + size_t total = 0; + size_t r; + + while (n > 0) { + r = read(fd, buf + total, n); + if (r == 0 || r == -1) + return -1; + total += r; + n -= r; + } + return total; +} + +static size_t +writen(int fd, void *buf, size_t n) +{ + size_t total = 0; + size_t r; + + while (n > 0) { + r = write(fd, buf + total, n); + if (r == 0 || r == -1) + return -1; + total += r; + n -= r; + } + return total; +} + +int +parsedomain(uint8_t *buf, size_t buflen, char *host, size_t hostlen) +{ + uint8_t *bp = &buf[0], *be = &buf[buflen]; + char *hp = &host[0], *he = &host[hostlen]; + + bp += sizeof(struct dnspacket); + if (bp >= be) + return -1; + for (;;) { + uint8_t len = *bp++; + if (len == 0) + break; + if (bp + len >= be || hp + len >= he) + return -1; + memcpy(hp, bp, len); + bp += len; + hp += len; + *hp++ = '.'; + if (hp == he) + return -1; + } + *hp = '\0'; + return 0; +} + +int +matchreq(uint8_t *buf, size_t buflen, struct sockaddr_storage *to) +{ + char host[65536]; + struct match *match; + + /* XXX: check flags/qdcount? */ + if (parsedomain(buf, buflen, host, sizeof(host)) == -1) + return -1; + TAILQ_FOREACH(match, &matches, entry) { + size_t hlen = strlen(host); + size_t glen = strlen(match->pat); + if (hlen < glen) + continue; + if (strcmp(&host[hlen - glen], match->pat) == 0) { + memcpy(to, &match->to, sizeof(*to)); + logmsg(LOG_DEBUG, "matched domain %s with %s", + host, match->pat); + /* first match wins */ + return 0; + } + } + return -1; +} + static struct request * -newrequest(int ud, struct sockaddr *remoteaddr) +newrequest(int ud) { - struct sockaddr from; + struct sockaddr_storage remoteaddr; + struct sockaddr from, *to; socklen_t fromlen; struct request *req; uint8_t buf[65536]; @@ -271,13 +364,17 @@ newrequest(int ud, struct sockaddr *remo } req->cacheent = hit; - req->s = socket(remoteaddr->sa_family, SOCK_DGRAM, 0); + if (matchreq(buf, r, &remoteaddr) == -1) + goto fail; + to = (struct sockaddr *)&remoteaddr; + + req->s = socket(to->sa_family, SOCK_DGRAM, 0); if (req->s == -1) goto fail; TAILQ_INSERT_TAIL(&reqfifo, req, fifo); - if (connect(req->s, remoteaddr, remoteaddr->sa_len) == -1) { + if (connect(req->s, to, to->sa_len) == -1) { logmsg(LOG_NOTICE, "failed to connect (%d)", errno); if (errno == EADDRNOTAVAIL) servfail(ud, req->clientid, &from, fromlen); @@ -335,36 +432,18 @@ sendreply(int
Re: list all iwm(4) firmware files
None of those files are actually used in the code, so this would not make sense. On 2016 Sep 16 (Fri) at 10:45:06 +0200 (+0200), Jan Stary wrote: :Index: iwm.4 :=== :RCS file: /cvs/src/share/man/man4/iwm.4,v :retrieving revision 1.18 :diff -u -p -r1.18 iwm.4 :--- iwm.4 28 May 2016 18:31:14 - 1.18 :+++ iwm.4 16 Sep 2016 08:44:13 - :@@ -71,8 +71,12 @@ which are loaded when an interface is br : .Pp : .Bl -tag -width Ds -offset indent -compact : .It Pa /etc/firmware/iwm-3160-16 :+.It Pa /etc/firmware/iwm-3160-9 : .It Pa /etc/firmware/iwm-7260-16 :+.It Pa /etc/firmware/iwm-7260-9 : .It Pa /etc/firmware/iwm-7265-16 :+.It Pa /etc/firmware/iwm-7265-9 :+.It Pa /etc/firmware/iwm-7265D-16 : .It Pa /etc/firmware/iwm-8000C-16 : .El : .Pp : -- Katz' Law: Man and nations will act rationally when all other possibilities have been exhausted.
list all iwm(4) firmware files
Index: iwm.4 === RCS file: /cvs/src/share/man/man4/iwm.4,v retrieving revision 1.18 diff -u -p -r1.18 iwm.4 --- iwm.4 28 May 2016 18:31:14 - 1.18 +++ iwm.4 16 Sep 2016 08:44:13 - @@ -71,8 +71,12 @@ which are loaded when an interface is br .Pp .Bl -tag -width Ds -offset indent -compact .It Pa /etc/firmware/iwm-3160-16 +.It Pa /etc/firmware/iwm-3160-9 .It Pa /etc/firmware/iwm-7260-16 +.It Pa /etc/firmware/iwm-7260-9 .It Pa /etc/firmware/iwm-7265-16 +.It Pa /etc/firmware/iwm-7265-9 +.It Pa /etc/firmware/iwm-7265D-16 .It Pa /etc/firmware/iwm-8000C-16 .El .Pp
Re: binutils-2.17 ownership fixes
On Thu, Sep 15, 2016 at 09:07:49PM -0700, Philip Guenther wrote: > On Thu, Sep 15, 2016 at 1:58 PM, Martin Natano wrote: > > This should do it. The 'fix' is ugly, but I couldn't find a cleaner way > > to pass the right STRIP value to libtool. Any better ideas? Ok? > ... > > --- gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper 11 Sep 2016 > > 07:42:02 - 1.9 > > +++ gnu/usr.bin/binutils-2.17/Makefile.bsd-wrapper 15 Sep 2016 > > 20:56:45 - > > @@ -80,6 +80,8 @@ do-config: .USE > > mv -f Makefile.tmp Makefile > > cd ${.OBJDIR} && \ > > ${MAKE} ${CONFIGURE_MODULES} > > + sed -i 's,^STRIP=strip$$,STRIP=/usr/bin/strip,' \ > > + ${.OBJDIR}/binutils/libtool > > Instead of hacking the generated libtool post-facto, maybe just > hardcode a usable value into what generates the script? > > > --- ltconfig24 Apr 2011 20:14:40 - 1.1.1.1 > +++ ltconfig16 Sep 2016 03:44:50 - > @@ -2331,7 +2331,7 @@ LN_S=$LN_S > NM=$NM > > # A symbol stripping program > -STRIP=$STRIP > +STRIP=/usr/bin/strip > > # Used to examine libraries when file_magic_cmd begins "file" > MAGIC_CMD=$MAGIC_CMD That's much nicer. OK, please commit.