Re: svn commit: r272144 - head/sbin/sysctl
On Thu, 25 Sep 2014, Xin Li wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 09/25/14 15:40, Mateusz Guzik wrote: On Thu, Sep 25, 2014 at 10:37:28PM +, Xin LI wrote: Author: delphij Date: Thu Sep 25 22:37:27 2014 New Revision: 272144 URL: http://svnweb.freebsd.org/changeset/base/272144 Log: The strtol(3) family of functions would set errno when it hits one. Check errno and handle it as invalid input. But this requires explicitely setting errno to 0 before strto* call, otherwise you cannot know whether errno is meaningful when you test it. Yes, it has error #3 of 1-10 for programming the strto*() family. (I made up the #3, and 10 is as high as I can count.) At least the following errors were already present: - clobbering the return value by assigning it to a variable of a wrong type. This causes implementation-defined behaviour. It prevents some types of range checking and some types of error reporting. - using a cast to possibly break possible compiler warnings about truncation from the previous bug - for CTLTYPE_UINT, using the wrong bogus cast (to int instead of u_int) to possibly not even break the compiler warnings, but to break the value on exotic arches - no range checking at all. I think you just added some, but with a bad error message. Input that is out of bounds is a little different from general invalid input. - for CTLTYPE_UINT, also using misformatting (space after cast) in the wrong bogus cast - verboseness. Despite the missing error handling, the code is large. Before the switch statement, there is a silly special check for all the numeric types. This checks for empty strings using a slow method of strlen() instead of checking if the first character is NUL (perhaps the compiler can optimize this). Leading whitespace is stripped before this, so this finds a few more errors than empty strings. But all this does is print "empty numeric value" of the less specific "invalid integer ''%s" when the string is empty. (Here %s prints the variable 'line'. It looks like an output formatting error to append it unquoted to the quoted string newval, but I couldn't find an example where 'line' is nonempty. The special cases is removed in my version. I didn't fix the other errors. The following error was not present: - saying in error messages that invalid input is "illegal". sysctl.c has worse style bugs than the verboseness. The case statement containing most of the strto*() statements is misindented. This gives verboseness and style bugs like splitting error messages strings colaterally, although not long lines. Also it looks like the code would use some deduplications with macros or something. I think the code can use some refactor. Does the attached patch look good to you? No, it looks bad. % Index: sysctl.c % === % --- sysctl.c (revision 272145) % +++ sysctl.c (working copy) % @@ -57,6 +57,7 @@ static const char rcsid[] = % #include % #endif % % +#include The necessary error handling is ugly enough. % #include % #include % #include % @@ -80,8 +81,32 @@ static int show_var(int *, int); % static int sysctl_all(int *oid, int len); % static int name2oid(const char *, int *); % % -static int set_IK(const char *, int *); % +static int strIKtoi(const char *, char **); % % +static int ctl_sign[CTLTYPE+1] = { % + [CTLTYPE_INT] = 1, % + [CTLTYPE_LONG] = 1, % + [CTLTYPE_S64] = 1, % +}; % + % +static int ctl_size[CTLTYPE+1] = { % + [CTLTYPE_INT] = sizeof(int), % + [CTLTYPE_UINT] = sizeof(u_int), % + [CTLTYPE_LONG] = sizeof(long), % + [CTLTYPE_ULONG] = sizeof(u_long), % + [CTLTYPE_S64] = sizeof(int64_t), % + [CTLTYPE_U64] = sizeof(uint64_t), % +}; % + % +static const char *ctl_typename[CTLTYPE+1] = { % + [CTLTYPE_INT] = "integer", % + [CTLTYPE_UINT] = "unsigned integer", % + [CTLTYPE_LONG] = "long integer", % + [CTLTYPE_ULONG] = "unsigned long", % + [CTLTYPE_S64] = "int64_t", % + [CTLTYPE_U64] = "uint64_t", % +}; % + % static void % usage(void) % { Takes about the same amount of code as before, and is harder to read. Loses some context-dependent error messages. Add tables to restore those and it might be larger than before. The old code could use goto to common error handling code if to reduce duplication in a different ugly way. % @@ -288,10 +314,22 @@ parse(const char *string, int lineno) % (kind & CTLTYPE) == CTLTYPE_ULONG || % (kind & CTLTYPE) == CTLTYPE_S64 || % (kind & CTLTYPE) == CTLTYPE_U64) { % - if (strlen(newval) == 0) { % + if (strlen(newvalstr) == 0) { % warnx("empty numeric value"); % return (1); % } Just remove this. % + } else if ((kind & CTLTYPE) != CTLTYPE_STRING) { %
svn commit: r272154 - head/sbin/sysctl
Author: delphij Date: Fri Sep 26 05:05:34 2014 New Revision: 272154 URL: http://svnweb.freebsd.org/changeset/base/272154 Log: Refactor the code a little bit to reduce duplicated code. Reviewed by: mjg MFC after:2 weeks Modified: head/sbin/sysctl/sysctl.c Modified: head/sbin/sysctl/sysctl.c == --- head/sbin/sysctl/sysctl.c Fri Sep 26 04:33:27 2014(r272153) +++ head/sbin/sysctl/sysctl.c Fri Sep 26 05:05:34 2014(r272154) @@ -57,6 +57,7 @@ static const char rcsid[] = #include #endif +#include #include #include #include @@ -80,7 +81,31 @@ static int show_var(int *, int); static int sysctl_all(int *oid, int len); static int name2oid(const char *, int *); -static int set_IK(const char *, int *); +static int strIKtoi(const char *, char **); + +static int ctl_sign[CTLTYPE+1] = { + [CTLTYPE_INT] = 1, + [CTLTYPE_LONG] = 1, + [CTLTYPE_S64] = 1, +}; + +static int ctl_size[CTLTYPE+1] = { + [CTLTYPE_INT] = sizeof(int), + [CTLTYPE_UINT] = sizeof(u_int), + [CTLTYPE_LONG] = sizeof(long), + [CTLTYPE_ULONG] = sizeof(u_long), + [CTLTYPE_S64] = sizeof(int64_t), + [CTLTYPE_U64] = sizeof(uint64_t), +}; + +static const char *ctl_typename[CTLTYPE+1] = { + [CTLTYPE_INT] = "integer", + [CTLTYPE_UINT] = "unsigned integer", + [CTLTYPE_LONG] = "long integer", + [CTLTYPE_ULONG] = "unsigned long", + [CTLTYPE_S64] = "int64_t", + [CTLTYPE_U64] = "uint64_t", +}; static void usage(void) @@ -191,7 +216,8 @@ static int parse(const char *string, int lineno) { int len, i, j; - void *newval = 0; + const void *newval; + const char *newvalstr = NULL; int intval; unsigned int uintval; long longval; @@ -200,7 +226,7 @@ parse(const char *string, int lineno) int64_t i64val; uint64_t u64val; int mib[CTL_MAXNAME]; - char *cp, *bufp, buf[BUFSIZ], *endptr, fmt[BUFSIZ], line[BUFSIZ]; + char *cp, *bufp, buf[BUFSIZ], *endptr = NULL, fmt[BUFSIZ], line[BUFSIZ]; u_int kind; if (lineno) @@ -230,7 +256,7 @@ parse(const char *string, int lineno) cp[strlen(cp) - 1] = '\0'; cp++; } - newval = cp; + newvalstr = cp; newsize = strlen(cp); } len = name2oid(bufp, mib); @@ -254,7 +280,7 @@ parse(const char *string, int lineno) exit(1); } - if (newval == NULL || dflag) { + if (newvalstr == NULL || dflag) { if ((kind & CTLTYPE) == CTLTYPE_NODE) { if (dflag) { i = show_var(mib, len); @@ -282,105 +308,77 @@ parse(const char *string, int lineno) return (1); } - if ((kind & CTLTYPE) == CTLTYPE_INT || - (kind & CTLTYPE) == CTLTYPE_UINT || - (kind & CTLTYPE) == CTLTYPE_LONG || - (kind & CTLTYPE) == CTLTYPE_ULONG || - (kind & CTLTYPE) == CTLTYPE_S64 || - (kind & CTLTYPE) == CTLTYPE_U64) { - if (strlen(newval) == 0) { + switch (kind & CTLTYPE) { + case CTLTYPE_INT: + case CTLTYPE_UINT: + case CTLTYPE_LONG: + case CTLTYPE_ULONG: + case CTLTYPE_S64: + case CTLTYPE_U64: + if (strlen(newvalstr) == 0) { warnx("empty numeric value"); return (1); } + /* FALLTHROUGH */ + case CTLTYPE_STRING: + break; + default: + warnx("oid '%s' is type %d," + " cannot set that%s", bufp, + kind & CTLTYPE, line); + return (1); } errno = 0; switch (kind & CTLTYPE) { case CTLTYPE_INT: - if (strcmp(fmt, "IK") == 0) { - if (!set_IK(newval, &intval)) { - warnx("invalid value '%s'%s", - (char *)newval, line); - return (1); - } - } else { - intval = (int)strtol(newval, &endptr, + if (strcmp(fmt, "IK") == 0) + intval = strIKtoi(newvalstr, &endptr); + else + intval = (int
svn commit: r272153 - head/lib/libthr
Author: pluknet Date: Fri Sep 26 04:33:27 2014 New Revision: 272153 URL: http://svnweb.freebsd.org/changeset/base/272153 Log: Fix description of mutex acquisition. Reviewed by: kib X-MFC with: r272070 Sponsored by: Nginx, Inc. Modified: head/lib/libthr/libthr.3 Modified: head/lib/libthr/libthr.3 == --- head/lib/libthr/libthr.3Fri Sep 26 03:03:58 2014(r272152) +++ head/lib/libthr/libthr.3Fri Sep 26 04:33:27 2014(r272153) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 20, 2014 +.Dd September 26, 2014 .Dt LIBTHR 3 .Os .Sh NAME @@ -85,8 +85,14 @@ owning the lock. .Nm performs a contested mutex acquisition in three stages, each of which is more resource-consuming than the previous. +The first two stages are only applied for a mutex of +.Dv PTHREAD_MUTEX_ADAPTIVE_NP +type and +.Dv PTHREAD_PRIO_NONE +protocol (see +.Xr pthread_mutexattr 3 ) . .Pp -First, a spin loop +First, on SMP systems, a spin loop is performed, where the library attempts to acquire the lock by .Xr atomic 9 operations. ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r271201 - head/sys/dev/ahci
Hey Bryan, Sorry for the hassle. This didn’t show up in the hardware I had, but did show up in Mav’s hardware. It was like this less than a day, I thought… Warner On Sep 25, 2014, at 5:18 PM, Bryan Drewery wrote: > This drove me crazy for the past few days! > > https://lists.freebsd.org/pipermail/freebsd-current/2014-September/052215.html > > Not sure about the first trace there, but the others I encountered were > due to this not being fixed yet. smh@ tracked the ordering down and then > we found this. I couldn't try a newer build easily since my system would > panic on just buildworld :) > > On 9/6/2014 1:20 PM, Warner Losh wrote: >> Author: imp >> Date: Sat Sep 6 18:20:50 2014 >> New Revision: 271201 >> URL: http://svnweb.freebsd.org/changeset/base/271201 >> >> Log: >> Restore order of interrupt setup. Minor problems can result by >> setting up the interrupts too early: >> >> Reviewed by: mav@ >> Sponsored by: Netflix >> >> Modified: >> head/sys/dev/ahci/ahci.c >> head/sys/dev/ahci/ahci_pci.c >> >> Modified: head/sys/dev/ahci/ahci.c >> == >> --- head/sys/dev/ahci/ahci.c Sat Sep 6 18:08:21 2014(r271200) >> +++ head/sys/dev/ahci/ahci.c Sat Sep 6 18:20:50 2014(r271201) >> @@ -229,6 +229,15 @@ ahci_attach(device_t dev) >> >> ahci_ctlr_setup(dev); >> >> +/* Setup interrupts. */ >> +if (ahci_setup_interrupt(dev)) { >> +bus_dma_tag_destroy(ctlr->dma_tag); >> +bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, >> +ctlr->r_mem); >> +rman_fini(&ctlr->sc_iomem); >> +return ENXIO; >> +} >> + >> i = 0; >> for (u = ctlr->ichannels; u != 0; u >>= 1) >> i += (u & 1); >> >> Modified: head/sys/dev/ahci/ahci_pci.c >> == >> --- head/sys/dev/ahci/ahci_pci.c Sat Sep 6 18:08:21 2014 >> (r271200) >> +++ head/sys/dev/ahci/ahci_pci.c Sat Sep 6 18:20:50 2014 >> (r271201) >> @@ -417,13 +417,6 @@ ahci_pci_attach(device_t dev) >> ctlr->numirqs = 1; >> } >> >> -if (ahci_setup_interrupt(dev)) { >> -if (ctlr->msi) >> -pci_release_msi(dev); >> -bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, >> ctlr->r_mem); >> -return ENXIO; >> -} >> - >> error = ahci_attach(dev); >> if (error != 0) >> if (ctlr->msi) >> > > > -- > Regards, > Bryan Drewery > signature.asc Description: Message signed with OpenPGP using GPGMail
Re: svn commit: r272144 - head/sbin/sysctl
On Thu, Sep 25, 2014 at 05:19:42PM -0700, Xin Li wrote: > - if (newval == NULL || dflag) { > + if (newvalstr == NULL || dflag) { > if ((kind & CTLTYPE) == CTLTYPE_NODE) { > if (dflag) { > i = show_var(mib, len); > @@ -288,10 +314,22 @@ parse(const char *string, int lineno) > (kind & CTLTYPE) == CTLTYPE_ULONG || > (kind & CTLTYPE) == CTLTYPE_S64 || > (kind & CTLTYPE) == CTLTYPE_U64) { > - if (strlen(newval) == 0) { > + if (strlen(newvalstr) == 0) { > warnx("empty numeric value"); > return (1); > } > + } else if ((kind & CTLTYPE) != CTLTYPE_STRING) { > + /* > + * The only acceptable types are: > + * CTLTYPE_INT, CTLTYPE_UINT, > + * CTLTYPE_LONG, CTLTYPE_ULONG, > + * CTLTYPE_S64, CTLTYPE_U64 and > + * CTLTYPE_STRING. > + */ > + warnx("oid '%s' is type %d," > + " cannot set that%s", bufp, > + kind & CTLTYPE, line); > + return (1); > } I think this should be converted to switch, +/-: switch (kind & CTLTYPE) { case CTLTYPE_INT: case CTLTYPE_UINT: case CTLTYPE_LONG: case CTLTYPE_ULONG: case CTLTYPE_S64: case CTLTYPE_U64: if (strlen(newvalstr) == 0) { warnx("empty numeric value"); return (1); } break; case CTLTYPE_STRING: break; default: warnx("oid '%s' is type %d cannot set that%s", bufp, kind & CTLTYPE, line); return (1); } > > errno = 0; > @@ -298,91 +336,53 @@ parse(const char *string, int lineno) > > switch (kind & CTLTYPE) { > default: > - warnx("oid '%s' is type %d," > - " cannot set that%s", bufp, > - kind & CTLTYPE, line); > + /* NOTREACHED */ > return (1); This one should be removed or should call abort() or something since it should be impossible to get here. > } > > + if (errno != 0 || endptr == newvalstr || *endptr != '\0') { > + warnx("invalid %s '%s'%s", ctl_typename[kind & CTLTYPE], > + newvalstr, line); > + return (1); > + } > + So one thing a big fan of is the fact that some values are still assigned based on possibly bogus result. Some static analysis tool may object. But it's just a note. In general I think it's fine. > i = show_var(mib, len); > if (sysctl(mib, len, 0, 0, newval, newsize) == -1) { > if (!i && !bflag) > @@ -665,33 +665,35 @@ S_bios_smap_xattr(size_t l2, void *p) > #endif > -- Mateusz Guzik ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r271201 - head/sys/dev/ahci
On 9/25/2014 7:59 PM, Warner Losh wrote: > Hey Bryan, > > Sorry for the hassle. This didn’t show up in the hardware I had, but did show > up in Mav’s hardware. It was like this less than a day, I thought… > > Warner > Yes only a day or two. I was just unlucky about it. Now I am able to get updated to latest head. > > On Sep 25, 2014, at 5:18 PM, Bryan Drewery wrote: > >> This drove me crazy for the past few days! >> >> https://lists.freebsd.org/pipermail/freebsd-current/2014-September/052215.html >> >> Not sure about the first trace there, but the others I encountered were >> due to this not being fixed yet. smh@ tracked the ordering down and then >> we found this. I couldn't try a newer build easily since my system would >> panic on just buildworld :) >> >> On 9/6/2014 1:20 PM, Warner Losh wrote: >>> Author: imp >>> Date: Sat Sep 6 18:20:50 2014 >>> New Revision: 271201 >>> URL: http://svnweb.freebsd.org/changeset/base/271201 >>> >>> Log: >>> Restore order of interrupt setup. Minor problems can result by >>> setting up the interrupts too early: >>> >>> Reviewed by: mav@ >>> Sponsored by: Netflix >>> >>> Modified: >>> head/sys/dev/ahci/ahci.c >>> head/sys/dev/ahci/ahci_pci.c >>> >>> Modified: head/sys/dev/ahci/ahci.c >>> == >>> --- head/sys/dev/ahci/ahci.cSat Sep 6 18:08:21 2014 >>> (r271200) >>> +++ head/sys/dev/ahci/ahci.cSat Sep 6 18:20:50 2014 >>> (r271201) >>> @@ -229,6 +229,15 @@ ahci_attach(device_t dev) >>> >>> ahci_ctlr_setup(dev); >>> >>> + /* Setup interrupts. */ >>> + if (ahci_setup_interrupt(dev)) { >>> + bus_dma_tag_destroy(ctlr->dma_tag); >>> + bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, >>> + ctlr->r_mem); >>> + rman_fini(&ctlr->sc_iomem); >>> + return ENXIO; >>> + } >>> + >>> i = 0; >>> for (u = ctlr->ichannels; u != 0; u >>= 1) >>> i += (u & 1); >>> >>> Modified: head/sys/dev/ahci/ahci_pci.c >>> == >>> --- head/sys/dev/ahci/ahci_pci.cSat Sep 6 18:08:21 2014 >>> (r271200) >>> +++ head/sys/dev/ahci/ahci_pci.cSat Sep 6 18:20:50 2014 >>> (r271201) >>> @@ -417,13 +417,6 @@ ahci_pci_attach(device_t dev) >>> ctlr->numirqs = 1; >>> } >>> >>> - if (ahci_setup_interrupt(dev)) { >>> - if (ctlr->msi) >>> - pci_release_msi(dev); >>> - bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, >>> ctlr->r_mem); >>> - return ENXIO; >>> - } >>> - >>> error = ahci_attach(dev); >>> if (error != 0) >>> if (ctlr->msi) >>> >> >> >> -- >> Regards, >> Bryan Drewery >> > -- Regards, Bryan Drewery signature.asc Description: OpenPGP digital signature
Re: svn commit: r272144 - head/sbin/sysctl
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 09/25/14 15:40, Mateusz Guzik wrote: > On Thu, Sep 25, 2014 at 10:37:28PM +, Xin LI wrote: >> Author: delphij Date: Thu Sep 25 22:37:27 2014 New Revision: >> 272144 URL: http://svnweb.freebsd.org/changeset/base/272144 >> >> Log: The strtol(3) family of functions would set errno when it >> hits one. Check errno and handle it as invalid input. >> > > But this requires explicitely setting errno to 0 before strto* > call, otherwise you cannot know whether errno is meaningful when > you test it. Fixed in r272145, good catch! > Also it looks like the code would use some deduplications with > macros or something. I think the code can use some refactor. Does the attached patch look good to you? Cheers, - -- Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -BEGIN PGP SIGNATURE- Version: GnuPG v2.0 iQIcBAEBCgAGBQJUJLEeAAoJEJW2GBstM+nsSD0P/3Oe4gzNc1AYy14cg8ewZ0nL w75gPr9rMABxMXk7tGut6qS+W1vTZ32g9rCpzE+7ra1A8kDZ9l+VkJbUwkN2nr/i udsMq+qQ1qB+dCsVJLm8Pjsh/g+AVlSxXdHrkD1u49XhANZQUGt9NBaO0ah84c5J vaZ+Sq7cR6fF2VrZDJ0MLxW8tHLgW6hIVORvyiohvOqhzBHOFihDEDcoUOamzFZI txqI2oxjuhGy+T1V4dVYso/PgYhhnFC4L9Lvx5E9EqUZrVzckPP1PYXiZiQR/i7H ZEV5RgxHOGXEYNVDZXoEQthE1iP3pzFhe/xNURzlUqZIwgPeJ6Q2xz+As/C0yXlT +LxmXdQ/zsQmRu5b2m7TvBjBp18znAR2c2mKbvHS3EX6UWEmUKwcb2CREm0AbnQL kFrLRsksJfxD1TCkfmqysOa6WSkvRQpJ4csZdKf9y5nZFh/yjdSnzJULLKphpbzr npc9ZYJ9m7bLj7OZF5UPwEr0JfTnRDn6VnMqKiUTgXpHk5Lpm7vm5WefdOWMyTmL nwtmU3SyaJdLBrWARY1ZyN0ENmzTrs3sjCyWvhwlAomYIVuahT1oCuaRYIDyzito mThiFbuRA+ufz6m8OcIXeiGLxkimdIHm68ZreNZlBHA/R/bH84vLiIN0HRNhgAOy bgc97yetD5PL8NhRC8G/ =PWTt -END PGP SIGNATURE- Index: sysctl.c === --- sysctl.c(revision 272145) +++ sysctl.c(working copy) @@ -57,6 +57,7 @@ static const char rcsid[] = #include #endif +#include #include #include #include @@ -80,8 +81,32 @@ static int show_var(int *, int); static int sysctl_all(int *oid, int len); static int name2oid(const char *, int *); -static int set_IK(const char *, int *); +static int strIKtoi(const char *, char **); +static int ctl_sign[CTLTYPE+1] = { + [CTLTYPE_INT] = 1, + [CTLTYPE_LONG] = 1, + [CTLTYPE_S64] = 1, +}; + +static int ctl_size[CTLTYPE+1] = { + [CTLTYPE_INT] = sizeof(int), + [CTLTYPE_UINT] = sizeof(u_int), + [CTLTYPE_LONG] = sizeof(long), + [CTLTYPE_ULONG] = sizeof(u_long), + [CTLTYPE_S64] = sizeof(int64_t), + [CTLTYPE_U64] = sizeof(uint64_t), +}; + +static const char *ctl_typename[CTLTYPE+1] = { + [CTLTYPE_INT] = "integer", + [CTLTYPE_UINT] = "unsigned integer", + [CTLTYPE_LONG] = "long integer", + [CTLTYPE_ULONG] = "unsigned long", + [CTLTYPE_S64] = "int64_t", + [CTLTYPE_U64] = "uint64_t", +}; + static void usage(void) { @@ -191,7 +216,8 @@ static int parse(const char *string, int lineno) { int len, i, j; - void *newval = 0; + const void *newval = NULL; + const char *newvalstr = NULL; int intval; unsigned int uintval; long longval; @@ -230,7 +256,7 @@ parse(const char *string, int lineno) cp[strlen(cp) - 1] = '\0'; cp++; } - newval = cp; + newvalstr = cp; newsize = strlen(cp); } len = name2oid(bufp, mib); @@ -254,7 +280,7 @@ parse(const char *string, int lineno) exit(1); } - if (newval == NULL || dflag) { + if (newvalstr == NULL || dflag) { if ((kind & CTLTYPE) == CTLTYPE_NODE) { if (dflag) { i = show_var(mib, len); @@ -288,10 +314,22 @@ parse(const char *string, int lineno) (kind & CTLTYPE) == CTLTYPE_ULONG || (kind & CTLTYPE) == CTLTYPE_S64 || (kind & CTLTYPE) == CTLTYPE_U64) { - if (strlen(newval) == 0) { + if (strlen(newvalstr) == 0) { warnx("empty numeric value"); return (1); } + } else if ((kind & CTLTYPE) != CTLTYPE_STRING) { + /* +* The only acceptable types are: +* CTLTYPE_INT, CTLTYPE_UINT, +* CTLTYPE_LONG, CTLTYPE_ULONG, +* CTLTYPE_S64, CTLTYPE_U64 and +* CTLTYPE_STRING. +*/ + warnx("oid '%s' is type %d," + " cannot set that%s", bufp, + kind & CTLTYPE, line); + return (1); } errno = 0; @@ -298,91 +336,53 @@ parse(const char *string, int lineno)
Re: svn commit: r271201 - head/sys/dev/ahci
This drove me crazy for the past few days! https://lists.freebsd.org/pipermail/freebsd-current/2014-September/052215.html Not sure about the first trace there, but the others I encountered were due to this not being fixed yet. smh@ tracked the ordering down and then we found this. I couldn't try a newer build easily since my system would panic on just buildworld :) On 9/6/2014 1:20 PM, Warner Losh wrote: > Author: imp > Date: Sat Sep 6 18:20:50 2014 > New Revision: 271201 > URL: http://svnweb.freebsd.org/changeset/base/271201 > > Log: > Restore order of interrupt setup. Minor problems can result by > setting up the interrupts too early: > > Reviewed by: mav@ > Sponsored by: Netflix > > Modified: > head/sys/dev/ahci/ahci.c > head/sys/dev/ahci/ahci_pci.c > > Modified: head/sys/dev/ahci/ahci.c > == > --- head/sys/dev/ahci/ahci.c Sat Sep 6 18:08:21 2014(r271200) > +++ head/sys/dev/ahci/ahci.c Sat Sep 6 18:20:50 2014(r271201) > @@ -229,6 +229,15 @@ ahci_attach(device_t dev) > > ahci_ctlr_setup(dev); > > + /* Setup interrupts. */ > + if (ahci_setup_interrupt(dev)) { > + bus_dma_tag_destroy(ctlr->dma_tag); > + bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, > + ctlr->r_mem); > + rman_fini(&ctlr->sc_iomem); > + return ENXIO; > + } > + > i = 0; > for (u = ctlr->ichannels; u != 0; u >>= 1) > i += (u & 1); > > Modified: head/sys/dev/ahci/ahci_pci.c > == > --- head/sys/dev/ahci/ahci_pci.c Sat Sep 6 18:08:21 2014 > (r271200) > +++ head/sys/dev/ahci/ahci_pci.c Sat Sep 6 18:20:50 2014 > (r271201) > @@ -417,13 +417,6 @@ ahci_pci_attach(device_t dev) > ctlr->numirqs = 1; > } > > - if (ahci_setup_interrupt(dev)) { > - if (ctlr->msi) > - pci_release_msi(dev); > - bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, > ctlr->r_mem); > - return ENXIO; > - } > - > error = ahci_attach(dev); > if (error != 0) > if (ctlr->msi) > -- Regards, Bryan Drewery signature.asc Description: OpenPGP digital signature
svn commit: r272146 - head/lib/libc/stdtime
Author: pfg Date: Thu Sep 25 23:04:37 2014 New Revision: 272146 URL: http://svnweb.freebsd.org/changeset/base/272146 Log: Revert r272122 The patch still needs to be more robust and it broke the build on MIPS so revert it for now while all the issues are fixed. Reported by: ache, davide PR: 137307 Modified: head/lib/libc/stdtime/strptime.c Modified: head/lib/libc/stdtime/strptime.c == --- head/lib/libc/stdtime/strptime.cThu Sep 25 22:47:19 2014 (r272145) +++ head/lib/libc/stdtime/strptime.cThu Sep 25 23:04:37 2014 (r272146) @@ -55,32 +55,10 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "libc_private.h" #include "timelocal.h" -#include "tzfile.h" static char * _strptime(const char *, const char *, struct tm *, int *, locale_t); -#defineasizeof(a) (sizeof(a) / sizeof((a)[0])) - -#defineFLAG_NONE (1 << 0) -#defineFLAG_YEAR (1 << 1) -#defineFLAG_MONTH (1 << 2) -#defineFLAG_YDAY (1 << 3) -#defineFLAG_MDAY (1 << 4) -#defineFLAG_WDAY (1 << 5) - -/* - * Calculate the week day of the first day of a year. Valid for - * the Gregorian calendar, which began Sept 14, 1752 in the UK - * and its colonies. Ref: - * http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week/ - */ - -static int -first_wday_of(int year) -{ - return (((2 * (3 - (year / 100) % 4)) + (year % 100) + - ((year % 100) / 4) + (isleap(year) ? 6 : 0) + 1) % 7); -} +#defineasizeof(a) (sizeof (a) / sizeof ((a)[0])) static char * _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, @@ -88,17 +66,9 @@ _strptime(const char *buf, const char *f { charc; const char *ptr; - int day_offset = -1, wday_offset; int i, len; - int flags; int Ealternative, Oalternative; - const struct lc_time_T *tptr = __get_current_time_locale(locale); - static int start_of_month[2][13] = { - {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, - {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} - }; - - flags = FLAG_NONE; + struct lc_time_T *tptr = __get_current_time_locale(locale); ptr = fmt; while (*ptr != 0) { @@ -149,9 +119,7 @@ label: if (i < 19) return (NULL); - tm->tm_year = i * 100 - TM_YEAR_BASE; - flags |= FLAG_YEAR; - + tm->tm_year = i * 100 - 1900; break; case 'c': @@ -229,8 +197,6 @@ label: return (NULL); tm->tm_yday = i - 1; - flags |= FLAG_YDAY; - break; case 'M': @@ -337,32 +303,7 @@ label: return (NULL); tm->tm_wday = i; - if (day_offset >= 0 && (i - day_offset) != 0) { - tm->tm_yday += i - day_offset; - i = 0; - while (tm->tm_yday >= - start_of_month[isleap(tm->tm_year + - TM_YEAR_BASE)][i]) - i++; - if (i > 12) - { - i = 1; - tm->tm_yday -= - start_of_month[isleap(tm->tm_year + - TM_YEAR_BASE)] - [12]; - tm->tm_year++; - } - tm->tm_mon = i - 1; - tm->tm_mday = tm->tm_yday - - start_of_month[isleap(tm->tm_year + - TM_YEAR_BASE)] - [i - 1] + 1; - } buf += len; - flags |= FLAG_YEAR | FLAG_MONTH | FLAG_YDAY | -FLAG_MDAY | FLAG_WDAY; - break; case 'U': @@ -372,8 +313,6 @@ label: * information present in the tm structure at this * point to calculate a real value, so just check the * range for now. -* We expect that the year has already been -* parsed. */ if (!isdigit_l((unsigned char)*buf, loca
svn commit: r272145 - head/sbin/sysctl
Author: delphij Date: Thu Sep 25 22:47:19 2014 New Revision: 272145 URL: http://svnweb.freebsd.org/changeset/base/272145 Log: Explicitly set errno to 0 before calling strto*. Suggested by: mjg MFC after:2 weeks Modified: head/sbin/sysctl/sysctl.c Modified: head/sbin/sysctl/sysctl.c == --- head/sbin/sysctl/sysctl.c Thu Sep 25 22:37:27 2014(r272144) +++ head/sbin/sysctl/sysctl.c Thu Sep 25 22:47:19 2014(r272145) @@ -294,6 +294,8 @@ parse(const char *string, int lineno) } } + errno = 0; + switch (kind & CTLTYPE) { case CTLTYPE_INT: if (strcmp(fmt, "IK") == 0) { @@ -673,6 +675,7 @@ set_IK(const char *str, int *val) if ((len = strlen(str)) == 0) return (0); p = &str[len - 1]; + errno = 0; if (*p == 'C' || *p == 'F') { temp = strtof(str, &endptr); if (errno != 0 || endptr == str || ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r272144 - head/sbin/sysctl
On Thu, Sep 25, 2014 at 10:37:28PM +, Xin LI wrote: > Author: delphij > Date: Thu Sep 25 22:37:27 2014 > New Revision: 272144 > URL: http://svnweb.freebsd.org/changeset/base/272144 > > Log: > The strtol(3) family of functions would set errno when it hits one. > Check errno and handle it as invalid input. > But this requires explicitely setting errno to 0 before strto* call, otherwise you cannot know whether errno is meaningful when you test it. Also it looks like the code would use some deduplications with macros or something. > Obtained from: HardenedBSD > Submitted by: David CARLIER > MFC after: 2 weeks > > Modified: > head/sbin/sysctl/sysctl.c > > Modified: head/sbin/sysctl/sysctl.c > == > --- head/sbin/sysctl/sysctl.c Thu Sep 25 22:22:57 2014(r272143) > +++ head/sbin/sysctl/sysctl.c Thu Sep 25 22:37:27 2014(r272144) > @@ -305,7 +305,8 @@ parse(const char *string, int lineno) > } else { > intval = (int)strtol(newval, &endptr, > 0); > - if (endptr == newval || *endptr != > '\0') { > + if (errno != 0 || endptr == newval || > + *endptr != '\0') { > warnx("invalid integer '%s'%s", > (char *)newval, line); > return (1); > @@ -316,7 +317,8 @@ parse(const char *string, int lineno) > break; > case CTLTYPE_UINT: > uintval = (int) strtoul(newval, &endptr, 0); > - if (endptr == newval || *endptr != '\0') { > + if (errno != 0 || endptr == newval || > + *endptr != '\0') { > warnx("invalid unsigned integer '%s'%s", > (char *)newval, line); > return (1); > @@ -326,7 +328,8 @@ parse(const char *string, int lineno) > break; > case CTLTYPE_LONG: > longval = strtol(newval, &endptr, 0); > - if (endptr == newval || *endptr != '\0') { > + if (errno != 0 || endptr == newval || > + *endptr != '\0') { > warnx("invalid long integer '%s'%s", > (char *)newval, line); > return (1); > @@ -336,7 +339,8 @@ parse(const char *string, int lineno) > break; > case CTLTYPE_ULONG: > ulongval = strtoul(newval, &endptr, 0); > - if (endptr == newval || *endptr != '\0') { > + if (errno != 0 || endptr == newval || > + *endptr != '\0') { > warnx("invalid unsigned long integer" > " '%s'%s", (char *)newval, line); > return (1); > @@ -348,7 +352,8 @@ parse(const char *string, int lineno) > break; > case CTLTYPE_S64: > i64val = strtoimax(newval, &endptr, 0); > - if (endptr == newval || *endptr != '\0') { > + if (errno != 0 || endptr == newval || > + *endptr != '\0') { > warnx("invalid int64_t '%s'%s", > (char *)newval, line); > return (1); > @@ -358,7 +363,8 @@ parse(const char *string, int lineno) > break; > case CTLTYPE_U64: > u64val = strtoumax(newval, &endptr, 0); > - if (endptr == newval || *endptr != '\0') { > + if (errno != 0 || endptr == newval || > + *endptr != '\0') { > warnx("invalid uint64_t '%s'%s", > (char *)newval, line); > return (1); > @@ -669,14 +675,16 @@ set_IK(const char *str, int *val) > p = &str[len - 1]; > if (*p == 'C' || *p == 'F') { > temp = strtof(str, &endptr); > - if (endptr == str || endptr != p) > + if (errno != 0 || endptr == str || > +
svn commit: r272144 - head/sbin/sysctl
Author: delphij Date: Thu Sep 25 22:37:27 2014 New Revision: 272144 URL: http://svnweb.freebsd.org/changeset/base/272144 Log: The strtol(3) family of functions would set errno when it hits one. Check errno and handle it as invalid input. Obtained from:HardenedBSD Submitted by: David CARLIER MFC after:2 weeks Modified: head/sbin/sysctl/sysctl.c Modified: head/sbin/sysctl/sysctl.c == --- head/sbin/sysctl/sysctl.c Thu Sep 25 22:22:57 2014(r272143) +++ head/sbin/sysctl/sysctl.c Thu Sep 25 22:37:27 2014(r272144) @@ -305,7 +305,8 @@ parse(const char *string, int lineno) } else { intval = (int)strtol(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { + if (errno != 0 || endptr == newval || + *endptr != '\0') { warnx("invalid integer '%s'%s", (char *)newval, line); return (1); @@ -316,7 +317,8 @@ parse(const char *string, int lineno) break; case CTLTYPE_UINT: uintval = (int) strtoul(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { + if (errno != 0 || endptr == newval || + *endptr != '\0') { warnx("invalid unsigned integer '%s'%s", (char *)newval, line); return (1); @@ -326,7 +328,8 @@ parse(const char *string, int lineno) break; case CTLTYPE_LONG: longval = strtol(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { + if (errno != 0 || endptr == newval || + *endptr != '\0') { warnx("invalid long integer '%s'%s", (char *)newval, line); return (1); @@ -336,7 +339,8 @@ parse(const char *string, int lineno) break; case CTLTYPE_ULONG: ulongval = strtoul(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { + if (errno != 0 || endptr == newval || + *endptr != '\0') { warnx("invalid unsigned long integer" " '%s'%s", (char *)newval, line); return (1); @@ -348,7 +352,8 @@ parse(const char *string, int lineno) break; case CTLTYPE_S64: i64val = strtoimax(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { + if (errno != 0 || endptr == newval || + *endptr != '\0') { warnx("invalid int64_t '%s'%s", (char *)newval, line); return (1); @@ -358,7 +363,8 @@ parse(const char *string, int lineno) break; case CTLTYPE_U64: u64val = strtoumax(newval, &endptr, 0); - if (endptr == newval || *endptr != '\0') { + if (errno != 0 || endptr == newval || + *endptr != '\0') { warnx("invalid uint64_t '%s'%s", (char *)newval, line); return (1); @@ -669,14 +675,16 @@ set_IK(const char *str, int *val) p = &str[len - 1]; if (*p == 'C' || *p == 'F') { temp = strtof(str, &endptr); - if (endptr == str || endptr != p) + if (errno != 0 || endptr == str || + endptr != p) return (0); if (*p == 'F') temp = (temp - 32) * 5 / 9; kelv = temp * 10 + 2732; } else { kelv = (int)strtol(str, &endptr, 10); - if (endptr == str || *endptr != '\0') + if (errno != 0 |
svn commit: r272139 - head/contrib/hyperv/tools
Author: delphij Date: Thu Sep 25 22:22:43 2014 New Revision: 272139 URL: http://svnweb.freebsd.org/changeset/base/272139 Log: Being able to access a path do not necessarily mean we have access to a directory. So instead of doing this, we just call mkdir(2) directly and test if the returned value is 0 or errno is EISDIR. Reported by: Coverity CID: 1238925 MFC after:1 week Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c == --- head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:15:10 2014 (r272138) +++ head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:43 2014 (r272139) @@ -284,12 +284,10 @@ kvp_file_init(void) int i; int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK; - if (access("/var/db/hyperv/pool", F_OK)) { - if (mkdir("/var/db/hyperv/pool", - S_IRUSR | S_IWUSR | S_IROTH)) { - KVP_LOG(LOG_ERR, " Failed to create /var/db/hyperv/pool\n"); - exit(EXIT_FAILURE); - } + if (mkdir("/var/db/hyperv/pool", S_IRUSR | S_IWUSR | S_IROTH) < 0 && + errno != EISDIR) { + KVP_LOG(LOG_ERR, " Failed to create /var/db/hyperv/pool\n"); + exit(EXIT_FAILURE); } for (i = 0; i < HV_KVP_POOL_COUNT; i++) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272140 - head/contrib/hyperv/tools
Author: delphij Date: Thu Sep 25 22:22:48 2014 New Revision: 272140 URL: http://svnweb.freebsd.org/changeset/base/272140 Log: Plug a file descriptor leak. Reported by: Coverity CID: 1238916 MFC after:1 week Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c == --- head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:43 2014 (r272139) +++ head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:48 2014 (r272140) @@ -305,11 +305,13 @@ kvp_file_init(void) filep = fopen(fname, "r"); if (!filep) { + close(fd); return (1); } record = malloc(alloc_unit * num_blocks); if (record == NULL) { + close(fd); fclose(filep); return (1); } @@ -334,6 +336,7 @@ kvp_file_init(void) record = realloc(record, alloc_unit * num_blocks); if (record == NULL) { + close(fd); fclose(filep); return (1); } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272142 - head/contrib/hyperv/tools
Author: delphij Date: Thu Sep 25 22:22:54 2014 New Revision: 272142 URL: http://svnweb.freebsd.org/changeset/base/272142 Log: Use strlcpy(). I don't believe these are real problems but it's better to use a safe idiom. Reported by: Coverity CID: 1238914 MFC after:1 week Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c == --- head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:51 2014 (r272141) +++ head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:54 2014 (r272142) @@ -1249,7 +1249,7 @@ kvp_op_enumerate(struct hv_kvp_msg *op_m case IntegrationServicesVersion: strcpy(key_name, "IntegrationServicesVersion"); - strcpy(key_value, lic_version); + strlcpy(key_value, lic_version, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); break; case NetworkAddressIPv4: @@ -1265,32 +1265,32 @@ kvp_op_enumerate(struct hv_kvp_msg *op_m break; case OSBuildNumber: - strcpy(key_value, os_build); + strlcpy(key_value, os_build, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "OSBuildNumber"); break; case OSName: - strcpy(key_value, os_name); + strlcpy(key_value, os_name, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "OSName"); break; case OSMajorVersion: - strcpy(key_value, os_major); + strlcpy(key_value, os_major, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "OSMajorVersion"); break; case OSMinorVersion: - strcpy(key_value, os_minor); + strlcpy(key_value, os_minor, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "OSMinorVersion"); break; case OSVersion: - strcpy(key_value, os_build); + strlcpy(key_value, os_build, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "OSVersion"); break; case ProcessorArchitecture: - strcpy(key_value, processor_arch); + strlcpy(key_value, processor_arch, HV_KVP_EXCHANGE_MAX_VALUE_SIZE); strcpy(key_name, "ProcessorArchitecture"); break; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272141 - head/contrib/hyperv/tools
Author: delphij Date: Thu Sep 25 22:22:51 2014 New Revision: 272141 URL: http://svnweb.freebsd.org/changeset/base/272141 Log: Refactor the code a little bit to avoid NULL deference when allocation was failed. Reported by: Coverity CID: 1238915 MFC after:1 week Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c == --- head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:48 2014 (r272140) +++ head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:51 2014 (r272141) @@ -612,18 +612,17 @@ kvp_mac_to_if_name(char *mac) sdl = (struct sockaddr_dl *)(uintptr_t)ifaddrs_ptr->ifa_addr; if (sdl->sdl_type == IFT_ETHER) { buf_ptr = strdup(ether_ntoa((struct ether_addr *)(LLADDR(sdl; - for (i = 0; i < strlen(buf_ptr); i++) - { - buf_ptr[i] = toupper(buf_ptr[i]); - } - - if (strncmp(buf_ptr, mac, strlen(mac)) == 0) { - /* Caller will free the memory */ - if_name = strdup(ifaddrs_ptr->ifa_name); - free(buf_ptr); - break; - }else if (buf_ptr != NULL) { - free(buf_ptr); + if (buf_ptr != NULL) { + for (i = 0; i < strlen(buf_ptr); i++) + buf_ptr[i] = toupper(buf_ptr[i]); + + if (strncmp(buf_ptr, mac, strlen(mac)) == 0) { + /* Caller will free the memory */ + if_name = strdup(ifaddrs_ptr->ifa_name); + free(buf_ptr); + break; + } else + free(buf_ptr); } } } while ((ifaddrs_ptr = ifaddrs_ptr->ifa_next) != NULL); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272143 - head/contrib/hyperv/tools
Author: delphij Date: Thu Sep 25 22:22:57 2014 New Revision: 272143 URL: http://svnweb.freebsd.org/changeset/base/272143 Log: Use a char * as iterator over a bounded string. MFC after:1 week Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c Modified: head/contrib/hyperv/tools/hv_kvp_daemon.c == --- head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:54 2014 (r272142) +++ head/contrib/hyperv/tools/hv_kvp_daemon.c Thu Sep 25 22:22:57 2014 (r272143) @@ -601,8 +601,7 @@ kvp_mac_to_if_name(char *mac) struct ifaddrs *head_ifaddrs_ptr; struct sockaddr_dl *sdl; int status; - size_t i; - char *buf_ptr; + char *buf_ptr, *p; status = getifaddrs(&ifaddrs_ptr); @@ -613,8 +612,8 @@ kvp_mac_to_if_name(char *mac) if (sdl->sdl_type == IFT_ETHER) { buf_ptr = strdup(ether_ntoa((struct ether_addr *)(LLADDR(sdl; if (buf_ptr != NULL) { - for (i = 0; i < strlen(buf_ptr); i++) - buf_ptr[i] = toupper(buf_ptr[i]); + for (p = buf_ptr; *p != '\0'; p++) + *p = toupper(*p); if (strncmp(buf_ptr, mac, strlen(mac)) == 0) { /* Caller will free the memory */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272138 - head/lib/msun/src
Author: kargl Date: Thu Sep 25 22:15:10 2014 New Revision: 272138 URL: http://svnweb.freebsd.org/changeset/base/272138 Log: * Whitespace. Modified: head/lib/msun/src/e_lgamma_r.c Modified: head/lib/msun/src/e_lgamma_r.c == --- head/lib/msun/src/e_lgamma_r.c Thu Sep 25 21:57:35 2014 (r272137) +++ head/lib/msun/src/e_lgamma_r.c Thu Sep 25 22:15:10 2014 (r272138) @@ -1,4 +1,3 @@ - /* @(#)e_lgamma_r.c 1.3 95/01/18 */ /* * @@ -6,10 +5,9 @@ * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice + * software is freely granted, provided that this notice * is preserved. * - * */ #include ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272137 - head/etc
Author: wblock (doc committer) Date: Thu Sep 25 21:57:35 2014 New Revision: 272137 URL: http://svnweb.freebsd.org/changeset/base/272137 Log: Revised to better point to release notes and errata, security advisories, and be more specific about the -questions list. MFC after:3 days Modified: head/etc/motd Modified: head/etc/motd == --- head/etc/motd Thu Sep 25 21:45:07 2014(r272136) +++ head/etc/motd Thu Sep 25 21:57:35 2014(r272137) @@ -1,12 +1,13 @@ FreeBSD ?.?.? (UNKNOWN) -Welcome to FreeBSD! Handy technical support resources: +Welcome to FreeBSD! -Security advisories and errata: https://www.FreeBSD.org/releases/ -Handbook: https://www.FreeBSD.org/handbook/ -FAQ: https://www.FreeBSD.org/faq/ -Mailing list: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/ -Forums: https://forums.FreeBSD.org/ +Release Notes, Errata: https://www.FreeBSD.org/releases/ +Security Advisories: https://www.FreeBSD.org/security/ +FreeBSD Handbook: https://www.FreeBSD.org/handbook/ +FreeBSD FAQ: https://www.FreeBSD.org/faq/ +Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/ +FreeBSD Forums:https://forums.FreeBSD.org/ Documents installed with the system are in the /usr/local/share/doc/freebsd/ directory, or can be installed later with: pkg install en-freebsd-doc @@ -14,7 +15,6 @@ For other languages, replace "en" with a Show the version of FreeBSD installed: uname -a Please include that output and any error messages when posting questions. - Introduction to manual pages: man man FreeBSD directory layout: man hier ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272135 - head/usr.bin/man
Author: allanjude (doc committer) Date: Thu Sep 25 21:34:57 2014 New Revision: 272135 URL: http://svnweb.freebsd.org/changeset/base/272135 Log: Update man(1) to list the different sections of the manual Add each of the intro sections to the 'Also See' list PR: 193460 Differential Revision:D834 Approved by: bcr (mentor) Sponsored by: ScaleEngine Inc. Modified: head/usr.bin/man/man.1 Modified: head/usr.bin/man/man.1 == --- head/usr.bin/man/man.1 Thu Sep 25 21:28:19 2014(r272134) +++ head/usr.bin/man/man.1 Thu Sep 25 21:34:57 2014(r272135) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 3, 2011 +.Dd September 26, 2014 .Dt MAN 1 .Os .Sh NAME @@ -58,6 +58,28 @@ is provided, .Nm restricts the search to the specific section of the manual. .Pp +The sections of the manual are: +.Bl -enum -offset indent -compact +.It +\*[volume-operating-system] \*[volume-ds-1] +.It +\*[volume-operating-system] \*[volume-ds-2] +.It +\*[volume-operating-system] \*[volume-ds-3] +.It +\*[volume-operating-system] \*[volume-ds-4] +.It +\*[volume-operating-system] \*[volume-ds-5] +.It +\*[volume-operating-system] \*[volume-ds-6] +.It +\*[volume-operating-system] \*[volume-ds-7] +.It +\*[volume-operating-system] \*[volume-ds-8] +.It +\*[volume-operating-system] \*[volume-ds-9] +.El +.Pp Options that .Nm understands: @@ -318,6 +340,14 @@ Local configuration files. .Sh SEE ALSO .Xr apropos 1 , .Xr intro 1 , +.Xr intro 2 , +.Xr intro 3 , +.Xr intro 4 , +.Xr intro 5 , +.Xr intro 6 , +.Xr intro 7 , +.Xr intro 8 , +.Xr intro 9 , .Xr locale 1 , .Xr manpath 1 , .Xr nroff 1 , ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272132 - in head/sys: compat/freebsd32 kern sys
Author: kib Date: Thu Sep 25 21:07:19 2014 New Revision: 272132 URL: http://svnweb.freebsd.org/changeset/base/272132 Log: Fix fcntl(2) compat32 after r270691. The copyin and copyout of the struct flock are done in the sys_fcntl(), which mean that compat32 used direct access to userland pointers. Move code from sys_fcntl() to new wrapper, kern_fcntl_freebsd(), which performs neccessary userland memory accesses, and use it from both native and compat32 fcntl syscalls. Reported by: jhibbits Sponsored by: The FreeBSD Foundation MFC after:3 days Modified: head/sys/compat/freebsd32/freebsd32_misc.c head/sys/kern/kern_descrip.c head/sys/sys/syscallsubr.h Modified: head/sys/compat/freebsd32/freebsd32_misc.c == --- head/sys/compat/freebsd32/freebsd32_misc.c Thu Sep 25 20:56:05 2014 (r272131) +++ head/sys/compat/freebsd32/freebsd32_misc.c Thu Sep 25 21:07:19 2014 (r272132) @@ -2984,7 +2984,7 @@ freebsd32_procctl(struct thread *td, str int freebsd32_fcntl(struct thread *td, struct freebsd32_fcntl_args *uap) { - intptr_t tmp; + long tmp; switch (uap->cmd) { /* @@ -3003,5 +3003,5 @@ freebsd32_fcntl(struct thread *td, struc tmp = uap->arg; break; } - return (kern_fcntl(td, uap->fd, uap->cmd, tmp)); + return (kern_fcntl_freebsd(td, uap->fd, uap->cmd, tmp)); } Modified: head/sys/kern/kern_descrip.c == --- head/sys/kern/kern_descrip.cThu Sep 25 20:56:05 2014 (r272131) +++ head/sys/kern/kern_descrip.cThu Sep 25 21:07:19 2014 (r272132) @@ -378,22 +378,27 @@ struct fcntl_args { int sys_fcntl(struct thread *td, struct fcntl_args *uap) { + + return (kern_fcntl_freebsd(td, uap->fd, uap->cmd, uap->arg)); +} + +int +kern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg) +{ struct flock fl; struct __oflock ofl; - intptr_t arg; + intptr_t arg1; int error; - int cmd; error = 0; - cmd = uap->cmd; - switch (uap->cmd) { + switch (cmd) { case F_OGETLK: case F_OSETLK: case F_OSETLKW: /* * Convert old flock structure to new. */ - error = copyin((void *)(intptr_t)uap->arg, &ofl, sizeof(ofl)); + error = copyin((void *)(intptr_t)arg, &ofl, sizeof(ofl)); fl.l_start = ofl.l_start; fl.l_len = ofl.l_len; fl.l_pid = ofl.l_pid; @@ -401,7 +406,7 @@ sys_fcntl(struct thread *td, struct fcnt fl.l_whence = ofl.l_whence; fl.l_sysid = 0; - switch (uap->cmd) { + switch (cmd) { case F_OGETLK: cmd = F_GETLK; break; @@ -412,33 +417,33 @@ sys_fcntl(struct thread *td, struct fcnt cmd = F_SETLKW; break; } - arg = (intptr_t)&fl; + arg1 = (intptr_t)&fl; break; case F_GETLK: case F_SETLK: case F_SETLKW: case F_SETLK_REMOTE: -error = copyin((void *)(intptr_t)uap->arg, &fl, sizeof(fl)); -arg = (intptr_t)&fl; +error = copyin((void *)(intptr_t)arg, &fl, sizeof(fl)); +arg1 = (intptr_t)&fl; break; default: - arg = uap->arg; + arg1 = arg; break; } if (error) return (error); - error = kern_fcntl(td, uap->fd, cmd, arg); + error = kern_fcntl(td, fd, cmd, arg1); if (error) return (error); - if (uap->cmd == F_OGETLK) { + if (cmd == F_OGETLK) { ofl.l_start = fl.l_start; ofl.l_len = fl.l_len; ofl.l_pid = fl.l_pid; ofl.l_type = fl.l_type; ofl.l_whence = fl.l_whence; - error = copyout(&ofl, (void *)(intptr_t)uap->arg, sizeof(ofl)); - } else if (uap->cmd == F_GETLK) { - error = copyout(&fl, (void *)(intptr_t)uap->arg, sizeof(fl)); + error = copyout(&ofl, (void *)(intptr_t)arg, sizeof(ofl)); + } else if (cmd == F_GETLK) { + error = copyout(&fl, (void *)(intptr_t)arg, sizeof(fl)); } return (error); } Modified: head/sys/sys/syscallsubr.h == --- head/sys/sys/syscallsubr.h Thu Sep 25 20:56:05 2014(r272131) +++ head/sys/sys/syscallsubr.h Thu Sep 25 21:07:19 2014(r272132) @@ -97,6 +97,7 @@ int kern_fchmodat(struct thread *td, int intkern_fchownat(struct thread *td, int fd, char *path, enum uio_seg path
svn commit: r272130 - head/sys/kern
Author: kib Date: Thu Sep 25 20:42:25 2014 New Revision: 272130 URL: http://svnweb.freebsd.org/changeset/base/272130 Log: In kern_linkat() and kern_renameat(), do not call namei(9) while holding a write reference on the filesystem. Try to get write reference in unblocked way after all vnodes are resolved; if failed, drop all locks and retry after waiting for suspension end. The VFS_UNMOUNT() methods for UFS and tmpfs try to establish suspension on unmount, while covered vnode is locked by VFS, which prevents namei() from stepping over the mount point. The thread doing namei() sleeps on the covered vnode lock, owning the write ref. Reported by: bdrewery Tested by:bdrewery (previous version), pho Sponsored by: The FreeBSD Foundation MFC after:1 week Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c == --- head/sys/kern/vfs_syscalls.cThu Sep 25 20:40:24 2014 (r272129) +++ head/sys/kern/vfs_syscalls.cThu Sep 25 20:42:25 2014 (r272130) @@ -1551,10 +1551,10 @@ kern_linkat(struct thread *td, int fd1, cap_rights_t rights; int error; +again: bwillwrite(); NDINIT_AT(&nd, LOOKUP, follow | AUDITVNODE1, segflg, path1, fd1, td); -again: if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1563,50 +1563,65 @@ again: vrele(vp); return (EPERM); /* POSIX */ } - if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) { - vrele(vp); - return (error); - } NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE2, segflg, path2, fd2, cap_rights_init(&rights, CAP_LINKAT), td); if ((error = namei(&nd)) == 0) { if (nd.ni_vp != NULL) { + NDFREE(&nd, NDF_ONLY_PNBUF); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vrele(nd.ni_vp); - error = EEXIST; - } else if ((error = vn_lock(vp, LK_EXCLUSIVE)) == 0) { + vrele(vp); + return (EEXIST); + } else if (nd.ni_dvp->v_mount != vp->v_mount) { /* -* Check for cross-device links. No need to -* recheck vp->v_type, since it cannot change -* for non-doomed vnode. +* Cross-device link. No need to recheck +* vp->v_type, since it cannot change, except +* to VBAD. */ - if (nd.ni_dvp->v_mount != vp->v_mount) - error = EXDEV; - else - error = can_hardlink(vp, td->td_ucred); - if (error == 0) + NDFREE(&nd, NDF_ONLY_PNBUF); + vput(nd.ni_dvp); + vrele(vp); + return (EXDEV); + } else if ((error = vn_lock(vp, LK_EXCLUSIVE)) == 0) { + error = can_hardlink(vp, td->td_ucred); #ifdef MAC + if (error == 0) error = mac_vnode_check_link(td->td_ucred, nd.ni_dvp, vp, &nd.ni_cnd); - if (error == 0) #endif - error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); + if (error != 0) { + vput(vp); + vput(nd.ni_dvp); + NDFREE(&nd, NDF_ONLY_PNBUF); + return (error); + } + error = vn_start_write(vp, &mp, V_NOWAIT); + if (error != 0) { + vput(vp); + vput(nd.ni_dvp); + NDFREE(&nd, NDF_ONLY_PNBUF); + error = vn_start_write(NULL, &mp, + V_XSLEEP | PCATCH); + if (error != 0) + return (error); + goto again; + } + error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); VOP_UNLOCK(vp, 0); vput(nd.ni_dvp); + vn_finished_write(mp); + NDFREE(&nd, NDF_ONLY_PNBUF); } else { vput(nd.ni_dvp); NDFREE(&nd, NDF_ONLY_PNBUF); vrele(vp);
svn commit: r272129 - in head/sys: conf dev/fdc modules/fdc pc98/cbus
Author: jhb Date: Thu Sep 25 20:40:24 2014 New Revision: 272129 URL: http://svnweb.freebsd.org/changeset/base/272129 Log: Merge the PC98 fdc(4) driver into the MI driver. While here, replace the magic numbers used with NE7CMD_SPECIFY with invocations of the NE7_SPEC_x() macros. Approved by: nyan Added: head/sys/dev/fdc/fdc_cbus.c - copied, changed from r272118, head/sys/pc98/cbus/fdc_cbus.c Deleted: head/sys/pc98/cbus/fdc.c head/sys/pc98/cbus/fdc_cbus.c head/sys/pc98/cbus/fdcreg.h head/sys/pc98/cbus/fdcvar.h Modified: head/sys/conf/files.pc98 head/sys/dev/fdc/fdc.c head/sys/dev/fdc/fdcvar.h head/sys/modules/fdc/Makefile Modified: head/sys/conf/files.pc98 == --- head/sys/conf/files.pc98Thu Sep 25 20:34:13 2014(r272128) +++ head/sys/conf/files.pc98Thu Sep 25 20:40:24 2014(r272129) @@ -98,6 +98,8 @@ dev/ct/ct_isa.c optional ct isa dev/ed/if_ed_cbus.coptional ed isa dev/ed/if_ed_wd80x3.c optional ed isa dev/fb/fb.coptional fb | gdc +dev/fdc/fdc.c optional fdc +dev/fdc/fdc_cbus.c optional fdc isa dev/fe/if_fe_cbus.coptional fe isa dev/hwpmc/hwpmc_amd.c optional hwpmc dev/hwpmc/hwpmc_intel.coptional hwpmc @@ -217,8 +219,6 @@ libkern/udivdi3.c standard libkern/umoddi3.c standard pc98/apm/apm_bioscall.Soptional apm pc98/cbus/cbus_dma.c optional isa -pc98/cbus/fdc.coptional fdc -pc98/cbus/fdc_cbus.c optional fdc isa pc98/cbus/gdc.coptional gdc pc98/cbus/nmi.cstandard pc98/cbus/olpt.c optional olpt Modified: head/sys/dev/fdc/fdc.c == --- head/sys/dev/fdc/fdc.c Thu Sep 25 20:34:13 2014(r272128) +++ head/sys/dev/fdc/fdc.c Thu Sep 25 20:40:24 2014(r272129) @@ -82,9 +82,13 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef PC98 +#include +#else #include -#include #include +#endif +#include #include @@ -136,33 +140,56 @@ __FBSDID("$FreeBSD$"); */ static struct fd_type fd_searchlist_360k[] = { +#ifndef PC98 { FDF_5_360 }, +#endif { 0 } }; static struct fd_type fd_searchlist_12m[] = { +#ifdef PC98 + { FDF_5_1200 | FL_AUTO }, + { FDF_5_720 | FL_AUTO }, + { FDF_5_360 | FL_AUTO }, + { FDF_5_640 | FL_AUTO }, + { FDF_5_1230 | FL_AUTO }, +#else { FDF_5_1200 | FL_AUTO }, { FDF_5_360 | FL_2STEP | FL_AUTO}, +#endif { 0 } }; static struct fd_type fd_searchlist_720k[] = { +#ifndef PC98 { FDF_3_720 }, +#endif { 0 } }; static struct fd_type fd_searchlist_144m[] = { +#ifdef PC98 { FDF_3_1440 | FL_AUTO}, + { FDF_3_1200 | FL_AUTO}, { FDF_3_720 | FL_AUTO}, + { FDF_3_360 | FL_AUTO}, + { FDF_3_640 | FL_AUTO}, + { FDF_3_1230 | FL_AUTO}, +#else + { FDF_3_1440 | FL_AUTO}, + { FDF_3_720 | FL_AUTO}, +#endif { 0 } }; static struct fd_type fd_searchlist_288m[] = { +#ifndef PC98 { FDF_3_1440 | FL_AUTO }, #if 0 { FDF_3_2880 | FL_AUTO }, /* XXX: probably doesn't work */ #endif { FDF_3_720 | FL_AUTO}, +#endif { 0 } }; @@ -183,6 +210,26 @@ static struct fd_type *fd_native_types[] * Internals start here */ +#ifdef PC98 +/* registers */ +#defineFDSTS 0 /* NEC 765 Main Status Register (R) */ +#defineFDDATA 1 /* NEC 765 Data Register (R/W) */ +#defineFDCTL 2 /* FD Control Register */ +#defineFDC_RST 0x80/* FDC RESET */ +#defineFDC_RDY 0x40/* force READY */ +#defineFDC_DD 0x20/* FDD Mode Exchange 0:1M 1:640K */ +#defineFDC_DMAE0x10/* enable floppy DMA */ +#defineFDC_MTON0x08/* MOTOR ON (when EMTON=1)*/ +#defineFDC_TMSK0x04/* TIMER MASK */ +#defineFDC_TTRG0x01/* TIMER TRIGER */ + +#defineFDP 3 +#defineFDP_EMTON 0x04/* enable MTON */ +#defineFDP_FDDEXC 0x02/* FDD Mode Exchange 1:1M 0:640K */ +#defineFDP_PORTEXC 0x01/* PORT Exchane 1:1M 0:640K */ + +#defineFDEM4 +#else /* registers */ #defineFDOUT 2 /* Digital Output Register (W) */ #defineFDO_FDSEL 0x03/* floppy device select */ @@ -197,6 +244,7 @@ static struct fd_type *fd_native_types[] #define FDDSR 4 /* Data Rate Select Register (W) */ #defineFDDATA 5 /* NEC 765 Data Register (R/W) */ #defineFDCTL 7 /* Control Register (W) */ +#endif /* PC98 */ /* * The YE-DATA PC Card floppies use PIO to read in the data rather
Re: svn commit: r272122 - head/lib/libc/stdtime
On 09/25/14 14:53, Bryan Drewery wrote: On 9/25/2014 1:52 PM, Pedro F. Giffuni wrote: Author: pfg Date: Thu Sep 25 18:52:17 2014 New Revision: 272122 URL: http://svnweb.freebsd.org/changeset/base/272122 Log: Add strptime(3) support for %U and %W Add support for the missing POSIX-2001 %U and %W features: the existing FreeBSD strptime code recognizes both directives and validates that the week number lies in the permitted range, but then simply discards the value. Initial support for the feature was written by Paul Green with important fixes by Andrey Chernov. Additional support for handling tm_wday/tm_yday was written by David Carlier. PR: 137307 MFC after: 1 month Seems Relnotes worthy. Ugh . yes, but it is not planned for 10.1 and there are still issues to fix. Pedro. ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r272122 - head/lib/libc/stdtime
On 9/25/2014 1:52 PM, Pedro F. Giffuni wrote: > Author: pfg > Date: Thu Sep 25 18:52:17 2014 > New Revision: 272122 > URL: http://svnweb.freebsd.org/changeset/base/272122 > > Log: > Add strptime(3) support for %U and %W > > Add support for the missing POSIX-2001 %U and %W features: the > existing FreeBSD strptime code recognizes both directives and > validates that the week number lies in the permitted range, > but then simply discards the value. > > Initial support for the feature was written by Paul Green with > important fixes by Andrey Chernov. Additional support for > handling tm_wday/tm_yday was written by David Carlier. > > PR: 137307 > MFC after: 1 month Seems Relnotes worthy. > > Modified: > head/lib/libc/stdtime/strptime.c > > Modified: head/lib/libc/stdtime/strptime.c > == > --- head/lib/libc/stdtime/strptime.c Thu Sep 25 18:43:52 2014 > (r272121) > +++ head/lib/libc/stdtime/strptime.c Thu Sep 25 18:52:17 2014 > (r272122) > @@ -55,10 +55,32 @@ __FBSDID("$FreeBSD$"); > #include "un-namespace.h" > #include "libc_private.h" > #include "timelocal.h" > +#include "tzfile.h" > > static char * _strptime(const char *, const char *, struct tm *, int *, > locale_t); > > -#define asizeof(a) (sizeof (a) / sizeof ((a)[0])) > +#define asizeof(a) (sizeof(a) / sizeof((a)[0])) > + > +#define FLAG_NONE (1 << 0) > +#define FLAG_YEAR (1 << 1) > +#define FLAG_MONTH (1 << 2) > +#define FLAG_YDAY (1 << 3) > +#define FLAG_MDAY (1 << 4) > +#define FLAG_WDAY (1 << 5) > + > +/* > + * Calculate the week day of the first day of a year. Valid for > + * the Gregorian calendar, which began Sept 14, 1752 in the UK > + * and its colonies. Ref: > + * http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week/ > + */ > + > +static int > +first_wday_of(int year) > +{ > + return (((2 * (3 - (year / 100) % 4)) + (year % 100) + > + ((year % 100) / 4) + (isleap(year) ? 6 : 0) + 1) % 7); > +} > > static char * > _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, > @@ -66,9 +88,17 @@ _strptime(const char *buf, const char *f > { > charc; > const char *ptr; > + int day_offset = -1, wday_offset; > int i, len; > + int flags; > int Ealternative, Oalternative; > - struct lc_time_T *tptr = __get_current_time_locale(locale); > + const struct lc_time_T *tptr = __get_current_time_locale(locale); > + static int start_of_month[2][13] = { > + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, > + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} > + }; > + > + flags = FLAG_NONE; > > ptr = fmt; > while (*ptr != 0) { > @@ -119,7 +149,9 @@ label: > if (i < 19) > return (NULL); > > - tm->tm_year = i * 100 - 1900; > + tm->tm_year = i * 100 - TM_YEAR_BASE; > + flags |= FLAG_YEAR; > + > break; > > case 'c': > @@ -197,6 +229,8 @@ label: > return (NULL); > > tm->tm_yday = i - 1; > + flags |= FLAG_YDAY; > + > break; > > case 'M': > @@ -303,7 +337,32 @@ label: > return (NULL); > > tm->tm_wday = i; > + if (day_offset >= 0 && (i - day_offset) != 0) { > + tm->tm_yday += i - day_offset; > + i = 0; > + while (tm->tm_yday >= > + start_of_month[isleap(tm->tm_year + > + TM_YEAR_BASE)][i]) > + i++; > + if (i > 12) > + { > + i = 1; > + tm->tm_yday -= > + > start_of_month[isleap(tm->tm_year + > + TM_YEAR_BASE)] > + [12]; > + tm->tm_year++; > + } > + tm->tm_mon = i - 1; > + tm->tm_mday = tm->tm_yday - > + start_of_month[isleap(tm->tm_year + > + TM_YEAR_BASE)] > + [i - 1] + 1; > + } > buf += len; > + flags |= FLAG_YEAR | FLAG_MONTH | FLAG_YDAY | > +
svn commit: r272127 - head/usr.bin/grep/regex
Author: pfg Date: Thu Sep 25 19:22:26 2014 New Revision: 272127 URL: http://svnweb.freebsd.org/changeset/base/272127 Log: bsdgrep: Work-around for segmentation fault. Fix by David Carlier. Obtained from:HardenedBSD PR: 167921 MFC after:1 month Modified: head/usr.bin/grep/regex/tre-fastmatch.c Modified: head/usr.bin/grep/regex/tre-fastmatch.c == --- head/usr.bin/grep/regex/tre-fastmatch.c Thu Sep 25 19:10:32 2014 (r272126) +++ head/usr.bin/grep/regex/tre-fastmatch.c Thu Sep 25 19:22:26 2014 (r272127) @@ -727,7 +727,7 @@ badpat: for (unsigned int i = 0; i < fg->len; i++) if (fg->pattern[i] == '\\') escaped = !escaped; - else if (fg->pattern[i] == '.' && escaped) + else if (fg->pattern[i] == '.' && fg->escmap && escaped) { fg->escmap[i] = true; escaped = false; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272126 - head/sys/gnu/fs/reiserfs
Author: pfg Date: Thu Sep 25 19:10:32 2014 New Revision: 272126 URL: http://svnweb.freebsd.org/changeset/base/272126 Log: reiserfs: Use signed i_nlink Unlike Linux, FreeBSD's kernel doesn't like unsigned file link count. This is consistent with our ext2fs implementation. MFC after:1 month Modified: head/sys/gnu/fs/reiserfs/reiserfs_fs_i.h Modified: head/sys/gnu/fs/reiserfs/reiserfs_fs_i.h == --- head/sys/gnu/fs/reiserfs/reiserfs_fs_i.hThu Sep 25 19:08:06 2014 (r272125) +++ head/sys/gnu/fs/reiserfs/reiserfs_fs_i.hThu Sep 25 19:10:32 2014 (r272126) @@ -59,7 +59,7 @@ struct reiserfs_node { flags read from sd_attrs. */ uint16_t i_mode; /* IFMT, permissions. */ - uint16_t i_nlink; /* File link count. */ + int16_t i_nlink; /* File link count. */ uint64_t i_size; /* File byte count. */ uint32_t i_bytes; uid_ti_uid; /* File owner. */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272125 - head/lib/libproc
Author: markj Date: Thu Sep 25 19:08:06 2014 New Revision: 272125 URL: http://svnweb.freebsd.org/changeset/base/272125 Log: Factor out some of the duplicated code in the symbol lookup functions, in preparation for adding userland CTF support to DTrace. MFC after:1 month Sponsored by: EMC / Isilon Storage Division Modified: head/lib/libproc/proc_sym.c Modified: head/lib/libproc/proc_sym.c == --- head/lib/libproc/proc_sym.c Thu Sep 25 18:54:36 2014(r272124) +++ head/lib/libproc/proc_sym.c Thu Sep 25 19:08:06 2014(r272125) @@ -26,20 +26,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include #include -#include +#include #include -#include +#include #include -#include #include #include #include @@ -228,22 +228,56 @@ proc_addr2map(struct proc_handle *p, uin return (NULL); } +/* + * Look up the symbol at addr, returning a copy of the symbol and its name. + */ +static int +lookup_addr(Elf *e, Elf_Scn *scn, u_long stridx, uintptr_t off, uintptr_t addr, +const char **name, GElf_Sym *symcopy) +{ + GElf_Sym sym; + Elf_Data *data; + const char *s; + uint64_t rsym; + int i; + + if ((data = elf_getdata(scn, NULL)) == NULL) { + DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1)); + return (1); + } + for (i = 0; gelf_getsym(data, i, &sym) != NULL; i++) { + rsym = off + sym.st_value; + if (addr >= rsym && addr < rsym + sym.st_size) { + s = elf_strptr(e, stridx, sym.st_name); + if (s != NULL) { + *name = s; + memcpy(symcopy, &sym, sizeof(*symcopy)); + /* +* DTrace expects the st_value to contain +* only the address relative to the start of +* the function. +*/ + symcopy->st_value = rsym; + return (0); + } + } + } + return (1); +} + int proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name, size_t namesz, GElf_Sym *symcopy) { + GElf_Ehdr ehdr; + GElf_Shdr shdr; Elf *e; Elf_Scn *scn, *dynsymscn = NULL, *symtabscn = NULL; - Elf_Data *data; - GElf_Shdr shdr; - GElf_Sym sym; - GElf_Ehdr ehdr; - int fd, error = -1; - size_t i; - uint64_t rsym; prmap_t *map; - char *s; - unsigned long symtabstridx = 0, dynsymstridx = 0; + const char *s; + uintptr_t off; + u_long symtabstridx = 0, dynsymstridx = 0; + int fd, error = -1; if ((map = proc_addr2map(p, addr)) == NULL) return (-1); @@ -259,6 +293,7 @@ proc_addr2sym(struct proc_handle *p, uin DPRINTFX("ERROR: gelf_getehdr() failed: %s", elf_errmsg(-1)); goto err2; } + /* * Find the index of the STRTAB and SYMTAB sections to locate * symbol names. @@ -275,80 +310,25 @@ proc_addr2sym(struct proc_handle *p, uin dynsymscn = scn; dynsymstridx = shdr.sh_link; break; - default: - break; - } - } - /* -* Iterate over the Dynamic Symbols table to find the symbol. -* Then look up the string name in STRTAB (.dynstr) -*/ - if ((data = elf_getdata(dynsymscn, NULL)) == NULL) { - DPRINTFX("ERROR: elf_getdata() failed: %s", elf_errmsg(-1)); - goto symtab; - } - i = 0; - while (gelf_getsym(data, i++, &sym) != NULL) { - /* -* Calculate the address mapped to the virtual memory -* by rtld. -*/ - if (ehdr.e_type != ET_EXEC) - rsym = map->pr_vaddr + sym.st_value; - else - rsym = sym.st_value; - if (addr >= rsym && addr < rsym + sym.st_size) { - s = elf_strptr(e, dynsymstridx, sym.st_name); - if (s) { - demangle(s, name, namesz); - memcpy(symcopy, &sym, sizeof(sym)); - /* -* DTrace expects the st_value to contain -* only the address relative to the start of -* the function. -
svn commit: r272124 - head/sys/pc98/cbus
Author: jhb Date: Thu Sep 25 18:54:36 2014 New Revision: 272124 URL: http://svnweb.freebsd.org/changeset/base/272124 Log: Use callout(9) instead of timeout(9). Approved by: nyan Modified: head/sys/pc98/cbus/olpt.c Modified: head/sys/pc98/cbus/olpt.c == --- head/sys/pc98/cbus/olpt.c Thu Sep 25 18:53:27 2014(r272123) +++ head/sys/pc98/cbus/olpt.c Thu Sep 25 18:54:36 2014(r272124) @@ -140,6 +140,7 @@ struct lpt_softc { struct resource *res_port; struct resource *res_irq; void *sc_ih; + struct callout timer; int sc_port; short sc_state; @@ -319,6 +320,7 @@ lpt_attach(device_t dev) unit = device_get_unit(dev); sc = device_get_softc(dev); + callout_init(&sc->timer, 0); rid = 0; sc->res_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, @@ -418,8 +420,8 @@ lptopen (struct cdev *dev, int flags, in lprintf(("irq %x\n", sc->sc_irq)); if (sc->sc_irq & LP_USE_IRQ) { sc->sc_state |= TOUT; - timeout (lptout, (caddr_t)sc, -(sc->sc_backoff = hz/LPTOUTINITIAL)); + sc->sc_backoff = hz / LPTOUTINITIAL;; + callout_reset(&sc->timer, sc->sc_backoff, lptout, sc); } lprintf(("opened.\n")); @@ -437,7 +439,7 @@ lptout (void *arg) sc->sc_backoff++; if (sc->sc_backoff > hz/LPTOUTMAX) sc->sc_backoff = sc->sc_backoff > hz/LPTOUTMAX; - timeout (lptout, (caddr_t)sc, sc->sc_backoff); + callout_reset(&sc->timer, sc->sc_backoff, lptout, sc); } else sc->sc_state &= ~TOUT; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272123 - head/sys/pc98/cbus
Author: jhb Date: Thu Sep 25 18:53:27 2014 New Revision: 272123 URL: http://svnweb.freebsd.org/changeset/base/272123 Log: Use callout() instead of timeout(). This is almost identical to the changes in r271963. Approved by: nyan Modified: head/sys/pc98/cbus/pckbd.c Modified: head/sys/pc98/cbus/pckbd.c == --- head/sys/pc98/cbus/pckbd.c Thu Sep 25 18:52:17 2014(r272122) +++ head/sys/pc98/cbus/pckbd.c Thu Sep 25 18:53:27 2014(r272123) @@ -52,6 +52,19 @@ /* device configuration flags */ #define KB_CONF_FAIL_IF_NO_KBD (1 << 0) /* don't install if no kbd is found */ +typedef caddr_tKBDC; + +typedef struct pckbd_state { + KBDCkbdc; /* keyboard controller */ + int ks_mode;/* input mode (K_XLATE,K_RAW,K_CODE) */ + int ks_flags; /* flags */ +#define COMPOSE(1 << 0) + int ks_state; /* shift/lock key state */ + int ks_accents; /* accent key index (> 0) */ + u_int ks_composed_char; /* composed char code (> 0) */ + struct callout ks_timer; +} pckbd_state_t; + static devclass_t pckbd_devclass; static int pckbdprobe(device_t dev); @@ -186,6 +199,7 @@ static int pckbd_attach_unit(device_t dev, keyboard_t **kbd, int port, int irq, int flags) { keyboard_switch_t *sw; + pckbd_state_t *state; int args[2]; int error; int unit; @@ -218,6 +232,8 @@ pckbd_attach_unit(device_t dev, keyboard * This is a kludge to compensate for lost keyboard interrupts. * A similar code used to be in syscons. See below. XXX */ + state = (pckbd_state_t *)(*kbd)->kb_data; + callout_init(&state->ks_timer, 0); pckbd_timeout(*kbd); if (bootverbose) @@ -229,6 +245,7 @@ pckbd_attach_unit(device_t dev, keyboard static void pckbd_timeout(void *arg) { + pckbd_state_t *state; keyboard_t *kbd; int s; @@ -259,7 +276,8 @@ pckbd_timeout(void *arg) kbdd_intr(kbd, NULL); } splx(s); - timeout(pckbd_timeout, arg, hz/10); + state = (pckbd_state_t *)kbd->kb_data; + callout_reset(&state->ks_timer, hz / 10, pckbd_timeout, arg); } /* LOW-LEVEL */ @@ -268,18 +286,6 @@ pckbd_timeout(void *arg) #define PC98KBD_DEFAULT0 -typedef caddr_tKBDC; - -typedef struct pckbd_state { - KBDCkbdc; /* keyboard controller */ - int ks_mode;/* input mode (K_XLATE,K_RAW,K_CODE) */ - int ks_flags; /* flags */ -#define COMPOSE(1 << 0) - int ks_state; /* shift/lock key state */ - int ks_accents; /* accent key index (> 0) */ - u_int ks_composed_char; /* composed char code (> 0) */ -} pckbd_state_t; - /* keyboard driver declaration */ static int pckbd_configure(int flags); static kbd_probe_t pckbd_probe; @@ -486,7 +492,10 @@ pckbd_init(int unit, keyboard_t **kbdp, static int pckbd_term(keyboard_t *kbd) { + pckbd_state_t *state = (pckbd_state_t *)kbd->kb_data; + kbd_unregister(kbd); + callout_drain(&state->ks_timer); return 0; } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272122 - head/lib/libc/stdtime
Author: pfg Date: Thu Sep 25 18:52:17 2014 New Revision: 272122 URL: http://svnweb.freebsd.org/changeset/base/272122 Log: Add strptime(3) support for %U and %W Add support for the missing POSIX-2001 %U and %W features: the existing FreeBSD strptime code recognizes both directives and validates that the week number lies in the permitted range, but then simply discards the value. Initial support for the feature was written by Paul Green with important fixes by Andrey Chernov. Additional support for handling tm_wday/tm_yday was written by David Carlier. PR: 137307 MFC after:1 month Modified: head/lib/libc/stdtime/strptime.c Modified: head/lib/libc/stdtime/strptime.c == --- head/lib/libc/stdtime/strptime.cThu Sep 25 18:43:52 2014 (r272121) +++ head/lib/libc/stdtime/strptime.cThu Sep 25 18:52:17 2014 (r272122) @@ -55,10 +55,32 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "libc_private.h" #include "timelocal.h" +#include "tzfile.h" static char * _strptime(const char *, const char *, struct tm *, int *, locale_t); -#defineasizeof(a) (sizeof (a) / sizeof ((a)[0])) +#defineasizeof(a) (sizeof(a) / sizeof((a)[0])) + +#defineFLAG_NONE (1 << 0) +#defineFLAG_YEAR (1 << 1) +#defineFLAG_MONTH (1 << 2) +#defineFLAG_YDAY (1 << 3) +#defineFLAG_MDAY (1 << 4) +#defineFLAG_WDAY (1 << 5) + +/* + * Calculate the week day of the first day of a year. Valid for + * the Gregorian calendar, which began Sept 14, 1752 in the UK + * and its colonies. Ref: + * http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week/ + */ + +static int +first_wday_of(int year) +{ + return (((2 * (3 - (year / 100) % 4)) + (year % 100) + + ((year % 100) / 4) + (isleap(year) ? 6 : 0) + 1) % 7); +} static char * _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp, @@ -66,9 +88,17 @@ _strptime(const char *buf, const char *f { charc; const char *ptr; + int day_offset = -1, wday_offset; int i, len; + int flags; int Ealternative, Oalternative; - struct lc_time_T *tptr = __get_current_time_locale(locale); + const struct lc_time_T *tptr = __get_current_time_locale(locale); + static int start_of_month[2][13] = { + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} + }; + + flags = FLAG_NONE; ptr = fmt; while (*ptr != 0) { @@ -119,7 +149,9 @@ label: if (i < 19) return (NULL); - tm->tm_year = i * 100 - 1900; + tm->tm_year = i * 100 - TM_YEAR_BASE; + flags |= FLAG_YEAR; + break; case 'c': @@ -197,6 +229,8 @@ label: return (NULL); tm->tm_yday = i - 1; + flags |= FLAG_YDAY; + break; case 'M': @@ -303,7 +337,32 @@ label: return (NULL); tm->tm_wday = i; + if (day_offset >= 0 && (i - day_offset) != 0) { + tm->tm_yday += i - day_offset; + i = 0; + while (tm->tm_yday >= + start_of_month[isleap(tm->tm_year + + TM_YEAR_BASE)][i]) + i++; + if (i > 12) + { + i = 1; + tm->tm_yday -= + start_of_month[isleap(tm->tm_year + + TM_YEAR_BASE)] + [12]; + tm->tm_year++; + } + tm->tm_mon = i - 1; + tm->tm_mday = tm->tm_yday - + start_of_month[isleap(tm->tm_year + + TM_YEAR_BASE)] + [i - 1] + 1; + } buf += len; + flags |= FLAG_YEAR | FLAG_MONTH | FLAG_YDAY | +FLAG_MDAY | FLAG_WDAY; + break; case 'U': @@ -313,6 +372,8 @@ label: * information present in the tm structure at this
svn commit: r272121 - in head/sys: conf dev/ncr
Author: jhb Date: Thu Sep 25 18:43:52 2014 New Revision: 272121 URL: http://svnweb.freebsd.org/changeset/base/272121 Log: Lock ncr(4) and mark it MPSAFE along with various other fixes: - Use bus_*() instead of bus_space_*(). - Use device_printf(). - Remove unused global variables and the extra warning suppression they required. - Use callout() instead of timeout(). Reviewed by: se Modified: head/sys/conf/files head/sys/dev/ncr/ncr.c Modified: head/sys/conf/files == --- head/sys/conf/files Thu Sep 25 18:03:14 2014(r272120) +++ head/sys/conf/files Thu Sep 25 18:43:52 2014(r272121) @@ -1949,8 +1949,7 @@ dev/nand/nandsim_ctrl.c optional nandsi dev/nand/nandsim_log.c optional nandsim nand dev/nand/nandsim_swap.coptional nandsim nand dev/nand/nfc_if.m optional nand -dev/ncr/ncr.c optional ncr pci \ - compile-with "${NORMAL_C} -Wno-unused" +dev/ncr/ncr.c optional ncr pci dev/ncv/ncr53c500.coptional ncv dev/ncv/ncr53c500_pccard.c optional ncv pccard dev/netmap/netmap.coptional netmap Modified: head/sys/dev/ncr/ncr.c == --- head/sys/dev/ncr/ncr.c Thu Sep 25 18:03:14 2014(r272120) +++ head/sys/dev/ncr/ncr.c Thu Sep 25 18:43:52 2014(r272121) @@ -43,11 +43,6 @@ __FBSDID("$FreeBSD$"); -#define NCR_DATE "pl30 98/1/1" - -#define NCR_VERSION(2) -#defineMAX_UNITS (16) - #define NCR_GETCC_WITHMSG #if defined (__FreeBSD__) && defined(_KERNEL) @@ -274,25 +269,22 @@ __FBSDID("$FreeBSD$"); **== */ -#defineINB(r) bus_space_read_1(np->bst, np->bsh, offsetof(struct ncr_reg, r)) -#defineINW(r) bus_space_read_2(np->bst, np->bsh, offsetof(struct ncr_reg, r)) -#defineINL(r) bus_space_read_4(np->bst, np->bsh, offsetof(struct ncr_reg, r)) - -#defineOUTB(r, val) bus_space_write_1(np->bst, np->bsh, \ - offsetof(struct ncr_reg, r), val) -#defineOUTW(r, val) bus_space_write_2(np->bst, np->bsh, \ - offsetof(struct ncr_reg, r), val) -#defineOUTL(r, val) bus_space_write_4(np->bst, np->bsh, \ - offsetof(struct ncr_reg, r), val) -#defineOUTL_OFF(o, val) bus_space_write_4(np->bst, np->bsh, o, val) - -#defineINB_OFF(o) bus_space_read_1(np->bst, np->bsh, o) -#defineINW_OFF(o) bus_space_read_2(np->bst, np->bsh, o) -#defineINL_OFF(o) bus_space_read_4(np->bst, np->bsh, o) +#defineINB(r) bus_read_1(np->reg_res, offsetof(struct ncr_reg, r)) +#defineINW(r) bus_read_2(np->reg_res, offsetof(struct ncr_reg, r)) +#defineINL(r) bus_read_4(np->reg_res, offsetof(struct ncr_reg, r)) + +#defineOUTB(r, val) bus_write_1(np->reg_res, offsetof(struct ncr_reg, r), val) +#defineOUTW(r, val) bus_write_2(np->reg_res, offsetof(struct ncr_reg, r), val) +#defineOUTL(r, val) bus_write_4(np->reg_res, offsetof(struct ncr_reg, r), val) +#defineOUTL_OFF(o, val) bus_write_4(np->reg_res, o, val) + +#defineINB_OFF(o) bus_read_1(np->reg_res, o) +#defineINW_OFF(o) bus_read_2(np->reg_res, o) +#defineINL_OFF(o) bus_read_4(np->reg_res, o) #defineREADSCRIPT_OFF(base, off) \ (base ? *((volatile u_int32_t *)((volatile char *)base + (off))) : \ -bus_space_read_4(np->bst2, np->bsh2, off)) +bus_read_4(np->sram_res, off)) #defineWRITESCRIPT_OFF(base, off, val) \ do { \ @@ -300,7 +292,7 @@ __FBSDID("$FreeBSD$"); *((volatile u_int32_t *)\ ((volatile char *)base + (off))) = (val); \ else\ - bus_space_write_4(np->bst2, np->bsh2, off, val);\ + bus_write_4(np->sram_res, off, val);\ } while (0) #defineREADSCRIPT(r) \ @@ -974,7 +966,7 @@ struct ncb { */ struct head header; - int unit; + device_t dev; /*--- ** Scripts .. @@ -999,13 +991,9 @@ struct ncb { */ int reg_rid; struct resource *reg_res; - bus_space_tag_t bst; - bus_space_handle_t bsh; int sram_rid; struct resource *sram_res; - bus_space_tag_t bst2; - bus_space_handle_t bsh2; struct resource *irq_res; void*irq_handle; @@ -1086,7 +1074,7 @@ struct
svn commit: r272120 - in head/sys: arm/altera/socfpga arm/conf boot/fdt/dts/arm dev/dwc
Author: br Date: Thu Sep 25 18:03:14 2014 New Revision: 272120 URL: http://svnweb.freebsd.org/changeset/base/272120 Log: Add driver for Synopsys DesignWare 3504-0 Universal 10/100/1000 Ethernet MAC. Sponsored by: DARPA, AFRL Added: head/sys/dev/dwc/ head/sys/dev/dwc/if_dwc.c (contents, props changed) head/sys/dev/dwc/if_dwc.h (contents, props changed) Modified: head/sys/arm/altera/socfpga/files.socfpga head/sys/arm/conf/SOCKIT head/sys/boot/fdt/dts/arm/socfpga-sockit.dts head/sys/boot/fdt/dts/arm/socfpga.dtsi Modified: head/sys/arm/altera/socfpga/files.socfpga == --- head/sys/arm/altera/socfpga/files.socfpga Thu Sep 25 17:59:00 2014 (r272119) +++ head/sys/arm/altera/socfpga/files.socfpga Thu Sep 25 18:03:14 2014 (r272120) @@ -17,3 +17,5 @@ arm/altera/socfpga/socfpga_common.c sta arm/altera/socfpga/socfpga_machdep.c standard arm/altera/socfpga/socfpga_manager.c standard arm/altera/socfpga/socfpga_rstmgr.cstandard + +dev/dwc/if_dwc.c optional dwc Modified: head/sys/arm/conf/SOCKIT == --- head/sys/arm/conf/SOCKITThu Sep 25 17:59:00 2014(r272119) +++ head/sys/arm/conf/SOCKITThu Sep 25 18:03:14 2014(r272120) @@ -124,6 +124,7 @@ device ether device mii device smsc device smscphy +device dwc # USB ethernet support, requires miibus device miibus Modified: head/sys/boot/fdt/dts/arm/socfpga-sockit.dts == --- head/sys/boot/fdt/dts/arm/socfpga-sockit.dtsThu Sep 25 17:59:00 2014(r272119) +++ head/sys/boot/fdt/dts/arm/socfpga-sockit.dtsThu Sep 25 18:03:14 2014(r272120) @@ -51,6 +51,10 @@ usb1: usb@ffb4 { status = "okay"; }; + + gmac1: ethernet@ff702000 { + status = "okay"; + }; }; chosen { Modified: head/sys/boot/fdt/dts/arm/socfpga.dtsi == --- head/sys/boot/fdt/dts/arm/socfpga.dtsi Thu Sep 25 17:59:00 2014 (r272119) +++ head/sys/boot/fdt/dts/arm/socfpga.dtsi Thu Sep 25 18:03:14 2014 (r272120) @@ -71,6 +71,11 @@ interrupt-parent = < &GIC >; }; + sysmgr: sysmgr@ffd08000 { + compatible = "altr,sys-mgr"; + reg = <0xffd08000 0x1000>; + }; + rstmgr: rstmgr@ffd05000 { compatible = "altr,rst-mgr"; reg = <0xffd05000 0x1000>; @@ -127,5 +132,25 @@ dr_mode = "host"; status = "disabled"; }; + + gmac0: ethernet@ff70 { + compatible = "altr,socfpga-stmmac", + "snps,dwmac-3.70a", "snps,dwmac"; + reg = <0xff70 0x2000>; + interrupts = <147>; + interrupt-parent = <&GIC>; + phy-mode = "rgmii"; + status = "disabled"; + }; + + gmac1: ethernet@ff702000 { + compatible = "altr,socfpga-stmmac", + "snps,dwmac-3.70a", "snps,dwmac"; + reg = <0xff702000 0x2000>; + interrupts = <152>; + interrupt-parent = <&GIC>; + phy-mode = "rgmii"; + status = "disabled"; + }; }; }; Added: head/sys/dev/dwc/if_dwc.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/dwc/if_dwc.c Thu Sep 25 18:03:14 2014(r272120) @@ -0,0 +1,1324 @@ +/*- + * Copyright (c) 2014 Ruslan Bukin + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. +
svn commit: r272111 - head/sys/dev/netmap
Author: luigi Date: Thu Sep 25 16:22:32 2014 New Revision: 272111 URL: http://svnweb.freebsd.org/changeset/base/272111 Log: fix a panic when passing ifioctl from a netmap file descriptor to the underlying device. This needs to be merged to 10.1 Reported by: Patrick Kelsey MFC after:3 days Modified: head/sys/dev/netmap/netmap.c Modified: head/sys/dev/netmap/netmap.c == --- head/sys/dev/netmap/netmap.cThu Sep 25 15:57:57 2014 (r272110) +++ head/sys/dev/netmap/netmap.cThu Sep 25 16:22:32 2014 (r272111) @@ -,23 +,18 @@ netmap_ioctl(struct cdev *dev, u_long cm default:/* allow device-specific ioctls */ { - struct socket so; - struct ifnet *ifp; - - bzero(&so, sizeof(so)); - NMG_LOCK(); - error = netmap_get_na(nmr, &na, 0 /* don't create */); /* keep reference */ - if (error) { - netmap_adapter_put(na); - NMG_UNLOCK(); - break; + struct ifnet *ifp = ifunit_ref(nmr->nr_name); + if (ifp == NULL) { + error = ENXIO; + } else { + struct socket so; + + bzero(&so, sizeof(so)); + so.so_vnet = ifp->if_vnet; + // so->so_proto not null. + error = ifioctl(&so, cmd, data, td); + if_rele(ifp); } - ifp = na->ifp; - so.so_vnet = ifp->if_vnet; - // so->so_proto not null. - error = ifioctl(&so, cmd, data, td); - netmap_adapter_put(na); - NMG_UNLOCK(); break; } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272110 - head/sys/dev/netmap
Author: luigi Date: Thu Sep 25 15:57:57 2014 New Revision: 272110 URL: http://svnweb.freebsd.org/changeset/base/272110 Log: adapt the code to different freebsd versions. Not necessary to MFC Modified: head/sys/dev/netmap/netmap_kern.h Modified: head/sys/dev/netmap/netmap_kern.h == --- head/sys/dev/netmap/netmap_kern.h Thu Sep 25 15:02:33 2014 (r272109) +++ head/sys/dev/netmap/netmap_kern.h Thu Sep 25 15:57:57 2014 (r272110) @@ -63,6 +63,12 @@ #define NM_ATOMIC_TEST_AND_SET(p) (!atomic_cmpset_acq_int((p), 0, 1)) #define NM_ATOMIC_CLEAR(p) atomic_store_rel_int((p), 0) +#if __FreeBSD_version >= 1100030 +#defineWNA(_ifp) (_ifp)->if_netmap +#else /* older FreeBSD */ +#defineWNA(_ifp) (_ifp)->if_pspare[0] +#endif /* older FreeBSD */ + #if __FreeBSD_version >= 115 struct netmap_adapter *netmap_getna(if_t ifp); #endif @@ -1186,9 +1192,6 @@ extern int netmap_generic_rings; * NA returns a pointer to the struct netmap adapter from the ifp, * WNA is used to write it. */ -#ifndef WNA -#defineWNA(_ifp) (_ifp)->if_netmap -#endif #defineNA(_ifp)((struct netmap_adapter *)WNA(_ifp)) /* ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272109 - in head/sys: dev/fdt dev/ofw mips/beri powerpc/ofw powerpc/pseries
Author: ian Date: Thu Sep 25 15:02:33 2014 New Revision: 272109 URL: http://svnweb.freebsd.org/changeset/base/272109 Log: Replace multiple nearly-identical copies of code to walk through an FDT node's interrupts=<...> property creating resource list entries with a single common implementation. This change makes ofw_bus_intr_to_rl() the one true copy of that code and removes the copies of it from other places. This also adds handling of the interrupts-extended property, which allows specifying multiple interrupts for a node where each interrupt can have a separate interrupt-parent. The bindings for this state that the property cells contain an xref phandle to the interrupt parent followed by whatever interrupt info that parent normally expects. This leads to having a variable number of icells per interrupt in the property. For example you could have <&intc1 1 &intc2 26 9 0 &intc3 9 4>. Differential Revision: https://reviews.freebsd.org/D803 Modified: head/sys/dev/fdt/fdt_common.c head/sys/dev/fdt/fdt_common.h head/sys/dev/fdt/simplebus.c head/sys/dev/ofw/ofw_bus_subr.c head/sys/dev/ofw/ofw_bus_subr.h head/sys/dev/ofw/ofwbus.c head/sys/mips/beri/beri_simplebus.c head/sys/powerpc/ofw/ofw_pcibus.c head/sys/powerpc/pseries/vdevice.c Modified: head/sys/dev/fdt/fdt_common.c == --- head/sys/dev/fdt/fdt_common.c Thu Sep 25 14:25:38 2014 (r272108) +++ head/sys/dev/fdt/fdt_common.c Thu Sep 25 15:02:33 2014 (r272109) @@ -494,46 +494,6 @@ out: } int -fdt_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl, -struct fdt_sense_level *intr_sl) -{ - phandle_t iparent; - uint32_t *intr, icells; - int nintr, i, k; - - nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr > 0) { - if (OF_searchencprop(node, "interrupt-parent", &iparent, - sizeof(iparent)) == -1) { - device_printf(dev, "No interrupt-parent found, " - "assuming direct parent\n"); - iparent = OF_parent(node); - } - if (OF_searchencprop(OF_node_from_xref(iparent), - "#interrupt-cells", &icells, sizeof(icells)) == -1) { - device_printf(dev, "Missing #interrupt-cells property, " - "assuming <1>\n"); - icells = 1; - } - if (icells < 1 || icells > nintr) { - device_printf(dev, "Invalid #interrupt-cells property " - "value <%d>, assuming <1>\n", icells); - icells = 1; - } - for (i = 0, k = 0; i < nintr; i += icells, k++) { - intr[i] = ofw_bus_map_intr(dev, iparent, icells, - &intr[i]); - resource_list_add(rl, SYS_RES_IRQ, k, intr[i], intr[i], - 1); - } - free(intr, M_OFWPROP); - } - - return (0); -} - -int fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc) { phandle_t phy_node; Modified: head/sys/dev/fdt/fdt_common.h == --- head/sys/dev/fdt/fdt_common.h Thu Sep 25 14:25:38 2014 (r272108) +++ head/sys/dev/fdt/fdt_common.h Thu Sep 25 15:02:33 2014 (r272109) @@ -88,7 +88,6 @@ int fdt_get_phyaddr(phandle_t, device_t, int fdt_get_range(phandle_t, int, u_long *, u_long *); int fdt_immr_addr(vm_offset_t); int fdt_regsize(phandle_t, u_long *, u_long *); -int fdt_intr_to_rl(device_t, phandle_t, struct resource_list *, struct fdt_sense_level *); int fdt_is_compatible(phandle_t, const char *); int fdt_is_compatible_strict(phandle_t, const char *); int fdt_is_enabled(phandle_t); Modified: head/sys/dev/fdt/simplebus.c == --- head/sys/dev/fdt/simplebus.cThu Sep 25 14:25:38 2014 (r272108) +++ head/sys/dev/fdt/simplebus.cThu Sep 25 15:02:33 2014 (r272109) @@ -247,11 +247,9 @@ simplebus_setup_dinfo(device_t dev, phan { struct simplebus_softc *sc; struct simplebus_devinfo *ndi; - uint32_t *reg, *intr, icells; + uint32_t *reg; uint64_t phys, size; - phandle_t iparent; int i, j, k; - int nintr; int nreg; sc = device_get_softc(dev); @@ -289,34 +287,7 @@ simplebus_setup_dinfo(device_t dev, phan } free(reg, M_OFWPROP); - nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr > 0) { - if (OF_searchencprop(node, "interrupt-parent", &iparent, -
svn commit: r272108 - head/sys/modules/netmap
Author: luigi Date: Thu Sep 25 14:25:38 2014 New Revision: 272108 URL: http://svnweb.freebsd.org/changeset/base/272108 Log: add missing file Submitted by: Daniel Peyrolon MFC after:3 days Modified: head/sys/modules/netmap/Makefile Modified: head/sys/modules/netmap/Makefile == --- head/sys/modules/netmap/MakefileThu Sep 25 14:22:32 2014 (r272107) +++ head/sys/modules/netmap/MakefileThu Sep 25 14:25:38 2014 (r272108) @@ -16,5 +16,6 @@ SRCS += netmap_vale.c SRCS += netmap_freebsd.c SRCS += netmap_offloadings.c SRCS += netmap_pipe.c +SRCS += netmap_monitor.c .include ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272107 - head/share/man/man4
Author: gavin Date: Thu Sep 25 14:22:32 2014 New Revision: 272107 URL: http://svnweb.freebsd.org/changeset/base/272107 Log: Cross reference cdce(4), ipheth(4) and urndis(4) from each other. MFC after:1 week Modified: head/share/man/man4/cdce.4 head/share/man/man4/urndis.4 Modified: head/share/man/man4/cdce.4 == --- head/share/man/man4/cdce.4 Thu Sep 25 14:18:34 2014(r272106) +++ head/share/man/man4/cdce.4 Thu Sep 25 14:22:32 2014(r272107) @@ -28,7 +28,7 @@ .\" $NetBSD: cdce.4,v 1.4 2004/12/08 18:35:56 peter Exp $ .\" $FreeBSD$ .\" -.Dd September 17, 2005 +.Dd September 25, 2014 .Dt CDCE 4 .Os .Sh NAME @@ -114,9 +114,10 @@ is running low on mbufs. .Sh SEE ALSO .Xr arp 4 , .Xr intro 4 , +.Xr ipheth 4 , .Xr netintro 4 , +.Xr urndis 4 , .Xr usb 4 , -.\" .Xr hostname.if 5 , .Xr ifconfig 8 .Rs .%T "Universal Serial Bus Class Definitions for Communication Devices" Modified: head/share/man/man4/urndis.4 == --- head/share/man/man4/urndis.4Thu Sep 25 14:18:34 2014 (r272106) +++ head/share/man/man4/urndis.4Thu Sep 25 14:22:32 2014 (r272107) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 21, 2014 +.Dd September 25, 2014 .Dt URNDIS 4 .Os .Sh NAME @@ -70,6 +70,8 @@ For more information on configuring this .Xr ifconfig 8 . .Sh SEE ALSO .Xr arp 4 , +.Xr cdce 4 , +.Xr ipheth 4 , .Xr netintro 4 , .Xr usb 4 , .Xr ifconfig 8 ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272106 - head/share/man/man4
Author: gavin Date: Thu Sep 25 14:18:34 2014 New Revision: 272106 URL: http://svnweb.freebsd.org/changeset/base/272106 Log: Add basic man page for ipheth(4). MFC after:1 week Added: head/share/man/man4/ipheth.4 (contents, props changed) Modified: head/share/man/man4/Makefile Modified: head/share/man/man4/Makefile == --- head/share/man/man4/MakefileThu Sep 25 13:31:08 2014 (r272105) +++ head/share/man/man4/MakefileThu Sep 25 14:18:34 2014 (r272106) @@ -200,6 +200,7 @@ MAN=aac.4 \ ip.4 \ ip6.4 \ ipfirewall.4 \ + ipheth.4 \ ${_ipmi.4} \ ips.4 \ ipsec.4 \ Added: head/share/man/man4/ipheth.4 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/ipheth.4Thu Sep 25 14:18:34 2014 (r272106) @@ -0,0 +1,93 @@ +.\" Copyright (c) 2014 Gavin Atkinson +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\"- Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\"- Redistributions in binary form must reproduce the above +.\" copyright notice, this list of conditions and the following +.\" disclaimer in the documentation and/or other materials provided +.\" with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd September 25, 2014 +.Dt IPHETH 4 +.Os +.Sh NAME +.Nm ipheth +.Nd "USB Apple iPhone/iPad Ethernet driver" +.Sh SYNOPSIS +To load the driver as a module at boot time, place the +following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_ipheth_load="YES" +.Ed +.Pp +Alternatively, to compile this driver into the kernel, place the +following lines in your kernel configuration file: +.Bd -ragged -offset indent +.Cd "device uhci" +.Cd "device ohci" +.Cd "device usb" +.Cd "device ipheth" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for network access through Apple +iPhone and iPad devices, often referred to as USB tethering. +.Pp +.Nm +should work with any Apple iPhone or iPad device. +In most cases this must be explicitly enabled on the device first. +.Pp +For more information on configuring this device, see +.Xr ifconfig 8 . +.Sh HARDWARE +The following devices are supported by the +.Nm +driver: +.Pp +.Bl -bullet -compact +.It +Apple iPhone (all models) +.It +Apple iPad (all models) +.El +.Sh SEE ALSO +.Xr arp 4 , +.Xr cdce 4 , +.Xr intro 4 , +.Xr netintro 4 , +.Xr urndis 4 , +.Xr usb 4 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 8.2 . +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An Hans Petter Selasky Aq Mt hsela...@freebsd.org . ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272105 - head/sys/boot/efi/include
Author: emaste Date: Thu Sep 25 13:31:08 2014 New Revision: 272105 URL: http://svnweb.freebsd.org/changeset/base/272105 Log: Remove duplicated header content I fail at patch(1). MFC after:3 days Modified: head/sys/boot/efi/include/eficonsctl.h Modified: head/sys/boot/efi/include/eficonsctl.h == --- head/sys/boot/efi/include/eficonsctl.h Thu Sep 25 13:08:31 2014 (r272104) +++ head/sys/boot/efi/include/eficonsctl.h Thu Sep 25 13:31:08 2014 (r272105) @@ -132,122 +132,3 @@ struct _EFI_CONSOLE_CONTROL_PROTOCOL { extern EFI_GUID gEfiConsoleControlProtocolGuid; #endif -/*- - * Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved. - * - * This program and the accompanying materials are licensed and made available - * under the terms and conditions of the BSD License which accompanies this - * distribution. The full text of the license may be found at - * http://opensource.org/licenses/bsd-license.php - * - * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR - * IMPLIED. - * - * Original Module Name: ConsoleControl.h - * Abstract: Abstraction of a Text mode or GOP/UGA screen - */ - -/* $FreeBSD */ - -#ifndef _EFI_CONS_CTL_H -#define _EFI_CONS_CTL_H - -#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \ - { 0xf42f7782, 0x12e, 0x4c12, {0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21} } - -typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL EFI_CONSOLE_CONTROL_PROTOCOL; - - -typedef enum { - EfiConsoleControlScreenText, - EfiConsoleControlScreenGraphics, - EfiConsoleControlScreenMaxValue -} EFI_CONSOLE_CONTROL_SCREEN_MODE; - - -typedef -EFI_STATUS -(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE) ( - IN EFI_CONSOLE_CONTROL_PROTOCOL *This, - OUT EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode, - OUT BOOLEAN *GopUgaExists, OPTIONAL - OUT BOOLEAN *StdInLockedOPTIONAL - ) -/*++ - - Routine Description: -Return the current video mode information. Also returns info about existence -of Graphics Output devices or UGA Draw devices in system, and if the Std In -device is locked. All the arguments are optional and only returned if a non -NULL pointer is passed in. - - Arguments: -This - Protocol instance pointer. -Mode - Are we in text of grahics mode. -GopUgaExists - TRUE if Console Spliter has found a GOP or UGA device -StdInLocked - TRUE if StdIn device is keyboard locked - - Returns: -EFI_SUCCESS - Mode information returned. - ---*/ -; - - -typedef -EFI_STATUS -(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) ( - IN EFI_CONSOLE_CONTROL_PROTOCOL *This, - IN EFI_CONSOLE_CONTROL_SCREEN_MODE Mode - ) -/*++ - - Routine Description: -Set the current mode to either text or graphics. Graphics is -for Quiet Boot. - - Arguments: -This - Protocol instance pointer. -Mode - Mode to set the - - Returns: -EFI_SUCCESS - Mode information returned. - ---*/ -; - - -typedef -EFI_STATUS -(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN) ( - IN EFI_CONSOLE_CONTROL_PROTOCOL *This, - IN CHAR16 *Password - ) -/*++ - - Routine Description: -Lock Std In devices until Password is typed. - - Arguments: -This - Protocol instance pointer. -Password - Password needed to unlock screen. NULL means unlock keyboard - - Returns: -EFI_SUCCESS - Mode information returned. -EFI_DEVICE_ERROR - Std In not locked - ---*/ -; - - - -struct _EFI_CONSOLE_CONTROL_PROTOCOL { - EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode; - EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode; - EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_INLockStdIn; -}; - -extern EFI_GUID gEfiConsoleControlProtocolGuid; - -#endif ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r272089 - head/sys/netpfil/ipfw
On Thu, 2014-09-25 at 09:18 +0400, Gleb Smirnoff wrote: > On Wed, Sep 24, 2014 at 07:40:23PM -0700, Adrian Chadd wrote: > A> Hm, I saw this from Kate on IRC. Did anyone figure out _where_ these > A> frames are coming from? > A> > A> Just dropping them is cool, but I'd really like to see the contents of > A> the frames and what their origin is. > A> > A> I'm worried that they're valid stack-generated frames.. > > I agree on this. Fixing NULL pointer derefs with NULL check is not > always a right thing to do. > > A> -a > A> > A> > A> On 24 September 2014 19:26, Sean Bruno wrote: > A> > Author: sbruno > A> > Date: Thu Sep 25 02:26:05 2014 > A> > New Revision: 272089 > A> > URL: http://svnweb.freebsd.org/changeset/base/272089 > A> > > A> > Log: > A> > Fix NULL pointer deref in ipfw when using dummynet at layer 2. > A> > Drop packet if pkg->ifp is NULL, which is the case here. > A> > > A> > ref. https://github.com/HardenedBSD/hardenedBSD > A> > commit 4eef3881c64f6e3aa38eebbeaf27a947a5d47dd7 > A> > > A> > PR 193861 -- DUMMYNET LAYER2: kernel panic > A> > > A> > in this case a kernel panic occurs. Hence, when we do not get an > interface, > A> > we just drop the packet in question. > A> > > A> > PR: 193681 > A> > Submitted by: David Carlier > A> > Obtained from:Hardened BSD > A> > MFC after:2 weeks > A> > Relnotes: yes > A> > > A> > Modified: > A> > head/sys/netpfil/ipfw/ip_dn_io.c > A> > > A> > Modified: head/sys/netpfil/ipfw/ip_dn_io.c > A> > > == > A> > --- head/sys/netpfil/ipfw/ip_dn_io.cWed Sep 24 22:58:10 2014 > (r272088) > A> > +++ head/sys/netpfil/ipfw/ip_dn_io.cThu Sep 25 02:26:05 2014 > (r272089) > A> > @@ -751,10 +751,15 @@ dummynet_send(struct mbuf *m) > A> > /* extract the dummynet info, rename the tag > A> > * to carry reinject info. > A> > */ > A> > - dst = pkt->dn_dir; > A> > - ifp = pkt->ifp; > A> > - tag->m_tag_cookie = MTAG_IPFW_RULE; > A> > - tag->m_tag_id = 0; > A> > + if (pkt->dn_dir == (DIR_OUT | PROTO_LAYER2) && > A> > + pkt->ifp == NULL) { > A> > + dst = DIR_DROP; > A> > + } else { > A> > + dst = pkt->dn_dir; > A> > + ifp = pkt->ifp; > A> > + tag->m_tag_cookie = MTAG_IPFW_RULE; > A> > + tag->m_tag_id = 0; > A> > + } > A> > } > A> > > A> > switch (dst) { > A> > > A> > Ok, moving off to freebsd-net. How should we proceded with debugging further? sean bcc src-all src-head ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272103 - in head/sys: arm/conf arm/s3c2xx0 arm/samsung/s3c2xx0 dev/usb/controller
Author: gavin Date: Thu Sep 25 11:38:26 2014 New Revision: 272103 URL: http://svnweb.freebsd.org/changeset/base/272103 Log: Move the ARM Samsung s3c2xx0 support files into the samsung directory, to match other platforms. Discussed with: andrew Added: head/sys/arm/samsung/s3c2xx0/ - copied from r272070, head/sys/arm/s3c2xx0/ Deleted: head/sys/arm/s3c2xx0/ Modified: head/sys/arm/conf/LN2410SBC head/sys/arm/conf/NOTES head/sys/arm/samsung/s3c2xx0/board_ln2410sbc.c head/sys/arm/samsung/s3c2xx0/files.s3c2xx0 head/sys/arm/samsung/s3c2xx0/s3c2410reg.h head/sys/arm/samsung/s3c2xx0/s3c2410var.h head/sys/arm/samsung/s3c2xx0/s3c2440reg.h head/sys/arm/samsung/s3c2xx0/s3c24x0.c head/sys/arm/samsung/s3c2xx0/s3c24x0_clk.c head/sys/arm/samsung/s3c2xx0/s3c24x0_machdep.c head/sys/arm/samsung/s3c2xx0/s3c24x0_rtc.c head/sys/arm/samsung/s3c2xx0/s3c24x0reg.h head/sys/arm/samsung/s3c2xx0/s3c24x0var.h head/sys/arm/samsung/s3c2xx0/std.ln2410sbc head/sys/arm/samsung/s3c2xx0/std.s3c2410 head/sys/arm/samsung/s3c2xx0/uart_bus_s3c2410.c head/sys/arm/samsung/s3c2xx0/uart_cpu_s3c2410.c head/sys/arm/samsung/s3c2xx0/uart_dev_s3c2410.c head/sys/dev/usb/controller/ohci_s3c24x0.c Modified: head/sys/arm/conf/LN2410SBC == --- head/sys/arm/conf/LN2410SBC Thu Sep 25 10:59:01 2014(r272102) +++ head/sys/arm/conf/LN2410SBC Thu Sep 25 11:38:26 2014(r272103) @@ -19,7 +19,7 @@ ident LN2410SBC -include"../s3c2xx0/std.ln2410sbc" +include"../samsung/s3c2xx0/std.ln2410sbc" #To statically compile in device wiring instead of /boot/device.hints #hints "GENERIC.hints" # Default places to look for devices. makeoptionsMODULES_OVERRIDE="" Modified: head/sys/arm/conf/NOTES == --- head/sys/arm/conf/NOTES Thu Sep 25 10:59:01 2014(r272102) +++ head/sys/arm/conf/NOTES Thu Sep 25 11:38:26 2014(r272103) @@ -19,7 +19,7 @@ files "../mv/discovery/files.db78xxx" files "../mv/kirkwood/files.kirkwood" files "../mv/orion/files.db88f5xxx" files "../mv/orion/files.ts7800" -files "../s3c2xx0/files.s3c2xx0" +files "../samsung/s3c2xx0/files.s3c2xx0" files "../xscale/i80321/files.ep80219" files "../xscale/i80321/files.i80219" files "../xscale/i80321/files.i80321" Modified: head/sys/arm/samsung/s3c2xx0/board_ln2410sbc.c == --- head/sys/arm/s3c2xx0/board_ln2410sbc.c Wed Sep 24 12:41:39 2014 (r272070) +++ head/sys/arm/samsung/s3c2xx0/board_ln2410sbc.c Thu Sep 25 11:38:26 2014(r272103) @@ -30,8 +30,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include extern vm_offset_t s3c2410_uart_vaddr; Modified: head/sys/arm/samsung/s3c2xx0/files.s3c2xx0 == --- head/sys/arm/s3c2xx0/files.s3c2xx0 Wed Sep 24 12:41:39 2014 (r272070) +++ head/sys/arm/samsung/s3c2xx0/files.s3c2xx0 Thu Sep 25 11:38:26 2014 (r272103) @@ -2,14 +2,14 @@ arm/arm/bus_space_asm_generic.Sstandard arm/arm/bus_space_generic.cstandard arm/arm/cpufunc_asm_arm9.S standard -arm/s3c2xx0/board_ln2410sbc.c optionalboard_ln2410sbc -arm/s3c2xx0/s3c24x0_rtc.c standard -arm/s3c2xx0/s3c24x0_machdep.c standard -arm/s3c2xx0/s3c24x0.c standard -arm/s3c2xx0/s3c2xx0_space.cstandard -arm/s3c2xx0/s3c24x0_clk.c standard -arm/s3c2xx0/uart_bus_s3c2410.c optionaluart -arm/s3c2xx0/uart_cpu_s3c2410.c optionaluart -arm/s3c2xx0/uart_dev_s3c2410.c optionaluart +arm/samsung/s3c2xx0/board_ln2410sbc.c optionalboard_ln2410sbc +arm/samsung/s3c2xx0/s3c24x0_rtc.c standard +arm/samsung/s3c2xx0/s3c24x0_machdep.c standard +arm/samsung/s3c2xx0/s3c24x0.c standard +arm/samsung/s3c2xx0/s3c2xx0_space.cstandard +arm/samsung/s3c2xx0/s3c24x0_clk.c standard +arm/samsung/s3c2xx0/uart_bus_s3c2410.c optionaluart +arm/samsung/s3c2xx0/uart_cpu_s3c2410.c optionaluart +arm/samsung/s3c2xx0/uart_dev_s3c2410.c optionaluart dev/usb/controller/ohci_s3c24x0.c optionalohci Modified: head/sys/arm/samsung/s3c2xx0/s3c2410reg.h == --- head/sys/arm/s3c2xx0/s3c2410reg.h Wed Sep 24 12:41:39 2014 (r272070) +++ head/sys/arm/samsung/s3c2xx0/s3c2410reg.h Thu Sep 25 11:38:26 2014 (r272103) @@ -42,7 +42,7 @@ #define_ARM_S3C2XX0_S3C2410REG_H_ /* common definitions for S3C2410 and S3C2440 */ -#include +#include /* * Memory Map Modified: head/sys/arm/samsung/s3c2xx0/s3c2410var.h == --- head/sys/arm/s3c2xx0/s3c2
svn commit: r272102 - head/lib/libnv
Author: pjd Date: Thu Sep 25 10:59:01 2014 New Revision: 272102 URL: http://svnweb.freebsd.org/changeset/base/272102 Log: Document the new nvlist_get_parent() function. Submitted by: Mariusz Zaborski Modified: head/lib/libnv/nv.3 Modified: head/lib/libnv/nv.3 == --- head/lib/libnv/nv.3 Thu Sep 25 09:12:11 2014(r272101) +++ head/lib/libnv/nv.3 Thu Sep 25 10:59:01 2014(r272102) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 21, 2014 +.Dd September 25, 2014 .Dt NV 3 .Os .Sh NAME @@ -150,6 +150,8 @@ .Fn nvlist_get_descriptor "const nvlist_t *nvl" "const char *name" .Ft "const void *" .Fn nvlist_get_binary "const nvlist_t *nvl" "const char *name" "size_t *sizep" +.Ft "const nvlist_t *" +.Fn nvlist_get_parent "const nvlist_t *nvl" .\" .Ft bool .Fn nvlist_take_bool "nvlist_t *nvl" "const char *name" @@ -437,6 +439,10 @@ extension, which allows to provide defau The nvlist must not be in error state. .Pp The +.Fn nvlist_get_parent +function allows to obtain the parent nvlist from the nested nvlist. +.Pp +The .Fn nvlist_take_bool , .Fn nvlist_take_number , .Fn nvlist_take_string , ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r272099 - head/sys/dev/vmware/vmxnet3
Author: glebius Date: Thu Sep 25 08:36:11 2014 New Revision: 272099 URL: http://svnweb.freebsd.org/changeset/base/272099 Log: Provide vmxnet3_get_counter() to return counters that are not collected, but taken from hardware. Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c == --- head/sys/dev/vmware/vmxnet3/if_vmx.cThu Sep 25 08:28:10 2014 (r272098) +++ head/sys/dev/vmware/vmxnet3/if_vmx.cThu Sep 25 08:36:11 2014 (r272099) @@ -187,6 +187,7 @@ static void vmxnet3_unregister_vlan(void static voidvmxnet3_set_rxfilter(struct vmxnet3_softc *); static int vmxnet3_change_mtu(struct vmxnet3_softc *, int); static int vmxnet3_ioctl(struct ifnet *, u_long, caddr_t); +static uint64_tvmxnet3_get_counter(struct ifnet *, ift_counter); #ifndef VMXNET3_LEGACY_TX static voidvmxnet3_qflush(struct ifnet *); @@ -194,10 +195,6 @@ static voidvmxnet3_qflush(struct ifnet static int vmxnet3_watchdog(struct vmxnet3_txqueue *); static voidvmxnet3_refresh_host_stats(struct vmxnet3_softc *); -static voidvmxnet3_txq_accum_stats(struct vmxnet3_txqueue *, - struct vmxnet3_txq_stats *); -static voidvmxnet3_rxq_accum_stats(struct vmxnet3_rxqueue *, - struct vmxnet3_rxq_stats *); static voidvmxnet3_tick(void *); static voidvmxnet3_link_status(struct vmxnet3_softc *); static voidvmxnet3_media_status(struct ifnet *, struct ifmediareq *); @@ -1722,6 +1719,7 @@ vmxnet3_setup_interface(struct vmxnet3_s ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_init = vmxnet3_init; ifp->if_ioctl = vmxnet3_ioctl; + ifp->if_get_counter = vmxnet3_get_counter; ifp->if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); ifp->if_hw_tsomaxsegcount = VMXNET3_TX_MAXSEGS; ifp->if_hw_tsomaxsegsize = VMXNET3_TX_MAXSEGSIZE; @@ -3344,56 +3342,14 @@ vmxnet3_refresh_host_stats(struct vmxnet vmxnet3_write_cmd(sc, VMXNET3_CMD_GET_STATS); } -static void -vmxnet3_txq_accum_stats(struct vmxnet3_txqueue *txq, -struct vmxnet3_txq_stats *accum) -{ - struct vmxnet3_txq_stats *st; - - st = &txq->vxtxq_stats; - - accum->vmtxs_opackets += st->vmtxs_opackets; - accum->vmtxs_obytes += st->vmtxs_obytes; - accum->vmtxs_omcasts += st->vmtxs_omcasts; - accum->vmtxs_csum += st->vmtxs_csum; - accum->vmtxs_tso += st->vmtxs_tso; - accum->vmtxs_full += st->vmtxs_full; - accum->vmtxs_offload_failed += st->vmtxs_offload_failed; -} - -static void -vmxnet3_rxq_accum_stats(struct vmxnet3_rxqueue *rxq, -struct vmxnet3_rxq_stats *accum) +static uint64_t +vmxnet3_get_counter(struct ifnet *ifp, ift_counter cnt) { - struct vmxnet3_rxq_stats *st; - - st = &rxq->vxrxq_stats; - - accum->vmrxs_ipackets += st->vmrxs_ipackets; - accum->vmrxs_ibytes += st->vmrxs_ibytes; - accum->vmrxs_iqdrops += st->vmrxs_iqdrops; - accum->vmrxs_ierrors += st->vmrxs_ierrors; -} - -static void -vmxnet3_accumulate_stats(struct vmxnet3_softc *sc) -{ - struct ifnet *ifp; - struct vmxnet3_statistics *st; - struct vmxnet3_txq_stats txaccum; - struct vmxnet3_rxq_stats rxaccum; - int i; - - ifp = sc->vmx_ifp; - st = &sc->vmx_stats; - - bzero(&txaccum, sizeof(struct vmxnet3_txq_stats)); - bzero(&rxaccum, sizeof(struct vmxnet3_rxq_stats)); + struct vmxnet3_softc *sc; + uint64_t rv; - for (i = 0; i < sc->vmx_ntxqueues; i++) - vmxnet3_txq_accum_stats(&sc->vmx_txq[i], &txaccum); - for (i = 0; i < sc->vmx_nrxqueues; i++) - vmxnet3_rxq_accum_stats(&sc->vmx_rxq[i], &rxaccum); + sc = if_getsoftc(ifp); + rv = 0; /* * With the exception of if_ierrors, these ifnet statistics are @@ -3401,14 +3357,36 @@ vmxnet3_accumulate_stats(struct vmxnet3_ * values. if_ierrors is updated in ether_input() for malformed * frames that we should have already discarded. */ - ifp->if_ipackets = rxaccum.vmrxs_ipackets; - ifp->if_iqdrops = rxaccum.vmrxs_iqdrops; - ifp->if_ierrors = rxaccum.vmrxs_ierrors; - ifp->if_opackets = txaccum.vmtxs_opackets; + switch (cnt) { + case IFCOUNTER_IPACKETS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_ipackets; + return (rv); + case IFCOUNTER_IQDROPS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_iqdrops; + return (rv); + case IFCOUNTER_IERRORS: + for (int i = 0; i < sc->vmx_nrxqueues; i++) + rv += sc->vmx_rxq[i].vxrxq_stats.vmrxs_ierrors; +
svn commit: r272098 - in head/sys: amd64/amd64 arm/arm ddb i386/i386 mips/mips pc98/pc98 powerpc/aim powerpc/booke sparc64/sparc64 x86/xen
Author: royger Date: Thu Sep 25 08:28:10 2014 New Revision: 272098 URL: http://svnweb.freebsd.org/changeset/base/272098 Log: ddb: allow specifying the exact address of the symtab and strtab When the FreeBSD kernel is loaded from Xen the symtab and strtab are not loaded the same way as the native boot loader. This patch adds three new global variables to ddb that can be used to specify the exact position and size of those tables, so they can be directly used as parameters to db_add_symbol_table. A new helper is introduced, so callers that used to set ksym_start and ksym_end can use this helper to set the new variables. It also adds support for loading them from the Xen PVH port, that was previously missing those tables. Sponsored by: Citrix Systems R&D Reviewed by: kib ddb/db_main.c: - Add three new global variables: ksymtab, kstrtab, ksymtab_size that can be used to specify the position and size of the symtab and strtab. - Use those new variables in db_init in order to call db_add_symbol_table. - Move the logic in db_init to db_fetch_symtab in order to set ksymtab, kstrtab, ksymtab_size from ksym_start and ksym_end. ddb/ddb.h: - Add prototype for db_fetch_ksymtab. - Declate the extern variables ksymtab, kstrtab and ksymtab_size. x86/xen/pv.c: - Add support for finding the symtab and strtab when booted as a Xen PVH guest. Since Xen loads the symtab and strtab as NetBSD expects to find them we have to adapt and use the same method. amd64/amd64/machdep.c: arm/arm/machdep.c: i386/i386/machdep.c: mips/mips/machdep.c: pc98/pc98/machdep.c: powerpc/aim/machdep.c: powerpc/booke/machdep.c: sparc64/sparc64/machdep.c: - Use the newly introduced db_fetch_ksymtab in order to set ksymtab, kstrtab and ksymtab_size. Modified: head/sys/amd64/amd64/machdep.c head/sys/arm/arm/machdep.c head/sys/ddb/db_main.c head/sys/ddb/ddb.h head/sys/i386/i386/machdep.c head/sys/mips/mips/machdep.c head/sys/pc98/pc98/machdep.c head/sys/powerpc/aim/machdep.c head/sys/powerpc/booke/machdep.c head/sys/sparc64/sparc64/machdep.c head/sys/x86/xen/pv.c Modified: head/sys/amd64/amd64/machdep.c == --- head/sys/amd64/amd64/machdep.c Thu Sep 25 07:37:41 2014 (r272097) +++ head/sys/amd64/amd64/machdep.c Thu Sep 25 08:28:10 2014 (r272098) @@ -184,9 +184,6 @@ struct init_ops init_ops = { * the physical address at which the kernel is loaded. */ extern char kernphys[]; -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif struct msgbuf *msgbufp; @@ -1823,6 +1820,10 @@ static caddr_t native_parse_preload_data(u_int64_t modulep) { caddr_t kmdp; +#ifdef DDB + vm_offset_t ksym_start; + vm_offset_t ksym_end; +#endif preload_metadata = (caddr_t)(uintptr_t)(modulep + KERNBASE); preload_bootstrap_relocate(KERNBASE); @@ -1834,6 +1835,7 @@ native_parse_preload_data(u_int64_t modu #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); + db_fetch_ksymtab(ksym_start, ksym_end); #endif return (kmdp); Modified: head/sys/arm/arm/machdep.c == --- head/sys/arm/arm/machdep.c Thu Sep 25 07:37:41 2014(r272097) +++ head/sys/arm/arm/machdep.c Thu Sep 25 08:28:10 2014(r272098) @@ -111,6 +111,10 @@ __FBSDID("$FreeBSD$"); #include #endif +#ifdef DDB +#include +#endif + #ifdef DEBUG #definedebugf(fmt, args...) printf(fmt, ##args) #else @@ -131,9 +135,6 @@ int _min_memcpy_size = 0; int _min_bzero_size = 0; extern int *end; -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif #ifdef FDT /* @@ -817,8 +818,7 @@ fake_preload_metadata(struct arm_boot_pa lastaddr = *(uint32_t *)(KERNVIRTADDR + 8); zend = lastaddr; zstart = *(uint32_t *)(KERNVIRTADDR + 4); - ksym_start = zstart; - ksym_end = zend; + db_fetch_ksymtab(zstart, zend); } else #endif lastaddr = (vm_offset_t)&end; @@ -912,6 +912,10 @@ freebsd_parse_boot_param(struct arm_boot vm_offset_t lastaddr = 0; void *mdp; void *kmdp; +#ifdef DDB + vm_offset_t ksym_start; + vm_offset_t ksym_end; +#endif /* * Mask metadata pointer: it is supposed to be on page boundary. If @@ -934,6 +938,7 @@ freebsd_parse_boot_param(struct arm_boot #ifdef DDB ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t); ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t); + db_fetch_ksymtab(ksym_start, ksym_end); #endif preload_addr_relocate = KERNVIRTADDR - abp->abp_physaddr; return lastaddr; Modified: head/sys/ddb/db_main.c
svn commit: r272096 - head/sys/dev/bce
Author: glebius Date: Thu Sep 25 07:22:24 2014 New Revision: 272096 URL: http://svnweb.freebsd.org/changeset/base/272096 Log: - Provide bce_get_counter() to return counters that are not collected, but taken from hardware. - Mechanically convert to if_inc_counter() the rest of counters. - While here fix 3 instances of the same bug, when error counter was ++ in one place and then assigned in other place, losing the increment. Achieve that storing soft errors counters in softc. Modified: head/sys/dev/bce/if_bce.c head/sys/dev/bce/if_bcereg.h Modified: head/sys/dev/bce/if_bce.c == --- head/sys/dev/bce/if_bce.c Thu Sep 25 07:00:31 2014(r272095) +++ head/sys/dev/bce/if_bce.c Thu Sep 25 07:22:24 2014(r272096) @@ -457,9 +457,10 @@ static struct mbuf *bce_tso_setup (struc struct mbuf **, u16 *); static int bce_tx_encap (struct bce_softc *, struct mbuf **); static void bce_start_locked (struct ifnet *); -static void bce_start (struct ifnet *); -static int bce_ioctl (struct ifnet *, u_long, caddr_t); -static void bce_watchdog (struct bce_softc *); +static void bce_start (struct ifnet *); +static int bce_ioctl (struct ifnet *, u_long, caddr_t); +static uint64_t bce_get_counter(struct ifnet *, ift_counter); +static void bce_watchdog (struct bce_softc *); static int bce_ifmedia_upd(struct ifnet *); static int bce_ifmedia_upd_locked (struct ifnet *); static void bce_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -1389,6 +1390,7 @@ bce_attach(device_t dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = bce_ioctl; ifp->if_start = bce_start; + ifp->if_get_counter = bce_get_counter; ifp->if_init= bce_init; ifp->if_mtu = ETHERMTU; @@ -6747,9 +6749,7 @@ bce_rx_intr(struct bce_softc *sc) L2_FHDR_ERRORS_TOO_SHORT | L2_FHDR_ERRORS_GIANT_FRAME)) { /* Log the error and release the mbuf. */ - ifp->if_ierrors++; sc->l2fhdr_error_count++; - m_freem(m0); m0 = NULL; goto bce_rx_intr_next_rx; @@ -6830,7 +6830,7 @@ bce_rx_intr(struct bce_softc *sc) } /* Increment received packet statistics. */ - ifp->if_ipackets++; + if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); bce_rx_intr_next_rx: sw_rx_cons = NEXT_RX_BD(sw_rx_cons); @@ -6988,7 +6988,7 @@ bce_tx_intr(struct bce_softc *sc) sc->tx_mbuf_ptr[sw_tx_chain_cons] = NULL; DBRUN(sc->debug_tx_mbuf_alloc--); - ifp->if_opackets++; + if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); } sc->used_tx_bd--; @@ -7901,7 +7901,7 @@ bce_watchdog(struct bce_softc *sc) sc->bce_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; bce_init_locked(sc); - sc->bce_ifp->if_oerrors++; + sc->watchdog_timeouts++; bce_watchdog_exit: REG_WR(sc, BCE_EMAC_RX_STATUS, status); @@ -8157,28 +8157,15 @@ bce_set_rx_mode(struct bce_softc *sc) static void bce_stats_update(struct bce_softc *sc) { - struct ifnet *ifp; struct statistics_block *stats; DBENTER(BCE_EXTREME_MISC); - ifp = sc->bce_ifp; - bus_dmamap_sync(sc->stats_tag, sc->stats_map, BUS_DMASYNC_POSTREAD); stats = (struct statistics_block *) sc->stats_block; /* -* Certain controllers don't report -* carrier sense errors correctly. -* See errata E11_5708CA0_1165. -*/ - if (!(BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5706) && - !(BCE_CHIP_ID(sc) == BCE_CHIP_ID_5708_A0)) - ifp->if_oerrors += - (u_long) stats->stat_Dot3StatsCarrierSenseErrors; - - /* * Update the sysctl statistics from the * hardware statistics. */ @@ -8359,35 +8346,51 @@ bce_stats_update(struct bce_softc *sc) sc->com_no_buffers = REG_RD_IND(sc, 0x120084); - /* -* Update the interface statistics from the -* hardware statistics. -*/ - ifp->if_collisions = - (u_long) sc->stat_EtherStatsCollisions; - - /* ToDo: This method loses soft errors. */ - ifp->if_ierrors = - (u_long) sc->stat_EtherStatsUndersizePkts + - (u_long) sc->stat_EtherStatsOversizePkts + - (u_long) sc->stat_IfInMBUFDiscards + - (u_long) sc->stat_Dot3StatsAlignmentErrors + - (u_long) sc->stat_Dot3StatsFCSErrors + - (u_long) sc->stat_IfInRuleChecker
svn commit: r272095 - head/sys/dev/lmc
Author: glebius Date: Thu Sep 25 07:00:31 2014 New Revision: 272095 URL: http://svnweb.freebsd.org/changeset/base/272095 Log: - Provide lmc_get_counter() to return counters that are not collected, but taken from hardware. - Mechanically convert to if_inc_counter() the rest of counters. Modified: head/sys/dev/lmc/if_lmc.c Modified: head/sys/dev/lmc/if_lmc.c == --- head/sys/dev/lmc/if_lmc.c Thu Sep 25 06:47:38 2014(r272094) +++ head/sys/dev/lmc/if_lmc.c Thu Sep 25 07:00:31 2014(r272095) @@ -2602,7 +2602,7 @@ rxintr_cleanup(softc_t *sc) /* Include CRC and one flag byte in input byte count. */ sc->status.cntrs.ibytes += first_mbuf->m_pkthdr.len + sc->config.crc_len +1; sc->status.cntrs.ipackets++; -sc->ifp->if_ipackets++; +if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1); LMC_BPF_MTAP(first_mbuf); #if defined(DEVICE_POLLING) sc->quota--; @@ -2765,7 +2765,7 @@ txintr_cleanup(softc_t *sc) /* Include CRC and one flag byte in output byte count. */ sc->status.cntrs.obytes += m->m_pkthdr.len + sc->config.crc_len +1; sc->status.cntrs.opackets++; - sc->ifp->if_opackets++; + if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1); LMC_BPF_MTAP(m); /* The only bad TX status is fifo underrun. */ if ((desc->status & TLP_DSTS_TX_UNDERRUN) != 0) @@ -3680,7 +3680,7 @@ lmc_raw_output(struct ifnet *ifp, struct { m_freem(m); sc->status.cntrs.odiscards++; -ifp->if_oqdrops++; +if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1); if (DRIVER_DEBUG) printf("%s: lmc_raw_output: IFQ_ENQUEUE() failed; error %d\n", NAME_UNIT, error); @@ -3692,11 +3692,10 @@ lmc_raw_output(struct ifnet *ifp, struct /* Called from a softirq once a second. */ static void lmc_watchdog(void *arg) - { +{ struct ifnet *ifp = arg; softc_t *sc = IFP2SC(ifp); u_int8_t old_oper_status = sc->status.oper_status; - struct event_cntrs *cntrs = &sc->status.cntrs; core_watchdog(sc); /* updates oper_status */ @@ -3762,16 +3761,7 @@ lmc_watchdog(void *arg) # endif } - /* Copy statistics from sc to ifp. */ ifp->if_baudrate = sc->status.tx_speed; - ifp->if_ipackets = cntrs->ipackets; - ifp->if_opackets = cntrs->opackets; - ifp->if_ibytes = cntrs->ibytes; - ifp->if_obytes = cntrs->obytes; - ifp->if_ierrors = cntrs->ierrors; - ifp->if_oerrors = cntrs->oerrors; - ifp->if_iqdrops = cntrs->idiscards; - if (sc->status.oper_status == STATUS_UP) ifp->if_link_state = LINK_STATE_UP; else @@ -3779,8 +3769,36 @@ lmc_watchdog(void *arg) /* Call this procedure again after one second. */ callout_reset(&sc->callout, hz, lmc_watchdog, ifp); - } +} +static uint64_t +lmc_get_counter(struct ifnet *ifp, ift_counter cnt) +{ + softc_t *sc; + struct event_cntrs *cntrs; + + sc = if_getsoftc(ifp); + cntrs = &sc->status.cntrs; + + switch (cnt) { + case IFCOUNTER_IPACKETS: + return (cntrs->ipackets); + case IFCOUNTER_OPACKETS: + return (cntrs->opackets); + case IFCOUNTER_IBYTES: + return (cntrs->ibytes); + case IFCOUNTER_OBYTES: + return (cntrs->obytes); + case IFCOUNTER_IERRORS: + return (cntrs->ierrors); + case IFCOUNTER_OERRORS: + return (cntrs->oerrors); + case IFCOUNTER_IQDROPS: + return (cntrs->idiscards); + default: + return (if_get_counter_default(ifp, cnt)); + } +} static void setup_ifnet(struct ifnet *ifp) @@ -3794,6 +3812,7 @@ setup_ifnet(struct ifnet *ifp) ifp->if_start= lmc_ifnet_start; /* sppp changes this */ ifp->if_output = lmc_raw_output; /* sppp & p2p change this */ ifp->if_input= lmc_raw_input; + ifp->if_get_counter = lmc_get_counter; ifp->if_mtu = MAX_DESC_LEN; /* sppp & p2p change this */ ifp->if_type = IFT_PTPSERIAL;/* p2p changes this */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"