Re: UTF-8 support for uniq(1)
10 дек. 2015 г. 18:51 пользователь "Ingo Schwarze" написал: > > Hi, > > here is a simple one. The uniq(1) utility only needs UTF-8 support > to distinguish blank and non-blank characters with -f and to skip > characters with -s. The former is easy to implement with mbtowc(3) > and iswblank(3), the latter with mblen(3). There is no need for > wrapper functions or a seperate utf8.c file. > > OK? > Ingo > > > Index: uniq.1 > === > RCS file: /cvs/src/usr.bin/uniq/uniq.1,v > retrieving revision 1.17 > diff -u -p -r1.17 uniq.1 > --- uniq.1 3 Sep 2010 11:09:29 - 1.17 > +++ uniq.1 10 Dec 2015 15:37:02 - > @@ -114,6 +114,14 @@ A file name of > .Ql - > denotes the standard input or the standard output > .Pq depending on its position on the command line . > +.Sh ENVIRONMENT > +.Bl -tag -width LC_CTYPE > +.It Ev LC_CTYPE > +The character set > +.Xr locale 1 . > +Determines which groups of bytes are treated as characters > +and which characters are considered blank. > +.El > .Sh EXIT STATUS > .Ex -std uniq > .Sh SEE ALSO > Index: uniq.c > === > RCS file: /cvs/src/usr.bin/uniq/uniq.c,v > retrieving revision 1.23 > diff -u -p -r1.23 uniq.c > --- uniq.c 2 Nov 2015 20:25:42 - 1.23 > +++ uniq.c 10 Dec 2015 15:37:02 - > @@ -37,10 +37,13 @@ > #include > #include > #include > +#include > #include > #include > #include > #include > +#include > +#include > > #defineMAXLINELEN (8 * 1024) > > @@ -61,6 +64,8 @@ main(int argc, char *argv[]) > int ch; > char *prevline, *thisline; > > + setlocale(LC_CTYPE, ""); > + > if (pledge("stdio rpath wpath cpath", NULL) == -1) > err(1, "pledge"); > > @@ -176,16 +181,38 @@ show(FILE *ofp, char *str) > char * > skip(char *str) > { > + wchar_t wc; > int nchars, nfields; > + int len; > > for (nfields = numfields; nfields && *str; nfields--) { > - while (isblank((unsigned char)*str)) > - str++; > - while (*str && !isblank((unsigned char)*str)) > - str++; > + > + /* Skip blanks before the next field. */ > + do { > + if ((len = mbtowc(&wc, str, MB_CUR_MAX)) == -1) { > + (void)mbtowc(NULL, NULL, MB_CUR_MAX); > + wc = L'?'; > + len = 1; > + } > + str += len; > + } while (*str != '\0' && iswblank(wc)); > + > + /* Skip one field. */ > + while (*str != '\0' && !iswblank(wc)) { > + if ((len = mbtowc(&wc, str, MB_CUR_MAX)) == -1) { > + (void)mbtowc(NULL, NULL, MB_CUR_MAX); > + wc = L'?'; > + len = 1; > + } > + str += len; > + } > } > - for (nchars = numchars; nchars-- && *str && *str != '\n'; ++str) > - ; > + > + /* Skip some additional characters. */ > + for (nchars = numchars; nchars-- && *str != '\0'; str += len) > + if ((len = mblen(str, MB_CUR_MAX)) == -1) > + len = 1; > + > return (str); > } Reads good to me, okay zhuk@. -- Vadim Zhukov
Pull tmpfs fix from NetBSD
Here's the PR: https://gnats.netbsd.org/50381 And the commit: https://marc.info/?l=netbsd-source-changes&m=144694603617544&w=2 We have very few local changes to tmpfs and we share the KASSERT(de->td_node == NULL), so I think this applies to us. Thoughts? ok? Index: sys/tmpfs/tmpfs_subr.c === RCS file: /cvsroot/src/sys/fs/tmpfs/tmpfs_subr.c,v retrieving revision 1.96.4.1 retrieving revision 1.96.4.1.2.1 diff -u -p -r1.96.4.1 -r1.96.4.1.2.1 --- sys/fs/tmpfs/tmpfs_subr.c 22 Dec 2014 02:05:08 - 1.96.4.1 +++ sys/fs/tmpfs/tmpfs_subr.c 8 Nov 2015 01:27:10 - 1.96.4.1.2.1 @@ -451,6 +451,7 @@ tmpfs_alloc_dirent(tmpfs_mount_t *tmp, c nde->td_namelen = len; memcpy(nde->td_name, name, len); nde->td_seq = TMPFS_DIRSEQ_NONE; + nde->td_node = NULL; /* for asserts */ *de = nde; return 0;
Re: ssh-agent: flush stdout before main loop in foreground mode
On Wed, Dec 2, 2015 at 9:12 AM, Dustin Lundquist wrote: > When ssh-agent is run in foreground mode with -d and stdout is not a > terminal, the output including the path to the listening socket and > PID may not be written before the main loop begins. Since no further > output is written to stdout, this output may never be written. Patch applied, thanks! -- Darren Tucker (dtucker at zip.com.au) GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69 Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
Remove allocation debugging junk from amd
ok? Index: amd/xutil.c === RCS file: /cvs/src/usr.sbin/amd/amd/xutil.c,v retrieving revision 1.17 diff -u -p -r1.17 xutil.c --- amd/xutil.c 26 Oct 2014 02:58:43 - 1.17 +++ amd/xutil.c 10 Dec 2015 20:04:43 - @@ -84,13 +84,9 @@ xmalloc(size_t len) int retries = 600; do { - p = malloc(len); - if (p) { -#if defined(DEBUG) && defined(DEBUG_MEM) - Debug(D_MEM) plog(XLOG_DEBUG, "Allocated size %zu; block %#x", len, p); -#endif /* defined(DEBUG) && defined(DEBUG_MEM) */ + if ((p = malloc(len)) != NULL) return p; - } + if (retries > 0) { plog(XLOG_ERROR, "Retrying memory allocation"); sleep(1); @@ -103,10 +99,6 @@ xmalloc(size_t len) void * xreallocarray(void *ptr, size_t nmemb, size_t size) { -#if defined(DEBUG) && defined(DEBUG_MEM) - Debug(D_MEM) plog(XLOG_DEBUG, "Reallocated nmemb %zu of size %zu; block %#x", nmemb, size, ptr); -#endif /* defined(DEBUG) && defined(DEBUG_MEM) */ - ptr = reallocarray(ptr, nmemb, size); if (ptr == NULL) @@ -114,14 +106,6 @@ xreallocarray(void *ptr, size_t nmemb, s return (ptr); } -#if defined(DEBUG) && defined(DEBUG_MEM) -xfree(char *f, int l, void *p) -{ - Debug(D_MEM) plog(XLOG_DEBUG, "Free in %s:%d: block %#x", f, l, p); -#undef free - free(p); -} -#endif /* defined(DEBUG) && defined(DEBUG_MEM) */ #ifdef DEBUG_MEM static int mem_bytes; static int orig_mem_bytes; Index: amq/amq.c === RCS file: /cvs/src/usr.sbin/amd/amq/amq.c,v retrieving revision 1.18 diff -u -p -r1.18 amq.c --- amq/amq.c 21 Jan 2015 09:50:25 - 1.18 +++ amq/amq.c 10 Dec 2015 20:04:44 - @@ -565,11 +565,3 @@ privsock(int ty) } return sock; } - -#ifdef DEBUG -void -xfree(char *f, char *l, void *p) -{ - free(p); -} -#endif /* DEBUG */ Index: include/config.h === RCS file: /cvs/src/usr.sbin/amd/include/config.h,v retrieving revision 1.11 diff -u -p -r1.11 config.h --- include/config.h26 Oct 2014 02:32:51 - 1.11 +++ include/config.h10 Dec 2015 20:04:44 - @@ -72,10 +72,6 @@ extern int orig_umask; /* umask() on st #ifdef DEBUG #defineD_ALL (~0) -#ifdef DEBUG_MEM -#define free(x) xfree(__FILE__,__LINE__,x) -#endif /* DEBUG_MEM */ - #define Debug(x) if (!(debug_flags & (x))) ; else #define dlog Debug(D_FULL) dplog #endif /* DEBUG */
Re: Remove plain DES from kernel crypto
On Thu, Dec 10, 2015 at 14:29 +0100, Christian Weisgerber wrote: > We just removed DES support from IPsec and there are no other users, > so this deletes plain DES from the kernel crypto framework, including > the crypto accelerator drivers. > > ok? > Thanks for doing this work, OK mikeb
Remove extraneous punctuation in unifdef.1
>From upstream, reduces diff: https://github.com/fanf2/unifdef/commit/cf9a7a6f161f3a83c587c485c362fea8d4c0e73e ok? Index: unifdef.1 === RCS file: /cvs/src/usr.bin/unifdef/unifdef.1,v retrieving revision 1.27 diff -u -p -r1.27 unifdef.1 --- unifdef.1 10 Dec 2015 19:13:46 - 1.27 +++ unifdef.1 10 Dec 2015 19:30:01 - @@ -422,22 +422,22 @@ command line options are given. .Bl -item .It .Tn EOF -in comment. +in comment .It Inappropriate .Ic #elif , .Ic #else or -.Ic #endif . +.Ic #endif .It -Obfuscated preprocessor control line. +Obfuscated preprocessor control line .It Premature .Tn EOF (with the line number of the most recent unterminated -.Ic #if ) . +.Ic #if ) .It -Too many levels of nesting. +Too many levels of nesting .El .Sh SEE ALSO .Xr cpp 1 ,
Unbound 1.5.7 update
As with NSD I've already committed the typo fixes etc. There's a fair bit of churn for the optional support for nettle instead of OpenSSL which involves some nsec3 refactoring so it's a bit long.. Notable addition is qname minimisation support (optional privacy feature, off by default). In short, "Only send minimum required labels of the QNAME and set QTYPE to NS when possible" - avoids sending full query to servers that don't need it. Index: doc/Changelog === RCS file: /cvs/src/usr.sbin/unbound/doc/Changelog,v retrieving revision 1.13 diff -u -p -r1.13 Changelog --- doc/Changelog 10 Dec 2015 17:16:46 - 1.13 +++ doc/Changelog 10 Dec 2015 17:31:20 - @@ -1,3 +1,99 @@ +8 December 2015: Wouter + - Fixup 724 for unbound-control. + +7 December 2015: Ralph + - Do not minimise forwarded requests. + +4 December 2015: Wouter + - Removed unneeded whitespace from example.conf. + +3 December 2015: Ralph + - (after rc1 tag) + - Committed fix to qname minimisation and unit test case for it. + +3 December 2015: Wouter + - iana portlist update. + - 1.5.7rc1 prerelease tag. + +2 December 2015: Wouter + - Fixup 724: Fix PCA prompt for unbound-service-install.exe. + re-enable stdout printout. + - For 724: Add Changelog to windows binary dist. + +1 December 2015: Ralph + - Qname minimisation review fixes + +1 December 2015: Wouter + - Fixup 724 fix for fname_after_chroot() calls. + - Remove stdout printout for unbound-service-install.exe + - .gitignore for git users. + +30 November 2015: Ralph + - Implemented qname minimisation + +30 November 2015: Wouter + - Fix for #724: conf syntax to read files from run dir (on Windows). + +25 November 2015: Wouter + - Fix for #720, fix unbound-control-setup windows batch file. + +24 November 2015: Wouter + - Fix #720: add windows scripts to zip bundle. + - iana portlist update. + +20 November 2015: Wouter + - Added assert on rrset cache correctness. + - Fix that malformed EDNS query gets a response without malformed EDNS. + +18 November 2015: Wouter + - newer acx_nlnetlabs.m4. + - spelling fixes from Igor Sobrado Delgado. + +17 November 2015: Wouter + - Fix #594. libunbound: optionally use libnettle for crypto. + Contributed by Luca Bruno. Added --with-nettle for use with + --with-libunbound-only. + - refactor nsec3 hash implementation to be more library-portable. + - iana portlist update. + - Fixup DER encoded DSA signatures for libnettle. + +16 November 2015: Wouter + - Fix for lenient accept of reverse order DNAME and CNAME. + +6 November 2015: Wouter + - Change example.conf: ftp.internic.net to https://www.internic.net + +5 November 2015: Wouter + - ACX_SSL_CHECKS no longer adds -ldl needlessly. + +3 November 2015: Wouter + - Fix #718: Fix unbound-control-setup with support for env + without HEREDOC bash support. + +29 October 2015: Wouter + - patch from Doug Hogan for SSL_OP_NO_SSLvx options. + - Fix #716: nodata proof with empty non-terminals and wildcards. + +28 October 2015: Wouter + - Fix checklock testcode for linux threads on exit. + +27 October 2015: Wouter + - isblank() compat implementation. + - detect libexpat without xml_StopParser function. + - portability fixes. + - portability, replace snprintf if return value broken. + +23 October 2015: Wouter + - Fix #714: Document config to block private-address for IPv4 + mapped IPv6 addresses. + +22 October 2015: Wouter + - Fix #712: unbound-anchor appears to not fsync root.key. + +20 October 2015: Wouter + - 1.5.6 release. + - trunk tracks development of 1.5.7. + 15 October 2015: Wouter - Fix segfault in the dns64 module in the formaterror error path. - Fix sldns_wire2str_rdata_scan for malformed RRs. Index: daemon/unbound.c === RCS file: /cvs/src/usr.sbin/unbound/daemon/unbound.c,v retrieving revision 1.10 diff -u -p -r1.10 unbound.c --- daemon/unbound.c16 Jul 2015 01:44:00 - 1.10 +++ daemon/unbound.c10 Dec 2015 17:31:19 - @@ -180,6 +180,8 @@ static void usage() SSLeay_version(SSLEAY_VERSION) #elif defined(HAVE_NSS) NSS_GetVersion() +#elif defined(HAVE_NETTLE) + "nettle" #endif ); printf("linked modules:"); @@ -449,6 +451,9 @@ perform_setup(struct daemon* daemon, str fatal_exit("user '%s' does not exist.", cfg->username); /* endpwent below, in case we need pwd for setusercontext */ } +#endif +#ifdef UB_ON_WINDOWS + w_config_adjust_directory(cfg); #endif /* init syslog (as root) if needed, before daemonize, otherwis
Re: pledge dhcpd(8), revised version with earler pledge
Hi Stuart, Great :) I have tested -y/-Y myself and didn't have any issues, but would like some more people to give it a go to ensure this is not committed without proper validation. On 10/12/2015 17:26, Stuart Henderson wrote: > On 2015/12/02 12:14, Ricardo Mestre wrote: >> Hi tech@ >> >> This is a revised version of pledging dhcpd(8) with earler pledging. >> >> Hoist up sync_init() due to a multicast setsockopt(2) (IP_MULTICAST_TTL) that >> pledge doesn't allow, also hoist up the daemon(3) section, getpwnam(3) and >> the >> check if arguments -A, -C or -L were used (pf table handling) since it calls >> 2 ioctl(2)'s that pledge pf doesn't allow. >> >> After this if !udpsockmode then apply the following annotations: >> >> "rpath": >> icmp_startup()->getprotobyname(3)->read /etc/protocols >> "inet": >> icmp_startup()->socket(2) >> "sendfd": >> for sendmsg(2) in ICMP echo request >> "proc/id" >> chroot(2) and privdrop section >> >> If in udpsockmode then the pledge needs to happen inside udpsock_startup() >> instead of main() since setsockopt(2) IP_RECVIF is not allowed by pledge. >> After >> that happens then apply the same pledge with the annotations above, although >> additionally this code path also needs "route" for ioctl(2) SIOCGIFADDR. >> >> Just before the main loop of the program then it can drop to "stdio inet >> route >> sendfd" if in udpsockmode or else just to "stdio inet sendfd". >> >> Any comments with this implementation? Specifically for the UDP code path >> since >> I don't have at the moment a way to test DHCPINFORM requests on non Ethernet >> packets? > > Works for me in normal usage, and I've tested the UDP code path using > dhcping to localhost. > > I haven't tested -y/-Y or the PF table support. >
[patch] nlist(3): out of bounds read
When dealing with a malformed ELF header, e_shentsize may be 0. This causes an out of bounds read while finding the symbol table on line 141. Found using afl. Index: nlist.c === RCS file: /cvs/src/lib/libc/gen/nlist.c,v retrieving revision 1.65 diff -u -p -r1.65 nlist.c --- nlist.c 16 Oct 2015 16:54:38 - 1.65 +++ nlist.c 10 Dec 2015 16:36:26 - @@ -102,6 +102,10 @@ __fdnlist(int fd, struct nlist *list) !__elf_is_okay__(&ehdr) || fstat(fd, &st) < 0) return (-1); + /* Make sure section header size is not too small */ + if (ehdr.e_shentsize < sizeof(Elf_Shdr)) + return (-1); + /* calculate section header table size */ shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
Re: pledge dhcpd(8), revised version with earler pledge
On 2015/12/02 12:14, Ricardo Mestre wrote: > Hi tech@ > > This is a revised version of pledging dhcpd(8) with earler pledging. > > Hoist up sync_init() due to a multicast setsockopt(2) (IP_MULTICAST_TTL) that > pledge doesn't allow, also hoist up the daemon(3) section, getpwnam(3) and the > check if arguments -A, -C or -L were used (pf table handling) since it calls > 2 ioctl(2)'s that pledge pf doesn't allow. > > After this if !udpsockmode then apply the following annotations: > > "rpath": > icmp_startup()->getprotobyname(3)->read /etc/protocols > "inet": > icmp_startup()->socket(2) > "sendfd": > for sendmsg(2) in ICMP echo request > "proc/id" > chroot(2) and privdrop section > > If in udpsockmode then the pledge needs to happen inside udpsock_startup() > instead of main() since setsockopt(2) IP_RECVIF is not allowed by pledge. > After > that happens then apply the same pledge with the annotations above, although > additionally this code path also needs "route" for ioctl(2) SIOCGIFADDR. > > Just before the main loop of the program then it can drop to "stdio inet route > sendfd" if in udpsockmode or else just to "stdio inet sendfd". > > Any comments with this implementation? Specifically for the UDP code path > since > I don't have at the moment a way to test DHCPINFORM requests on non Ethernet > packets? Works for me in normal usage, and I've tested the UDP code path using dhcping to localhost. I haven't tested -y/-Y or the PF table support.
Re: mpsafe re(4)
Dimitris Papastamos [s...@2f30.org] wrote: > On Sat, Dec 05, 2015 at 06:11:51PM +0100, Jonathan Matthew wrote: > > The main interesting bit here is the txeof and start loops, which previously > > operated based on the prod/cons indices and the contents of the tx queue, > > but now just uses the indices as that's the only way to get a consistent > > view > > of the tx queue state. > > > > At the moment I don't think the tx ring is big enough to use IFQ_DEQUEUE > > instead of ifq_deq_begin/commit, but maybe I'm wrong about that. > > > > can someone try this on an APU1? > > I've tested this on my router and it seems to work okay. I've also used > tcpbench with various combinations. > > re0 at pci2 dev 0 function 0 "Realtek 8168" rev 0x0c: RTL8168G/8111G > (0x4c00), msi, address 80:ee:73:9f:1d:3e > re1 at pci3 dev 0 function 0 "Realtek 8168" rev 0x0c: RTL8168G/8111G > (0x4c00), msi, address 80:ee:73:9f:1d:3d Testing fine for me on APU1 so far.
[trivial] Specify SOCKS version in nc
Objections? Index: socks.c === RCS file: /cvs/src/usr.bin/nc/socks.c,v retrieving revision 1.22 diff -u -p -r1.22 socks.c --- socks.c 10 Dec 2015 16:49:28 - 1.22 +++ socks.c 10 Dec 2015 16:52:55 - @@ -278,7 +278,7 @@ socks_connect(const char *host, const ch if (cnt != 4) err(1, "read failed (%zu/4)", cnt); if (buf[1] != 0) { - errx(1, "connection failed, SOCKS error: %s", + errx(1, "connection failed, SOCKSv5 error: %s", socks5_strerror(buf[1])); } switch (buf[3]) { @@ -316,7 +316,7 @@ socks_connect(const char *host, const ch if (cnt != 8) err(1, "read failed (%zu/8)", cnt); if (buf[1] != 90) { - errx(1, "connection failed, SOCKS error: %s", + errx(1, "connection failed, SOCKSv4 error: %s", socks4_strerror(buf[1])); } } else if (socksv == -1) {
Re: pledge dhcpd(8), revised version with earler pledge
Hello! Any testers out there that could provide some feedback on this? I tested it and didn't have any problems with any parameters, except UDP that I don't have how to test it, although it kept running without problems as well. On 02/12/2015 12:14, Ricardo Mestre wrote: > Hi tech@ > > This is a revised version of pledging dhcpd(8) with earler pledging. > > Hoist up sync_init() due to a multicast setsockopt(2) (IP_MULTICAST_TTL) that > pledge doesn't allow, also hoist up the daemon(3) section, getpwnam(3) and the > check if arguments -A, -C or -L were used (pf table handling) since it calls > 2 ioctl(2)'s that pledge pf doesn't allow. > > After this if !udpsockmode then apply the following annotations: > > "rpath": > icmp_startup()->getprotobyname(3)->read /etc/protocols > "inet": > icmp_startup()->socket(2) > "sendfd": > for sendmsg(2) in ICMP echo request > "proc/id" > chroot(2) and privdrop section > > If in udpsockmode then the pledge needs to happen inside udpsock_startup() > instead of main() since setsockopt(2) IP_RECVIF is not allowed by pledge. > After > that happens then apply the same pledge with the annotations above, although > additionally this code path also needs "route" for ioctl(2) SIOCGIFADDR. > > Just before the main loop of the program then it can drop to "stdio inet route > sendfd" if in udpsockmode or else just to "stdio inet sendfd". > > Any comments with this implementation? Specifically for the UDP code path > since > I don't have at the moment a way to test DHCPINFORM requests on non Ethernet > packets? > > Index: dhcpd.c > === > RCS file: /cvs/src/usr.sbin/dhcpd/dhcpd.c,v > retrieving revision 1.48 > diff -u -p -u -r1.48 dhcpd.c > --- dhcpd.c 10 Feb 2015 23:06:13 - 1.48 > +++ dhcpd.c 2 Dec 2015 11:28:50 - > @@ -45,7 +45,7 @@ > #include > #include > > -void usage(void); > +__dead void usage(void); > > time_t cur_time, last_scan; > struct group root_group; > @@ -187,22 +187,18 @@ main(int argc, char *argv[]) > if (setrtable(rdomain) == -1) > error("setrtable (%m)"); > > - if (udpsockmode) > - udpsock_startup(udpaddr); > - icmp_startup(1, lease_pinged); > - > if (syncsend || syncrecv) { > syncfd = sync_init(sync_iface, sync_baddr, sync_port); > if (syncfd == -1) > err(1, "sync init"); > } > > - if ((pw = getpwnam("_dhcp")) == NULL) > - error("user \"_dhcp\" not found"); > - > if (daemonize) > daemon(0, 0); > > + if ((pw = getpwnam("_dhcp")) == NULL) > + error("user \"_dhcp\" not found"); > + > /* don't go near /dev/pf unless we actually intend to use it */ > if ((abandoned_tab != NULL) || > (changedmac_tab != NULL) || > @@ -227,6 +223,15 @@ main(int argc, char *argv[]) > } > } > > + if (udpsockmode) { > + udpsock_startup(udpaddr); > + } else { > + if (pledge("stdio rpath inet sendfd proc id", NULL) == -1) > + err(1, "pledge"); > + } > + > + icmp_startup(1, lease_pinged); > + > if (chroot(_PATH_VAREMPTY) == -1) > error("chroot %s: %m", _PATH_VAREMPTY); > if (chdir("/") == -1) > @@ -236,6 +241,14 @@ main(int argc, char *argv[]) > setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) > error("can't drop privileges: %m"); > > + if (udpsockmode) { > + if (pledge("stdio inet route sendfd", NULL) == -1) > + err(1, "pledge"); > + } else { > + if (pledge("stdio inet sendfd", NULL) == -1) > + err(1, "pledge"); > + } > + > add_timeout(cur_time + 5, periodic_scan, NULL); > dispatch(); > > @@ -243,7 +256,7 @@ main(int argc, char *argv[]) > exit(0); > } > > -void > +__dead void > usage(void) > { > extern char *__progname; > Index: udpsock.c > === > RCS file: /cvs/src/usr.sbin/dhcpd/udpsock.c,v > retrieving revision 1.2 > diff -u -p -u -r1.2 udpsock.c > --- udpsock.c 16 Jan 2015 06:40:16 - 1.2 > +++ udpsock.c 2 Dec 2015 11:28:55 - > @@ -56,6 +56,9 @@ udpsock_startup(struct in_addr bindaddr) > error("setsocketopt IP_RECVIF failed for udp: %s", > strerror(errno)); > > + if (pledge("stdio rpath inet route sendfd proc id", NULL) == -1) > + error("pledge: %s", strerror(errno)); > + > sin4.sin_family = AF_INET; > sin4.sin_len = sizeof(sin4); > sin4.sin_addr = bindaddr; >
UTF-8 support for uniq(1)
Hi, here is a simple one. The uniq(1) utility only needs UTF-8 support to distinguish blank and non-blank characters with -f and to skip characters with -s. The former is easy to implement with mbtowc(3) and iswblank(3), the latter with mblen(3). There is no need for wrapper functions or a seperate utf8.c file. OK? Ingo Index: uniq.1 === RCS file: /cvs/src/usr.bin/uniq/uniq.1,v retrieving revision 1.17 diff -u -p -r1.17 uniq.1 --- uniq.1 3 Sep 2010 11:09:29 - 1.17 +++ uniq.1 10 Dec 2015 15:37:02 - @@ -114,6 +114,14 @@ A file name of .Ql - denotes the standard input or the standard output .Pq depending on its position on the command line . +.Sh ENVIRONMENT +.Bl -tag -width LC_CTYPE +.It Ev LC_CTYPE +The character set +.Xr locale 1 . +Determines which groups of bytes are treated as characters +and which characters are considered blank. +.El .Sh EXIT STATUS .Ex -std uniq .Sh SEE ALSO Index: uniq.c === RCS file: /cvs/src/usr.bin/uniq/uniq.c,v retrieving revision 1.23 diff -u -p -r1.23 uniq.c --- uniq.c 2 Nov 2015 20:25:42 - 1.23 +++ uniq.c 10 Dec 2015 15:37:02 - @@ -37,10 +37,13 @@ #include #include #include +#include #include #include #include #include +#include +#include #defineMAXLINELEN (8 * 1024) @@ -61,6 +64,8 @@ main(int argc, char *argv[]) int ch; char *prevline, *thisline; + setlocale(LC_CTYPE, ""); + if (pledge("stdio rpath wpath cpath", NULL) == -1) err(1, "pledge"); @@ -176,16 +181,38 @@ show(FILE *ofp, char *str) char * skip(char *str) { + wchar_t wc; int nchars, nfields; + int len; for (nfields = numfields; nfields && *str; nfields--) { - while (isblank((unsigned char)*str)) - str++; - while (*str && !isblank((unsigned char)*str)) - str++; + + /* Skip blanks before the next field. */ + do { + if ((len = mbtowc(&wc, str, MB_CUR_MAX)) == -1) { + (void)mbtowc(NULL, NULL, MB_CUR_MAX); + wc = L'?'; + len = 1; + } + str += len; + } while (*str != '\0' && iswblank(wc)); + + /* Skip one field. */ + while (*str != '\0' && !iswblank(wc)) { + if ((len = mbtowc(&wc, str, MB_CUR_MAX)) == -1) { + (void)mbtowc(NULL, NULL, MB_CUR_MAX); + wc = L'?'; + len = 1; + } + str += len; + } } - for (nchars = numchars; nchars-- && *str && *str != '\n'; ++str) - ; + + /* Skip some additional characters. */ + for (nchars = numchars; nchars-- && *str != '\0'; str += len) + if ((len = mblen(str, MB_CUR_MAX)) == -1) + len = 1; + return (str); }
NSD 4.1.7 update
I've already merged in most of the doc fixes etc, here are the remaining parts (mostly code/build infrastructure). Any concerns, test reports, OKs? (See below for diff; changelog entries with inline comments first).. |FEATURES: | - support configure --with-dbfile="" for nodb mode by default, where | there is no binary database, but nsd reads and writes zonefiles. -- using this; it's safer than relying on an nsd.conf setting to disable the db. this also required setting --with-zonelistfile which is based on the dir from --with-dbfile. | - reuseport: no is the default, because the feature is not troublefree. -- noop for us | - configure --enable-ratelimit-default-is-off with --enable-ratelimit | to set the default ratelimit to disabled but available in nsd.conf. -- I haven't changed anything here (currently we use --enable-ratelimit) but it may make sense to set default-is-off and add suitable config sections to src/etc/nsd.conf. that's for another day though. | - version: "string" option to set chaos version query reply string. |BUG FIXES: | - Fix zones updates from nsd parent event loop when there are a lot | of interfaces. | - portability fixes. | - patch from Doug Hogan for SSL_OP_NO_SSLvx options, for the new | defaults in the ssl libraries. -- we already have these | - updated contrib/nsd.spec, from Bálint Szigeti, with new configure | options. | - Allocate less memory for TSIG digest. | - Fix #721: Fix wrong error code (FORMERR) returned for unknown | opcode. NOTIMP expected. | - Fix zonec ttl mismatch printout to include more information. | - Fix TCP responses when REUSEPORT is in use by turning it off. | - Document default in manpage for rrl-slip, ip4 and 6 prefixlength. | - Explain rrl-slip better in documentation. | - Document that ratelimit qps and slip are updated in reconfig. | - Fix up defaults in manpage. Index: Makefile.bsd-wrapper === RCS file: /cvs/src/usr.sbin/nsd/Makefile.bsd-wrapper,v retrieving revision 1.12 diff -u -p -r1.12 Makefile.bsd-wrapper --- Makefile.bsd-wrapper15 Oct 2015 21:22:11 - 1.12 +++ Makefile.bsd-wrapper10 Dec 2015 14:47:14 - @@ -17,7 +17,8 @@ CONFIGURE_OPTS= --prefix=/usr \ --with-configdir=${CHROOTDIR}/etc \ --with-pidfile=${CHROOTDIR}/run/nsd.pid \ --with-zonesdir=${CHROOTDIR}/zones \ - --with-dbfile=${CHROOTDIR}/db/nsd.db \ + --with-dbfile="" \ + --with-zonelistfile="${CHROOTDIR}/db/zone.list" \ --with-xfrdir=${CHROOTDIR}/run/xfr \ --with-xfrdfile=${CHROOTDIR}/run/xfrd.state \ --with-libevent=/usr \ Index: Makefile.in === RCS file: /cvs/src/usr.sbin/nsd/Makefile.in,v retrieving revision 1.17 diff -u -p -r1.17 Makefile.in --- Makefile.in 17 Jul 2015 17:36:33 - 1.17 +++ Makefile.in 10 Dec 2015 14:47:14 - @@ -65,6 +65,7 @@ EDIT = sed \ -e 's,@zonelistfile\@,$(zonelistfile),g' \ -e 's,@nsdconfigfile\@,$(nsdconfigfile),g' \ -e 's,@shell\@,$(SHELL),g' \ + -e 's,@ratelimit_default\@,@ratelimit_default@,g' \ -e 's,@user\@,$(user),g' TARGETS=nsd nsd-checkconf nsd-checkzone nsd-control nsd.conf.sample nsd-control-setup.sh Index: acx_nlnetlabs.m4 === RCS file: /cvs/src/usr.sbin/nsd/acx_nlnetlabs.m4,v retrieving revision 1.1.1.10 diff -u -p -r1.1.1.10 acx_nlnetlabs.m4 --- acx_nlnetlabs.m45 Nov 2015 21:21:05 - 1.1.1.10 +++ acx_nlnetlabs.m410 Dec 2015 14:47:14 - @@ -2,7 +2,9 @@ # Copyright 2009, Wouter Wijngaards, NLnet Labs. # BSD licensed. # -# Version 28 +# Version 30 +# 2015-11-18 spelling check fix. +# 2015-11-05 ACX_SSL_CHECKS no longer adds -ldl needlessly. # 2015-08-28 ACX_CHECK_PIE and ACX_CHECK_RELRO_NOW added. # 2015-03-17 AHX_CONFIG_REALLOCARRAY added # 2013-09-19 FLTO help text improved. @@ -24,7 +26,7 @@ # 2010-07-02 Add check for ss_family (for minix). # 2010-04-26 Fix to use CPPFLAGS for CHECK_COMPILER_FLAGS. # 2010-03-01 Fix RPATH using CONFIG_COMMANDS to run at the very end. -# 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS seperate, -ldl +# 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS separate, -ldl # 2010-02-01 added ACX_CHECK_MEMCMP_SIGNED, AHX_MEMCMP_BROKEN # 2010-01-20 added AHX_COONFIG_STRLCAT # 2009-07-14 U_CHAR detection improved for windows crosscompile. @@ -715,12 +717,6 @@ AC_DEFUN([ACX_SSL_CHECKS], [ fi AC_SUBST(HAVE_SSL) AC_SUBST(RUNTIME_PATH) - # openssl engine functionality needs dlopen().
Remove plain DES from kernel crypto
We just removed DES support from IPsec and there are no other users, so this deletes plain DES from the kernel crypto framework, including the crypto accelerator drivers. ok? Index: sys/crypto/cryptodev.h === RCS file: /cvs/src/sys/crypto/cryptodev.h,v retrieving revision 1.66 diff -u -p -r1.66 cryptodev.h --- sys/crypto/cryptodev.h 13 Nov 2015 15:29:55 - 1.66 +++ sys/crypto/cryptodev.h 10 Dec 2015 12:50:32 - @@ -72,7 +72,6 @@ #define HMAC_OPAD_VAL 0x5C /* Encryption algorithm block sizes */ -#define DES_BLOCK_LEN 8 #define DES3_BLOCK_LEN 8 #define BLOWFISH_BLOCK_LEN 8 #define CAST128_BLOCK_LEN 8 @@ -83,32 +82,31 @@ /* Maximum hash algorithm result length */ #define AALG_MAX_RESULT_LEN64 /* Keep this updated */ -#define CRYPTO_DES_CBC 1 -#define CRYPTO_3DES_CBC2 -#define CRYPTO_BLF_CBC 3 -#define CRYPTO_CAST_CBC4 -#define CRYPTO_MD5_HMAC6 -#define CRYPTO_SHA1_HMAC 7 -#define CRYPTO_RIPEMD160_HMAC 8 -#define CRYPTO_RIJNDAEL128_CBC 11 /* 128 bit blocksize */ -#define CRYPTO_AES_CBC 11 /* 128 bit blocksize -- the same as above */ -#define CRYPTO_DEFLATE_COMP12 /* Deflate compression algorithm */ -#define CRYPTO_NULL13 -#define CRYPTO_LZS_COMP14 /* LZS compression algorithm */ -#define CRYPTO_SHA2_256_HMAC 15 -#define CRYPTO_SHA2_384_HMAC 16 -#define CRYPTO_SHA2_512_HMAC 17 -#define CRYPTO_AES_CTR 18 -#define CRYPTO_AES_XTS 19 -#define CRYPTO_AES_GCM_16 20 -#define CRYPTO_AES_128_GMAC21 -#define CRYPTO_AES_192_GMAC22 -#define CRYPTO_AES_256_GMAC23 -#define CRYPTO_AES_GMAC24 -#define CRYPTO_CHACHA20_POLY1305 25 -#define CRYPTO_CHACHA20_POLY1305_MAC 26 -#define CRYPTO_ESN 27 /* Support for Extended Sequence Numbers */ -#define CRYPTO_ALGORITHM_MAX 27 /* Keep updated */ +#define CRYPTO_3DES_CBC1 +#define CRYPTO_BLF_CBC 2 +#define CRYPTO_CAST_CBC3 +#define CRYPTO_MD5_HMAC4 +#define CRYPTO_SHA1_HMAC 5 +#define CRYPTO_RIPEMD160_HMAC 6 +#define CRYPTO_RIJNDAEL128_CBC 7 /* 128 bit blocksize */ +#define CRYPTO_AES_CBC 7 /* 128 bit blocksize -- the same as above */ +#define CRYPTO_DEFLATE_COMP8 /* Deflate compression algorithm */ +#define CRYPTO_NULL9 +#define CRYPTO_LZS_COMP10 /* LZS compression algorithm */ +#define CRYPTO_SHA2_256_HMAC 11 +#define CRYPTO_SHA2_384_HMAC 12 +#define CRYPTO_SHA2_512_HMAC 13 +#define CRYPTO_AES_CTR 14 +#define CRYPTO_AES_XTS 15 +#define CRYPTO_AES_GCM_16 16 +#define CRYPTO_AES_128_GMAC17 +#define CRYPTO_AES_192_GMAC18 +#define CRYPTO_AES_256_GMAC19 +#define CRYPTO_AES_GMAC20 +#define CRYPTO_CHACHA20_POLY1305 21 +#define CRYPTO_CHACHA20_POLY1305_MAC 22 +#define CRYPTO_ESN 23 /* Support for Extended Sequence Numbers */ +#define CRYPTO_ALGORITHM_MAX 23 /* Keep updated */ /* Algorithm flags */ #defineCRYPTO_ALG_FLAG_SUPPORTED 0x01 /* Algorithm is supported */ @@ -220,7 +218,7 @@ struct cryptocap { * ioctl parameter to request creation of a session. */ struct session_op { - u_int32_t cipher; /* ie. CRYPTO_DES_CBC */ + u_int32_t cipher; /* ie. CRYPTO_AES_CBC */ u_int32_t mac;/* ie. CRYPTO_MD5_HMAC */ u_int32_t keylen; /* cipher key */ Index: sys/crypto/cryptosoft.c === RCS file: /cvs/src/sys/crypto/cryptosoft.c,v retrieving revision 1.79 diff -u -p -r1.79 cryptosoft.c --- sys/crypto/cryptosoft.c 18 Nov 2015 12:23:14 - 1.79 +++ sys/crypto/cryptosoft.c 10 Dec 2015 12:53:13 - @@ -789,9 +789,6 @@ swcr_newsession(u_int32_t *sid, struct c } switch (cri->cri_alg) { - case CRYPTO_DES_CBC: - txf = &enc_xform_des; - goto enccommon; case CRYPTO_3DES_CBC: txf = &enc_xform_3des; goto enccommon; @@ -963,7 +960,6 @@ swcr_freesession(u_int64_t tid) swcr_sessions[sid] = swd->sw_next; switch (swd->sw_alg) { - case CRYPTO_DES_CBC: case CRYPTO_3DES_CBC: case CRYPTO_BLF_CBC: case CRYPTO_CAST_CBC: @@ -1075,7 +1071,6 @@ swcr_process(struct cryptop *crp) switch (sw->sw_alg) { case CRYPTO_NULL: break; - case CRYPTO_DES_CBC: case CRYPTO_3DES_CBC: case CRYPTO_BLF_CBC: case CRYPTO_CAST_CBC: @@ -1144,7 +1139,6 @@ swcr_init(void) bzero(algs, sizeof(algs));
Re: Question about shm_open and sem_open
Jeunder Yu wrote: > > geteuid may be better. though i would hope the difference doesn't matter. > > The difference is very important for me. > > In my application, I am root and change to different uid, create semaphore > and share memory, make some hand sharking to client app with different uid. > > May I give a patch to fix it? Ah, thanks, I had forgotten about this. I changed it to geteuid.
Re: Question about shm_open and sem_open
2015年11月20日 下午2:46於 "Ted Unangst" 寫道: > > 游俊德 wrote: > > Hello, > > > > I have a question about source code of shm_open and sem_open functions. > > > > int > > shm_open(const char *path, int flags, mode_t mode) > > { > > (skipped) > > > > if (sb,st_uid != getuid()) { > > close(fd); > >errno = EPERM; > > return -1; > > } > > > > (skipped) > > } > > > > I know the UID comparison is used to avoid share memory accessed by > > different user. Similar code also existed in sem_open function. > > > > My question is, why it is getuid(), why not use geteuid()? > > I am not sure if it is bug or not, but I think it is more reasonable > > if it checked > > by effective user id, > > geteuid may be better. though i would hope the difference doesn't matter. The difference is very important for me. In my application, I am root and change to different uid, create semaphore and share memory, make some hand sharking to client app with different uid. May I give a patch to fix it?
Re: umass: size for free
Mathieu - wrote: > > Hello, > > Martin Pieuchot wrote: > > Hello, > > > > On 07/12/15(Mon) 16:48, Mathieu - wrote: > > > Hello, > > > > > > I worked a bit on umass(4) recently and had a diff to pass the > > > umassbus_softc's real size to free so here it is. At some point I > > > pondered about deleting the whole abstraction, as it would simplify the > > > free'ing, for we only have one implementation (umass_scsi_softc, as atapi > > > uses it too). But I figured it would be against the whole design of the > > > umass driver, thoughts? > > > > I'd rather create a umass_scsi_detach() function symmetrical to > > umass_scsi_attach(). This way you don't need an extra variable > > for the size, keep the autoconf(9) glue inside umass_scsi.c and > > can turn "struct umassbus_softc" into an opaque type. > > Please find a patch implementing the suggested approach below. Oups I left a debugging printf in there. Here is the clean patch, sorry again for the noise. Index: usb/umass.c === RCS file: /cvs/src/sys/dev/usb/umass.c,v retrieving revision 1.70 diff -u -p -r1.70 umass.c --- usb/umass.c 14 Mar 2015 03:38:50 - 1.70 +++ usb/umass.c 10 Dec 2015 11:03:16 - @@ -129,7 +129,6 @@ #include #include #include -#include #include #include #undef KASSERT @@ -616,7 +615,6 @@ int umass_detach(struct device *self, int flags) { struct umass_softc *sc = (struct umass_softc *)self; - struct umassbus_softc *scbus; int rv = 0, i, s; DPRINTF(UDMASS_USB, ("%s: detached\n", sc->sc_dev.dv_xname)); @@ -647,12 +645,16 @@ umass_detach(struct device *self, int fl } splx(s); - scbus = sc->bus; - if (scbus != NULL) { - if (scbus->sc_child != NULL) - rv = config_detach(scbus->sc_child, flags); - free(scbus, M_DEVBUF, 0); - sc->bus = NULL; + switch (sc->sc_cmd) { + case UMASS_CPROTO_RBC: + case UMASS_CPROTO_SCSI: + rv = umass_scsi_detach(sc, flags); + break; + + case UMASS_CPROTO_UFI: + case UMASS_CPROTO_ATAPI: + rv = umass_atapi_detach(sc, flags); + break; } if (rv != 0) Index: usb/umass_scsi.c === RCS file: /cvs/src/sys/dev/usb/umass_scsi.c,v retrieving revision 1.42 diff -u -p -r1.42 umass_scsi.c --- usb/umass_scsi.c14 Mar 2015 03:38:50 - 1.42 +++ usb/umass_scsi.c10 Dec 2015 11:03:17 - @@ -51,8 +51,8 @@ #include #include -struct umass_scsi_softc { - struct umassbus_softc base; +struct umassbus_softc { + struct device *sc_child; /* child device, for detach */ struct scsi_linksc_link; struct scsi_iopool sc_iopool; int sc_open; @@ -78,7 +78,7 @@ void umass_scsi_cb(struct umass_softc *s int status); void umass_scsi_sense_cb(struct umass_softc *sc, void *priv, int residue, int status); -struct umass_scsi_softc *umass_scsi_setup(struct umass_softc *); +struct umassbus_softc *umass_scsi_setup(struct umass_softc *); void *umass_io_get(void *); void umass_io_put(void *, void *); @@ -87,7 +87,7 @@ int umass_scsi_attach(struct umass_softc *sc) { struct scsibus_attach_args saa; - struct umass_scsi_softc *scbus; + struct umassbus_softc *scbus; scbus = umass_scsi_setup(sc); scbus->sc_link.adapter_target = UMASS_SCSIID_HOST; @@ -103,8 +103,7 @@ umass_scsi_attach(struct umass_softc *sc sc->sc_dev.dv_xname, sc, scbus)); sc->sc_refcnt++; - scbus->base.sc_child = - config_found((struct device *)sc, &saa, scsiprint); + scbus->sc_child = config_found((struct device *)sc, &saa, scsiprint); if (--sc->sc_refcnt < 0) usb_detach_wakeup(&sc->sc_dev); @@ -115,7 +114,7 @@ int umass_atapi_attach(struct umass_softc *sc) { struct scsibus_attach_args saa; - struct umass_scsi_softc *scbus; + struct umassbus_softc *scbus; scbus = umass_scsi_setup(sc); scbus->sc_link.adapter_target = UMASS_SCSIID_HOST; @@ -131,22 +130,21 @@ umass_atapi_attach(struct umass_softc *s sc->sc_dev.dv_xname, sc, scbus)); sc->sc_refcnt++; - scbus->base.sc_child = config_found((struct device *)sc, - &saa, scsiprint); + scbus->sc_child = config_found((struct device *)sc, &saa, scsiprint); if (--sc->sc_refcnt < 0) usb_detach_wakeup(&sc->sc_dev); return (0); } -struct umass_scsi_softc * +struct umassbus_softc * umass_scsi_setup(struct umass_softc *sc) { - struct umass_scsi_softc *scbus; + struct umassbus_softc *scbus; scbus = malloc(sizeof(*scbus), M_DEVBUF, M_WAITOK | M_ZERO); -
Re: umass: size for free
Hello, Martin Pieuchot wrote: > Hello, > > On 07/12/15(Mon) 16:48, Mathieu - wrote: > > Hello, > > > > I worked a bit on umass(4) recently and had a diff to pass the > > umassbus_softc's real size to free so here it is. At some point I > > pondered about deleting the whole abstraction, as it would simplify the > > free'ing, for we only have one implementation (umass_scsi_softc, as atapi > > uses it too). But I figured it would be against the whole design of the > > umass driver, thoughts? > > I'd rather create a umass_scsi_detach() function symmetrical to > umass_scsi_attach(). This way you don't need an extra variable > for the size, keep the autoconf(9) glue inside umass_scsi.c and > can turn "struct umassbus_softc" into an opaque type. Please find a patch implementing the suggested approach below. Index: usb/umass.c === RCS file: /cvs/src/sys/dev/usb/umass.c,v retrieving revision 1.70 diff -u -p -r1.70 umass.c --- usb/umass.c 14 Mar 2015 03:38:50 - 1.70 +++ usb/umass.c 10 Dec 2015 10:57:43 - @@ -129,7 +129,6 @@ #include #include #include -#include #include #include #undef KASSERT @@ -616,7 +615,6 @@ int umass_detach(struct device *self, int flags) { struct umass_softc *sc = (struct umass_softc *)self; - struct umassbus_softc *scbus; int rv = 0, i, s; DPRINTF(UDMASS_USB, ("%s: detached\n", sc->sc_dev.dv_xname)); @@ -647,12 +645,16 @@ umass_detach(struct device *self, int fl } splx(s); - scbus = sc->bus; - if (scbus != NULL) { - if (scbus->sc_child != NULL) - rv = config_detach(scbus->sc_child, flags); - free(scbus, M_DEVBUF, 0); - sc->bus = NULL; + switch (sc->sc_cmd) { + case UMASS_CPROTO_RBC: + case UMASS_CPROTO_SCSI: + rv = umass_scsi_detach(sc, flags); + break; + + case UMASS_CPROTO_UFI: + case UMASS_CPROTO_ATAPI: + rv = umass_atapi_detach(sc, flags); + break; } if (rv != 0) Index: usb/umass_scsi.c === RCS file: /cvs/src/sys/dev/usb/umass_scsi.c,v retrieving revision 1.42 diff -u -p -r1.42 umass_scsi.c --- usb/umass_scsi.c14 Mar 2015 03:38:50 - 1.42 +++ usb/umass_scsi.c10 Dec 2015 10:57:43 - @@ -51,8 +51,8 @@ #include #include -struct umass_scsi_softc { - struct umassbus_softc base; +struct umassbus_softc { + struct device *sc_child; /* child device, for detach */ struct scsi_linksc_link; struct scsi_iopool sc_iopool; int sc_open; @@ -78,7 +78,7 @@ void umass_scsi_cb(struct umass_softc *s int status); void umass_scsi_sense_cb(struct umass_softc *sc, void *priv, int residue, int status); -struct umass_scsi_softc *umass_scsi_setup(struct umass_softc *); +struct umassbus_softc *umass_scsi_setup(struct umass_softc *); void *umass_io_get(void *); void umass_io_put(void *, void *); @@ -87,7 +87,7 @@ int umass_scsi_attach(struct umass_softc *sc) { struct scsibus_attach_args saa; - struct umass_scsi_softc *scbus; + struct umassbus_softc *scbus; scbus = umass_scsi_setup(sc); scbus->sc_link.adapter_target = UMASS_SCSIID_HOST; @@ -103,8 +103,7 @@ umass_scsi_attach(struct umass_softc *sc sc->sc_dev.dv_xname, sc, scbus)); sc->sc_refcnt++; - scbus->base.sc_child = - config_found((struct device *)sc, &saa, scsiprint); + scbus->sc_child = config_found((struct device *)sc, &saa, scsiprint); if (--sc->sc_refcnt < 0) usb_detach_wakeup(&sc->sc_dev); @@ -115,7 +114,7 @@ int umass_atapi_attach(struct umass_softc *sc) { struct scsibus_attach_args saa; - struct umass_scsi_softc *scbus; + struct umassbus_softc *scbus; scbus = umass_scsi_setup(sc); scbus->sc_link.adapter_target = UMASS_SCSIID_HOST; @@ -131,22 +130,21 @@ umass_atapi_attach(struct umass_softc *s sc->sc_dev.dv_xname, sc, scbus)); sc->sc_refcnt++; - scbus->base.sc_child = config_found((struct device *)sc, - &saa, scsiprint); + scbus->sc_child = config_found((struct device *)sc, &saa, scsiprint); if (--sc->sc_refcnt < 0) usb_detach_wakeup(&sc->sc_dev); return (0); } -struct umass_scsi_softc * +struct umassbus_softc * umass_scsi_setup(struct umass_softc *sc) { - struct umass_scsi_softc *scbus; + struct umassbus_softc *scbus; scbus = malloc(sizeof(*scbus), M_DEVBUF, M_WAITOK | M_ZERO); - sc->bus = (struct umassbus_softc *)scbus; + sc->bus = scbus; scsi_iopool_init(&scbus->sc_iopool, scbus, umass_io_get, umass_io_put);
Re: umass: size for free
Hello, On 07/12/15(Mon) 16:48, Mathieu - wrote: > Hello, > > I worked a bit on umass(4) recently and had a diff to pass the > umassbus_softc's real size to free so here it is. At some point I > pondered about deleting the whole abstraction, as it would simplify the > free'ing, for we only have one implementation (umass_scsi_softc, as atapi > uses it too). But I figured it would be against the whole design of the > umass driver, thoughts? I'd rather create a umass_scsi_detach() function symmetrical to umass_scsi_attach(). This way you don't need an extra variable for the size, keep the autoconf(9) glue inside umass_scsi.c and can turn "struct umassbus_softc" into an opaque type. > > Index: usb/umass.c > === > RCS file: /cvs/src/sys/dev/usb/umass.c,v > retrieving revision 1.70 > diff -u -p -r1.70 umass.c > --- usb/umass.c 14 Mar 2015 03:38:50 - 1.70 > +++ usb/umass.c 7 Dec 2015 15:40:15 - > @@ -651,7 +651,7 @@ umass_detach(struct device *self, int fl > if (scbus != NULL) { > if (scbus->sc_child != NULL) > rv = config_detach(scbus->sc_child, flags); > - free(scbus, M_DEVBUF, 0); > + free(scbus, M_DEVBUF, scbus->sc_size); > sc->bus = NULL; > } > > Index: usb/umass_scsi.c > === > RCS file: /cvs/src/sys/dev/usb/umass_scsi.c,v > retrieving revision 1.42 > diff -u -p -r1.42 umass_scsi.c > --- usb/umass_scsi.c 14 Mar 2015 03:38:50 - 1.42 > +++ usb/umass_scsi.c 7 Dec 2015 15:40:16 - > @@ -145,6 +145,7 @@ umass_scsi_setup(struct umass_softc *sc) > struct umass_scsi_softc *scbus; > > scbus = malloc(sizeof(*scbus), M_DEVBUF, M_WAITOK | M_ZERO); > + scbus->base.sc_size = sizeof(*scbus); > > sc->bus = (struct umassbus_softc *)scbus; > > Index: usb/umassvar.h > === > RCS file: /cvs/src/sys/dev/usb/umassvar.h,v > retrieving revision 1.14 > diff -u -p -r1.14 umassvar.h > --- usb/umassvar.h6 Nov 2013 14:37:31 - 1.14 > +++ usb/umassvar.h7 Dec 2015 15:40:16 - > @@ -146,6 +146,7 @@ struct umass_wire_methods { > > struct umassbus_softc { > struct device *sc_child; /* child device, for detach */ > + size_t sc_size; > }; > > /* the per device structure */ >
rtdeletemsg() & NULL ifp pointer
I'd like to change rtdeletemsg() to stop accepting a NULL ifp pointer. Here's a diff converting the last occurrence. This will then allow me to move a hack checking for interface index out of rtrequest_delete(). Ok? Index: net/route.c === RCS file: /cvs/src/sys/net/route.c,v retrieving revision 1.291 diff -u -p -r1.291 route.c --- net/route.c 9 Dec 2015 09:23:08 - 1.291 +++ net/route.c 9 Dec 2015 09:34:09 - @@ -623,6 +623,8 @@ rtdeletemsg(struct rtentry *rt, struct i unsigned intifidx; struct sockaddr_in6 sa_mask; + KASSERT(rt->rt_ifidx == ifp->if_index); + /* * Request the new route so that the entry is not actually * deleted. That will allow the information being reported to @@ -1088,8 +1090,14 @@ rtrequest(int req, struct rt_addrinfo *i rt->rt_priority, rt); if (error != 0 && (crt = rtalloc(ndst, 0, tableid)) != NULL) { /* overwrite cloned route */ - if ((crt->rt_flags & RTF_CLONED) != 0) { - rtdeletemsg(crt, NULL, tableid); + if (ISSET(crt->rt_flags, RTF_CLONED)) { + struct ifnet *cifp; + + cifp = if_get(crt->rt_ifidx); + KASSERT(cifp != NULL); + rtdeletemsg(crt, cifp, tableid); + if_put(cifp); + error = rtable_insert(tableid, ndst, info->rti_info[RTAX_NETMASK], info->rti_info[RTAX_GATEWAY],