From 690af69ec09298d4567fd1c682d3a8d9992a1c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sat, 14 May 2011 19:03:30 +0000 Subject: [PATCH 001/200] morse(6): fix typos and space-before-tabs --- games/morse/morse.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/games/morse/morse.c b/games/morse/morse.c index 6c8ff5ff9a79..f0abae3995df 100644 --- a/games/morse/morse.c +++ b/games/morse/morse.c @@ -161,20 +161,20 @@ static const struct morsetab iso8859_1tab[] = { static const struct morsetab iso8859_7tab[] = { /* - * The greek alphabet; you'll need an 8859-7 font in order + * The Greek alphabet; you'll need an ISO8859-7 font in order * to see the actual characters. * This table does not implement: * - the special sequences for the seven diphthongs, * - the punctuation differences. * Implementing these features would introduce too many * special-cases in the program's main loop. - * The diphtong sequences are: + * The diphthong sequences are: * alpha iota .-.- * alpha upsilon ..-- * epsilon upsilon ---. * eta upsilon ...- - * omikron iota ---.. - * omikron upsilon ..- + * omicron iota ---.. + * omicron upsilon ..- * upsilon iota .--- * The different punctuation symbols are: * ; ..-.- @@ -193,10 +193,10 @@ static const struct morsetab iso8859_7tab[] = { {'è', "-.-."}, /* theta */ {'é', ".."}, /* iota */ {'ß', ".."}, /* iota with acute */ - {'ú', ".."}, /* iota with diairesis */ - {'À', ".."}, /* iota with acute and diairesis */ + {'ú', ".."}, /* iota with diaeresis */ + {'À', ".."}, /* iota with acute and diaeresis */ {'ê', "-.-"}, /* kappa */ - {'ë', ".-.."}, /* lamda */ + {'ë', ".-.."}, /* lambda */ {'ì', "--"}, /* mu */ {'í', "-."}, /* nu */ {'î', "-..-"}, /* xi */ @@ -209,8 +209,8 @@ static const struct morsetab iso8859_7tab[] = { {'ô', "-"}, /* tau */ {'õ', "-.--"}, /* upsilon */ {'ý', "-.--"}, /* upsilon with acute */ - {'û', "-.--"}, /* upsilon and diairesis */ - {'à', "-.--"}, /* upsilon with acute and diairesis */ + {'û', "-.--"}, /* upsilon and diaeresis */ + {'à', "-.--"}, /* upsilon with acute and diaeresis */ {'ö', "..-."}, /* phi */ {'÷', "----"}, /* chi */ {'ø', "--.-"}, /* psi */ @@ -222,29 +222,29 @@ static const struct morsetab iso8859_7tab[] = { static const struct morsetab koi8rtab[] = { /* - * the cyrillic alphabet; you'll need a KOI8R font in order + * The Cyrillic alphabet; you'll need a KOI8-R font in order * to see the actual characters */ - {'Á', ".-"}, /* a */ + {'Á', ".-"}, /* a */ {'Â', "-..."}, /* be */ {'×', ".--"}, /* ve */ {'Ç', "--."}, /* ge */ {'Ä', "-.."}, /* de */ - {'Å', "."}, /* ye */ - {'£', "."}, /* yo, the same as ye */ + {'Å', "."}, /* ye */ + {'£', "."}, /* yo, the same as ye */ {'Ö', "...-"}, /* she */ {'Ú', "--.."}, /* ze */ - {'É', ".."}, /* i */ + {'É', ".."}, /* i */ {'Ê', ".---"}, /* i kratkoye */ {'Ë', "-.-"}, /* ka */ {'Ì', ".-.."}, /* el */ - {'Í', "--"}, /* em */ - {'Î', "-."}, /* en */ + {'Í', "--"}, /* em */ + {'Î', "-."}, /* en */ {'Ï', "---"}, /* o */ {'Ð', ".--."}, /* pe */ {'Ò', ".-."}, /* er */ {'Ó', "..."}, /* es */ - {'Ô', "-"}, /* te */ + {'Ô', "-"}, /* te */ {'Õ', "..-"}, /* u */ {'Æ', "..-."}, /* ef */ {'È', "...."}, /* kha */ @@ -305,9 +305,9 @@ main(int argc, char **argv) while ((ch = getopt(argc, argv, GETOPTOPTS)) != -1) switch ((char) ch) { - case 'c': - cpm = atoi(optarg); - break; + case 'c': + cpm = atoi(optarg); + break; case 'd': device = optarg; break; From ad85c5040d8835f5d0c088d17be06ae7686af7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sat, 14 May 2011 19:03:45 +0000 Subject: [PATCH 002/200] fortune(6): fix typos and misspellings. While here, drop words in the spelling files that are no longer used anywhere. Speling errors found via: codespell from Lucas De Marchi --- games/fortune/datfiles/fortunes | 10 ++--- games/fortune/datfiles/fortunes-o.real | 4 +- games/fortune/datfiles/fortunes-o.sp.ok | 2 - games/fortune/datfiles/fortunes.sp.ok | 51 ----------------------- games/fortune/datfiles/freebsd-tips.sp.ok | 1 - games/fortune/datfiles/limerick | 4 +- games/fortune/datfiles/limerick.sp.ok | 3 +- games/fortune/datfiles/startrek.sp.ok | 1 - games/fortune/datfiles/zippy.sp.ok | 2 +- 9 files changed, 11 insertions(+), 67 deletions(-) diff --git a/games/fortune/datfiles/fortunes b/games/fortune/datfiles/fortunes index 3f0ef02a73a7..7f2a7d45cc4a 100644 --- a/games/fortune/datfiles/fortunes +++ b/games/fortune/datfiles/fortunes @@ -10494,13 +10494,13 @@ Anti-trust laws should be approached with exactly that attitude. Antonio Antonio Was tired of living alonio He thought he would woo Antonio Antonio -Miss Lucamy Lu, Rode of on his polo ponio +Miss Lucamy Lu, Rode off on his polo ponio Miss Lucamy Lucy Molonio. And found the maid In a bowery shade, Sitting and knitting alonio. Antonio Antonio Said if you will be my ownio -I'll love tou true Oh nonio Antonio +I'll love you true Oh nonio Antonio And buy for you You're far too bleak and bonio An icery creamry conio. And all that I wish You singular fish @@ -10509,7 +10509,7 @@ Antonio Antonio Uttered a dismal moanio And went off and hid Or I'm told that he did -In the Antartical Zonio. +In the Antarctical Zonio. % Antonym, n.: The opposite of the word you're trying to think of. @@ -20232,7 +20232,7 @@ Good-bye. I am leaving because I am bored. Goodbye, cool world. % Goose pimples rose all over me, my hair stood on end, my eyes filled with -tears of love and gratitude for this greatest of all conquerers of human +tears of love and gratitude for this greatest of all conquerors of human misery and shame, and my breath came in little gasps. If I had not known that the Leader would have scorned such adulation, I might have fallen to my knees in unashamed worship, but instead I drew myself to attention, raised @@ -25099,7 +25099,7 @@ intellectual enlightenment % IBM: - [Internation Business Machines Corp.] Also known as Itty Bitty + [International Business Machines Corp.] Also known as Itty Bitty Machines or The Lawyer's Friend. The dominant force in computer marketing, having supplied worldwide some 75% of all known hardware and 10% of all software. To protect itself from the litigious envy diff --git a/games/fortune/datfiles/fortunes-o.real b/games/fortune/datfiles/fortunes-o.real index 3e477928d865..3733ef9885f1 100644 --- a/games/fortune/datfiles/fortunes-o.real +++ b/games/fortune/datfiles/fortunes-o.real @@ -7722,7 +7722,7 @@ I wooed a stewed nude in Bermuda, I was lewd, but my God! she was lewder. She said it was crude To be wooed in the nude-- -I persued her, subdued her, and screwed her! +I pursued her, subdued her, and screwed her! % I would like to say, Mister Bunce, I'm a great connoisseur of hot cunts. @@ -9044,7 +9044,7 @@ raped, his house burned, and all his cattle rustled. When he told his distant neighbors about the tragedy, a few of them reported that the only stranger they had seen in the area for weeks was a tall desperado wearing a black hat and a red neckerchief. - The cowboy saddled his fastest horse and set out to find the villian. + The cowboy saddled his fastest horse and set out to find the villain. He searched for months but couldn't catch up with the culprit; in town after dusty town he was told that a man fitting the description had been there but had just departed; usually after some heinous crime. diff --git a/games/fortune/datfiles/fortunes-o.sp.ok b/games/fortune/datfiles/fortunes-o.sp.ok index 75cff751f68a..e7734c6ebe60 100644 --- a/games/fortune/datfiles/fortunes-o.sp.ok +++ b/games/fortune/datfiles/fortunes-o.sp.ok @@ -1121,7 +1121,6 @@ pees penis pere Perelman -persued pestes Peteer Pettigrew @@ -1600,7 +1599,6 @@ vibrators vici Vida vidi -villian virginem Visme viziti diff --git a/games/fortune/datfiles/fortunes.sp.ok b/games/fortune/datfiles/fortunes.sp.ok index 2ba73ec389af..02229cd5a791 100644 --- a/games/fortune/datfiles/fortunes.sp.ok +++ b/games/fortune/datfiles/fortunes.sp.ok @@ -139,7 +139,6 @@ Anouilh ANRS Ansley answerback -Antartic Anthony's Antonym Antrim @@ -375,7 +374,6 @@ Bertolt Besicovitch Beslove Betazoid -bethumped Bette Bevan BEW @@ -468,7 +466,6 @@ booing bookaholic Booker's boola -Boorchi Boorstin bootable Boothe @@ -576,7 +573,6 @@ Bulwer bumperless Bumstead Bungei -BURBULATION Buren Burggoven burgled @@ -623,7 +619,6 @@ Callahan Callahan's Callimachus Camden -Camelia Cameron Camillo Campbell @@ -771,7 +766,6 @@ Churchill's Churchy Chuzzlewit CI -Cianci Ciardi cinched cinema's @@ -806,7 +800,6 @@ Cochran cockamamie Cocteau Cody -Cody's Coevolution cogito Cohen's @@ -826,7 +819,6 @@ Comebacks Commedia Commie CommUNIXque -compuberty computatis Computerdom computerites @@ -1077,8 +1069,6 @@ DJ DMPK Dobb's Dobbs -doberman -doberperson Dobie Doc Docquier @@ -1203,7 +1193,6 @@ EINS Einstein's Eisley Elbert -ELBONICS Eldridge electrocommunications Electrocution @@ -1264,7 +1253,6 @@ Eschenbach Escher esperantisto Esplandian -Esser est estas Estes @@ -1293,7 +1281,6 @@ exhalation exhibitionists EXP expatriated -extemporanea extracurricular Exupery Exxon's @@ -1301,7 +1288,6 @@ eyestalks Eyquem Ezrin FAA -FACISM Factorials Fadiman Fafhrd @@ -1340,7 +1326,6 @@ Fellgett's Felton feminism's Femme -FENDERBERG Fenelon Fenster Ferber @@ -1369,7 +1354,6 @@ fikcio fiks filees filename -Filgoer's filigrees Filkharmonics Fillmore @@ -1398,7 +1382,6 @@ flamewars Flandry Flannagan's Flannery -FLANNISTER Flappity flatfoot flatteries @@ -1410,7 +1393,6 @@ Flon's floppity Florio floss -flouride Flugg's Flummery flutterby @@ -1557,7 +1539,6 @@ Geminis Genderplex Genesereth Genghis -genlock genocide Genter Geritol @@ -1605,7 +1586,6 @@ Giuseppe Glanvill Glaser gleekzorp -GLEEMITES Glegg gleknow Glib's @@ -2013,7 +1993,6 @@ if's ifthen Igmmlptk Ignatowski -ignisecond ihuxw IIc III's @@ -2498,7 +2477,6 @@ Lovin Lowells Lowery's Lowes -Lownes LP LPA LSD @@ -2534,7 +2512,6 @@ Ma's Mabbitt Mabley Macaroons -MacBeth Maccius MacDowell MacDuff @@ -2621,7 +2598,6 @@ Matz's Maud Maud'Dib Maugham -Maughm Maupin Maureens Maurois @@ -2630,7 +2606,6 @@ Maxey Maxson May's Mayorga -Mårten MBAs MBH MC @@ -2687,7 +2662,6 @@ Mendelson mendicants Mengot Menninger -Mensa Menschen Meow meowing @@ -2715,7 +2689,6 @@ Mickos microchips Microcomputing micrometric -Microsystem's Microsystems MicroVAXes midgets @@ -2730,7 +2703,6 @@ milk's Milkbone Millay Milligan -millihelen Millikan Millikan's millions @@ -2763,7 +2735,6 @@ Mitford Mitgong mittengrabben mitts -mittsquinter MITZIE Mix's Miyamoto @@ -2779,7 +2750,6 @@ modifaiing Modula Moebius Mohandas -Mohandis mohmen Moishe Molander @@ -2803,7 +2773,6 @@ Moolah moonshiner's Moore's mopeds -mophobia Moping moralists Mordecai @@ -2832,7 +2801,6 @@ Mt MTA Muad'dib muckest -mucklucks Mudgeeraba Mudhead mudslide @@ -2888,7 +2856,6 @@ nanohenry nanometers Nansen Napoleon's -narcolepulacyi Narnia Nasium's Naso @@ -2909,7 +2876,6 @@ Neantical Nebuchadnezzar Nebuchadnezzar's necesas -necessitious NecroSoft Nehru Neil's @@ -2940,7 +2906,6 @@ NF NFL Ngdanga Niagra -Niccoli Nicklaus Nicol Nicolaides @@ -3165,7 +3130,6 @@ Pearsall PECCATOPHOBIA Pecor's Pedaeration -pediddel Peers's Pegler pelted @@ -3192,7 +3156,6 @@ Personifiers Petaluma Petersons Petr -petribar Petronius Pfeiffer Pfffttt @@ -3204,7 +3167,6 @@ Philips philogyny phoney Phooey -phosflink Picadilly Pickard Pickle's @@ -3246,7 +3208,6 @@ Pocataligo Pocatello Podunk Pohl's -Poincair Poincare's pointy Polanski @@ -3347,7 +3308,6 @@ Pumpernickel punchline punning PUPs -PURPITATION Purshottam PUSHes pushy @@ -3551,7 +3511,6 @@ Saberhagen Sacher's Sadat Saddam -sadoequinecrophilia Saens Safford Safire's @@ -3605,7 +3564,6 @@ Schickele Schieffer schisms schizophrenics -schlattwhapper schlichte schluerfen Schmendrick @@ -3631,7 +3589,6 @@ Scintillae Scott's Scoville SCRBL -SCRIBLINE Scrubb scullery scurries @@ -3784,7 +3741,6 @@ somebody'd something's Sondheim Sooooo -Soren Sorhed sort've sorta @@ -3799,7 +3755,6 @@ SP Spacemen Spaceport spacewar -SPAGMUMPS spake Spam spank @@ -3824,7 +3779,6 @@ springenwerk Springsteen sprites SPSW -SQUATCHO squaws squealers squrooneg @@ -3980,7 +3934,6 @@ teepers telematic telepath teleportation -TELEPRESSION telepsychology tempfile tendrils @@ -4028,7 +3981,6 @@ tinpot Tirith tis Tiselius -Titas tites TLC TM @@ -4060,7 +4012,6 @@ toun Tourbillon Toven trans -transcendant transmogrifiers trapezes Traub @@ -4121,7 +4072,6 @@ TYDFS tyg typefaces Tyroon -tzu Ubi UDA Udall's @@ -4152,7 +4102,6 @@ Unseld untechnician unvoist Updike -upharsen uponst Urey Urho diff --git a/games/fortune/datfiles/freebsd-tips.sp.ok b/games/fortune/datfiles/freebsd-tips.sp.ok index b543ea0bdee9..968f318400dc 100644 --- a/games/fortune/datfiles/freebsd-tips.sp.ok +++ b/games/fortune/datfiles/freebsd-tips.sp.ok @@ -45,7 +45,6 @@ misc natserv ncal netcat -netscape netstat newfile NICs diff --git a/games/fortune/datfiles/limerick b/games/fortune/datfiles/limerick index a0344a8a6fc1..5a92c786ac7a 100644 --- a/games/fortune/datfiles/limerick +++ b/games/fortune/datfiles/limerick @@ -260,7 +260,7 @@ And white footgear intended for tennis. % A dulcet-voiced callgirl named Shedd, Who's cultured, well-spoken, well-bred, - Had achieved some reknown + Had achieved some renown For her tone going down-- There's a nice civil tongue in her head. % @@ -307,7 +307,7 @@ Had sex with a virgin named Grace. By bleeding all over his face. % A gay young prince from Morocco -Made love in a manner rococco. +Made love in a manner rococo. He painted his penis To resemble a Venus And flavored his semen with cocoa. diff --git a/games/fortune/datfiles/limerick.sp.ok b/games/fortune/datfiles/limerick.sp.ok index 00f1b42f2d85..be7135d57027 100644 --- a/games/fortune/datfiles/limerick.sp.ok +++ b/games/fortune/datfiles/limerick.sp.ok @@ -283,6 +283,7 @@ McTavish meanie meanies meany +Mensa mentis midgets minimis @@ -353,11 +354,9 @@ quimmy quints ravished Reims -reknown Resounded retriebrve Rhyll -rococco rogered Salinas Sandem diff --git a/games/fortune/datfiles/startrek.sp.ok b/games/fortune/datfiles/startrek.sp.ok index 5d1180e0230b..ccca7090d602 100644 --- a/games/fortune/datfiles/startrek.sp.ok +++ b/games/fortune/datfiles/startrek.sp.ok @@ -14,7 +14,6 @@ Corbomite Corby Daystrom Deela -Dehaver Elaan Eleen Eneg diff --git a/games/fortune/datfiles/zippy.sp.ok b/games/fortune/datfiles/zippy.sp.ok index 4214fca564c6..b2f3fff9a251 100644 --- a/games/fortune/datfiles/zippy.sp.ok +++ b/games/fortune/datfiles/zippy.sp.ok @@ -180,7 +180,7 @@ manicurist matic meatball meltdown -naugahide +naugahyde obstetrician poindexter pre From 1372d81a400af4dca32fa292ab83869eb7f205ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sat, 14 May 2011 19:03:54 +0000 Subject: [PATCH 003/200] Convert a file to UTF-8. This only changes a character in the copyright section and will not require UTF-8 for fortune(6). --- games/fortune/datfiles/gerrold.limerick | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games/fortune/datfiles/gerrold.limerick b/games/fortune/datfiles/gerrold.limerick index 8c6d0549251d..f0bbce637cb2 100644 --- a/games/fortune/datfiles/gerrold.limerick +++ b/games/fortune/datfiles/gerrold.limerick @@ -3,7 +3,7 @@ %% Copyright David Gerrold, 1984-2000, all rights reserved, %% used with permission of the author. %% -%%© This is the copyright line. +%%© This is the copyright line. %%Eighty-nine is the year we assign. %% These verses are caroled %% by one David Gerrold. From af49c942206177a6a9e4158ed28cce5ff83a900e Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Sat, 14 May 2011 19:27:15 +0000 Subject: [PATCH 004/200] sysctl that displays the absolute queue id of an rxq. --- sys/dev/cxgbe/t4_sge.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 54405287e36b..5f59db63343f 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -141,6 +141,7 @@ static int handle_sge_egr_update(struct adapter *, const struct cpl_sge_egr_update *); static int ctrl_tx(struct adapter *, struct sge_ctrlq *, struct mbuf *); +static int sysctl_abs_id(SYSCTL_HANDLER_ARGS); extern void filter_rpl(struct adapter *, const struct cpl_set_tcb_rpl *); @@ -1363,6 +1364,9 @@ alloc_rxq(struct port_info *pi, struct sge_rxq *rxq, int intr_idx, int idx) NULL, "rx queue"); children = SYSCTL_CHILDREN(oid); + SYSCTL_ADD_PROC(&pi->ctx, children, OID_AUTO, "abs_id", + CTLTYPE_INT | CTLFLAG_RD, &rxq->iq.abs_id, 0, sysctl_abs_id, "I", + "absolute id of the queue"); #ifdef INET SYSCTL_ADD_INT(&pi->ctx, children, OID_AUTO, "lro_queued", CTLFLAG_RD, &rxq->lro.lro_queued, 0, NULL); @@ -2733,3 +2737,12 @@ ctrl_tx(struct adapter *sc, struct sge_ctrlq *ctrlq, struct mbuf *m0) return (rc); } + +static int +sysctl_abs_id(SYSCTL_HANDLER_ARGS) +{ + uint16_t *id = arg1; + int i = *id; + + return sysctl_handle_int(oidp, &i, 0, req); +} From 087a4650e2f4affdf81f1a74c1d5a171283b925e Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sat, 14 May 2011 20:31:04 +0000 Subject: [PATCH 005/200] - There's no need for nibbletab to be static, it's const however. - Fix whitespace. --- sys/dev/mii/mii.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/mii/mii.c b/sys/dev/mii/mii.c index fbdd0eac6892..224f85df085e 100644 --- a/sys/dev/mii/mii.c +++ b/sys/dev/mii/mii.c @@ -552,7 +552,7 @@ mii_down(struct mii_data *mii) static unsigned char mii_bitreverse(unsigned char x) { - static unsigned char nibbletab[16] = { + unsigned const char const nibbletab[16] = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; @@ -567,6 +567,6 @@ mii_oui(u_int id1, u_int id2) h = (id1 << 6) | (id2 >> 10); return ((mii_bitreverse(h >> 16) << 16) | - (mii_bitreverse((h >> 8) & 0xff) << 8) | - mii_bitreverse(h & 0xff)); + (mii_bitreverse((h >> 8) & 0xff) << 8) | + mii_bitreverse(h & 0xff)); } From 2f7e4c22b91c0e660d4a1911c4367388f7d63016 Mon Sep 17 00:00:00 2001 From: Stanislav Sedov Date: Sat, 14 May 2011 22:15:38 +0000 Subject: [PATCH 006/200] - Add symbol versioning to libprocstat. Suggested by: kib --- lib/libprocstat/Makefile | 3 +++ lib/libprocstat/Symbol.map | 16 ++++++++++++++++ lib/libprocstat/Versions.def | 5 +++++ 3 files changed, 24 insertions(+) create mode 100644 lib/libprocstat/Symbol.map create mode 100644 lib/libprocstat/Versions.def diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile index e289ef51dbbe..e5091694e86c 100644 --- a/lib/libprocstat/Makefile +++ b/lib/libprocstat/Makefile @@ -12,6 +12,9 @@ SRCS= cd9660.c \ smbfs.c \ udf.c +VERSION_DEF= ${.CURDIR}/Versions.def +SYMBOL_MAPS= ${.CURDIR}/Symbol.map + INCS= libprocstat.h CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE SHLIB_MAJOR= 1 diff --git a/lib/libprocstat/Symbol.map b/lib/libprocstat/Symbol.map new file mode 100644 index 000000000000..b5d64d0ff78e --- /dev/null +++ b/lib/libprocstat/Symbol.map @@ -0,0 +1,16 @@ +/* + * $FreeBSD$ + */ +FBSD_1.2 { + procstat_close; + procstat_freefiles; + procstat_freeprocs; + procstat_get_pipe_info; + procstat_get_pts_info; + procstat_get_socket_info; + procstat_get_vnode_info; + procstat_getfiles; + procstat_getprocs; + procstat_open_kvm; + procstat_open_sysctl; +}; diff --git a/lib/libprocstat/Versions.def b/lib/libprocstat/Versions.def new file mode 100644 index 000000000000..d69f5c996f75 --- /dev/null +++ b/lib/libprocstat/Versions.def @@ -0,0 +1,5 @@ +# $FreeBSD$ + +# This version was first added to 9.0-current. +FBSD_1.2 { +}; From 72266aa3ba4dc5a8c57a9136fbd02371b927b9b2 Mon Sep 17 00:00:00 2001 From: Stanislav Sedov Date: Sun, 15 May 2011 00:46:25 +0000 Subject: [PATCH 007/200] - Whitespace fix. --- lib/libprocstat/libprocstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 95b00d32bf75..8440bec2cbc6 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -253,7 +253,7 @@ procstat_getfiles(struct procstat *procstat, struct kinfo_proc *kp, int mmapped) if (procstat->type == PROCSTAT_SYSCTL) return (procstat_getfiles_sysctl(procstat, kp, mmapped)); else if (procstat->type == PROCSTAT_KVM) - return (procstat_getfiles_kvm(procstat, kp, mmapped)); + return (procstat_getfiles_kvm(procstat, kp, mmapped)); else return (NULL); } From 7480c2a5212f0e5a0b6fd635a1ff01aa8103e4e8 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 15 May 2011 01:01:53 +0000 Subject: [PATCH 008/200] Fix few typos. Submitted by: uqs MFC after: 1 week --- share/man/man4/hpet.4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/man/man4/hpet.4 b/share/man/man4/hpet.4 index f787895cc5d9..f501e0be3f82 100644 --- a/share/man/man4/hpet.4 +++ b/share/man/man4/hpet.4 @@ -69,14 +69,14 @@ This driver uses High Precision Event Timer hardware (part of the chipset, usually enumerated via ACPI) to supply kernel with one time counter and several (usually from 3 to 8) event timers. This hardware includes single main counter with known increment frequency -(10MHz or more), and several programable comparators (optionally with +(10MHz or more), and several programmable comparators (optionally with automatic reload feature). When value of the main counter matches current value of any comparator, interrupt can be generated. Depending on hardware capabilities and configuration, interrupt can be delivered as regular I/O APIC interrupt (ISA or PCI) in range from 0 to 31, or as Front Side Bus interrupt, alike to PCI MSI interrupts, or in so called -"LegacyReplacement Route" HPET can speal IRQ0 of i8254 and IRQ8 of the RTC. +"LegacyReplacement Route" HPET can steal IRQ0 of i8254 and IRQ8 of the RTC. Interrupt can be either edge- or level-triggered. In last case they could be safely shared with PCI IRQs. Driver prefers to use FSB interrupts, if supported, to avoid sharing. From 0148401a3fd90e4fdbe8b5fe096fed17fd1b64ce Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 15 May 2011 07:59:33 +0000 Subject: [PATCH 009/200] Fix NF calibration breakage introduced by me in a past commit. Since the returned NF will be -ve, checking for <= 0 is not good enough. For now, check whether it equals 0 or -1; a future commit will tidy this mess up and have it return HAL_BOOL instead. --- sys/dev/ath/ath_hal/ar5416/ar5416_cal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c index d8609bb899a0..ee61c3013cd3 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c @@ -501,7 +501,7 @@ ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan, * and update the history buffer. */ r = ar5416GetNf(ah, chan); - if (r <= 0) { + if (r == 0 || r == -1) { /* NF calibration result isn't valid */ HALDEBUG(ah, HAL_DEBUG_UNMASKABLE, "%s: NF calibration" " didn't finish; delaying CCA\n", __func__); From 4f6760821e10c3fb55d5a059f576e370641c70a1 Mon Sep 17 00:00:00 2001 From: Bernhard Schmidt Date: Sun, 15 May 2011 08:09:36 +0000 Subject: [PATCH 010/200] Only update the scheduler's byte count table for aggregation queues. The other queues, especially the command queue, uses the FIFO mode which doesn't require the byte count table because queued entries are processed in order. Pointed out by: Lucius Windschuh --- sys/dev/iwn/if_iwn.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 11c5238bd19a..29e391f3548c 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -3527,7 +3527,8 @@ iwn_tx_data(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) BUS_DMASYNC_PREWRITE); /* Update TX scheduler. */ - ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen); + if (ring->qid >= sc->firstaggqueue) + ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen); /* Kick TX ring. */ ring->cur = (ring->cur + 1) % IWN_TX_RING_COUNT; @@ -3730,7 +3731,8 @@ iwn_tx_data_raw(struct iwn_softc *sc, struct mbuf *m, BUS_DMASYNC_PREWRITE); /* Update TX scheduler. */ - ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen); + if (ring->qid >= sc->firstaggqueue) + ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen); /* Kick TX ring. */ ring->cur = (ring->cur + 1) % IWN_TX_RING_COUNT; @@ -3894,7 +3896,6 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) static int iwn_cmd(struct iwn_softc *sc, int code, const void *buf, int size, int async) { - struct iwn_ops *ops = &sc->ops; struct iwn_tx_ring *ring = &sc->txq[4]; struct iwn_tx_desc *desc; struct iwn_tx_data *data; @@ -3954,9 +3955,6 @@ iwn_cmd(struct iwn_softc *sc, int code, const void *buf, int size, int async) bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, BUS_DMASYNC_PREWRITE); - /* Update TX scheduler. */ - ops->update_sched(sc, ring->qid, ring->cur, 0, 0); - /* Kick command ring. */ ring->cur = (ring->cur + 1) % IWN_TX_RING_COUNT; IWN_WRITE(sc, IWN_HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur); From cb86ada75ddbf6d7ca887a42bcc1d33b9da4328d Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Sun, 15 May 2011 11:45:13 +0000 Subject: [PATCH 011/200] Simplify the code a bit. For own providers GEOM_PART always provides "start" and "end" config attributes. MFC after: 1 week --- sbin/geom/class/part/geom_part.c | 75 ++++++-------------------------- 1 file changed, 14 insertions(+), 61 deletions(-) diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index ed7b8f830cc7..81d02914f9d1 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -253,13 +253,7 @@ find_provider(struct ggeom *gp, off_t minsector) bestsector = 0; LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { s = find_provcfg(pp, "start"); - if (s == NULL) { - s = find_provcfg(pp, "offset"); - sector = - (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; - } else - sector = (off_t)strtoimax(s, NULL, 0); - + sector = (off_t)strtoimax(s, NULL, 0); if (sector < minsector) continue; if (bestpp != NULL && sector >= bestsector) @@ -379,18 +373,9 @@ gpart_autofill_resize(struct gctl_req *req) errx(EXIT_FAILURE, "invalid partition index"); s = find_provcfg(pp, "start"); - if (s == NULL) { - s = find_provcfg(pp, "offset"); - start = (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; - } else - start = (off_t)strtoimax(s, NULL, 0); + start = (off_t)strtoimax(s, NULL, 0); s = find_provcfg(pp, "end"); - if (s == NULL) { - s = find_provcfg(pp, "length"); - lba = start + - (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; - } else - lba = (off_t)strtoimax(s, NULL, 0) + 1; + lba = (off_t)strtoimax(s, NULL, 0) + 1; if (lba > last) { geom_deletetree(&mesh); @@ -402,12 +387,7 @@ gpart_autofill_resize(struct gctl_req *req) new_size = ALIGNDOWN(last - start + 1, alignment); else { s = find_provcfg(pp, "start"); - if (s == NULL) { - s = find_provcfg(pp, "offset"); - new_lba = - (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; - } else - new_lba = (off_t)strtoimax(s, NULL, 0); + new_lba = (off_t)strtoimax(s, NULL, 0); /* * Is there any free space between current and * next providers? @@ -512,12 +492,7 @@ gpart_autofill(struct gctl_req *req) last = ALIGNDOWN(last, alignment); while ((pp = find_provider(gp, first)) != NULL) { s = find_provcfg(pp, "start"); - if (s == NULL) { - s = find_provcfg(pp, "offset"); - lba = (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; - } else - lba = (off_t)strtoimax(s, NULL, 0); - + lba = (off_t)strtoimax(s, NULL, 0); a_lba = ALIGNDOWN(lba, alignment); if (first < a_lba && a_first < a_lba) { /* Free space [first, lba> */ @@ -543,12 +518,7 @@ gpart_autofill(struct gctl_req *req) } s = find_provcfg(pp, "end"); - if (s == NULL) { - s = find_provcfg(pp, "length"); - first = lba + - (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; - } else - first = (off_t)strtoimax(s, NULL, 0) + 1; + first = (off_t)strtoimax(s, NULL, 0) + 1; a_first = ALIGNUP(first, alignment); } if (a_first <= last) { @@ -625,21 +595,12 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers) while ((pp = find_provider(gp, first)) != NULL) { s = find_provcfg(pp, "start"); - if (s == NULL) { - s = find_provcfg(pp, "offset"); - sector = (off_t)strtoimax(s, NULL, 0) / secsz; - } else - sector = (off_t)strtoimax(s, NULL, 0); + sector = (off_t)strtoimax(s, NULL, 0); s = find_provcfg(pp, "end"); - if (s == NULL) { - s = find_provcfg(pp, "length"); - length = (off_t)strtoimax(s, NULL, 0) / secsz; - end = sector + length - 1; - } else { - end = (off_t)strtoimax(s, NULL, 0); - length = end - sector + 1; - } + end = (off_t)strtoimax(s, NULL, 0); + length = end - sector + 1; + s = find_provcfg(pp, "index"); idx = atoi(s); if (first < sector) { @@ -782,20 +743,12 @@ gpart_backup(struct gctl_req *req, unsigned int fl __unused) printf("%s %s\n", scheme, s); LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { s = find_provcfg(pp, "start"); - if (s == NULL) { - s = find_provcfg(pp, "offset"); - sector = (off_t)strtoimax(s, NULL, 0) / secsz; - } else - sector = (off_t)strtoimax(s, NULL, 0); + sector = (off_t)strtoimax(s, NULL, 0); s = find_provcfg(pp, "end"); - if (s == NULL) { - s = find_provcfg(pp, "length"); - length = (off_t)strtoimax(s, NULL, 0) / secsz; - } else { - end = (off_t)strtoimax(s, NULL, 0); - length = end - sector + 1; - } + end = (off_t)strtoimax(s, NULL, 0); + length = end - sector + 1; + s = find_provcfg(pp, "label"); printf("%-*s %*s %*jd %*jd %s %s\n", windex, find_provcfg(pp, "index"), From 76cc7f6dd6701da0163e11d3cbd0a37209584731 Mon Sep 17 00:00:00 2001 From: Mikolaj Golub Date: Sun, 15 May 2011 12:39:30 +0000 Subject: [PATCH 012/200] Fix a memory leak possible in g_eli_key_allocate() if the key with the same keyno is added while we aren't holding the lock. Approved by: pjd (mentor) MFC after: 1 week --- sys/geom/eli/g_eli_key_cache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/geom/eli/g_eli_key_cache.c b/sys/geom/eli/g_eli_key_cache.c index 0a5a9ca6e8d3..de4989b72f6c 100644 --- a/sys/geom/eli/g_eli_key_cache.c +++ b/sys/geom/eli/g_eli_key_cache.c @@ -124,6 +124,7 @@ g_eli_key_allocate(struct g_eli_softc *sc, uint64_t keyno) ekey = RB_FIND(g_eli_key_tree, &sc->sc_ekeys_tree, &keysearch); if (ekey != NULL) { bzero(key, sizeof(*key)); + free(key, M_ELI); key = ekey; TAILQ_REMOVE(&sc->sc_ekeys_queue, key, gek_next); } else { From 6f135a7584d9cba78aab7bd3b810d5f29e39b53d Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sun, 15 May 2011 12:51:00 +0000 Subject: [PATCH 013/200] When setting media always and not just in case of switching to IFM_AUTO clear the options of the current media, i.e. only inherit the instance, which matches what NetBSD does. Without this it's really non-intuitive that the following sequence: ifconfig bge0 media 1000baseT mediaopt full-duplex ifconfig bge0 media 100baseTX results in 100baseTX full-duplex to be set or that: ifconfig bge0 media autoselect mediaopt flowcontrol ifconfig bge0 media 1000baseT mediaopt full-duplex tries to set 1000baseT full-duplex with flowcontrol, which isn't suported und thus fails while the following: ifconfig re0 media 1000baseT mediaopt flowcontrol,full-duplex ifconfig re0 media autoselect just switches to autoselection without flowcontrol. MFC after: 2 weeks --- sbin/ifconfig/ifmedia.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c index 0fd2f2b3dee2..0b0daa3086a1 100644 --- a/sbin/ifconfig/ifmedia.c +++ b/sbin/ifconfig/ifmedia.c @@ -268,13 +268,9 @@ setmedia(const char *val, int d, int s, const struct afswtch *afp) subtype = get_media_subtype(IFM_TYPE(ifmr->ifm_ulist[0]), val); strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - ifr.ifr_media = (ifmr->ifm_current & ~(IFM_NMASK|IFM_TMASK)) | + ifr.ifr_media = (ifmr->ifm_current & IFM_IMASK) | IFM_TYPE(ifmr->ifm_ulist[0]) | subtype; - if ((ifr.ifr_media & IFM_TMASK) == 0) { - ifr.ifr_media &= ~(IFM_GMASK | IFM_OMASK); - } - ifmr->ifm_current = ifr.ifr_media; callback_register(setifmediacallback, (void *)ifmr); } From d09c5f16b069577f843236706c04017264977743 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sun, 15 May 2011 12:58:29 +0000 Subject: [PATCH 014/200] - Add 10baseT as an alias for 10baseT/UTP. - Add shorthand aliases for common media+option combinations as announced by miibus(4) so that one can actually supply the media strings found in the dmesg output to ifconfig(8). Obtained from: NetBSD (in principle) MFC after: 2 weeks --- sys/net/if_media.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sys/net/if_media.h b/sys/net/if_media.h index 1eb26ea3efae..b6fd316633c9 100644 --- a/sys/net/if_media.h +++ b/sys/net/if_media.h @@ -370,6 +370,7 @@ struct ifmedia_description { } #define IFM_SUBTYPE_ETHERNET_ALIASES { \ + { IFM_10_T, "10baseT" }, \ { IFM_10_T, "UTP" }, \ { IFM_10_T, "10UTP" }, \ { IFM_10_2, "BNC" }, \ @@ -389,6 +390,23 @@ struct ifmedia_description { { IFM_1000_T, "1000TX" }, \ { IFM_1000_T, "1000T" }, \ { IFM_2500_SX, "2500SX" }, \ + \ + /* \ + * Shorthands for common media+option combinations as announced \ + * by miibus(4) \ + */ \ + { IFM_10_T | IFM_FDX, "10baseT-FDX" }, \ + { IFM_10_T | IFM_FDX | IFM_FLOW, "10baseT-FDX-flow" }, \ + { IFM_100_TX | IFM_FDX, "100baseTX-FDX" }, \ + { IFM_100_TX | IFM_FDX | IFM_FLOW, "100baseTX-FDX-flow" }, \ + { IFM_1000_T | IFM_FDX, "1000baseT-FDX" }, \ + { IFM_1000_T | IFM_FDX | IFM_FLOW, "1000baseT-FDX-flow" }, \ + { IFM_1000_T | IFM_FDX | IFM_FLOW | IFM_ETH_MASTER, \ + "1000baseT-FDX-flow-master" }, \ + { IFM_1000_T | IFM_FDX | IFM_ETH_MASTER, \ + "1000baseT-FDX-master" }, \ + { IFM_1000_T | IFM_ETH_MASTER, "1000baseT-master" }, \ + \ { 0, NULL }, \ } @@ -584,6 +602,13 @@ struct ifmedia_description { #define IFM_SUBTYPE_SHARED_ALIASES { \ { IFM_AUTO, "auto" }, \ + \ + /* \ + * Shorthands for common media+option combinations as announced \ + * by miibus(4) \ + */ \ + { IFM_AUTO | IFM_FLOW, "auto-flow" }, \ + \ { 0, NULL }, \ } From c6d7d6c03e75b12ee4627ceda938402a8bb9cc8f Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sun, 15 May 2011 13:17:08 +0000 Subject: [PATCH 015/200] Add support for MK48T37. --- sys/dev/mk48txx/mk48txx.c | 4 +++- sys/dev/mk48txx/mk48txxreg.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/dev/mk48txx/mk48txx.c b/sys/dev/mk48txx/mk48txx.c index 9742e82748c8..de116d0d0c33 100644 --- a/sys/dev/mk48txx/mk48txx.c +++ b/sys/dev/mk48txx/mk48txx.c @@ -33,7 +33,8 @@ __FBSDID("$FreeBSD$"); /* - * Mostek MK48T02, MK48T08, MK48T18, MK48T59 time-of-day chip subroutines + * Mostek MK48T02, MK48T08, MK48T18, MK48T37 and MK48T59 time-of-day chip + * subroutines */ #include @@ -67,6 +68,7 @@ static const struct { { "mk48t02", MK48T02_CLKSZ, MK48T02_CLKOFF, 0 }, { "mk48t08", MK48T08_CLKSZ, MK48T08_CLKOFF, 0 }, { "mk48t18", MK48T18_CLKSZ, MK48T18_CLKOFF, 0 }, + { "mk48t37", MK48T37_CLKSZ, MK48T37_CLKOFF, MK48TXX_EXT_REGISTERS }, { "mk48t59", MK48T59_CLKSZ, MK48T59_CLKOFF, MK48TXX_EXT_REGISTERS }, }; diff --git a/sys/dev/mk48txx/mk48txxreg.h b/sys/dev/mk48txx/mk48txxreg.h index bae6ae5f51b8..ef55b87229b9 100644 --- a/sys/dev/mk48txx/mk48txxreg.h +++ b/sys/dev/mk48txx/mk48txxreg.h @@ -152,5 +152,8 @@ #define MK48T18_CLKSZ 8192 #define MK48T18_CLKOFF 0x1ff0 +#define MK48T37_CLKSZ 32768 +#define MK48T37_CLKOFF 0x1ff0 + #define MK48T59_CLKSZ 8192 #define MK48T59_CLKOFF 0x1ff0 From 3bb1fd1bc4128a7c813385485ebb9736292e0b54 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sun, 15 May 2011 13:25:26 +0000 Subject: [PATCH 016/200] Recognize the eeprom device found in Fujitsu PRIMEPOWER650 and 900. --- sys/sparc64/sparc64/eeprom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/sparc64/sparc64/eeprom.c b/sys/sparc64/sparc64/eeprom.c index da9909a5d30c..e90aecb9f99e 100644 --- a/sys/sparc64/sparc64/eeprom.c +++ b/sys/sparc64/sparc64/eeprom.c @@ -107,8 +107,11 @@ DRIVER_MODULE(eeprom, sbus, eeprom_driver, eeprom_devclass, 0, 0); static int eeprom_probe(device_t dev) { + const char *name; - if (strcmp("eeprom", ofw_bus_get_name(dev)) == 0) { + name = ofw_bus_get_name(dev); + if (strcmp(name, "eeprom") == 0 || + strcmp(name, "FJSV,eeprom") == 0) { device_set_desc(dev, "EEPROM/clock"); return (0); } From c71dacd16819b980c0b740e5cecc5e9f6331c080 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sun, 15 May 2011 13:27:38 +0000 Subject: [PATCH 017/200] Recognize the SAB 82532 found in Fujitsu PRIMEPOWER650 and 900. --- sys/dev/scc/scc_bfe_ebus.c | 3 ++- sys/dev/uart/uart_cpu_sparc64.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/dev/scc/scc_bfe_ebus.c b/sys/dev/scc/scc_bfe_ebus.c index 17386db3751c..6c944f7341ef 100644 --- a/sys/dev/scc/scc_bfe_ebus.c +++ b/sys/dev/scc/scc_bfe_ebus.c @@ -56,7 +56,8 @@ scc_ebus_probe(device_t dev) cmpt = ofw_bus_get_compat(dev); if (cmpt == NULL) cmpt = ""; - if (!strcmp(nm, "se") || !strcmp(cmpt, "sab82532")) { + if (!strcmp(nm, "se") || !strcmp(nm, "FJSV,se") || + !strcmp(cmpt, "sab82532")) { device_set_desc(dev, "Siemens SAB 82532 dual channel SCC"); sc->sc_class = &scc_sab82532_class; return (scc_bfe_probe(dev, EBUS_REGSHFT, EBUS_RCLK, 0)); diff --git a/sys/dev/uart/uart_cpu_sparc64.c b/sys/dev/uart/uart_cpu_sparc64.c index c89b39fcc9eb..582e919c9955 100644 --- a/sys/dev/uart/uart_cpu_sparc64.c +++ b/sys/dev/uart/uart_cpu_sparc64.c @@ -238,7 +238,8 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di) di->bas.regshft = 0; di->bas.rclk = 0; class = NULL; - if (!strcmp(buf, "se") || !strcmp(compat, "sab82532")) { + if (!strcmp(buf, "se") || !strcmp(buf, "FJSV,se") || + !strcmp(compat, "sab82532")) { class = &uart_sab82532_class; /* SAB82532 are only known to be used for TTYs. */ if ((di->bas.chan = uart_cpu_channel(dev)) == 0) From 149d1c897ec65a35ce3742bca80f5ca49dd3123f Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 15 May 2011 14:01:23 +0000 Subject: [PATCH 018/200] Add I2C bus driver for the AMD Geode LX series CS5536 Companion Device. Reviewed by: jhb (newbus bits only), adrian --- share/man/man4/man4.i386/Makefile | 1 + share/man/man4/man4.i386/glxiic.4 | 106 +++ sys/conf/files.i386 | 1 + sys/dev/glxiic/glxiic.c | 1077 +++++++++++++++++++++++++++++ sys/i386/conf/NOTES | 6 + sys/modules/Makefile | 2 + sys/modules/glxiic/Makefile | 10 + 7 files changed, 1203 insertions(+) create mode 100644 share/man/man4/man4.i386/glxiic.4 create mode 100644 sys/dev/glxiic/glxiic.c create mode 100644 sys/modules/glxiic/Makefile diff --git a/share/man/man4/man4.i386/Makefile b/share/man/man4/man4.i386/Makefile index 0134d5783889..974eec02df73 100644 --- a/share/man/man4/man4.i386/Makefile +++ b/share/man/man4/man4.i386/Makefile @@ -12,6 +12,7 @@ MAN= aic.4 \ ep.4 \ ex.4 \ fe.4 \ + glxiic.4 \ glxsb.4 \ ie.4 \ longrun.4 \ diff --git a/share/man/man4/man4.i386/glxiic.4 b/share/man/man4/man4.i386/glxiic.4 new file mode 100644 index 000000000000..30d3ffe98de8 --- /dev/null +++ b/share/man/man4/man4.i386/glxiic.4 @@ -0,0 +1,106 @@ +.\" Copyright (c) 2011 Henrik Brix Andersen +.\" All rights reserved. +.\" +.\" 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. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 May 15, 2011 +.Dt GLXIIC 4 i386 +.Os +.Sh NAME +.Nm glxiic +.Nd Geode LX CS5536 I2C controller driver +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device pci" +.Cd "device isa" +.Cd "device glxiic" +.Cd "device iicbus" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +glxiic_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver supports the System Management Bus controller of the Geode LX +series CS5536 Companion Device. The Geode LX is a member of the AMD +Geode family of integrated x86 system chips. +.Pp +Although AMD refers to this device as a System Management Bus (SMBus) +controller, it is really an I2C controller (it lacks SMBus ALERT# and +Alert Response support). +.Pp +The +.Nm +driver supports both I2C master and slave mode. +.Sh SYSCTL VARIABLE +The +.Nm +driver supports the following variable as both +.Xr sysctl 8 +and +.Xr loader 8 +tunable: +.Bl -tag -width indent +.It Va dev.glxiic.0.timeout +This variable controls the I2C bus timeout in milliseconds. The +default timeout is 35 milliseconds. A value of zero disables the +timeout. +.El +.Sh CAVEAT +The +.Nm +driver uses the interrupt line number configured by the board firmware +by default. If no interrupt line number has been configured by the +board firmware (or to override the interrupt line number configured by +board firmware), place the following line in +.Xr device.hints 5 : +.Bd -ragged -offset indent +hint.glxiic.0.irq="10" +.Ed +.Pp +The interrupt line number must be between 1 and 15. +.Sh SEE ALSO +.Xr iicbus 4 , +.Xr device.hints 5 , +.Xr loader.conf 5 , +.Xr loader 8 , +.Xr sysctl 8 +.Sh HISTORY +The +.Nm +device driver and manual page first appeared in +.Fx 9.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +device driver and manual page were written by +.An Henrik Brix Andersen Aq brix@FreeBSD.org . diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index f518bc98c167..4f0d0d0ffdff 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -171,6 +171,7 @@ dev/fdc/fdc_acpi.c optional fdc dev/fdc/fdc_isa.c optional fdc isa dev/fdc/fdc_pccard.c optional fdc pccard dev/fe/if_fe_isa.c optional fe isa +dev/glxiic/glxiic.c optional glxiic dev/glxsb/glxsb.c optional glxsb dev/glxsb/glxsb_hash.c optional glxsb dev/hptmv/entry.c optional hptmv diff --git a/sys/dev/glxiic/glxiic.c b/sys/dev/glxiic/glxiic.c new file mode 100644 index 000000000000..204095166192 --- /dev/null +++ b/sys/dev/glxiic/glxiic.c @@ -0,0 +1,1077 @@ +/*- + * Copyright (c) 2011 Henrik Brix Andersen + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#include +__FBSDID("$FreeBSD$"); +/* + * AMD Geode LX CS5536 System Management Bus controller. + * + * Although AMD refers to this device as an SMBus controller, it + * really is an I2C controller (It lacks SMBus ALERT# and Alert + * Response support). + * + * The driver is implemented as an interrupt-driven state machine, + * supporting both master and slave mode. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef GLXIIC_DEBUG +#include +#endif + +#include +#include + +#include +#include +#include + +#include +#include + +#include "iicbus_if.h" + +/* CS5536 PCI-ISA ID. */ +#define GLXIIC_CS5536_DEV_ID 0x20901022 + +/* MSRs. */ +#define GLXIIC_MSR_PIC_YSEL_HIGH 0x51400021 + +/* Bus speeds. */ +#define GLXIIC_SLOW 0x0258 /* 10 kHz. */ +#define GLXIIC_FAST 0x0078 /* 50 kHz. */ +#define GLXIIC_FASTEST 0x003c /* 100 kHz. */ + +/* Default bus activity timeout in milliseconds. */ +#define GLXIIC_DEFAULT_TIMEOUT 35 + +/* GPIO register offsets. */ +#define GLXIIC_GPIOL_OUT_AUX1_SEL 0x10 +#define GLXIIC_GPIOL_IN_AUX1_SEL 0x34 + +/* GPIO 14 (SMB_CLK) and 15 (SMB_DATA) bitmasks. */ +#define GLXIIC_GPIO_14_15_ENABLE 0x0000c000 +#define GLXIIC_GPIO_14_15_DISABLE 0xc0000000 + +/* SMB register offsets. */ +#define GLXIIC_SMB_SDA 0x00 +#define GLXIIC_SMB_STS 0x01 +#define GLXIIC_SMB_STS_SLVSTP_BIT (1 << 7) +#define GLXIIC_SMB_STS_SDAST_BIT (1 << 6) +#define GLXIIC_SMB_STS_BER_BIT (1 << 5) +#define GLXIIC_SMB_STS_NEGACK_BIT (1 << 4) +#define GLXIIC_SMB_STS_STASTR_BIT (1 << 3) +#define GLXIIC_SMB_STS_NMATCH_BIT (1 << 2) +#define GLXIIC_SMB_STS_MASTER_BIT (1 << 1) +#define GLXIIC_SMB_STS_XMIT_BIT (1 << 0) +#define GLXIIC_SMB_CTRL_STS 0x02 +#define GLXIIC_SMB_CTRL_STS_TGSCL_BIT (1 << 5) +#define GLXIIC_SMB_CTRL_STS_TSDA_BIT (1 << 4) +#define GLXIIC_SMB_CTRL_STS_GCMTCH_BIT (1 << 3) +#define GLXIIC_SMB_CTRL_STS_MATCH_BIT (1 << 2) +#define GLXIIC_SMB_CTRL_STS_BB_BIT (1 << 1) +#define GLXIIC_SMB_CTRL_STS_BUSY_BIT (1 << 0) +#define GLXIIC_SMB_CTRL1 0x03 +#define GLXIIC_SMB_CTRL1_STASTRE_BIT (1 << 7) +#define GLXIIC_SMB_CTRL1_NMINTE_BIT (1 << 6) +#define GLXIIC_SMB_CTRL1_GCMEN_BIT (1 << 5) +#define GLXIIC_SMB_CTRL1_ACK_BIT (1 << 4) +#define GLXIIC_SMB_CTRL1_INTEN_BIT (1 << 2) +#define GLXIIC_SMB_CTRL1_STOP_BIT (1 << 1) +#define GLXIIC_SMB_CTRL1_START_BIT (1 << 0) +#define GLXIIC_SMB_ADDR 0x04 +#define GLXIIC_SMB_ADDR_SAEN_BIT (1 << 7) +#define GLXIIC_SMB_CTRL2 0x05 +#define GLXIIC_SMB_CTRL2_EN_BIT (1 << 0) +#define GLXIIC_SMB_CTRL3 0x06 + +typedef enum { + GLXIIC_STATE_IDLE, + GLXIIC_STATE_SLAVE_TX, + GLXIIC_STATE_SLAVE_RX, + GLXIIC_STATE_MASTER_ADDR, + GLXIIC_STATE_MASTER_TX, + GLXIIC_STATE_MASTER_RX, + GLXIIC_STATE_MASTER_STOP, + GLXIIC_STATE_MAX, +} glxiic_state_t; + +struct glxiic_softc { + device_t dev; /* Myself. */ + device_t iicbus; /* IIC bus. */ + struct mtx mtx; /* Lock. */ + glxiic_state_t state; /* Driver state. */ + struct callout callout; /* Driver state timeout callout. */ + int timeout; /* Driver state timeout (ms). */ + + int smb_rid; /* SMB controller resource ID. */ + struct resource *smb_res; /* SMB controller resource. */ + int gpio_rid; /* GPIO resource ID. */ + struct resource *gpio_res; /* GPIO resource. */ + + int irq_rid; /* IRQ resource ID. */ + struct resource *irq_res; /* IRQ resource. */ + void *irq_handler; /* IRQ handler cookie. */ + int old_irq; /* IRQ mapped by board firmware. */ + + struct iic_msg *msg; /* Current master mode message. */ + uint32_t nmsgs; /* Number of messages remaining. */ + uint8_t *data; /* Current master mode data byte. */ + uint16_t ndata; /* Number of data bytes remaining. */ + int error; /* Last master mode error. */ + + uint8_t addr; /* Own address. */ + uint16_t sclfrq; /* Bus frequency. */ +}; + +#ifdef GLXIIC_DEBUG +#define DEBUG(fmt, args...) log(LOG_DEBUG, "%s: " fmt "\n" , __func__ , ## args) +#else +#define DEBUG(fmt, args...) +#endif + +#define GLXIIC_SCLFRQ(n) ((n << 1)) +#define GLXIIC_SMBADDR(n) ((n >> 1)) +#define GLXIIC_SMB_IRQ_TO_MAP(n) ((n << 16)) +#define GLXIIC_MAP_TO_SMB_IRQ(n) ((n >> 16) & 0xf) + +#define GLXIIC_LOCK(_sc) mtx_lock(&_sc->mtx) +#define GLXIIC_UNLOCK(_sc) mtx_unlock(&_sc->mtx) +#define GLXIIC_LOCK_INIT(_sc) \ + mtx_init(&_sc->mtx, device_get_nameunit(_sc->dev), "glxiic", MTX_DEF) +#define GLXIIC_SLEEP(_sc) \ + mtx_sleep(_sc, &_sc->mtx, IICPRI, "glxiic", 0) +#define GLXIIC_WAKEUP(_sc) wakeup(_sc); +#define GLXIIC_LOCK_DESTROY(_sc) mtx_destroy(&_sc->mtx); +#define GLXIIC_ASSERT_LOCKED(_sc) mtx_assert(&_sc->mtx, MA_OWNED); + +typedef int (glxiic_state_callback_t)(struct glxiic_softc *sc, + uint8_t status); + +static glxiic_state_callback_t glxiic_state_idle_callback; +static glxiic_state_callback_t glxiic_state_slave_tx_callback; +static glxiic_state_callback_t glxiic_state_slave_rx_callback; +static glxiic_state_callback_t glxiic_state_master_addr_callback; +static glxiic_state_callback_t glxiic_state_master_tx_callback; +static glxiic_state_callback_t glxiic_state_master_rx_callback; +static glxiic_state_callback_t glxiic_state_master_stop_callback; + +struct glxiic_state_table_entry { + glxiic_state_callback_t *callback; + boolean_t master; +}; +typedef struct glxiic_state_table_entry glxiic_state_table_entry_t; + +static glxiic_state_table_entry_t glxiic_state_table[GLXIIC_STATE_MAX] = { + [GLXIIC_STATE_IDLE] = { + .callback = &glxiic_state_idle_callback, + .master = FALSE, + }, + + [GLXIIC_STATE_SLAVE_TX] = { + .callback = &glxiic_state_slave_tx_callback, + .master = FALSE, + }, + + [GLXIIC_STATE_SLAVE_RX] = { + .callback = &glxiic_state_slave_rx_callback, + .master = FALSE, + }, + + [GLXIIC_STATE_MASTER_ADDR] = { + .callback = &glxiic_state_master_addr_callback, + .master = TRUE, + }, + + [GLXIIC_STATE_MASTER_TX] = { + .callback = &glxiic_state_master_tx_callback, + .master = TRUE, + }, + + [GLXIIC_STATE_MASTER_RX] = { + .callback = &glxiic_state_master_rx_callback, + .master = TRUE, + }, + + [GLXIIC_STATE_MASTER_STOP] = { + .callback = &glxiic_state_master_stop_callback, + .master = TRUE, + }, +}; + +static void glxiic_identify(driver_t *driver, device_t parent); +static int glxiic_probe(device_t dev); +static int glxiic_attach(device_t dev); +static int glxiic_detach(device_t dev); + +static uint8_t glxiic_read_status_locked(struct glxiic_softc *sc); +static void glxiic_stop_locked(struct glxiic_softc *sc); +static void glxiic_timeout(void *arg); +static void glxiic_start_timeout_locked(struct glxiic_softc *sc); +static void glxiic_set_state_locked(struct glxiic_softc *sc, + glxiic_state_t state); +static int glxiic_handle_slave_match_locked(struct glxiic_softc *sc, + uint8_t status); +static void glxiic_intr(void *arg); + +static int glxiic_reset(device_t dev, u_char speed, u_char addr, + u_char *oldaddr); +static int glxiic_transfer(device_t dev, struct iic_msg *msgs, + uint32_t nmsgs); + +static void glxiic_smb_map_interrupt(int irq); +static void glxiic_gpio_enable(struct glxiic_softc *sc); +static void glxiic_gpio_disable(struct glxiic_softc *sc); +static void glxiic_smb_enable(struct glxiic_softc *sc, uint8_t speed, + uint8_t addr); +static void glxiic_smb_disable(struct glxiic_softc *sc); + +static device_method_t glxiic_methods[] = { + DEVMETHOD(device_identify, glxiic_identify), + DEVMETHOD(device_probe, glxiic_probe), + DEVMETHOD(device_attach, glxiic_attach), + DEVMETHOD(device_detach, glxiic_detach), + + DEVMETHOD(iicbus_reset, glxiic_reset), + DEVMETHOD(iicbus_transfer, glxiic_transfer), + DEVMETHOD(iicbus_callback, iicbus_null_callback), + + { 0, 0 } +}; + +static driver_t glxiic_driver = { + "glxiic", + glxiic_methods, + sizeof(struct glxiic_softc), +}; + +static devclass_t glxiic_devclass; + +DRIVER_MODULE(glxiic, isab, glxiic_driver, glxiic_devclass, 0, 0); +DRIVER_MODULE(iicbus, glxiic, iicbus_driver, iicbus_devclass, 0, 0); +MODULE_DEPEND(glxiic, iicbus, 1, 1, 1); + +static void +glxiic_identify(driver_t *driver, device_t parent) +{ + + /* Prevent child from being added more than once. */ + if (device_find_child(parent, driver->name, -1) != NULL) + return; + + if (pci_get_devid(parent) == GLXIIC_CS5536_DEV_ID) { + if (device_add_child(parent, driver->name, -1) == NULL) + device_printf(parent, "Could not add glxiic child\n"); + } +} + +static int +glxiic_probe(device_t dev) +{ + + if (resource_disabled("glxiic", device_get_unit(dev))) + return (ENXIO); + + device_set_desc(dev, "AMD Geode CS5536 SMBus controller"); + + return (BUS_PROBE_DEFAULT); +} + +static int +glxiic_attach(device_t dev) +{ + struct glxiic_softc *sc; + struct sysctl_ctx_list *ctx; + struct sysctl_oid *tree; + int error, irq, unit; + uint32_t irq_map; + char tn[32]; + + sc = device_get_softc(dev); + sc->dev = dev; + sc->state = GLXIIC_STATE_IDLE; + error = 0; + + GLXIIC_LOCK_INIT(sc); + callout_init_mtx(&sc->callout, &sc->mtx, 0); + + sc->smb_rid = PCIR_BAR(0); + sc->smb_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->smb_rid, + RF_ACTIVE); + if (sc->smb_res == NULL) { + device_printf(dev, "Could not allocate SMBus I/O port\n"); + error = ENXIO; + goto out; + } + + sc->gpio_rid = PCIR_BAR(1); + sc->gpio_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, + &sc->gpio_rid, RF_SHAREABLE | RF_ACTIVE); + if (sc->gpio_res == NULL) { + device_printf(dev, "Could not allocate GPIO I/O port\n"); + error = ENXIO; + goto out; + } + + /* Ensure the controller is not enabled by firmware. */ + glxiic_smb_disable(sc); + + /* Read the existing IRQ map. */ + irq_map = rdmsr(GLXIIC_MSR_PIC_YSEL_HIGH); + sc->old_irq = GLXIIC_MAP_TO_SMB_IRQ(irq_map); + + unit = device_get_unit(dev); + if (resource_int_value("glxiic", unit, "irq", &irq) == 0) { + if (irq < 1 || irq > 15) { + device_printf(dev, "Bad value %d for glxiic.%d.irq\n", + irq, unit); + error = ENXIO; + goto out; + } + + if (bootverbose) + device_printf(dev, "Using irq %d set by hint\n", irq); + } else if (sc->old_irq != 0) { + if (bootverbose) + device_printf(dev, "Using irq %d set by firmware\n", + irq); + irq = sc->old_irq; + } else { + device_printf(dev, "No irq mapped by firmware"); + printf(" and no glxiic.%d.irq hint provided\n", unit); + error = ENXIO; + goto out; + } + + /* Map the SMBus interrupt to the requested legacy IRQ. */ + glxiic_smb_map_interrupt(irq); + + sc->irq_rid = 0; + sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid, + irq, irq, 1, RF_SHAREABLE | RF_ACTIVE); + if (sc->irq_res == NULL) { + device_printf(dev, "Could not allocate IRQ %d\n", irq); + error = ENXIO; + goto out; + } + + error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE, + NULL, glxiic_intr, sc, &(sc->irq_handler)); + if (error != 0) { + device_printf(dev, "Could not setup IRQ handler\n"); + error = ENXIO; + goto out; + } + + if ((sc->iicbus = device_add_child(dev, "iicbus", -1)) == NULL) { + device_printf(dev, "Could not allocate iicbus instance\n"); + error = ENXIO; + goto out; + } + + ctx = device_get_sysctl_ctx(dev); + tree = device_get_sysctl_tree(dev); + + sc->timeout = GLXIIC_DEFAULT_TIMEOUT; + snprintf(tn, sizeof(tn), "dev.glxiic.%d.timeout", unit); + TUNABLE_INT_FETCH(tn, &sc->timeout); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "timeout", CTLFLAG_RW | CTLFLAG_TUN, &sc->timeout, 0, + "activity timeout in ms"); + + glxiic_gpio_enable(sc); + glxiic_smb_enable(sc, IIC_FASTEST, 0); + + error = bus_generic_attach(dev); + if (error != 0) { + device_printf(dev, "Could not probe and attach children\n"); + error = ENXIO; + } +out: + if (error != 0) { + callout_drain(&sc->callout); + + if (sc->iicbus != NULL) + device_delete_child(dev, sc->iicbus); + if (sc->smb_res != NULL) { + glxiic_smb_disable(sc); + bus_release_resource(dev, SYS_RES_IOPORT, sc->smb_rid, + sc->smb_res); + } + if (sc->gpio_res != NULL) { + glxiic_gpio_disable(sc); + bus_release_resource(dev, SYS_RES_IOPORT, sc->gpio_rid, + sc->gpio_res); + } + if (sc->irq_handler != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->irq_handler); + if (sc->irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, + sc->irq_res); + + /* Restore the old SMBus interrupt mapping. */ + glxiic_smb_map_interrupt(sc->old_irq); + + GLXIIC_LOCK_DESTROY(sc); + } + + return (error); +} + +static int +glxiic_detach(device_t dev) +{ + struct glxiic_softc *sc; + int error; + + sc = device_get_softc(dev); + + error = bus_generic_detach(dev); + if (error != 0) + goto out; + if (sc->iicbus != NULL) + error = device_delete_child(dev, sc->iicbus); + +out: + callout_drain(&sc->callout); + + if (sc->smb_res != NULL) { + glxiic_smb_disable(sc); + bus_release_resource(dev, SYS_RES_IOPORT, sc->smb_rid, + sc->smb_res); + } + if (sc->gpio_res != NULL) { + glxiic_gpio_disable(sc); + bus_release_resource(dev, SYS_RES_IOPORT, sc->gpio_rid, + sc->gpio_res); + } + if (sc->irq_handler != NULL) + bus_teardown_intr(dev, sc->irq_res, sc->irq_handler); + if (sc->irq_res != NULL) + bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, + sc->irq_res); + + /* Restore the old SMBus interrupt mapping. */ + glxiic_smb_map_interrupt(sc->old_irq); + + GLXIIC_LOCK_DESTROY(sc); + + return (error); +} + +static uint8_t +glxiic_read_status_locked(struct glxiic_softc *sc) +{ + uint8_t status; + + GLXIIC_ASSERT_LOCKED(sc); + + status = bus_read_1(sc->smb_res, GLXIIC_SMB_STS); + + /* Clear all status flags except SDAST and STASTR after reading. */ + bus_write_1(sc->smb_res, GLXIIC_SMB_STS, (GLXIIC_SMB_STS_SLVSTP_BIT | + GLXIIC_SMB_STS_BER_BIT | GLXIIC_SMB_STS_NEGACK_BIT | + GLXIIC_SMB_STS_NMATCH_BIT)); + + return (status); +} + +static void +glxiic_stop_locked(struct glxiic_softc *sc) +{ + uint8_t status, ctrl1; + + GLXIIC_ASSERT_LOCKED(sc); + + status = glxiic_read_status_locked(sc); + + ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1); + bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1, + ctrl1 | GLXIIC_SMB_CTRL1_STOP_BIT); + + /* + * Perform a dummy read of SDA in master receive mode to clear + * SDAST if set. + */ + if ((status & GLXIIC_SMB_STS_XMIT_BIT) == 0 && + (status & GLXIIC_SMB_STS_SDAST_BIT) != 0) + bus_read_1(sc->smb_res, GLXIIC_SMB_SDA); + + /* Check stall after start bit and clear if needed */ + if ((status & GLXIIC_SMB_STS_STASTR_BIT) != 0) { + bus_write_1(sc->smb_res, GLXIIC_SMB_STS, + GLXIIC_SMB_STS_STASTR_BIT); + } +} + +static void +glxiic_timeout(void *arg) +{ + struct glxiic_softc *sc; + uint8_t error; + + sc = (struct glxiic_softc *)arg; + + DEBUG("timeout in state %d", sc->state); + + if (glxiic_state_table[sc->state].master) { + sc->error = IIC_ETIMEOUT; + GLXIIC_WAKEUP(sc); + } else { + error = IIC_ETIMEOUT; + iicbus_intr(sc->iicbus, INTR_ERROR, &error); + } + + glxiic_smb_disable(sc); + glxiic_smb_enable(sc, IIC_UNKNOWN, sc->addr); + glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE); +} + +static void +glxiic_start_timeout_locked(struct glxiic_softc *sc) +{ + + GLXIIC_ASSERT_LOCKED(sc); + + callout_reset(&sc->callout, sc->timeout * 1000 / hz, glxiic_timeout, + sc); +} + +static void +glxiic_set_state_locked(struct glxiic_softc *sc, glxiic_state_t state) +{ + + GLXIIC_ASSERT_LOCKED(sc); + + if (state == GLXIIC_STATE_IDLE) + callout_stop(&sc->callout); + else if (sc->timeout > 0) + glxiic_start_timeout_locked(sc); + + sc->state = state; +} + +static int +glxiic_handle_slave_match_locked(struct glxiic_softc *sc, uint8_t status) +{ + uint8_t ctrl_sts, addr; + + GLXIIC_ASSERT_LOCKED(sc); + + ctrl_sts = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL_STS); + + if ((ctrl_sts & GLXIIC_SMB_CTRL_STS_MATCH_BIT) != 0) { + if ((status & GLXIIC_SMB_STS_XMIT_BIT) != 0) { + addr = sc->addr | LSB; + glxiic_set_state_locked(sc, + GLXIIC_STATE_SLAVE_TX); + } else { + addr = sc->addr & ~LSB; + glxiic_set_state_locked(sc, + GLXIIC_STATE_SLAVE_RX); + } + iicbus_intr(sc->iicbus, INTR_START, &addr); + } else if ((ctrl_sts & GLXIIC_SMB_CTRL_STS_GCMTCH_BIT) != 0) { + addr = 0; + glxiic_set_state_locked(sc, GLXIIC_STATE_SLAVE_RX); + iicbus_intr(sc->iicbus, INTR_GENERAL, &addr); + } else { + DEBUG("unknown slave match"); + return (IIC_ESTATUS); + } + + return (IIC_NOERR); +} + +static int +glxiic_state_idle_callback(struct glxiic_softc *sc, uint8_t status) +{ + + GLXIIC_ASSERT_LOCKED(sc); + + if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { + DEBUG("bus error in idle"); + return (IIC_EBUSERR); + } + + if ((status & GLXIIC_SMB_STS_NMATCH_BIT) != 0) { + return (glxiic_handle_slave_match_locked(sc, status)); + } + + return (IIC_NOERR); +} + +static int +glxiic_state_slave_tx_callback(struct glxiic_softc *sc, uint8_t status) +{ + uint8_t data; + + GLXIIC_ASSERT_LOCKED(sc); + + if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { + DEBUG("bus error in slave tx"); + return (IIC_EBUSERR); + } + + if ((status & GLXIIC_SMB_STS_SLVSTP_BIT) != 0) { + iicbus_intr(sc->iicbus, INTR_STOP, NULL); + glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE); + return (IIC_NOERR); + } + + if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { + iicbus_intr(sc->iicbus, INTR_NOACK, NULL); + return (IIC_NOERR); + } + + if ((status & GLXIIC_SMB_STS_NMATCH_BIT) != 0) { + /* Handle repeated start in slave mode. */ + return (glxiic_handle_slave_match_locked(sc, status)); + } + + if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { + DEBUG("not awaiting data in slave tx"); + return (IIC_ESTATUS); + } + + iicbus_intr(sc->iicbus, INTR_TRANSMIT, &data); + bus_write_1(sc->smb_res, GLXIIC_SMB_SDA, data); + + glxiic_start_timeout_locked(sc); + + return (IIC_NOERR); +} + +static int +glxiic_state_slave_rx_callback(struct glxiic_softc *sc, uint8_t status) +{ + uint8_t data; + + GLXIIC_ASSERT_LOCKED(sc); + + if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { + DEBUG("bus error in slave rx"); + return (IIC_EBUSERR); + } + + if ((status & GLXIIC_SMB_STS_SLVSTP_BIT) != 0) { + iicbus_intr(sc->iicbus, INTR_STOP, NULL); + glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE); + return (IIC_NOERR); + } + + if ((status & GLXIIC_SMB_STS_NMATCH_BIT) != 0) { + /* Handle repeated start in slave mode. */ + return (glxiic_handle_slave_match_locked(sc, status)); + } + + if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { + DEBUG("no pending data in slave rx"); + return (IIC_ESTATUS); + } + + data = bus_read_1(sc->smb_res, GLXIIC_SMB_SDA); + iicbus_intr(sc->iicbus, INTR_RECEIVE, &data); + + glxiic_start_timeout_locked(sc); + + return (IIC_NOERR); +} + +static int +glxiic_state_master_addr_callback(struct glxiic_softc *sc, uint8_t status) +{ + uint8_t slave; + + GLXIIC_ASSERT_LOCKED(sc); + + if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { + DEBUG("bus error after master start"); + return (IIC_EBUSERR); + } + + if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { + DEBUG("not bus master after master start"); + return (IIC_ESTATUS); + } + + if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { + DEBUG("not awaiting address in master addr"); + return (IIC_ESTATUS); + } + + if ((sc->msg->flags & IIC_M_RD) != 0) { + slave = sc->msg->slave | LSB; + glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_RX); + } else { + slave = sc->msg->slave & ~LSB; + glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_TX); + } + + sc->data = sc->msg->buf; + sc->ndata = sc->msg->len; + + /* Handle address-only transfer. */ + if (sc->ndata == 0) + glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_STOP); + + bus_write_1(sc->smb_res, GLXIIC_SMB_SDA, slave); + + return (IIC_NOERR); +} + +static int +glxiic_state_master_tx_callback(struct glxiic_softc *sc, uint8_t status) +{ + + GLXIIC_ASSERT_LOCKED(sc); + + if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { + DEBUG("bus error in master tx"); + return (IIC_EBUSERR); + } + + if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { + DEBUG("not bus master in master tx"); + return (IIC_ESTATUS); + } + + if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { + DEBUG("slave nack in master tx"); + return (IIC_ENOACK); + } + + if ((status & GLXIIC_SMB_STS_STASTR_BIT) != 0) { + bus_write_1(sc->smb_res, GLXIIC_SMB_STS, + GLXIIC_SMB_STS_STASTR_BIT); + } + + if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { + DEBUG("not awaiting data in master tx"); + return (IIC_ESTATUS); + } + + bus_write_1(sc->smb_res, GLXIIC_SMB_SDA, *sc->data++); + if (--sc->ndata == 0) + glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_STOP); + else + glxiic_start_timeout_locked(sc); + + return (IIC_NOERR); +} + +static int +glxiic_state_master_rx_callback(struct glxiic_softc *sc, uint8_t status) +{ + uint8_t ctrl1; + + GLXIIC_ASSERT_LOCKED(sc); + + if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { + DEBUG("bus error in master rx"); + return (IIC_EBUSERR); + } + + if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { + DEBUG("not bus master in master rx"); + return (IIC_ESTATUS); + } + + if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { + DEBUG("slave nack in rx"); + return (IIC_ENOACK); + } + + if (sc->ndata == 1) { + /* Last byte from slave, set NACK. */ + ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1); + bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1, + ctrl1 | GLXIIC_SMB_CTRL1_ACK_BIT); + } + + if ((status & GLXIIC_SMB_STS_STASTR_BIT) != 0) { + /* Bus is stalled, clear and wait for data. */ + bus_write_1(sc->smb_res, GLXIIC_SMB_STS, + GLXIIC_SMB_STS_STASTR_BIT); + return (IIC_NOERR); + } + + if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { + DEBUG("no pending data in master rx"); + return (IIC_ESTATUS); + } + + *sc->data++ = bus_read_1(sc->smb_res, GLXIIC_SMB_SDA); + if (--sc->ndata == 0) { + /* Proceed with stop on reading last byte. */ + glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_STOP); + return (glxiic_state_table[sc->state].callback(sc, status)); + } + + glxiic_start_timeout_locked(sc); + + return (IIC_NOERR); +} + +static int +glxiic_state_master_stop_callback(struct glxiic_softc *sc, uint8_t status) +{ + uint8_t ctrl1; + + GLXIIC_ASSERT_LOCKED(sc); + + if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { + DEBUG("bus error in master stop"); + return (IIC_EBUSERR); + } + + if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { + DEBUG("not bus master in master stop"); + return (IIC_ESTATUS); + } + + if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { + DEBUG("slave nack in master stop"); + return (IIC_ENOACK); + } + + if (--sc->nmsgs > 0) { + /* Start transfer of next message. */ + if ((sc->msg->flags & IIC_M_NOSTOP) == 0) { + glxiic_stop_locked(sc); + } + + ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1); + bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1, + ctrl1 | GLXIIC_SMB_CTRL1_START_BIT); + + glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_ADDR); + sc->msg++; + } else { + /* Last message. */ + glxiic_stop_locked(sc); + glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE); + sc->error = IIC_NOERR; + GLXIIC_WAKEUP(sc); + } + + return (IIC_NOERR); +} + +static void +glxiic_intr(void *arg) +{ + struct glxiic_softc *sc; + int error; + uint8_t status, data; + + sc = (struct glxiic_softc *)arg; + + GLXIIC_LOCK(sc); + + status = glxiic_read_status_locked(sc); + + /* Check if this interrupt originated from the SMBus. */ + if ((status & + ~(GLXIIC_SMB_STS_MASTER_BIT | GLXIIC_SMB_STS_XMIT_BIT)) != 0) { + + error = glxiic_state_table[sc->state].callback(sc, status); + + if (error != IIC_NOERR) { + if (glxiic_state_table[sc->state].master) { + glxiic_stop_locked(sc); + glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE); + sc->error = error; + GLXIIC_WAKEUP(sc); + } else { + data = error & 0xff; + iicbus_intr(sc->iicbus, INTR_ERROR, &data); + glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE); + } + } + } + + GLXIIC_UNLOCK(sc); +} + +static int +glxiic_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr) +{ + struct glxiic_softc *sc; + + sc = device_get_softc(dev); + + GLXIIC_LOCK(sc); + + if (oldaddr != NULL) + *oldaddr = sc->addr; + sc->addr = addr; + + /* A disable/enable cycle resets the controller. */ + glxiic_smb_disable(sc); + glxiic_smb_enable(sc, speed, addr); + + if (glxiic_state_table[sc->state].master) { + sc->error = IIC_ESTATUS; + GLXIIC_WAKEUP(sc); + } + glxiic_set_state_locked(sc, GLXIIC_STATE_IDLE); + + GLXIIC_UNLOCK(sc); + + return (IIC_NOERR); +} + +static int +glxiic_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) +{ + struct glxiic_softc *sc; + int error; + uint8_t ctrl1; + + sc = device_get_softc(dev); + + GLXIIC_LOCK(sc); + + if (sc->state != GLXIIC_STATE_IDLE) { + error = IIC_EBUSBSY; + goto out; + } + + sc->msg = msgs; + sc->nmsgs = nmsgs; + glxiic_set_state_locked(sc, GLXIIC_STATE_MASTER_ADDR); + + /* Set start bit and let glxiic_intr() handle the transfer. */ + ctrl1 = bus_read_1(sc->smb_res, GLXIIC_SMB_CTRL1); + bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1, + ctrl1 | GLXIIC_SMB_CTRL1_START_BIT); + + GLXIIC_SLEEP(sc); + error = sc->error; +out: + GLXIIC_UNLOCK(sc); + + return (error); +} + +static void +glxiic_smb_map_interrupt(int irq) +{ + uint32_t irq_map; + int old_irq; + + /* Protect the read-modify-write operation. */ + critical_enter(); + + irq_map = rdmsr(GLXIIC_MSR_PIC_YSEL_HIGH); + old_irq = GLXIIC_MAP_TO_SMB_IRQ(irq_map); + + if (irq != old_irq) { + irq_map &= ~GLXIIC_SMB_IRQ_TO_MAP(old_irq); + irq_map |= GLXIIC_SMB_IRQ_TO_MAP(irq); + wrmsr(GLXIIC_MSR_PIC_YSEL_HIGH, irq_map); + } + + critical_exit(); +} + +static void +glxiic_gpio_enable(struct glxiic_softc *sc) +{ + + bus_write_4(sc->gpio_res, GLXIIC_GPIOL_IN_AUX1_SEL, + GLXIIC_GPIO_14_15_ENABLE); + bus_write_4(sc->gpio_res, GLXIIC_GPIOL_OUT_AUX1_SEL, + GLXIIC_GPIO_14_15_ENABLE); +} + +static void +glxiic_gpio_disable(struct glxiic_softc *sc) +{ + + bus_write_4(sc->gpio_res, GLXIIC_GPIOL_OUT_AUX1_SEL, + GLXIIC_GPIO_14_15_DISABLE); + bus_write_4(sc->gpio_res, GLXIIC_GPIOL_IN_AUX1_SEL, + GLXIIC_GPIO_14_15_DISABLE); +} + +static void +glxiic_smb_enable(struct glxiic_softc *sc, uint8_t speed, uint8_t addr) +{ + uint8_t ctrl1; + + ctrl1 = 0; + + switch (speed) { + case IIC_SLOW: + sc->sclfrq = GLXIIC_SLOW; + break; + case IIC_FAST: + sc->sclfrq = GLXIIC_FAST; + break; + case IIC_FASTEST: + sc->sclfrq = GLXIIC_FASTEST; + break; + case IIC_UNKNOWN: + default: + /* Reuse last frequency. */ + break; + } + + /* Set bus speed and enable controller. */ + bus_write_2(sc->smb_res, GLXIIC_SMB_CTRL2, + GLXIIC_SCLFRQ(sc->sclfrq) | GLXIIC_SMB_CTRL2_EN_BIT); + + if (addr != 0) { + /* Enable new match and global call match interrupts. */ + ctrl1 |= GLXIIC_SMB_CTRL1_NMINTE_BIT | + GLXIIC_SMB_CTRL1_GCMEN_BIT; + bus_write_1(sc->smb_res, GLXIIC_SMB_ADDR, + GLXIIC_SMB_ADDR_SAEN_BIT | GLXIIC_SMBADDR(addr)); + } else { + bus_write_1(sc->smb_res, GLXIIC_SMB_ADDR, 0); + } + + /* Enable stall after start and interrupt. */ + bus_write_1(sc->smb_res, GLXIIC_SMB_CTRL1, + ctrl1 | GLXIIC_SMB_CTRL1_STASTRE_BIT | GLXIIC_SMB_CTRL1_INTEN_BIT); +} + +static void +glxiic_smb_disable(struct glxiic_softc *sc) +{ + uint16_t sclfrq; + + sclfrq = bus_read_2(sc->smb_res, GLXIIC_SMB_CTRL2); + bus_write_2(sc->smb_res, GLXIIC_SMB_CTRL2, + sclfrq & ~GLXIIC_SMB_CTRL2_EN_BIT); +} diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index a68037bb2f63..866e64178488 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -730,6 +730,12 @@ device safe # SafeNet 1141 options SAFE_DEBUG # enable debugging support: hw.safe.debug options SAFE_RNDTEST # enable rndtest support +# +# glxiic is an I2C driver for the AMD Geode LX CS5536 System Management Bus +# controller. Requires 'device iicbus'. +# +device glxiic # AMD Geode LX CS5536 System Management Bus + # # glxsb is a driver for the Security Block in AMD Geode LX processors. # Requires 'device crypto'. diff --git a/sys/modules/Makefile b/sys/modules/Makefile index f3e67c93cb61..a83d56fe00b9 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -102,6 +102,7 @@ SUBDIR= ${_3dfx} \ fxp \ gem \ geom \ + ${_glxiic} \ ${_glxsb} \ hatm \ hifn \ @@ -419,6 +420,7 @@ _et= et _exca= exca _ext2fs= ext2fs _fe= fe +_glxiic= glxiic _glxsb= glxsb _i2c= i2c _ibcs2= ibcs2 diff --git a/sys/modules/glxiic/Makefile b/sys/modules/glxiic/Makefile new file mode 100644 index 000000000000..46b0c071c611 --- /dev/null +++ b/sys/modules/glxiic/Makefile @@ -0,0 +1,10 @@ +# $FreeBSD$ + +#CFLAGS+= -DGLXIIC_DEBUG + +.PATH: ${.CURDIR}/../../dev/glxiic +KMOD= glxiic +SRCS= glxiic.c +SRCS+= device_if.h bus_if.h pci_if.h iicbus_if.h + +.include From e9d1191f6a80c75e2f00470056c21f922f696f67 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sun, 15 May 2011 15:54:34 +0000 Subject: [PATCH 019/200] * Add some more TX descriptor error counters; this'll be helpful when implementing TX aggregation * Whilst I'm there, comment some RX error counters --- sys/dev/ath/if_ath.c | 12 ++++++++++++ sys/dev/ath/if_ath_sysctl.c | 6 ++++++ sys/dev/ath/if_athioctl.h | 17 ++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 8f13b267c0e4..745a0d5a9509 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -3966,9 +3966,21 @@ ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) sc->sc_stats.ast_tx_fifoerr++; if (ts->ts_status & HAL_TXERR_FILT) sc->sc_stats.ast_tx_filtered++; + if (ts->ts_status & HAL_TXERR_XTXOP) + sc->sc_stats.ast_tx_xtxop++; + if (ts->ts_status & HAL_TXERR_TIMER_EXPIRED) + sc->sc_stats.ast_tx_timerexpired++; + + /* XXX HAL_TX_DATA_UNDERRUN */ + /* XXX HAL_TX_DELIM_UNDERRUN */ + if (bf->bf_m->m_flags & M_FF) sc->sc_stats.ast_ff_txerr++; } + /* XXX when is this valid? */ + if (ts->ts_status & HAL_TX_DESC_CFG_ERR) + sc->sc_stats.ast_tx_desccfgerr++; + sr = ts->ts_shortretry; lr = ts->ts_longretry; sc->sc_stats.ast_tx_shortretry += sr; diff --git a/sys/dev/ath/if_ath_sysctl.c b/sys/dev/ath/if_ath_sysctl.c index 8e064971bfbc..6c1a6b210425 100644 --- a/sys/dev/ath/if_ath_sysctl.c +++ b/sys/dev/ath/if_ath_sysctl.c @@ -709,6 +709,12 @@ ath_sysctl_stats_attach(struct ath_softc *sc) &sc->sc_stats.ast_tx_timeout, 0, "TX Global Timeout"); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_cst", CTLFLAG_RD, &sc->sc_stats.ast_tx_cst, 0, "TX Carrier Sense Timeout"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_xtxop", CTLFLAG_RD, + &sc->sc_stats.ast_tx_xtxop, 0, "TX exceeded TXOP"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_timerexpired", CTLFLAG_RD, + &sc->sc_stats.ast_tx_timerexpired, 0, "TX exceeded TX_TIMER register"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_desccfgerr", CTLFLAG_RD, + &sc->sc_stats.ast_tx_desccfgerr, 0, "TX Descriptor Cfg Error"); /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); diff --git a/sys/dev/ath/if_athioctl.h b/sys/dev/ath/if_athioctl.h index 1c9d23fe7cd7..98dd03791d99 100644 --- a/sys/dev/ath/if_athioctl.h +++ b/sys/dev/ath/if_athioctl.h @@ -121,17 +121,20 @@ struct ath_stats { u_int32_t ast_be_missed; /* missed beacons */ u_int32_t ast_ani_cal; /* ANI calibrations performed */ u_int32_t ast_rx_agg; /* number of aggregate frames RX'ed */ - u_int32_t ast_rx_halfgi; - u_int32_t ast_rx_2040; - u_int32_t ast_rx_pre_crc_err; - u_int32_t ast_rx_post_crc_err; - u_int32_t ast_rx_decrypt_busy_err; + u_int32_t ast_rx_halfgi; /* RX half-GI */ + u_int32_t ast_rx_2040; /* RX 40mhz frame */ + u_int32_t ast_rx_pre_crc_err; /* RX pre-delimiter CRC error */ + u_int32_t ast_rx_post_crc_err; /* RX post-delimiter CRC error */ + u_int32_t ast_rx_decrypt_busy_err; /* RX decrypt engine busy error */ u_int32_t ast_rx_hi_rx_chain; u_int32_t ast_tx_htprotect; /* HT tx frames with protection */ - u_int32_t ast_rx_hitqueueend; + u_int32_t ast_rx_hitqueueend; /* RX hit descr queue end */ u_int32_t ast_tx_timeout; /* Global TX timeout */ u_int32_t ast_tx_cst; /* Carrier sense timeout */ - u_int32_t ast_pad[16]; + u_int32_t ast_tx_xtxop; /* tx exceeded TXOP */ + u_int32_t ast_tx_timerexpired; /* tx exceeded TX_TIMER */ + u_int32_t ast_tx_desccfgerr; /* tx desc cfg error */ + u_int32_t ast_pad[13]; }; #define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) From 6c7e04f0f30d7631dc9819205fd517bee9af1967 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Sun, 15 May 2011 16:16:48 +0000 Subject: [PATCH 020/200] Some partitioning schemes want to have partitions that are aligned with geometry. And they do recalculation of user specified parameters. MBR, PC98, VTOC8, EBR schemes are doing that. For these schemes an auto alignment feature (ie. gpart add -a alignment) would not work. But it can work for GPT and BSD schemes. BSD scheme usualy is created inside MBR, so we can use knowledge about offset of MBR partition to calculate aligned values for BSD partitions. Use "offset" attribute of the parent provider for better alignment. MFC after: 2 weeks --- sbin/geom/class/part/geom_part.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index 81d02914f9d1..19d1502fbe7d 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -416,7 +416,7 @@ gpart_autofill(struct gctl_req *req) struct gprovider *pp; off_t first, last, a_first; off_t size, start, a_lba; - off_t lba, len, alignment; + off_t lba, len, alignment, offset; uintmax_t grade; const char *s; int error, has_size, has_start, has_alignment; @@ -467,8 +467,6 @@ gpart_autofill(struct gctl_req *req) error = g_parse_lba(s, pp->lg_sectorsize, &size); if (error) errc(EXIT_FAILURE, error, "Invalid size param"); - if (size > alignment) - size = ALIGNDOWN(size, alignment); } s = gctl_get_ascii(req, "start"); @@ -478,22 +476,29 @@ gpart_autofill(struct gctl_req *req) error = g_parse_lba(s, pp->lg_sectorsize, &start); if (error) errc(EXIT_FAILURE, error, "Invalid start param"); - start = ALIGNUP(start, alignment); } /* No autofill necessary. */ if (has_size && has_start && !has_alignment) goto done; + /* Adjust parameters to offset value for better alignment */ + s = find_provcfg(pp, "offset"); + offset = (s == NULL) ? 0: + (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; + start = ALIGNUP(start + offset, alignment); + if (size + offset > alignment) + size = ALIGNDOWN(size + offset, alignment); + first = (off_t)strtoimax(find_geomcfg(gp, "first"), NULL, 0); last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0); grade = ~0ULL; - a_first = ALIGNUP(first, alignment); - last = ALIGNDOWN(last, alignment); + a_first = ALIGNUP(first + offset, alignment); + last = ALIGNDOWN(last + offset, alignment); while ((pp = find_provider(gp, first)) != NULL) { s = find_provcfg(pp, "start"); lba = (off_t)strtoimax(s, NULL, 0); - a_lba = ALIGNDOWN(lba, alignment); + a_lba = ALIGNDOWN(lba + offset, alignment); if (first < a_lba && a_first < a_lba) { /* Free space [first, lba> */ len = a_lba - a_first; @@ -519,7 +524,7 @@ gpart_autofill(struct gctl_req *req) s = find_provcfg(pp, "end"); first = (off_t)strtoimax(s, NULL, 0) + 1; - a_first = ALIGNUP(first, alignment); + a_first = ALIGNUP(first + offset, alignment); } if (a_first <= last) { /* Free space [first-last] */ @@ -543,12 +548,11 @@ gpart_autofill(struct gctl_req *req) } } } - if (grade == ~0ULL) { geom_deletetree(&mesh); return (ENOSPC); } - + start -= offset; /* Return back to real offset */ done: snprintf(ssize, sizeof(ssize), "%jd", (intmax_t)size); gctl_change_param(req, "size", -1, ssize); From e64a11e9eb3544ebd91b4ed27543fc98122c773a Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 15 May 2011 17:00:43 +0000 Subject: [PATCH 021/200] sh: Avoid close(-1) when evaluating a multi-command pipeline. Valgrind complains about this. --- bin/sh/eval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/sh/eval.c b/bin/sh/eval.c index b0ee28e7b0e7..b19c24f81a91 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -552,7 +552,8 @@ evalpipe(union node *n) if (prevfd >= 0) close(prevfd); prevfd = pip[0]; - close(pip[1]); + if (pip[1] != -1) + close(pip[1]); } INTON; if (n->npipe.backgnd == 0) { From da25396a71f41608eab1ffb4f70204b3cf2c0ac5 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 15 May 2011 19:04:08 +0000 Subject: [PATCH 022/200] Fix breakage on pc98 by redefining DEBUG(). Pointy hat to: brix --- sys/dev/glxiic/glxiic.c | 47 +++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/sys/dev/glxiic/glxiic.c b/sys/dev/glxiic/glxiic.c index 204095166192..6eeac7cee381 100644 --- a/sys/dev/glxiic/glxiic.c +++ b/sys/dev/glxiic/glxiic.c @@ -153,9 +153,10 @@ struct glxiic_softc { }; #ifdef GLXIIC_DEBUG -#define DEBUG(fmt, args...) log(LOG_DEBUG, "%s: " fmt "\n" , __func__ , ## args) +#define GLXIIC_DEBUG_LOG(fmt, args...) \ + log(LOG_DEBUG, "%s: " fmt "\n" , __func__ , ## args) #else -#define DEBUG(fmt, args...) +#define GLXIIC_DEBUG_LOG(fmt, args...) #endif #define GLXIIC_SCLFRQ(n) ((n << 1)) @@ -540,7 +541,7 @@ glxiic_timeout(void *arg) sc = (struct glxiic_softc *)arg; - DEBUG("timeout in state %d", sc->state); + GLXIIC_DEBUG_LOG("timeout in state %d", sc->state); if (glxiic_state_table[sc->state].master) { sc->error = IIC_ETIMEOUT; @@ -604,7 +605,7 @@ glxiic_handle_slave_match_locked(struct glxiic_softc *sc, uint8_t status) glxiic_set_state_locked(sc, GLXIIC_STATE_SLAVE_RX); iicbus_intr(sc->iicbus, INTR_GENERAL, &addr); } else { - DEBUG("unknown slave match"); + GLXIIC_DEBUG_LOG("unknown slave match"); return (IIC_ESTATUS); } @@ -618,7 +619,7 @@ glxiic_state_idle_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in idle"); + GLXIIC_DEBUG_LOG("bus error in idle"); return (IIC_EBUSERR); } @@ -637,7 +638,7 @@ glxiic_state_slave_tx_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in slave tx"); + GLXIIC_DEBUG_LOG("bus error in slave tx"); return (IIC_EBUSERR); } @@ -658,7 +659,7 @@ glxiic_state_slave_tx_callback(struct glxiic_softc *sc, uint8_t status) } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("not awaiting data in slave tx"); + GLXIIC_DEBUG_LOG("not awaiting data in slave tx"); return (IIC_ESTATUS); } @@ -678,7 +679,7 @@ glxiic_state_slave_rx_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in slave rx"); + GLXIIC_DEBUG_LOG("bus error in slave rx"); return (IIC_EBUSERR); } @@ -694,7 +695,7 @@ glxiic_state_slave_rx_callback(struct glxiic_softc *sc, uint8_t status) } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("no pending data in slave rx"); + GLXIIC_DEBUG_LOG("no pending data in slave rx"); return (IIC_ESTATUS); } @@ -714,17 +715,17 @@ glxiic_state_master_addr_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error after master start"); + GLXIIC_DEBUG_LOG("bus error after master start"); return (IIC_EBUSERR); } if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { - DEBUG("not bus master after master start"); + GLXIIC_DEBUG_LOG("not bus master after master start"); return (IIC_ESTATUS); } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("not awaiting address in master addr"); + GLXIIC_DEBUG_LOG("not awaiting address in master addr"); return (IIC_ESTATUS); } @@ -755,17 +756,17 @@ glxiic_state_master_tx_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in master tx"); + GLXIIC_DEBUG_LOG("bus error in master tx"); return (IIC_EBUSERR); } if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { - DEBUG("not bus master in master tx"); + GLXIIC_DEBUG_LOG("not bus master in master tx"); return (IIC_ESTATUS); } if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { - DEBUG("slave nack in master tx"); + GLXIIC_DEBUG_LOG("slave nack in master tx"); return (IIC_ENOACK); } @@ -775,7 +776,7 @@ glxiic_state_master_tx_callback(struct glxiic_softc *sc, uint8_t status) } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("not awaiting data in master tx"); + GLXIIC_DEBUG_LOG("not awaiting data in master tx"); return (IIC_ESTATUS); } @@ -796,17 +797,17 @@ glxiic_state_master_rx_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in master rx"); + GLXIIC_DEBUG_LOG("bus error in master rx"); return (IIC_EBUSERR); } if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { - DEBUG("not bus master in master rx"); + GLXIIC_DEBUG_LOG("not bus master in master rx"); return (IIC_ESTATUS); } if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { - DEBUG("slave nack in rx"); + GLXIIC_DEBUG_LOG("slave nack in rx"); return (IIC_ENOACK); } @@ -825,7 +826,7 @@ glxiic_state_master_rx_callback(struct glxiic_softc *sc, uint8_t status) } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("no pending data in master rx"); + GLXIIC_DEBUG_LOG("no pending data in master rx"); return (IIC_ESTATUS); } @@ -849,17 +850,17 @@ glxiic_state_master_stop_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in master stop"); + GLXIIC_DEBUG_LOG("bus error in master stop"); return (IIC_EBUSERR); } if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { - DEBUG("not bus master in master stop"); + GLXIIC_DEBUG_LOG("not bus master in master stop"); return (IIC_ESTATUS); } if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { - DEBUG("slave nack in master stop"); + GLXIIC_DEBUG_LOG("slave nack in master stop"); return (IIC_ENOACK); } From 6e81b75a3c19afa344e6c0686166858de8af56ee Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Sun, 15 May 2011 20:03:54 +0000 Subject: [PATCH 023/200] Add a sysctl kern.geom.part.check_integrity for those who has corrupt partition tables and lost an ability to boot after r221788. Also unhide an error message from bootverbose, this would help to easier determine the problem. --- sys/geom/part/g_part.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index aa5444e3c8f4..c9ff9c0a2254 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -104,6 +105,13 @@ struct g_part_alias_list { { "netbsd-swap", G_PART_ALIAS_NETBSD_SWAP }, }; +SYSCTL_DECL(_kern_geom); +SYSCTL_NODE(_kern_geom, OID_AUTO, part, CTLFLAG_RW, 0, "GEOM_PART stuff"); +static u_int check_integrity = 1; +TUNABLE_INT("kern.geom.part.check_integrity", &check_integrity); +SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity, CTLFLAG_RW, + &check_integrity, 1, "Enable integrity checking"); + /* * The GEOM partitioning class. */ @@ -267,9 +275,12 @@ g_part_check_integrity(struct g_part_table *table, struct g_consumer *cp) } return (0); fail: - if (bootverbose) - printf("GEOM_PART: integrity check failed (%s, %s)\n", - pp->name, table->gpt_scheme->name); + printf("GEOM_PART: integrity check failed (%s, %s)\n", pp->name, + table->gpt_scheme->name); + if (check_integrity == 0) { + table->gpt_corrupt = 1; + return (0); + } return (EINVAL); } From 1f3765902ce180e571939880f99afd9b4d290b7b Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Sun, 15 May 2011 20:52:43 +0000 Subject: [PATCH 024/200] Change the sysctl naming for the old and new NFS clients to vfs.oldnfs.xxx and vfs.nfs.xxx respectively. This makes the default nfs client use vfs.nfs.xxx after r221124. --- sys/fs/nfs/nfs_commonkrpc.c | 12 ++++++------ sys/fs/nfs/nfs_commonport.c | 10 ++++------ sys/fs/nfsclient/nfs_clkrpc.c | 2 -- sys/fs/nfsclient/nfs_clnfsiod.c | 12 ++++++------ sys/fs/nfsclient/nfs_clsubs.c | 4 ++-- sys/fs/nfsclient/nfs_clvfsops.c | 16 +++++++--------- sys/fs/nfsclient/nfs_clvnops.c | 18 +++++++++--------- sys/nfs/nfs_common.c | 2 +- sys/nfsclient/nfs_krpc.c | 10 +++++----- sys/nfsclient/nfs_nfsiod.c | 12 ++++++------ sys/nfsclient/nfs_subs.c | 4 ++-- sys/nfsclient/nfs_vfsops.c | 18 +++++++++--------- sys/nfsclient/nfs_vnops.c | 18 +++++++++--------- usr.bin/nfsstat/nfsstat.c | 4 ++-- 14 files changed, 68 insertions(+), 74 deletions(-) diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 8b5f3910900d..ba1ac4efbb4b 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -78,17 +78,17 @@ static int nfs3_jukebox_delay = 10; static int nfs_skip_wcc_data_onerr = 1; static int nfs_keytab_enctype = ETYPE_DES_CBC_CRC; -SYSCTL_DECL(_vfs_newnfs); +SYSCTL_DECL(_vfs_nfs); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "Buffer reservation size 2 < x < 64"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0, "Number of times the nfs client has had to reconnect"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, &nfs3_jukebox_delay, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, &nfs3_jukebox_delay, 0, "Number of seconds to delay a retry after receiving EJUKEBOX"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, &nfs_skip_wcc_data_onerr, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, &nfs_skip_wcc_data_onerr, 0, "Disable weak cache consistency checking when server returns an error"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, keytab_enctype, CTLFLAG_RW, &nfs_keytab_enctype, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, keytab_enctype, CTLFLAG_RW, &nfs_keytab_enctype, 0, "Encryption type for the keytab entry used by nfs"); static void nfs_down(struct nfsmount *, struct thread *, const char *, diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index ee37cbc18a08..62549158870d 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -69,14 +69,12 @@ void (*ncl_call_invalcaches)(struct vnode *) = NULL; static int nfs_realign_test; static int nfs_realign_count; -SYSCTL_NODE(_vfs, OID_AUTO, newnfs, CTLFLAG_RW, 0, "New NFS filesystem"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, +SYSCTL_NODE(_vfs, OID_AUTO, nfs, CTLFLAG_RW, 0, "New NFS filesystem"); +SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, 0, "Number of realign tests done"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, +SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, 0, "Number of mbuf realignments done"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs4acl_enable, CTLFLAG_RW, &nfsrv_useacl, - 0, "Enable NFSv4 ACLs"); -SYSCTL_STRING(_vfs_newnfs, OID_AUTO, callback_addr, CTLFLAG_RW, +SYSCTL_STRING(_vfs_nfs, OID_AUTO, callback_addr, CTLFLAG_RW, nfsv4_callbackaddr, sizeof(nfsv4_callbackaddr), "NFSv4 callback addr for server to use"); diff --git a/sys/fs/nfsclient/nfs_clkrpc.c b/sys/fs/nfsclient/nfs_clkrpc.c index 1b6734d74f5b..c4f7e94c103c 100644 --- a/sys/fs/nfsclient/nfs_clkrpc.c +++ b/sys/fs/nfsclient/nfs_clkrpc.c @@ -46,8 +46,6 @@ __FBSDID("$FreeBSD$"); NFSDLOCKMUTEX; -SYSCTL_DECL(_vfs_newnfs); - SVCPOOL *nfscbd_pool; static int nfs_cbproc(struct nfsrv_descript *, u_int32_t); diff --git a/sys/fs/nfsclient/nfs_clnfsiod.c b/sys/fs/nfsclient/nfs_clnfsiod.c index 7ee19ad0fd02..0f1810fe00c4 100644 --- a/sys/fs/nfsclient/nfs_clnfsiod.c +++ b/sys/fs/nfsclient/nfs_clnfsiod.c @@ -80,11 +80,11 @@ static void nfssvc_iod(void *); static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON]; -SYSCTL_DECL(_vfs_newnfs); +SYSCTL_DECL(_vfs_nfs); /* Maximum number of seconds a nfsiod kthread will sleep before exiting */ static unsigned int nfs_iodmaxidle = 120; -SYSCTL_UINT(_vfs_newnfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0, +SYSCTL_UINT(_vfs_nfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0, "Max number of seconds an nfsiod kthread will sleep before exiting"); /* Maximum number of nfsiod kthreads */ @@ -123,7 +123,7 @@ sysctl_iodmin(SYSCTL_HANDLER_ARGS) mtx_unlock(&ncl_iod_mutex); return (0); } -SYSCTL_PROC(_vfs_newnfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0, +SYSCTL_PROC(_vfs_nfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof (nfs_iodmin), sysctl_iodmin, "IU", "Min number of nfsiod kthreads to keep as spares"); @@ -159,7 +159,7 @@ sysctl_iodmax(SYSCTL_HANDLER_ARGS) mtx_unlock(&ncl_iod_mutex); return (0); } -SYSCTL_PROC(_vfs_newnfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, +SYSCTL_PROC(_vfs_nfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof (ncl_iodmax), sysctl_iodmax, "IU", "Max number of nfsiod kthreads"); @@ -214,7 +214,7 @@ nfsiod_setup(void *dummy) { int error; - TUNABLE_INT_FETCH("vfs.newnfs.iodmin", &nfs_iodmin); + TUNABLE_INT_FETCH("vfs.nfs.iodmin", &nfs_iodmin); nfscl_init(); mtx_lock(&ncl_iod_mutex); /* Silently limit the start number of nfsiod's */ @@ -231,7 +231,7 @@ nfsiod_setup(void *dummy) SYSINIT(newnfsiod, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, nfsiod_setup, NULL); static int nfs_defect = 0; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, "Allow nfsiods to migrate serving different mounts"); /* diff --git a/sys/fs/nfsclient/nfs_clsubs.c b/sys/fs/nfsclient/nfs_clsubs.c index 7bff646a6e49..0c0563150ee0 100644 --- a/sys/fs/nfsclient/nfs_clsubs.c +++ b/sys/fs/nfsclient/nfs_clsubs.c @@ -174,9 +174,9 @@ ncl_printf(const char *fmt, ...) #ifdef NFS_ACDEBUG #include -SYSCTL_DECL(_vfs_newnfs); +SYSCTL_DECL(_vfs_nfs); static int nfs_acdebug; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, ""); #endif /* diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index b11160be6fcd..b062d2cd46c6 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -83,18 +83,16 @@ extern struct nfsstats newnfsstats; MALLOC_DEFINE(M_NEWNFSREQ, "newnfsclient_req", "New NFS request header"); MALLOC_DEFINE(M_NEWNFSMNT, "newnfsmnt", "New NFS mount struct"); -SYSCTL_DECL(_vfs_newnfs); -SYSCTL_STRUCT(_vfs_newnfs, NFS_NFSSTATS, nfsstats, CTLFLAG_RW, - &newnfsstats, nfsstats, "S,nfsstats"); +SYSCTL_DECL(_vfs_nfs); static int nfs_ip_paranoia = 1; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs_ip_paranoia, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_ip_paranoia, CTLFLAG_RW, &nfs_ip_paranoia, 0, ""); static int nfs_tprintf_initial_delay = NFS_TPRINTF_INITIAL_DELAY; -SYSCTL_INT(_vfs_newnfs, NFS_TPRINTF_INITIAL_DELAY, +SYSCTL_INT(_vfs_nfs, NFS_TPRINTF_INITIAL_DELAY, downdelayinitial, CTLFLAG_RW, &nfs_tprintf_initial_delay, 0, ""); /* how long between console messages "nfs server foo not responding" */ static int nfs_tprintf_delay = NFS_TPRINTF_DELAY; -SYSCTL_INT(_vfs_newnfs, NFS_TPRINTF_DELAY, +SYSCTL_INT(_vfs_nfs, NFS_TPRINTF_DELAY, downdelayinterval, CTLFLAG_RW, &nfs_tprintf_delay, 0, ""); static int nfs_mountroot(struct mount *); @@ -152,14 +150,14 @@ struct nfsv3_diskless nfsv3_diskless = { { { 0 } } }; int nfs_diskless_valid = 0; #endif -SYSCTL_INT(_vfs_newnfs, OID_AUTO, diskless_valid, CTLFLAG_RD, +SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD, &nfs_diskless_valid, 0, "Has the diskless struct been filled correctly"); -SYSCTL_STRING(_vfs_newnfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, +SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, nfsv3_diskless.root_hostnam, 0, "Path to nfs root"); -SYSCTL_OPAQUE(_vfs_newnfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, +SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, &nfsv3_diskless.root_saddr, sizeof(nfsv3_diskless.root_saddr), "%Ssockaddr_in", "Diskless root nfs address"); diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 6dc709fc9ce4..eac9eaa4c19f 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -199,27 +199,27 @@ static int nfs_renameit(struct vnode *sdvp, struct vnode *svp, */ #define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) -SYSCTL_DECL(_vfs_newnfs); +SYSCTL_DECL(_vfs_nfs); static int nfsaccess_cache_timeout = NFS_MAXATTRTIMO; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, &nfsaccess_cache_timeout, 0, "NFS ACCESS cache timeout"); static int nfs_prime_access_cache = 0; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, prime_access_cache, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, prime_access_cache, CTLFLAG_RW, &nfs_prime_access_cache, 0, "Prime NFS ACCESS cache when fetching attributes"); static int newnfs_commit_on_close = 0; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, commit_on_close, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, commit_on_close, CTLFLAG_RW, &newnfs_commit_on_close, 0, "write+commit on close, else only write"); static int nfs_clean_pages_on_close = 1; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, clean_pages_on_close, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, clean_pages_on_close, CTLFLAG_RW, &nfs_clean_pages_on_close, 0, "NFS clean dirty pages on close"); int newnfs_directio_enable = 0; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, &newnfs_directio_enable, 0, "Enable NFS directio"); /* @@ -234,14 +234,14 @@ SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, * meaningful. */ int newnfs_directio_allow_mmap = 1; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, &newnfs_directio_allow_mmap, 0, "Enable mmaped IO on file with O_DIRECT opens"); #if 0 -SYSCTL_INT(_vfs_newnfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, +SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, &newnfsstats.accesscache_hits, 0, "NFS ACCESS cache hit count"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, +SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, &newnfsstats.accesscache_misses, 0, "NFS ACCESS cache miss count"); #endif diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c index c56f31f9331a..09dbfabed320 100644 --- a/sys/nfs/nfs_common.c +++ b/sys/nfs/nfs_common.c @@ -361,7 +361,7 @@ nfsm_adv_xx(int s, struct mbuf **md, caddr_t *dpos) * * We would prefer to avoid this situation entirely. The situation does not * occur with NFS/UDP and is supposed to only occassionally occur with TCP. - * Use vfs.nfs.realign_count and realign_test to check this. + * Use vfs.nfs_common.realign_count and realign_test to check this. */ int nfs_realign(struct mbuf **pm, int how) diff --git a/sys/nfsclient/nfs_krpc.c b/sys/nfsclient/nfs_krpc.c index bfb1ea177eff..242d42521f38 100644 --- a/sys/nfsclient/nfs_krpc.c +++ b/sys/nfsclient/nfs_krpc.c @@ -93,16 +93,16 @@ static int nfs3_jukebox_delay = 10; static int nfs_skip_wcc_data_onerr = 1; static int fake_wchan; -SYSCTL_DECL(_vfs_nfs); +SYSCTL_DECL(_vfs_oldnfs); -SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "Buffer reservation size 2 < x < 64"); -SYSCTL_INT(_vfs_nfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0, "Number of times the nfs client has had to reconnect"); -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, &nfs3_jukebox_delay, 0, "Number of seconds to delay a retry after receiving EJUKEBOX"); -SYSCTL_INT(_vfs_nfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, &nfs_skip_wcc_data_onerr, 0, "Disable weak cache consistency checking when server returns an error"); diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c index fcb987e57677..d34c205a48e5 100644 --- a/sys/nfsclient/nfs_nfsiod.c +++ b/sys/nfsclient/nfs_nfsiod.c @@ -78,11 +78,11 @@ static void nfssvc_iod(void *); static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON]; -SYSCTL_DECL(_vfs_nfs); +SYSCTL_DECL(_vfs_oldnfs); /* Maximum number of seconds a nfsiod kthread will sleep before exiting */ static unsigned int nfs_iodmaxidle = 120; -SYSCTL_UINT(_vfs_nfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0, +SYSCTL_UINT(_vfs_oldnfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0, "Max number of seconds an nfsiod kthread will sleep before exiting"); /* Maximum number of nfsiod kthreads */ @@ -121,7 +121,7 @@ sysctl_iodmin(SYSCTL_HANDLER_ARGS) mtx_unlock(&nfs_iod_mtx); return (0); } -SYSCTL_PROC(_vfs_nfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0, +SYSCTL_PROC(_vfs_oldnfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof (nfs_iodmin), sysctl_iodmin, "IU", "Min number of nfsiod kthreads to keep as spares"); @@ -158,7 +158,7 @@ sysctl_iodmax(SYSCTL_HANDLER_ARGS) mtx_unlock(&nfs_iod_mtx); return (0); } -SYSCTL_PROC(_vfs_nfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, +SYSCTL_PROC(_vfs_oldnfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof (nfs_iodmax), sysctl_iodmax, "IU", "Max number of nfsiod kthreads"); @@ -213,7 +213,7 @@ nfsiod_setup(void *dummy) { int error; - TUNABLE_INT_FETCH("vfs.nfs.iodmin", &nfs_iodmin); + TUNABLE_INT_FETCH("vfs.oldnfs.iodmin", &nfs_iodmin); mtx_lock(&nfs_iod_mtx); /* Silently limit the start number of nfsiod's */ if (nfs_iodmin > NFS_MAXASYNCDAEMON) @@ -229,7 +229,7 @@ nfsiod_setup(void *dummy) SYSINIT(nfsiod, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, nfsiod_setup, NULL); static int nfs_defect = 0; -SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, "Allow nfsiods to migrate serving different mounts"); /* diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c index fe4f5cc545a1..19fde06dab07 100644 --- a/sys/nfsclient/nfs_subs.c +++ b/sys/nfsclient/nfs_subs.c @@ -653,9 +653,9 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp, #ifdef NFS_ACDEBUG #include -SYSCTL_DECL(_vfs_nfs); +SYSCTL_DECL(_vfs_oldnfs); static int nfs_acdebug; -SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "Toggle acdebug (attribute cache debug) flag"); #endif diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index ba3f41d5552f..04fd37500669 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -90,25 +90,25 @@ uma_zone_t nfsmount_zone; struct nfsstats nfsstats; -SYSCTL_NODE(_vfs, OID_AUTO, nfs, CTLFLAG_RW, 0, "NFS filesystem"); -SYSCTL_STRUCT(_vfs_nfs, NFS_NFSSTATS, nfsstats, CTLFLAG_RW, +SYSCTL_NODE(_vfs, OID_AUTO, oldnfs, CTLFLAG_RW, 0, "Old NFS filesystem"); +SYSCTL_STRUCT(_vfs_oldnfs, NFS_NFSSTATS, nfsstats, CTLFLAG_RW, &nfsstats, nfsstats, "S,nfsstats"); static int nfs_ip_paranoia = 1; -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_ip_paranoia, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs_ip_paranoia, CTLFLAG_RW, &nfs_ip_paranoia, 0, "Disallow accepting replies from IPs which differ from those sent"); #ifdef NFS_DEBUG int nfs_debug; -SYSCTL_INT(_vfs_nfs, OID_AUTO, debug, CTLFLAG_RW, &nfs_debug, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, debug, CTLFLAG_RW, &nfs_debug, 0, "Toggle debug flag"); #endif static int nfs_tprintf_initial_delay = NFS_TPRINTF_INITIAL_DELAY; -SYSCTL_INT(_vfs_nfs, NFS_TPRINTF_INITIAL_DELAY, +SYSCTL_INT(_vfs_oldnfs, NFS_TPRINTF_INITIAL_DELAY, downdelayinitial, CTLFLAG_RW, &nfs_tprintf_initial_delay, 0, "Delay before printing \"nfs server not responding\" messages"); /* how long between console messages "nfs server foo not responding" */ static int nfs_tprintf_delay = NFS_TPRINTF_DELAY; -SYSCTL_INT(_vfs_nfs, NFS_TPRINTF_DELAY, +SYSCTL_INT(_vfs_oldnfs, NFS_TPRINTF_DELAY, downdelayinterval, CTLFLAG_RW, &nfs_tprintf_delay, 0, "Delay between printing \"nfs server not responding\" messages"); @@ -176,14 +176,14 @@ struct nfsv3_diskless nfsv3_diskless = { { { 0 } } }; int nfs_diskless_valid = 0; #endif -SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, diskless_valid, CTLFLAG_RD, &nfs_diskless_valid, 0, "Has the diskless struct been filled correctly"); -SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, +SYSCTL_STRING(_vfs_oldnfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, nfsv3_diskless.root_hostnam, 0, "Path to nfs root"); -SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, +SYSCTL_OPAQUE(_vfs_oldnfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, &nfsv3_diskless.root_saddr, sizeof nfsv3_diskless.root_saddr, "%Ssockaddr_in", "Diskless root nfs address"); diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index fb3a746c9461..61fcb6c5714f 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -217,27 +217,27 @@ struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON]; int nfs_numasync = 0; #define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) -SYSCTL_DECL(_vfs_nfs); +SYSCTL_DECL(_vfs_oldnfs); static int nfsaccess_cache_timeout = NFS_MAXATTRTIMO; -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, &nfsaccess_cache_timeout, 0, "NFS ACCESS cache timeout"); static int nfs_prime_access_cache = 0; -SYSCTL_INT(_vfs_nfs, OID_AUTO, prime_access_cache, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, prime_access_cache, CTLFLAG_RW, &nfs_prime_access_cache, 0, "Prime NFS ACCESS cache when fetching attributes"); static int nfsv3_commit_on_close = 0; -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfsv3_commit_on_close, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfsv3_commit_on_close, CTLFLAG_RW, &nfsv3_commit_on_close, 0, "write+commit on close, else only write"); static int nfs_clean_pages_on_close = 1; -SYSCTL_INT(_vfs_nfs, OID_AUTO, clean_pages_on_close, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, clean_pages_on_close, CTLFLAG_RW, &nfs_clean_pages_on_close, 0, "NFS clean dirty pages on close"); int nfs_directio_enable = 0; -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, &nfs_directio_enable, 0, "Enable NFS directio"); /* @@ -252,14 +252,14 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, * meaningful. */ int nfs_directio_allow_mmap = 1; -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, &nfs_directio_allow_mmap, 0, "Enable mmaped IO on file with O_DIRECT opens"); #if 0 -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, &nfsstats.accesscache_hits, 0, "NFS ACCESS cache hit count"); -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, &nfsstats.accesscache_misses, 0, "NFS ACCESS cache miss count"); #endif diff --git a/usr.bin/nfsstat/nfsstat.c b/usr.bin/nfsstat/nfsstat.c index b833123ef622..b8f29e66bf6b 100644 --- a/usr.bin/nfsstat/nfsstat.c +++ b/usr.bin/nfsstat/nfsstat.c @@ -221,10 +221,10 @@ readstats(struct nfsstats **stp, struct nfsrvstats **srvstp, int zero) if (zero) bzero(&zerostat, sizeof(zerostat)); buflen = sizeof(struct nfsstats); - if (*stp != NULL && sysctlbyname("vfs.nfs.nfsstats", *stp, + if (*stp != NULL && sysctlbyname("vfs.oldnfs.nfsstats", *stp, &buflen, zero ? &zerostat : NULL, zero ? buflen : 0) < 0) { if (errno != ENOENT) - err(1, "sysctl: vfs.nfs.nfsstats"); + err(1, "sysctl: vfs.oldnfs.nfsstats"); *stp = NULL; } buflen = sizeof(struct nfsrvstats); From 463a7e27bf8fc0a954a793c37e1ee6322ddd8fdc Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Sun, 15 May 2011 21:44:51 +0000 Subject: [PATCH 025/200] Correctly disable jumbo frame support for BCM5719 A0. --- sys/dev/bge/if_bge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 3d725fcc4f9a..0f87eb0ba5f5 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -2836,7 +2836,7 @@ bge_attach(device_t dev) if (sc->bge_asicrev == BGE_ASICREV_BCM5719 && sc->bge_chipid == BGE_CHIPID_BCM5719_A0) { /* Jumbo frame on BCM5719 A0 does not work. */ - sc->bge_flags &= ~BGE_FLAG_JUMBO_FRAME; + sc->bge_flags &= ~BGE_FLAG_JUMBO; } break; case BGE_ASICREV_BCM5755: From 258ef734e711e866a0030c182643c873a5e53930 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 15 May 2011 22:09:27 +0000 Subject: [PATCH 026/200] sh: Minor optimization to output from ulimit/export/readonly. No functional change is intended. --- bin/sh/miscbltin.c | 4 ++-- bin/sh/var.c | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c index dc200b6d566e..fce13b5c147d 100644 --- a/bin/sh/miscbltin.c +++ b/bin/sh/miscbltin.c @@ -465,7 +465,7 @@ ulimitcmd(int argc __unused, char **argv __unused) "(-%c) ", l->option); out1fmt("%-18s %18s ", l->name, optbuf); if (val == RLIM_INFINITY) - out1fmt("unlimited\n"); + out1str("unlimited\n"); else { val /= l->factor; @@ -491,7 +491,7 @@ ulimitcmd(int argc __unused, char **argv __unused) val = limit.rlim_max; if (val == RLIM_INFINITY) - out1fmt("unlimited\n"); + out1str("unlimited\n"); else { val /= l->factor; diff --git a/bin/sh/var.c b/bin/sh/var.c index 84b6dea66d4c..f6d7fb1c1aa0 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -681,14 +681,13 @@ exportcmd(int argc, char **argv) out1str(cmdname); out1c(' '); } - p = strchr(vp->text, '='); if (values && !(vp->flags & VUNSET)) { - p++; - outbin(vp->text, p - vp->text, - out1); - out1qstr(p); + outbin(vp->text, + vp->name_len + 1, out1); + out1qstr(vp->text + + vp->name_len + 1); } else - outbin(vp->text, p - vp->text, + outbin(vp->text, vp->name_len, out1); out1c('\n'); } From ed3f96b28e197dcfa65db753803f2b1f4b5cc1a7 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Sun, 15 May 2011 22:46:45 +0000 Subject: [PATCH 027/200] Fix the nfsv4 man page to reflect the changes related to making the new NFS client and server the default. This is a content change. --- usr.sbin/nfsd/nfsv4.4 | 54 ++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/usr.sbin/nfsd/nfsv4.4 b/usr.sbin/nfsd/nfsv4.4 index 071a646814e4..ba855d20e05f 100644 --- a/usr.sbin/nfsd/nfsv4.4 +++ b/usr.sbin/nfsd/nfsv4.4 @@ -24,14 +24,14 @@ .\" .\" $FreeBSD$ .\" -.Dd April 10, 2011 +.Dd May 15, 2011 .Dt NFSV4 4 .Os .Sh NAME .Nm NFSv4 .Nd NFS Version 4 Protocol .Sh DESCRIPTION -The experimental NFS client and server provides support for the +The NFS client and server provides support for the .Tn NFSv4 specification; see .%T "Network File System (NFS) Version 4 Protocol RFC 3530" . @@ -153,27 +153,11 @@ with RPCSEC_GSS (sec=krb5, krb5i, krb5p), only names and KerberosV tickets will go on the wire. .Sh SERVER SETUP .Pp -To set up the experimental NFS server that supports +To set up the NFS server that supports .Nm , -you will need to either build a kernel with: -.sp -.Bd -literal -offset indent -compact -options NFSD -.Ed -and not -.Bd -literal -offset indent -compact -options NFSSERVER -.Ed -.sp -or start -.Xr mountd 8 -and -.Xr nfsd 8 -with the ``-e'' option to force use of the experimental server. -The -.Xr nfsuserd 8 -daemon must also be running. -This will occur if +you will need to either set the variables in +.Xr rc.conf 5 +as follows: .sp .Bd -literal -offset indent -compact nfs_server_enable="YES" @@ -181,8 +165,14 @@ nfsv4_server_enable="YES" nfsuserd_enable="YES" .Ed .sp -are set in -.Xr rc.conf 5 . +or start +.Xr mountd 8 +and +.Xr nfsd 8 +without the ``-o'' option, which would force use of the old server. +The +.Xr nfsuserd 8 +daemon must also be running. .Pp You will also need to add at least one ``V4:'' line to the .Xr exports 5 @@ -196,7 +186,7 @@ there are a couple of .Xr sysctl 8 variables that you can change, which might improve performance. .Bl -tag -width Ds -.It Cm vfs.newnfs.issue_delegations +.It Cm vfs.nfsd.issue_delegations when set non-zero, allows the server to issue Open Delegations to clients. These delegations permit the client to manipulate the file @@ -208,7 +198,7 @@ This can only be enabled when the file systems being exported to clients are not being accessed locally on the server and, if being accessed via NFS Version 2 or 3 clients, these clients cannot be using the NLM. -.It Cm vfs.newnfs.enable_locallocks +.It Cm vfs.nfsd.enable_locallocks can be set to 0 to disable acquisition of local byte range locks. Disabling local locking can only be done if neither local accesses to the exported file systems nor the NLM is operating on them. @@ -217,7 +207,7 @@ to the exported file systems nor the NLM is operating on them. Note that Samba server access would be considered ``local access'' for the above discussion. .Pp -To build a kernel with the experimental +To build a kernel with the NFS server that supports .Nm linked into it, the .sp @@ -235,7 +225,9 @@ To do an mount, specify the ``nfsv4'' option on the .Xr mount_nfs 8 command line. -This will force use of the experimental client plus set ``tcp'' and +This will force use of the client that supports +.Nm +plus set ``tcp'' and .Nm . .Pp The @@ -269,16 +261,16 @@ To get callbacks to work when behind a NAT gateway, a port for the callback service will need to be set up on the NAT gateway and then the address of the NAT gateway (host IP plus port#) will need to be set by assigning the .Xr sysctl 8 -variable vfs.newnfs.callback_addr to a string of the form: +variable vfs.nfs.callback_addr to a string of the form: .sp N.N.N.N.N.N .sp where the first 4 Ns are the host IP address and the last two are the port# in network byte order (all decimal #s in the range 0-255). .Pp -To build a kernel with the experimental +To build a kernel with the client that supports .Nm -client linked into it, the option +linked into it, the option .sp .Bd -literal -offset indent -compact options NFSCL From 43db7b0eab8bcb9657ead61cbf8b60539f5c54fb Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Mon, 16 May 2011 03:32:40 +0000 Subject: [PATCH 028/200] Remove a useless check that served only to make 64-bit PPC systems unbootable after r221855. Submitted by: andreast MFC after: 1 week --- sys/powerpc/aim/mmu_oea64.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c index d20de530455b..c33a0941c396 100644 --- a/sys/powerpc/aim/mmu_oea64.c +++ b/sys/powerpc/aim/mmu_oea64.c @@ -1141,8 +1141,6 @@ moea64_zero_page_area(mmu_t mmu, vm_page_t m, int off, int size) { vm_offset_t pa = VM_PAGE_TO_PHYS(m); - if (!moea64_initialized) - panic("moea64_zero_page: can't zero pa %#" PRIxPTR, pa); if (size + off > PAGE_SIZE) panic("moea64_zero_page: size + off > PAGE_SIZE"); @@ -1165,9 +1163,6 @@ moea64_zero_page(mmu_t mmu, vm_page_t m) vm_offset_t pa = VM_PAGE_TO_PHYS(m); vm_offset_t va, off; - if (!moea64_initialized) - panic("moea64_zero_page: can't zero pa %#zx", pa); - if (!hw_direct_map) { mtx_lock(&moea64_scratchpage_mtx); From b6c4978f6f2d0e4b88cf8456d7a62aa461db448e Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Mon, 16 May 2011 12:00:32 +0000 Subject: [PATCH 029/200] Add diagnostic messages for integrity checks. --- sys/geom/part/g_part.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index c9ff9c0a2254..eaf24f960f13 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -245,6 +245,7 @@ g_part_check_integrity(struct g_part_table *table, struct g_consumer *cp) struct g_part_entry *e1, *e2; struct g_provider *pp; + e1 = e2 = NULL; pp = cp->provider; if (table->gpt_first > table->gpt_last || table->gpt_last > pp->mediasize / pp->sectorsize - 1) @@ -277,6 +278,25 @@ g_part_check_integrity(struct g_part_table *table, struct g_consumer *cp) fail: printf("GEOM_PART: integrity check failed (%s, %s)\n", pp->name, table->gpt_scheme->name); + if (bootverbose) { + if (e1 == NULL) + printf("GEOM_PART: invalid geom configuration:\n"); + else if (e2 == NULL) + printf("GEOM_PART: invalid partition entry:\n"); + else + printf("GEOM_PART: overlapped partition entries:\n"); + if (e1 != NULL) + printf("GEOM_PART: index: %d, start: %jd, end: %jd\n", + e1->gpe_index, + (intmax_t)e1->gpe_start, (intmax_t)e1->gpe_end); + if (e2 != NULL) + printf("GEOM_PART: index: %d, start: %jd, end: %jd\n", + e2->gpe_index, + (intmax_t)e2->gpe_start, (intmax_t)e2->gpe_end); + printf("GEOM_PART: first: %jd, last: %jd, sectors: %jd\n", + (intmax_t)table->gpt_first, (intmax_t)table->gpt_last, + (intmax_t)pp->mediasize / pp->sectorsize - 1); + } if (check_integrity == 0) { table->gpt_corrupt = 1; return (0); From e4301e1709722afc4fa75dec0747d37a01496061 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Mon, 16 May 2011 13:12:09 +0000 Subject: [PATCH 030/200] Fix a comment that got missed by r221973 which changed the sysctl naming for the old NFS client to vfs.oldnfs. --- sys/nfsclient/nfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/nfsclient/nfs.h b/sys/nfsclient/nfs.h index 99b86f85d7a2..22a291a0d89c 100644 --- a/sys/nfsclient/nfs.h +++ b/sys/nfsclient/nfs.h @@ -107,7 +107,7 @@ #endif /* - * vfs.nfs sysctl(3) identifiers + * vfs.oldnfs sysctl(3) identifiers */ #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ From 87065c6765505b3daf6bbb62033b89f511489379 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Mon, 16 May 2011 15:20:54 +0000 Subject: [PATCH 031/200] Fix a = pregions[i].mr_start) - && (addr + len < pregions[i].mr_start + pregions[i].mr_size)) + && (addr + len <= pregions[i].mr_start + pregions[i].mr_size)) return (0); return (EFAULT); From dd7498ae03a927ed2336ce8d4ad27a08c577cbbb Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Mon, 16 May 2011 15:29:59 +0000 Subject: [PATCH 032/200] better integrate cyclic module with clocksource/eventtimer subsystem Now in the case when one-shot timers are used cyclic events should fire closer to theier scheduled times. As the cyclic is currently used only to drive DTrace profile provider, this is the area where the change makes a difference. Reviewed by: mav (earlier version, a while ago) X-MFC after: clocksource/eventtimer subsystem --- sys/cddl/compat/opensolaris/sys/time.h | 2 +- sys/cddl/dev/cyclic/cyclic.c | 14 ++++- sys/cddl/dev/cyclic/i386/cyclic_machdep.c | 40 +++++++------ sys/kern/kern_clocksource.c | 73 +++++++++++++++++++---- sys/sys/dtrace_bsd.h | 9 +-- 5 files changed, 97 insertions(+), 41 deletions(-) diff --git a/sys/cddl/compat/opensolaris/sys/time.h b/sys/cddl/compat/opensolaris/sys/time.h index 05db50e57ef5..cd5e69579bfc 100644 --- a/sys/cddl/compat/opensolaris/sys/time.h +++ b/sys/cddl/compat/opensolaris/sys/time.h @@ -53,7 +53,7 @@ gethrtime(void) { struct timespec ts; hrtime_t nsec; - getnanouptime(&ts); + nanouptime(&ts); nsec = (hrtime_t)ts.tv_sec * NANOSEC + ts.tv_nsec; return (nsec); } diff --git a/sys/cddl/dev/cyclic/cyclic.c b/sys/cddl/dev/cyclic/cyclic.c index b9a6979924db..e7b7f50f1917 100644 --- a/sys/cddl/dev/cyclic/cyclic.c +++ b/sys/cddl/dev/cyclic/cyclic.c @@ -341,6 +341,16 @@ static cyc_backend_t cyclic_backend; MALLOC_DEFINE(M_CYCLIC, "cyclic", "Cyclic timer subsystem"); +static __inline hrtime_t +cyc_gethrtime(void) +{ + struct bintime bt; + + binuptime(&bt); + return ((hrtime_t)bt.sec * NANOSEC + + (((uint64_t)NANOSEC * (uint32_t)(bt.frac >> 32)) >> 32)); +} + /* * Returns 1 if the upheap propagated to the root, 0 if it did not. This * allows the caller to reprogram the backend only when the root has been @@ -507,7 +517,7 @@ cyclic_fire(cpu_t *c) cyc_index_t *heap = cpu->cyp_heap; cyclic_t *cyclic, *cyclics = cpu->cyp_cyclics; void *arg = be->cyb_arg; - hrtime_t now = gethrtime(); + hrtime_t now = cyc_gethrtime(); hrtime_t exp; if (cpu->cyp_nelems == 0) { @@ -687,7 +697,7 @@ cyclic_add_xcall(cyc_xcallarg_t *arg) * If a start time hasn't been explicitly specified, we'll * start on the next interval boundary. */ - cyclic->cy_expire = (gethrtime() / cyclic->cy_interval + 1) * + cyclic->cy_expire = (cyc_gethrtime() / cyclic->cy_interval + 1) * cyclic->cy_interval; } else { cyclic->cy_expire = when->cyt_when; diff --git a/sys/cddl/dev/cyclic/i386/cyclic_machdep.c b/sys/cddl/dev/cyclic/i386/cyclic_machdep.c index 1c18fc14e96c..6f9366316115 100644 --- a/sys/cddl/dev/cyclic/i386/cyclic_machdep.c +++ b/sys/cddl/dev/cyclic/i386/cyclic_machdep.c @@ -30,6 +30,7 @@ static void enable(cyb_arg_t); static void disable(cyb_arg_t); static void reprogram(cyb_arg_t, hrtime_t); static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *); +static void cyclic_clock(struct trapframe *frame); static cyc_backend_t be = { NULL, /* cyb_configure */ @@ -45,6 +46,7 @@ static void cyclic_ap_start(void *dummy) { /* Initialise the rest of the CPUs. */ + cyclic_clock_func = cyclic_clock; cyclic_mp_init(); } @@ -63,18 +65,10 @@ cyclic_machdep_init(void) static void cyclic_machdep_uninit(void) { - int i; - - for (i = 0; i <= mp_maxid; i++) - /* Reset the cyclic clock callback hook. */ - cyclic_clock_func[i] = NULL; - /* De-register the cyclic backend. */ cyclic_uninit(); } -static hrtime_t exp_due[MAXCPU]; - /* * This function is the one registered by the machine dependent * initialiser as the callback for high speed timer events. @@ -84,7 +78,7 @@ cyclic_clock(struct trapframe *frame) { cpu_t *c = &solaris_cpu[curcpu]; - if (c->cpu_cyclic != NULL && gethrtime() >= exp_due[curcpu]) { + if (c->cpu_cyclic != NULL) { if (TRAPF_USERMODE(frame)) { c->cpu_profile_pc = 0; c->cpu_profile_upc = TRAPF_PC(frame); @@ -102,26 +96,34 @@ cyclic_clock(struct trapframe *frame) } } -static void enable(cyb_arg_t arg) +static void +enable(cyb_arg_t arg __unused) { - /* Register the cyclic clock callback function. */ - cyclic_clock_func[curcpu] = cyclic_clock; + } -static void disable(cyb_arg_t arg) +static void +disable(cyb_arg_t arg __unused) { - /* Reset the cyclic clock callback function. */ - cyclic_clock_func[curcpu] = NULL; + } -static void reprogram(cyb_arg_t arg, hrtime_t exp) +static void +reprogram(cyb_arg_t arg __unused, hrtime_t exp) { - exp_due[curcpu] = exp; + struct bintime bt; + struct timespec ts; + + ts.tv_sec = exp / 1000000000; + ts.tv_nsec = exp % 1000000000; + timespec2bintime(&ts, &bt); + clocksource_cyc_set(&bt); } -static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param) +static void xcall(cyb_arg_t arg __unused, cpu_t *c, cyc_func_t func, + void *param) { - smp_rendezvous_cpus((cpumask_t) (1 << c->cpuid), + smp_rendezvous_cpus((cpumask_t)1 << c->cpuid, smp_no_rendevous_barrier, func, smp_no_rendevous_barrier, param); } diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index 604bd2d056f2..dd8bab5275e7 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); #ifdef KDTRACE_HOOKS #include -cyclic_clock_func_t cyclic_clock_func[MAXCPU]; +cyclic_clock_func_t cyclic_clock_func = NULL; #endif int cpu_disable_deep_sleep = 0; /* Timer dies in C3. */ @@ -128,6 +128,9 @@ struct pcpu_state { struct bintime nexthard; /* Next hardlock() event. */ struct bintime nextstat; /* Next statclock() event. */ struct bintime nextprof; /* Next profclock() event. */ +#ifdef KDTRACE_HOOKS + struct bintime nextcyc; /* Next OpenSolaris cyclics event. */ +#endif int ipi; /* This CPU needs IPI. */ int idle; /* This CPU is in idle mode. */ }; @@ -190,17 +193,10 @@ handleevents(struct bintime *now, int fake) usermode = TRAPF_USERMODE(frame); pc = TRAPF_PC(frame); } -#ifdef KDTRACE_HOOKS - /* - * If the DTrace hooks are configured and a callback function - * has been registered, then call it to process the high speed - * timers. - */ - if (!fake && cyclic_clock_func[curcpu] != NULL) - (*cyclic_clock_func[curcpu])(frame); -#endif + runs = 0; state = DPCPU_PTR(timerstate); + while (bintime_cmp(now, &state->nexthard, >=)) { bintime_add(&state->nexthard, &hardperiod); runs++; @@ -224,6 +220,16 @@ handleevents(struct bintime *now, int fake) } } else state->nextprof = state->nextstat; + +#ifdef KDTRACE_HOOKS + if (fake == 0 && cyclic_clock_func != NULL && + state->nextcyc.sec != -1 && + bintime_cmp(now, &state->nextcyc, >=)) { + state->nextcyc.sec = -1; + (*cyclic_clock_func)(frame); + } +#endif + getnextcpuevent(&t, 0); if (fake == 2) { state->nextevent = t; @@ -263,10 +269,13 @@ getnextcpuevent(struct bintime *event, int idle) } else { /* If CPU is active - handle all types of events. */ if (bintime_cmp(event, &state->nextstat, >)) *event = state->nextstat; - if (profiling && - bintime_cmp(event, &state->nextprof, >)) + if (profiling && bintime_cmp(event, &state->nextprof, >)) *event = state->nextprof; } +#ifdef KDTRACE_HOOKS + if (state->nextcyc.sec != -1 && bintime_cmp(event, &state->nextcyc, >)) + *event = state->nextcyc; +#endif } /* @@ -590,6 +599,9 @@ cpu_initclocks_bsp(void) CPU_FOREACH(cpu) { state = DPCPU_ID_PTR(cpu, timerstate); mtx_init(&state->et_hw_mtx, "et_hw_mtx", NULL, MTX_SPIN); +#ifdef KDTRACE_HOOKS + state->nextcyc.sec = -1; +#endif } #ifdef SMP callout_new_inserted = cpu_new_callout; @@ -784,6 +796,43 @@ cpu_activeclock(void) spinlock_exit(); } +#ifdef KDTRACE_HOOKS +void +clocksource_cyc_set(const struct bintime *t) +{ + struct bintime now; + struct pcpu_state *state; + + state = DPCPU_PTR(timerstate); + if (periodic) + now = state->now; + else + binuptime(&now); + + CTR4(KTR_SPARE2, "set_cyc at %d: now %d.%08x%08x", + curcpu, now.sec, (unsigned int)(now.frac >> 32), + (unsigned int)(now.frac & 0xffffffff)); + CTR4(KTR_SPARE2, "set_cyc at %d: t %d.%08x%08x", + curcpu, t->sec, (unsigned int)(t->frac >> 32), + (unsigned int)(t->frac & 0xffffffff)); + + ET_HW_LOCK(state); + if (bintime_cmp(t, &state->nextcyc, ==)) { + ET_HW_UNLOCK(state); + return; + } + state->nextcyc = *t; + if (bintime_cmp(&state->nextcyc, &state->nextevent, >=)) { + ET_HW_UNLOCK(state); + return; + } + state->nextevent = state->nextcyc; + if (!periodic) + loadtimer(&now, 0); + ET_HW_UNLOCK(state); +} +#endif + #ifdef SMP static void cpu_new_callout(int cpu, int ticks) diff --git a/sys/sys/dtrace_bsd.h b/sys/sys/dtrace_bsd.h index 2eded7b689a3..15e1be9d7616 100644 --- a/sys/sys/dtrace_bsd.h +++ b/sys/sys/dtrace_bsd.h @@ -44,14 +44,9 @@ struct reg; * subsystem into the appropriate timer interrupt. */ typedef void (*cyclic_clock_func_t)(struct trapframe *); +extern cyclic_clock_func_t cyclic_clock_func; -/* - * These external variables are actually machine-dependent, so - * they might not actually exist. - * - * Defining them here avoids a proliferation of header files. - */ -extern cyclic_clock_func_t cyclic_clock_func[]; +void clocksource_cyc_set(const struct bintime *t); /* * The dtrace module handles traps that occur during a DTrace probe. From 20208c3bf06a215068c2a7cf3d2aa91c1a6f5ef2 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Mon, 16 May 2011 15:36:11 +0000 Subject: [PATCH 033/200] Revert accidentally committed local change in r221990 Pointyhat to: avg --- sys/cddl/compat/opensolaris/sys/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/cddl/compat/opensolaris/sys/time.h b/sys/cddl/compat/opensolaris/sys/time.h index cd5e69579bfc..05db50e57ef5 100644 --- a/sys/cddl/compat/opensolaris/sys/time.h +++ b/sys/cddl/compat/opensolaris/sys/time.h @@ -53,7 +53,7 @@ gethrtime(void) { struct timespec ts; hrtime_t nsec; - nanouptime(&ts); + getnanouptime(&ts); nsec = (hrtime_t)ts.tv_sec * NANOSEC + ts.tv_nsec; return (nsec); } From d0c8ecb812f952a0e935f5e61cf755169dfef6ce Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Mon, 16 May 2011 15:59:50 +0000 Subject: [PATCH 034/200] Make diagnostic messages more specific. With bootverbose print out all inconsistencies of integrity in the partition table, not first found only. Requested by: kib --- sys/geom/part/g_part.c | 125 +++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 42 deletions(-) diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index eaf24f960f13..a3f857599f42 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -239,70 +239,111 @@ g_part_geometry(struct g_part_table *table, struct g_consumer *cp, } } +#define DPRINTF(...) if (bootverbose) { \ + printf("GEOM_PART: " __VA_ARGS__); \ +} + static int g_part_check_integrity(struct g_part_table *table, struct g_consumer *cp) { struct g_part_entry *e1, *e2; struct g_provider *pp; + int failed; - e1 = e2 = NULL; + failed = 0; pp = cp->provider; - if (table->gpt_first > table->gpt_last || - table->gpt_last > pp->mediasize / pp->sectorsize - 1) - goto fail; - + if (table->gpt_last < table->gpt_first) { + DPRINTF("last LBA is below first LBA: %jd < %jd\n", + (intmax_t)table->gpt_last, (intmax_t)table->gpt_first); + failed++; + } + if (table->gpt_last > pp->mediasize / pp->sectorsize - 1) { + DPRINTF("last LBA extends beyond mediasize: " + "%jd > %jd\n", (intmax_t)table->gpt_last, + (intmax_t)pp->mediasize / pp->sectorsize - 1); + failed++; + } LIST_FOREACH(e1, &table->gpt_entry, gpe_entry) { if (e1->gpe_deleted || e1->gpe_internal) continue; - if (e1->gpe_start < table->gpt_first || - e1->gpe_start > table->gpt_last || - e1->gpe_end < e1->gpe_start || - e1->gpe_end > table->gpt_last) - goto fail; + if (e1->gpe_start < table->gpt_first) { + DPRINTF("partition %d has start offset below first " + "LBA: %jd < %jd\n", e1->gpe_index, + (intmax_t)e1->gpe_start, + (intmax_t)table->gpt_first); + failed++; + } + if (e1->gpe_start > table->gpt_last) { + DPRINTF("partition %d has start offset beyond last " + "LBA: %jd > %jd\n", e1->gpe_index, + (intmax_t)e1->gpe_start, + (intmax_t)table->gpt_last); + failed++; + } + if (e1->gpe_end < e1->gpe_start) { + DPRINTF("partition %d has end offset below start " + "offset: %jd < %jd\n", e1->gpe_index, + (intmax_t)e1->gpe_end, + (intmax_t)e1->gpe_start); + failed++; + } + if (e1->gpe_end > table->gpt_last) { + DPRINTF("partition %d has end offset beyond last " + "LBA: %jd > %jd\n", e1->gpe_index, + (intmax_t)e1->gpe_end, + (intmax_t)table->gpt_last); + failed++; + } e2 = e1; while ((e2 = LIST_NEXT(e2, gpe_entry)) != NULL) { if (e2->gpe_deleted || e2->gpe_internal) continue; if (e1->gpe_start >= e2->gpe_start && - e1->gpe_start <= e2->gpe_end) - goto fail; + e1->gpe_start <= e2->gpe_end) { + DPRINTF("partition %d has start offset inside " + "partition %d: start[%d] %jd >= start[%d] " + "%jd <= end[%d] %jd\n", + e1->gpe_index, e2->gpe_index, + e2->gpe_index, (intmax_t)e2->gpe_start, + e1->gpe_index, (intmax_t)e1->gpe_start, + e2->gpe_index, (intmax_t)e2->gpe_end); + failed++; + } if (e1->gpe_end >= e2->gpe_start && - e1->gpe_end <= e2->gpe_end) - goto fail; + e1->gpe_end <= e2->gpe_end) { + DPRINTF("partition %d has end offset inside " + "partition %d: start[%d] %jd >= end[%d] " + "%jd <= end[%d] %jd\n", + e1->gpe_index, e2->gpe_index, + e2->gpe_index, (intmax_t)e2->gpe_start, + e1->gpe_index, (intmax_t)e1->gpe_end, + e2->gpe_index, (intmax_t)e2->gpe_end); + failed++; + } if (e1->gpe_start < e2->gpe_start && - e1->gpe_end > e2->gpe_end) - goto fail; + e1->gpe_end > e2->gpe_end) { + DPRINTF("partition %d contains partition %d: " + "start[%d] %jd > start[%d] %jd, end[%d] " + "%jd < end[%d] %jd\n", + e1->gpe_index, e2->gpe_index, + e1->gpe_index, (intmax_t)e1->gpe_start, + e2->gpe_index, (intmax_t)e2->gpe_start, + e2->gpe_index, (intmax_t)e2->gpe_end, + e1->gpe_index, (intmax_t)e1->gpe_end); + failed++; + } } } - return (0); -fail: - printf("GEOM_PART: integrity check failed (%s, %s)\n", pp->name, - table->gpt_scheme->name); - if (bootverbose) { - if (e1 == NULL) - printf("GEOM_PART: invalid geom configuration:\n"); - else if (e2 == NULL) - printf("GEOM_PART: invalid partition entry:\n"); - else - printf("GEOM_PART: overlapped partition entries:\n"); - if (e1 != NULL) - printf("GEOM_PART: index: %d, start: %jd, end: %jd\n", - e1->gpe_index, - (intmax_t)e1->gpe_start, (intmax_t)e1->gpe_end); - if (e2 != NULL) - printf("GEOM_PART: index: %d, start: %jd, end: %jd\n", - e2->gpe_index, - (intmax_t)e2->gpe_start, (intmax_t)e2->gpe_end); - printf("GEOM_PART: first: %jd, last: %jd, sectors: %jd\n", - (intmax_t)table->gpt_first, (intmax_t)table->gpt_last, - (intmax_t)pp->mediasize / pp->sectorsize - 1); - } - if (check_integrity == 0) { + if (failed != 0) { + printf("GEOM_PART: integrity check failed (%s, %s)\n", + pp->name, table->gpt_scheme->name); + if (check_integrity != 0) + return (EINVAL); table->gpt_corrupt = 1; - return (0); } - return (EINVAL); + return (0); } +#undef DPRINTF struct g_part_entry * g_part_new_entry(struct g_part_table *table, int index, quad_t start, From 71c2bc5c6b9427ee790022f35c57e43412814d4f Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Mon, 16 May 2011 16:18:40 +0000 Subject: [PATCH 035/200] Change the length quantities of sbufs to be ssize_t rather than int. Constify a couple of arguments. --- sys/kern/subr_sbuf.c | 16 +++++++++------- sys/sys/sbuf.h | 12 ++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index 0d083b4b33e9..793e17ec4ebb 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -94,7 +94,8 @@ _assert_sbuf_integrity(const char *fun, struct sbuf *s) KASSERT(s->s_buf != NULL, ("%s called with uninitialized or corrupt sbuf", fun)); KASSERT(s->s_len < s->s_size, - ("wrote past end of sbuf (%d >= %d)", s->s_len, s->s_size)); + ("wrote past end of sbuf (%jd >= %jd)", + (intmax_t)s->s_len, (intmax_t)s->s_size)); } static void @@ -255,16 +256,17 @@ sbuf_clear(struct sbuf *s) * Effectively truncates the sbuf at the new position. */ int -sbuf_setpos(struct sbuf *s, int pos) +sbuf_setpos(struct sbuf *s, ssize_t pos) { assert_sbuf_integrity(s); assert_sbuf_state(s, 0); KASSERT(pos >= 0, - ("attempt to seek to a negative position (%d)", pos)); + ("attempt to seek to a negative position (%jd)", (intmax_t)pos)); KASSERT(pos < s->s_size, - ("attempt to seek past end of sbuf (%d >= %d)", pos, s->s_size)); + ("attempt to seek past end of sbuf (%jd >= %jd)", + (intmax_t)pos, (intmax_t)s->s_size)); if (pos < 0 || pos > s->s_len) return (-1); @@ -640,7 +642,7 @@ sbuf_trim(struct sbuf *s) * Check if an sbuf has an error. */ int -sbuf_error(struct sbuf *s) +sbuf_error(const struct sbuf *s) { return (s->s_error); @@ -691,7 +693,7 @@ sbuf_data(struct sbuf *s) /* * Return the length of the sbuf data. */ -int +ssize_t sbuf_len(struct sbuf *s) { @@ -728,7 +730,7 @@ sbuf_delete(struct sbuf *s) * Check if an sbuf has been finished. */ int -sbuf_done(struct sbuf *s) +sbuf_done(const struct sbuf *s) { return (SBUF_ISFINISHED(s)); diff --git a/sys/sys/sbuf.h b/sys/sys/sbuf.h index eeb38140da52..2a9cb0e9c1f0 100644 --- a/sys/sys/sbuf.h +++ b/sys/sys/sbuf.h @@ -44,8 +44,8 @@ struct sbuf { sbuf_drain_func *s_drain_func; /* drain function */ void *s_drain_arg; /* user-supplied drain argument */ int s_error; /* current error code */ - int s_size; /* size of storage buffer */ - int s_len; /* current length of string */ + ssize_t s_size; /* size of storage buffer */ + ssize_t s_len; /* current length of string */ #define SBUF_FIXEDLEN 0x00000000 /* fixed length buffer (default) */ #define SBUF_AUTOEXTEND 0x00000001 /* automatically extend buffer */ #define SBUF_USRFLAGMSK 0x0000ffff /* mask of flags the user may specify */ @@ -63,7 +63,7 @@ struct sbuf *sbuf_new(struct sbuf *, char *, int, int); #define sbuf_new_auto() \ sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND) void sbuf_clear(struct sbuf *); -int sbuf_setpos(struct sbuf *, int); +int sbuf_setpos(struct sbuf *, ssize_t); int sbuf_bcat(struct sbuf *, const void *, size_t); int sbuf_bcpy(struct sbuf *, const void *, size_t); int sbuf_cat(struct sbuf *, const char *); @@ -75,11 +75,11 @@ int sbuf_vprintf(struct sbuf *, const char *, __va_list) int sbuf_putc(struct sbuf *, int); void sbuf_set_drain(struct sbuf *, sbuf_drain_func *, void *); int sbuf_trim(struct sbuf *); -int sbuf_error(struct sbuf *); +int sbuf_error(const struct sbuf *); int sbuf_finish(struct sbuf *); char *sbuf_data(struct sbuf *); -int sbuf_len(struct sbuf *); -int sbuf_done(struct sbuf *); +ssize_t sbuf_len(struct sbuf *); +int sbuf_done(const struct sbuf *); void sbuf_delete(struct sbuf *); #ifdef _KERNEL From d59dd76c224fe6d8d156a02d5694f286fb3dbc1f Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Mon, 16 May 2011 23:20:12 +0000 Subject: [PATCH 036/200] Merge r221278 from largeSMP project: idle_cpus_mask is just used in sched_4bsd, thus make it private for it. Tested by: several --- sys/kern/sched_4bsd.c | 2 ++ sys/kern/subr_smp.c | 1 - sys/sys/smp.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 9424f73d2d80..668ecd165e52 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -155,6 +155,8 @@ static struct runq runq; */ static struct runq runq_pcpu[MAXCPU]; long runq_length[MAXCPU]; + +static cpumask_t idle_cpus_mask; #endif struct pcpuidlestat { diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 9ae63810f72b..aba6f0e1ea7e 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$"); #ifdef SMP volatile cpumask_t stopped_cpus; volatile cpumask_t started_cpus; -cpumask_t idle_cpus_mask; cpumask_t hlt_cpus_mask; cpumask_t logical_cpus_mask; diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 6104d3e22422..544cb9575f91 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -73,7 +73,6 @@ extern int smp_active; extern int smp_cpus; extern volatile cpumask_t started_cpus; extern volatile cpumask_t stopped_cpus; -extern cpumask_t idle_cpus_mask; extern cpumask_t hlt_cpus_mask; extern cpumask_t logical_cpus_mask; #endif /* SMP */ From 7c1b3c092065a2522eab5aec906676b4bb479fcf Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Mon, 16 May 2011 23:35:14 +0000 Subject: [PATCH 037/200] Merge r221279,221280 from largeSMP project: pmc_mask doesn't need to use memory barriers. Reviewed by: fabient Tested by: several MFC after: 1 week --- sys/dev/hwpmc/hwpmc_mod.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 4fa169c6b349..d6225d8f5ae3 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -4083,7 +4083,7 @@ pmc_process_interrupt(int cpu, struct pmc *pm, struct trapframe *tf, done: /* mark CPU as needing processing */ - atomic_set_rel_int(&pmc_cpumask, (1 << cpu)); + atomic_set_int(&pmc_cpumask, (1 << cpu)); return (error); } @@ -4193,7 +4193,7 @@ pmc_process_samples(int cpu) break; if (ps->ps_nsamples == PMC_SAMPLE_INUSE) { /* Need a rescan at a later time. */ - atomic_set_rel_int(&pmc_cpumask, (1 << cpu)); + atomic_set_int(&pmc_cpumask, (1 << cpu)); break; } @@ -4782,7 +4782,7 @@ pmc_cleanup(void) PMCDBG(MOD,INI,0, "%s", "cleanup"); /* switch off sampling */ - atomic_store_rel_int(&pmc_cpumask, 0); + pmc_cpumask = 0; pmc_intr = NULL; sx_xlock(&pmc_sx); From c43431465e547c3f81c10553710a2aaf6068301e Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Tue, 17 May 2011 00:40:11 +0000 Subject: [PATCH 038/200] Add missing header. The test for VLAN_CAPABILITIES later in the file doesn't make sense without it. MFC after: 3 days --- sys/dev/cxgbe/t4_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 929f31b06dee..e336566d3804 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "common/t4_hw.h" #include "common/common.h" From eb05ee7a71ff589e31ef69e6efae5009ee891d04 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 06:36:32 +0000 Subject: [PATCH 039/200] Don't expect PAGE_SIZE to exist on all platforms (It is a pretty arbitrary choice of default size in the first place) Reverse the order of arguments to the internal static sbuf_put_byte() function to match everything else in this file. Move sbuf_putc_func() inside the kernel version of sbuf_vprintf where it belongs. sbuf_putc() incorrectly used sbuf_putc_func() which supress NUL characters, it should use sbuf_put_byte(). Make sbuf_finish() return -1 on error. Minor stylistic nits fixed. --- sys/kern/subr_sbuf.c | 60 ++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index 793e17ec4ebb..bf4e73c0f03b 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -67,7 +67,7 @@ static MALLOC_DEFINE(M_SBUF, "sbuf", "string buffers"); #define SBUF_ISDYNSTRUCT(s) ((s)->s_flags & SBUF_DYNSTRUCT) #define SBUF_ISFINISHED(s) ((s)->s_flags & SBUF_FINISHED) #define SBUF_HASROOM(s) ((s)->s_len < (s)->s_size - 1) -#define SBUF_FREESPACE(s) ((s)->s_size - (s)->s_len - 1) +#define SBUF_FREESPACE(s) ((s)->s_size - ((s)->s_len + 1)) #define SBUF_CANEXTEND(s) ((s)->s_flags & SBUF_AUTOEXTEND) /* @@ -77,8 +77,14 @@ static MALLOC_DEFINE(M_SBUF, "sbuf", "string buffers"); #define SBUF_CLEARFLAG(s, f) do { (s)->s_flags &= ~(f); } while (0) #define SBUF_MINEXTENDSIZE 16 /* Should be power of 2. */ + +#ifdef PAGE_SIZE #define SBUF_MAXEXTENDSIZE PAGE_SIZE #define SBUF_MAXEXTENDINCR PAGE_SIZE +#else +#define SBUF_MAXEXTENDSIZE 4096 +#define SBUF_MAXEXTENDINCR 4096 +#endif /* * Debugging support @@ -328,7 +334,7 @@ sbuf_drain(struct sbuf *s) * buffer and marking overflow. */ static void -sbuf_put_byte(int c, struct sbuf *s) +sbuf_put_byte(struct sbuf *s, int c) { assert_sbuf_integrity(s); @@ -337,7 +343,7 @@ sbuf_put_byte(int c, struct sbuf *s) if (s->s_error != 0) return; if (SBUF_FREESPACE(s) <= 0) { - /* + /* * If there is a drain, use it, otherwise extend the * buffer. */ @@ -351,18 +357,6 @@ sbuf_put_byte(int c, struct sbuf *s) s->s_buf[s->s_len++] = c; } -/* - * Append a non-NUL character to an sbuf. This prototype signature is - * suitable for use with kvprintf(9). - */ -static void -sbuf_putc_func(int c, void *arg) -{ - - if (c != '\0') - sbuf_put_byte(c, arg); -} - /* * Append a byte string to an sbuf. */ @@ -378,10 +372,10 @@ sbuf_bcat(struct sbuf *s, const void *buf, size_t len) if (s->s_error != 0) return (-1); for (; str < end; str++) { - sbuf_put_byte(*str, s); + sbuf_put_byte(s, *str); if (s->s_error != 0) return (-1); - } + } return (0); } @@ -443,7 +437,7 @@ sbuf_cat(struct sbuf *s, const char *str) return (-1); while (*str != '\0') { - sbuf_put_byte(*str++, s); + sbuf_put_byte(s, *str++); if (s->s_error != 0) return (-1); } @@ -507,6 +501,19 @@ sbuf_cpy(struct sbuf *s, const char *str) * Format the given argument list and append the resulting string to an sbuf. */ #ifdef _KERNEL + +/* + * Append a non-NUL character to an sbuf. This prototype signature is + * suitable for use with kvprintf(9). + */ +static void +sbuf_putc_func(int c, void *arg) +{ + + if (c != '\0') + sbuf_put_byte(arg, c); +} + int sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap) { @@ -611,7 +618,7 @@ int sbuf_putc(struct sbuf *s, int c) { - sbuf_putc_func(c, s); + sbuf_put_byte(s, c); if (s->s_error != 0) return (-1); return (0); @@ -654,24 +661,23 @@ sbuf_error(const struct sbuf *s) int sbuf_finish(struct sbuf *s) { - int error; assert_sbuf_integrity(s); assert_sbuf_state(s, 0); - error = s->s_error; if (s->s_drain_func != NULL) { - while (s->s_len > 0 && error == 0) - error = sbuf_drain(s); + while (s->s_len > 0 && s->s_error == 0) + s->s_error = sbuf_drain(s); } s->s_buf[s->s_len] = '\0'; - s->s_error = 0; SBUF_SETFLAG(s, SBUF_FINISHED); #ifdef _KERNEL - return (error); + return (s->s_error); #else - errno = error; - return (-1); + errno = s->s_error; + if (s->s_error) + return (-1); + return (0); #endif } From 88492dfb20fb0b7c880af51ead18875f83e35731 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Tue, 17 May 2011 07:40:13 +0000 Subject: [PATCH 040/200] Remove redundant keywords. Submitted by: wxs --- etc/rc.d/ipfilter | 2 +- etc/rc.d/pf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/ipfilter b/etc/rc.d/ipfilter index fd1e99bbe08e..b6bdb4bcb2ef 100755 --- a/etc/rc.d/ipfilter +++ b/etc/rc.d/ipfilter @@ -23,7 +23,7 @@ resync_precmd="$stop_precmd" resync_cmd="ipfilter_resync" status_precmd="$stop_precmd" status_cmd="ipfilter_status" -extra_commands="reload resync status" +extra_commands="reload resync" required_modules="ipl:ipfilter" ipfilter_start() diff --git a/etc/rc.d/pf b/etc/rc.d/pf index 3426e90f413e..3180a2c51837 100755 --- a/etc/rc.d/pf +++ b/etc/rc.d/pf @@ -19,7 +19,7 @@ check_cmd="pf_check" reload_cmd="pf_reload" resync_cmd="pf_resync" status_cmd="pf_status" -extra_commands="check reload resync status" +extra_commands="check reload resync" required_files="$pf_rules" required_modules="pf" From b7f54343cc5c4e9c4c354fae11f18318420e5b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 08:12:59 +0000 Subject: [PATCH 041/200] Typos, wording and mdoc fixes. --- share/man/man4/geom_map.4 | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/share/man/man4/geom_map.4 b/share/man/man4/geom_map.4 index 3d65dcd7650b..36a5b419b661 100644 --- a/share/man/man4/geom_map.4 +++ b/share/man/man4/geom_map.4 @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm geom_map -.Nd "GEOM module that map difined items as separate partitions" +.Nd "GEOM module that maps defined items as separate partitions" .Sh SYNOPSIS To compile this driver into the kernel, place the following line in your @@ -41,16 +41,16 @@ kernel configuration file: .Sh DESCRIPTION The .Nm -framework provides support for mapping defined parts of the media. Basicaly it -is helpful in the embedded devices where in the one continous flash are loader, -kernel and rootfs parts. The +framework provides support for mapping defined parts of the media. +Basically it is helpful for embedded devices where in the one continuous +flash are loader, kernel and rootfs parts. .Nm -allows making them available as separate parts and protect loader from -overwriting. +allows making them available as separate parts and protects the loader from +being overwritten. .Pp At boot time .Nm -partitions listed (only with bootverbose) as: +partitions are listed (only with bootverbose) as: .Bd -literal -offset indent MAP: 0x30000, data=0x30000 "/dev/map/bootloader" MAP: 30000x10000, data=0x10000 "/dev/map/factory" @@ -62,10 +62,12 @@ MAP: 150000x690000, data=0x690000 "/dev/map/rootfs" MAP: 7e0000x20000, data=0x20000 "/dev/map/config" .Ed .Pp -Also +The current .Nm -current configuration can be accessible with sysctl's kern.geom.conftxt, -kern.geom.confxml, kern.geom.confdot or geom map list. +configuration can be accessed with the following +.Xr sysctl 8 +nodes: kern.geom.conftxt, kern.geom.confxml, and kern.geom.confdot +or by using "geom map list". .Bd -literal -offset indent # sysctl kern.geom.conftxt kern.geom.conftxt: 0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc @@ -84,7 +86,7 @@ Driver configuration can be done in device hints file. List of used parameters: .It Fa at select media to attach .It Fa name -name of partiton (will create device /dev/map/that_name) +name of partition (will create device /dev/map/that_name) .It Fa start offset from the beginning of the parent media to start of the mapped partition. This field can also have special value @@ -119,9 +121,7 @@ MAP: 150000x690000, data=0x690000 "/dev/map/rootfs" "map/rootfs" - new media will be accessible via /dev/map/rootfs dev. .Ed .Sh EXAMPLES -.Pp -.Bl -bullet -compact -If we need to implement layout shown above, we need to define the folowing +If we need to implement layout shown above, we need to define the following hints: .Bd -literal -offset indent hint.map.0.at="cfid0" @@ -129,8 +129,8 @@ hint.map.0.start=0x00000000 hint.map.0.end=0x00030000 hint.map.0.name="bootloader" hint.map.0.readonly=1 - .Ed +.Pp define "/dev/map/bootloader" at disk "cfid0" starting at 0x00000000 and end 0x00030000, also marked as readonly. .Bd -literal -offset indent @@ -148,8 +148,8 @@ hint.map.3.at="cfid0" hint.map.3.name="kernel" hint.map.3.start=0x00040000 hint.map.3.end="search:0x00100000:0x10000:.!/bin/sh" - .Ed +.Pp define "/dev/map/kernel" at disk "cfid0" starting at 0x00040000, but end position must be searched by the key ".!/bin/sh", from offset 0x00100000 to end of media with step 0x10000. Real marker in that case is "#!/bin/sh", but "#" @@ -166,7 +166,6 @@ hint.map.5.start=0x007e0000 hint.map.5.end=0x00800000 hint.map.5.name="config" .Ed -.El .Sh SEE ALSO .Xr GEOM 4 , .Xr geom 8 , From f93fa1cb17fcd1fa2b144205f3b67e5b7bddb7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 08:13:10 +0000 Subject: [PATCH 042/200] Typo fix. --- share/man/man4/cc_hd.4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man4/cc_hd.4 b/share/man/man4/cc_hd.4 index d761539d14dd..5c4c2deb92a4 100644 --- a/share/man/man4/cc_hd.4 +++ b/share/man/man4/cc_hd.4 @@ -98,7 +98,7 @@ Community Foundation Silicon Valley. .Sh FUTURE WORK The Hamilton Institute have recently made some improvements to the algorithm implemented by this module and have called it Coexistent-TCP (C-TCP). -The improvments should be evaluated and potentially incorporated into this +The improvements should be evaluated and potentially incorporated into this module. .Sh HISTORY The From 60134116ed3b7bd40cbd1310d2c5fddf1ee1e8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 08:13:18 +0000 Subject: [PATCH 043/200] Whitespace and typo fixes. Found by: codespell Reviewed by: ru --- share/misc/iso3166 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/share/misc/iso3166 b/share/misc/iso3166 index 70ca84f497bc..b01fe149a0a2 100644 --- a/share/misc/iso3166 +++ b/share/misc/iso3166 @@ -395,7 +395,7 @@ ZW ZWE 716 Zimbabwe # Newsletter III-41 1993-07-28 # MAURITIUS, changes outside this document # -# Newletter III-42 1993-07-12 +# Newsletter III-42 1993-07-12 # SAINT VINCENT AND THE GRENADINES, changes outside this document # # Newsletter III-43 1993-07-12 @@ -426,15 +426,15 @@ ZW ZWE 716 Zimbabwe # Czechoslovakia officially deleted # # Newsletter III-52, 1993-07-02 -# Angola, changing information not included in this file. Offical name +# Angola, changing information not included in this file. Official name # change to Republic of Angola # # Newsletter III-53, 1993-07-12 -# Madagascar, changing information not included in this file. Official +# Madagascar, changing information not included in this file. Official # name change to Republic of Madagascar # # Newsletter III-54, 1993-07-23 -# South Georgia and the South Sandwich Islands, previously covered by +# South Georgia and the South Sandwich Islands, previously covered by # Falkland Islands # # Newsletter III-55, 1993-07-16 @@ -450,23 +450,23 @@ ZW ZWE 716 Zimbabwe # # Newsletter III-58, 1993-07-16 # Afghanistan, changing information not included in this file -# Official name change to Islamic State of Afghanistan +# Official name change to Islamic State of Afghanistan # -# Newsletter III-32, 1993-07-25 ammendment -# Kyrgyzstan, changing information not included in this file. Offical name +# Newsletter III-32, 1993-07-25 amendment +# Kyrgyzstan, changing information not included in this file. Official name # change to Kyrgyz Republic # # Newsletter III-59, 1994-01-26 -# Andorra, changing information not included in this file. Offical name +# Andorra, changing information not included in this file. Official name # change to Pricipality of Andorra # # Newsletter III-60, 1994-01-26 -# Cambodia, changing information not included in this file. Offical name +# Cambodia, changing information not included in this file. Official name # change to Kingdom of Cambodia # # Thu Feb 10 1994 # At this point the fourth edition of ISO 3166 appears. It can *now* be -# ordered from national standards institutions. The RIPE NCC will continue +# ordered from national standards institutions. The RIPE NCC will continue # tracking changes. # # [deletia] From f8037af57c43cbb1bd4764bb15f33e902a9dd5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 08:13:27 +0000 Subject: [PATCH 044/200] ISO3166: Update for newsletters VI-7 and VI-8 from 2010 - Name change for SH - BQ, CW, and SX replace AN Reviewed by: ru --- share/misc/iso3166 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/share/misc/iso3166 b/share/misc/iso3166 index b01fe149a0a2..45c4d0ba70cc 100644 --- a/share/misc/iso3166 +++ b/share/misc/iso3166 @@ -46,6 +46,7 @@ BJ BEN 204 Benin BM BMU 060 Bermuda BT BTN 064 Bhutan BO BOL 068 Bolivia, Plurinational State of +BQ BES 535 Bonaire, Saint Eustatius and Saba BA BIH 070 Bosnia and Herzegovina BW BWA 072 Botswana BV BVT 074 Bouvet Island @@ -75,6 +76,7 @@ CR CRI 188 Costa Rica CI CIV 384 Cote d'Ivoire HR HRV 191 Croatia CU CUB 192 Cuba +CW CUW 531 Curacao CY CYP 196 Cyprus CZ CZE 203 Czech Republic DK DNK 208 Denmark @@ -174,7 +176,6 @@ NA NAM 516 Namibia NR NRU 520 Nauru NP NPL 524 Nepal NL NLD 528 Netherlands -AN ANT 530 Netherlands Antilles NC NCL 540 New Caledonia NZ NZL 554 New Zealand NI NIC 558 Nicaragua @@ -216,6 +217,7 @@ RS SRB 688 Serbia SC SYC 690 Seychelles SL SLE 694 Sierra Leone SG SGP 702 Singapore +SX SXM 534 Sint Maarten (Dutch part) SK SVK 703 Slovakia SI SVN 705 Slovenia SB SLB 090 Solomon Islands @@ -224,7 +226,7 @@ ZA ZAF 710 South Africa GS SGS 239 South Georgia and the South Sandwich Islands ES ESP 724 Spain LK LKA 144 Sri Lanka -SH SHN 654 Saint Helena +SH SHN 654 Saint Helena, Ascension and Tristan da Cunha PM SPM 666 Saint Pierre and Miquelon SD SDN 736 Sudan SR SUR 740 Suriname @@ -537,3 +539,11 @@ ZW ZWE 716 Zimbabwe # # Newsletter VI-6 2009-05-08 # Name change for Plurinational State of Bolivia. +# +# Newsletter VI-7 2010-02-22 +# Name change for Saint Helena, Ascension and Tristan da Cunha +# +# Newsletter VI-8 2010-12-15 +# BONAIRE, SAINT EUSTATIUS AND SABA (BQ), CURACAO (CW) and +# SINT MAARTEN (DUTCH PART) (SX) added as new entries. +# NETHERLANDS ANTILLES (AN) removed. From 1da306338fd86b13685dd5bd0028c784f5eac0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 09:51:02 +0000 Subject: [PATCH 045/200] More thorough mdoc and language fixes. Submitted by: ru --- share/man/man4/geom_map.4 | 103 +++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/share/man/man4/geom_map.4 b/share/man/man4/geom_map.4 index 36a5b419b661..6af91be5d82c 100644 --- a/share/man/man4/geom_map.4 +++ b/share/man/man4/geom_map.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 5, 2011 +.Dd May 17, 2011 .Dt GEOM_MAP 4 .Os .Sh NAME @@ -66,11 +66,15 @@ The current .Nm configuration can be accessed with the following .Xr sysctl 8 -nodes: kern.geom.conftxt, kern.geom.confxml, and kern.geom.confdot -or by using "geom map list". +nodes: +.Va kern.geom.conftxt , kern.geom.confxml , +and +.Va kern.geom.confdot +or by using +.Dq Li "geom map list" . .Bd -literal -offset indent -# sysctl kern.geom.conftxt -kern.geom.conftxt: 0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc +# sysctl -n kern.geom.conftxt +0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc 0 DISK cfid0 8388608 4 hd 0 sc 0 1 MAP map/config 131072 4 i 5 o 8257536 entry 0 dsize 131072 1 MAP map/rootfs 6881280 4 i 4 o 1376256 entry 0 dsize 6881280 @@ -81,40 +85,48 @@ kern.geom.conftxt: 0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc 1 MAP map/bootloader 196608 4 i 0 o 0 entry 0 dsize 196608 .Ed .Pp -Driver configuration can be done in device hints file. List of used parameters: +Driver configuration can be done in +.Xr device.hints 5 . +List of used parameters: .Bl -tag -width indent -.It Fa at +.It Va at select media to attach -.It Fa name -name of partition (will create device /dev/map/that_name) -.It Fa start +.It Va name +name of partition (will create device +.Pa /dev/map/ Ns Ar that_name ) +.It Va start offset from the beginning of the parent media to start of the mapped partition. -This field can also have special value -"search:searchstart:searchstep:searchkey", where: +This field can also have a special value +.Qq Li search: Ns Ar searchstart Ns Li : Ns Ar searchstep Ns Li : Ns Ar searchkey , +where: .Bl -tag -width indent -.It Fa searchstart +.It Ar searchstart offset from the beginning of the parent media where search will be started -.It Fa searchstep +.It Ar searchstep value of the increment used while searching for the partition boundary markers -.It Fa searchkey -key which will be used to find partition boundary markers. Wildcard "." char -can be used to match any char on that position +.It Ar searchkey +key which will be used to find partition boundary markers. +The wildcard +.Ql .\& +can be used to match any character on that position .El -.It Fa end -offset from the beginning of the parent media to end of the mapped partition. -This field can also have special value -"search:searchstart:searchstep:searchkey", look "start" for details. -.It Fa offset -offset where the data of mapped partition begins +.It Va end +offset from the beginning of the parent media to the end of the mapped partition. +This field can also have the special value +.Qq Li search: Ns Ar searchstart Ns Li : Ns Ar searchstep Ns Li : Ns Ar searchkey , +as described above. +.It Va offset +offset where the data of the mapped partition begins .El .Pp -Each record contains start address(bytes) from the media begin, size(bytes), -offset where the data of mapped partition begins, and the name of new device. +Each record contains the start address (in bytes) from the media begin, size +(in bytes), offset where the data of mapped partition begins, and the name of +new device. .Bd -literal -offset indent MAP: 150000x690000, data=0x690000 "/dev/map/rootfs" .Ed .Bd -literal -00150000 - begin address +00150000 - start address 00690000 - size 00000000 - data begin from zero offset 00690000 - data size @@ -131,8 +143,15 @@ hint.map.0.name="bootloader" hint.map.0.readonly=1 .Ed .Pp -define "/dev/map/bootloader" at disk "cfid0" starting at 0x00000000 and end -0x00030000, also marked as readonly. +This defines +.Pa /dev/map/bootloader +at disk +.Pa cfid0 +starting at +.Li 0x00000000 +and ending at +.Li 0x00030000 , +it is also marked as readonly. .Bd -literal -offset indent hint.map.1.at="cfid0" hint.map.1.start=0x00030000 @@ -150,11 +169,26 @@ hint.map.3.start=0x00040000 hint.map.3.end="search:0x00100000:0x10000:.!/bin/sh" .Ed .Pp -define "/dev/map/kernel" at disk "cfid0" starting at 0x00040000, but end -position must be searched by the key ".!/bin/sh", from offset 0x00100000 to end -of media with step 0x10000. Real marker in that case is "#!/bin/sh", but "#" -terminates the line when hints file is parsed, so we need to use wildcard "." -instead of "#". +This defines +.Pa /dev/map/kernel +at disk +.Pa cfid0 +starting at +.Li 0x00040000 , +but the end position must be searched by finding the key +.Dq Li ".!/bin/sh" , +from offset +.Li 0x00100000 +to the end of media with step +.Li 0x10000 . +The real marker in this case is +.Dq Li "#!/bin/sh" , +but +.Ql # +terminates the line when the hints file is parsed, so we need to use wildcard +.Ql .\& +instead of +.Ql # . .Bd -literal -offset indent hint.map.4.at="cfid0" hint.map.4.name="rootfs" @@ -167,11 +201,10 @@ hint.map.5.end=0x00800000 hint.map.5.name="config" .Ed .Sh SEE ALSO -.Xr GEOM 4 , +.Xr geom 4 , .Xr geom 8 , .Xr sysctl 8 .Sh AUTHORS -.An -nosplit The .Nm driver was written by From e61b0f4a3d1aa0526350fec3d8e3e951fdae931e Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Tue, 17 May 2011 10:38:44 +0000 Subject: [PATCH 046/200] Add missing section number for .Xr jail. MFC after: 3 days --- share/man/man5/rc.conf.5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 16f247be81ac..cf062c57c3be 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -3772,7 +3772,7 @@ Set to .Dq Li -l -U root by default. These are flags to pass to -.Xr jail . +.Xr jail 8 . .It Va jail_ Ns Ao Ar jname Ac Ns Va _interface .Pq Vt str Unset by default. From cf7d1a17c23aa891d9cfa04e3e87e0f0795fd0b4 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 10:44:11 +0000 Subject: [PATCH 047/200] Revert change to "MF" I made in r189767. I bet that at the time of r189767 I checked with http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm and "MF" was officially spelled in English as "Saint Martin" there, but now that "SX" exists (for "Sint Maarten (Dutch part)") (nice official "English" spelling!) they seem to have added a "(French part)" suffix to "MF". Since this is also in line with Newsletter VI-1 (2007-09-21), catch up. --- share/misc/iso3166 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/misc/iso3166 b/share/misc/iso3166 index 45c4d0ba70cc..23c9bd65e312 100644 --- a/share/misc/iso3166 +++ b/share/misc/iso3166 @@ -206,7 +206,7 @@ RW RWA 646 Rwanda BL BLM 652 Saint Barthelemy KN KNA 659 Saint Kitts and Nevis LC LCA 662 Saint Lucia -MF MAF 663 Saint Martin +MF MAF 663 Saint Martin (French Part) VC VCT 670 Saint Vincent and the Grenadines WS WSM 882 Samoa SM SMR 674 San Marino From 384bf94c48a3d82e88f00737ebf4a68a5d51414e Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 11:04:50 +0000 Subject: [PATCH 048/200] Use memset() instead of bzero() and memcpy() instead of bcopy(), there is no relevant difference for sbufs, and it increases portability of the source code. Split the actual initialization of the sbuf into a separate local function, so that certain static code checkers can understand what sbuf_new() does, thus eliminating on silly annoyance of MISRA compliance testing. Contributed by: An anonymous company in the last business I expected sbufs to invade. --- sys/kern/subr_sbuf.c | 69 +++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index bf4e73c0f03b..e931e6550330 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -144,7 +144,6 @@ sbuf_extendsize(int size) return (newsize); } - /* * Extend an sbuf. */ @@ -160,7 +159,7 @@ sbuf_extend(struct sbuf *s, int addlen) newbuf = SBMALLOC(newsize); if (newbuf == NULL) return (-1); - bcopy(s->s_buf, newbuf, s->s_size); + memcpy(newbuf, s->s_buf, s->s_size); if (SBUF_ISDYNAMIC(s)) SBFREE(s->s_buf); else @@ -170,6 +169,38 @@ sbuf_extend(struct sbuf *s, int addlen) return (0); } +/* + * Initialize the internals of an sbuf. + * If buf is non-NULL, it points to a static or already-allocated string + * big enough to hold at least length characters. + */ +static struct sbuf * +sbuf_newbuf(struct sbuf *s, char *buf, int length, int flags) +{ + + memset(s, 0, sizeof(*s)); + s->s_flags = flags; + s->s_size = length; + s->s_buf = buf; + + if ((s->s_flags & SBUF_AUTOEXTEND) == 0) { + KASSERT(s->s_size > 1, + ("attempt to create a too small sbuf")); + } + + if (s->s_buf != NULL) + return (s); + + if ((flags & SBUF_AUTOEXTEND) != 0) + s->s_size = sbuf_extendsize(s->s_size); + + s->s_buf = SBMALLOC(s->s_size); + if (s->s_buf == NULL) + return (NULL); + SBUF_SETFLAG(s, SBUF_DYNAMIC); + return (s); +} + /* * Initialize an sbuf. * If buf is non-NULL, it points to a static or already-allocated string @@ -185,31 +216,17 @@ sbuf_new(struct sbuf *s, char *buf, int length, int flags) ("%s called with invalid flags", __func__)); flags &= SBUF_USRFLAGMSK; - if (s == NULL) { - s = SBMALLOC(sizeof(*s)); - if (s == NULL) - return (NULL); - bzero(s, sizeof(*s)); - s->s_flags = flags; - SBUF_SETFLAG(s, SBUF_DYNSTRUCT); - } else { - bzero(s, sizeof(*s)); - s->s_flags = flags; - } - s->s_size = length; - if (buf != NULL) { - s->s_buf = buf; - return (s); - } - if ((flags & SBUF_AUTOEXTEND) != 0) - s->s_size = sbuf_extendsize(s->s_size); - s->s_buf = SBMALLOC(s->s_size); - if (s->s_buf == NULL) { - if (SBUF_ISDYNSTRUCT(s)) - SBFREE(s); + if (s != NULL) + return (sbuf_newbuf(s, buf, length, flags)); + + s = SBMALLOC(sizeof(*s)); + if (s == NULL) + return (NULL); + if (sbuf_newbuf(s, buf, length, flags) == NULL) { + SBFREE(s); return (NULL); } - SBUF_SETFLAG(s, SBUF_DYNAMIC); + SBUF_SETFLAG(s, SBUF_DYNSTRUCT); return (s); } @@ -727,7 +744,7 @@ sbuf_delete(struct sbuf *s) if (SBUF_ISDYNAMIC(s)) SBFREE(s->s_buf); isdyn = SBUF_ISDYNSTRUCT(s); - bzero(s, sizeof(*s)); + memset(s, 0, sizeof(*s)); if (isdyn) SBFREE(s); } From 1562ef0218faf3566975ebfe95bbbb76940278c0 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 11:06:41 +0000 Subject: [PATCH 049/200] Added description for WITH_OFED. --- tools/build/options/WITH_OFED | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tools/build/options/WITH_OFED diff --git a/tools/build/options/WITH_OFED b/tools/build/options/WITH_OFED new file mode 100644 index 000000000000..a995fb8cdab8 --- /dev/null +++ b/tools/build/options/WITH_OFED @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to build the +.Dq "OpenFabrics Enterprise Distribution" +Infiniband software stack. From ff7794059ea703f28fb7fac9499254bddbda52d9 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 11:08:15 +0000 Subject: [PATCH 050/200] Regen for WITH_OFED. --- share/man/man5/src.conf.5 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 134e4f310fba..acae4c03fc82 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 221733 2011-05-10 13:01:11Z ru .\" $FreeBSD$ -.Dd May 10, 2011 +.Dd May 17, 2011 .Dt SRC.CONF 5 .Os .Sh NAME @@ -712,6 +712,11 @@ will not be built either if this option is set. Set to not build .Xr ntpd 8 and related programs. +.It Va WITH_OFED +.\" from FreeBSD: head/tools/build/options/WITH_OFED 222016 2011-05-17 11:06:41Z ru +Set to build the +.Dq "OpenFabrics Enterprise Distribution" +Infiniband software stack. .It Va WITHOUT_OPENSSH .\" from FreeBSD: head/tools/build/options/WITHOUT_OPENSSH 156932 2006-03-21 07:50:50Z ru Set to not build OpenSSH. From 934d7bccdbf4d67bce00c2469de596a6f5b53594 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 11:23:43 +0000 Subject: [PATCH 051/200] Renamed PCI_INTERFACE_XHCI to PCIP_SERIALBUS_USB_XHCI and moved it to . Reviewed by: hselasky MFC after: 3 days --- sys/dev/pci/pcireg.h | 1 + sys/dev/usb/controller/xhci_pci.c | 2 +- sys/dev/usb/controller/xhcireg.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/pcireg.h b/sys/dev/pci/pcireg.h index db74809d5310..216882c8336b 100644 --- a/sys/dev/pci/pcireg.h +++ b/sys/dev/pci/pcireg.h @@ -367,6 +367,7 @@ #define PCIP_SERIALBUS_USB_UHCI 0x00 #define PCIP_SERIALBUS_USB_OHCI 0x10 #define PCIP_SERIALBUS_USB_EHCI 0x20 +#define PCIP_SERIALBUS_USB_XHCI 0x30 #define PCIP_SERIALBUS_USB_DEVICE 0xfe #define PCIS_SERIALBUS_FC 0x04 #define PCIS_SERIALBUS_SMBUS 0x05 diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c index 984ed39dcb0d..40358bfa570f 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -137,7 +137,7 @@ xhci_pci_match(device_t self) { if ((pci_get_class(self) == PCIC_SERIALBUS) && (pci_get_subclass(self) == PCIS_SERIALBUS_USB) - && (pci_get_progif(self) == PCI_INTERFACE_XHCI)) { + && (pci_get_progif(self) == PCIP_SERIALBUS_USB_XHCI)) { return ("XHCI (generic) USB 3.0 controller"); } return (NULL); /* dunno */ diff --git a/sys/dev/usb/controller/xhcireg.h b/sys/dev/usb/controller/xhcireg.h index fb2d1cad21e1..71c5c284a17f 100644 --- a/sys/dev/usb/controller/xhcireg.h +++ b/sys/dev/usb/controller/xhcireg.h @@ -33,7 +33,6 @@ #define PCI_XHCI_USBREV 0x60 /* RO USB protocol revision */ #define PCI_USB_REV_3_0 0x30 /* USB 3.0 */ #define PCI_XHCI_FLADJ 0x61 /* RW frame length adjust */ -#define PCI_INTERFACE_XHCI 0x30 /* USB 3.0 - XHCI */ /* XHCI capability registers */ #define XHCI_CAPLENGTH 0x00 /* RO capability */ From 1d40404b7bdd664a1eaf47664001eda386fefcf4 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 11:26:59 +0000 Subject: [PATCH 052/200] Document the supported hardware, somewhat. Reviewed by: hselasky MFC after: 3 days --- share/man/man4/xhci.4 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/share/man/man4/xhci.4 b/share/man/man4/xhci.4 index 670d395b9b7a..09f3185353c5 100644 --- a/share/man/man4/xhci.4 +++ b/share/man/man4/xhci.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 24, 2011 +.Dd May 17, 2011 .Dt XHCI 4 .Os .Sh NAME @@ -49,6 +49,13 @@ The controller supports .Tn USB connection speeds up to 5.0Gbps when using a USB 3.0 compliant device. +.Sh HARDWARE +The +.Nm +driver supports +.Tn XHCI +compatible controllers having PCI class 12 (serial bus), +subclass 3 (USB) and programming interface 48 (XHCI). .Sh SEE ALSO .Xr ehci 4 , .Xr ohci 4 , From 90de864a5e7b61743483e8b6025bb729ae75fd9e Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 17 May 2011 11:52:53 +0000 Subject: [PATCH 053/200] Set this HAL capabilities flag correctly even though it isn't currently being used. --- sys/dev/ath/ath_hal/ar5416/ar5416_attach.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c index d54573352c9c..6779bf9f846a 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c @@ -816,7 +816,7 @@ ar5416FillCapabilityInfo(struct ath_hal *ah) pCap->halPSPollBroken = AH_TRUE; /* XXX fixed in later revs? */ pCap->halVEOLSupport = AH_TRUE; pCap->halBssIdMaskSupport = AH_TRUE; - pCap->halMcastKeySrchSupport = AH_FALSE; + pCap->halMcastKeySrchSupport = AH_TRUE; /* Works on AR5416 and later */ pCap->halTsfAddSupport = AH_TRUE; pCap->hal4AddrAggrSupport = AH_FALSE; /* Broken in Owl */ From 655a610236f0d758ba5ed43d813a87649354a032 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 17 May 2011 11:56:50 +0000 Subject: [PATCH 054/200] Use the halMcastKeySrchSupport capability bit to selectively enable/disable the multicast key search support for AR5212, AR5416 and later. The general HAL routine ath_hal_getcapability() implement checking this but it's overridden by a check in ar5212_misc:ar5212GetCapability(). This restores the later functionality in case it's found to be broken in any of the 11n chipsets. --- sys/dev/ath/ath_hal/ar5212/ar5212_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c index 15f38644869f..7677f6c832ae 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c @@ -857,7 +857,7 @@ ar5212GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, case HAL_CAP_MCAST_KEYSRCH: /* multicast frame keycache search */ switch (capability) { case 0: /* hardware capability */ - return HAL_OK; + return pcap->halMcastKeySrchSupport ? HAL_OK : HAL_ENXIO; case 1: return (ahp->ah_staId1Defaults & AR_STA_ID1_MCAST_KSRCH) ? HAL_OK : HAL_ENXIO; From 3e71d7d04e1cf9ed7ecc8b172730c3efd0d0e10c Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Tue, 17 May 2011 12:58:19 +0000 Subject: [PATCH 055/200] mdoc: - use a proper macro for interface name ipfw0. - add missing section number for bpf cross reference. --- sbin/ipfw/ipfw.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8 index a984f70cb9e7..710996b7fce1 100644 --- a/sbin/ipfw/ipfw.8 +++ b/sbin/ipfw/ipfw.8 @@ -565,9 +565,9 @@ if the sysctl variable is set to 0 (default), one can use .Xr bpf 4 attached to the -.Xr ipfw0 +.Li ipfw0 pseudo interface. There is no overhead if no -.Xr bpf +.Xr bpf 4 is attached to the pseudo interface. .Pp If From 5c0e8d8a88f5b039f6bfaee1e23813ebf834b3d9 Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Tue, 17 May 2011 14:46:28 +0000 Subject: [PATCH 056/200] Fix manual section number for netstat(1). MFC after: 5 days --- usr.sbin/ifmcstat/ifmcstat.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/ifmcstat/ifmcstat.8 b/usr.sbin/ifmcstat/ifmcstat.8 index 5a6956d52e91..9794d70a44df 100644 --- a/usr.sbin/ifmcstat/ifmcstat.8 +++ b/usr.sbin/ifmcstat/ifmcstat.8 @@ -125,7 +125,7 @@ This support is recommended for debugging purposes. It requires super-user privilege if used to inspect a running kernel. .Pp .Sh SEE ALSO +.Xr netstat 1 , .Xr getifaddrs 3 , .Xr getifmaddrs 3 , -.Xr kvm 3 , -.Xr netstat 8 +.Xr kvm 3 From fdc2e66c57dd08126913182bf5313c07416b44b4 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 17 May 2011 15:03:39 +0000 Subject: [PATCH 057/200] Fix case, introduced in my previous commit. Pointy hat goes to: adrian, for having multiple build screens open and checking the wrong one. --- sys/dev/ath/ath_hal/ar5212/ar5212_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c index 7677f6c832ae..0d6adc13e982 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c @@ -857,7 +857,7 @@ ar5212GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, case HAL_CAP_MCAST_KEYSRCH: /* multicast frame keycache search */ switch (capability) { case 0: /* hardware capability */ - return pcap->halMcastKeySrchSupport ? HAL_OK : HAL_ENXIO; + return pCap->halMcastKeySrchSupport ? HAL_OK : HAL_ENXIO; case 1: return (ahp->ah_staId1Defaults & AR_STA_ID1_MCAST_KSRCH) ? HAL_OK : HAL_ENXIO; From c954cac48b1c87e0edc9cc957ba673e3ca4bd993 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Tue, 17 May 2011 15:46:28 +0000 Subject: [PATCH 058/200] Fix whitespacing. Reported by scf@ MFC after: 1 week. --- sys/netinet/sctp_output.c | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 0dad4e51f836..aea43b2dbe37 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -2210,26 +2210,26 @@ sctp_is_ifa_addr_preferred(struct sctp_ifa *ifa, * means it is the same scope or higher scope then the destination. * L = loopback, P = private, G = global * ----------------------------------------- - * src | dest | result - * ---------------------------------------- - * L | L | yes - * ----------------------------------------- - * P | L | yes-v4 no-v6 - * ----------------------------------------- - * G | L | yes-v4 no-v6 - * ----------------------------------------- - * L | P | no - * ----------------------------------------- - * P | P | yes - * ----------------------------------------- - * G | P | no - * ----------------------------------------- - * L | G | no - * ----------------------------------------- - * P | G | no - * ----------------------------------------- - * G | G | yes - * ----------------------------------------- + * src | dest | result + * ---------------------------------------- + * L | L | yes + * ----------------------------------------- + * P | L | yes-v4 no-v6 + * ----------------------------------------- + * G | L | yes-v4 no-v6 + * ----------------------------------------- + * L | P | no + * ----------------------------------------- + * P | P | yes + * ----------------------------------------- + * G | P | no + * ----------------------------------------- + * L | G | no + * ----------------------------------------- + * P | G | no + * ----------------------------------------- + * G | G | yes + * ----------------------------------------- */ if (ifa->address.sa.sa_family != fam) { @@ -2310,14 +2310,14 @@ sctp_is_ifa_addr_acceptable(struct sctp_ifa *ifa, * * L = loopback, P = private, G = global * ----------------------------------------- - * src | dest | result + * src | dest | result * ----------------------------------------- * L | L | yes * ----------------------------------------- * P | L | yes-v4 no-v6 * ----------------------------------------- * G | L | yes - * ----------------------------------------- + * ----------------------------------------- * L | P | no * ----------------------------------------- * P | P | yes @@ -2325,7 +2325,7 @@ sctp_is_ifa_addr_acceptable(struct sctp_ifa *ifa, * G | P | yes - May not work * ----------------------------------------- * L | G | no - * ----------------------------------------- + * ----------------------------------------- * P | G | yes - May not work * ----------------------------------------- * G | G | yes From 4f36da915f9997be5e8a3f485705f2b06d9c4f4f Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Tue, 17 May 2011 15:57:31 +0000 Subject: [PATCH 059/200] Copy out the mtu when calling getsockopt() with SCTP_GET_PEER_ADDR_INFO. MFC after: 1 week. --- sys/netinet/sctp_usrreq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index c9fad80f01c9..b3eb805edfbe 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -2489,6 +2489,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, paddri->spinfo_srtt = net->lastsa >> SCTP_RTT_SHIFT; paddri->spinfo_rto = net->RTO; paddri->spinfo_assoc_id = sctp_get_associd(stcb); + paddri->spinfo_mtu = net->mtu; SCTP_TCB_UNLOCK(stcb); } else { if (stcb) { From 6c63a20b4939d86a62970f62be6e78a055da0df2 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 17 May 2011 16:30:34 +0000 Subject: [PATCH 060/200] Fix the debugging code path to correctly support HAL_DEBUG_UNMASKABLE. --- sys/dev/ath/ah_osdep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/dev/ath/ah_osdep.c b/sys/dev/ath/ah_osdep.c index 090b690943c7..b14bba037e5b 100644 --- a/sys/dev/ath/ah_osdep.c +++ b/sys/dev/ath/ah_osdep.c @@ -140,16 +140,20 @@ ath_hal_ether_sprintf(const u_int8_t *mac) } #ifdef AH_DEBUG + +/* This must match the definition in ath_hal/ah_debug.h */ +#define HAL_DEBUG_UNMASKABLE 0xf0000000 void DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) { - if (ath_hal_debug & mask) { + if ((mask == HAL_DEBUG_UNMASKABLE) || (ath_hal_debug & mask)) { __va_list ap; va_start(ap, fmt); ath_hal_vprintf(ah, fmt, ap); va_end(ap); } } +#undef HAL_DEBUG_UNMASKABLE #endif /* AH_DEBUG */ #ifdef AH_DEBUG_ALQ From f83e8b25c1ef10af62fabdd117aec0db71d33cc3 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 17 May 2011 16:39:08 +0000 Subject: [PATCH 061/200] Fix a race in the SMP rendezvous code. Specifically, the write by the last CPU to to finish the rendezvous action may become visible to different CPUs at different times. As a result, the CPU that initiated the rendezvous may exit the rendezvous and drop the lock allowing another rendezvous to be initiated on the same CPU or a different CPU. In that case the exit sentinel may be cleared before all CPUs have noticed causing those CPUs to hang forever. Workaround this by using a generation count to notice when this race occurs and to exit the rendezvous in that case. The problem was independently diagnosted by mlaier@ and avg@ as well. Submitted by: neel Reviewed by: avg, mlaier Obtained from: NetApp MFC after: 1 week --- sys/kern/subr_smp.c | 63 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index aba6f0e1ea7e..0c2c286f1d03 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -110,6 +110,7 @@ static void (*volatile smp_rv_action_func)(void *arg); static void (*volatile smp_rv_teardown_func)(void *arg); static void *volatile smp_rv_func_arg; static volatile int smp_rv_waiters[3]; +static volatile int smp_rv_generation; /* * Shared mutex to restrict busywaits between smp_rendezvous() and @@ -310,39 +311,63 @@ restart_cpus(cpumask_t map) void smp_rendezvous_action(void) { - void* local_func_arg = smp_rv_func_arg; - void (*local_setup_func)(void*) = smp_rv_setup_func; - void (*local_action_func)(void*) = smp_rv_action_func; - void (*local_teardown_func)(void*) = smp_rv_teardown_func; + void *local_func_arg; + void (*local_setup_func)(void*); + void (*local_action_func)(void*); + void (*local_teardown_func)(void*); + int generation; /* Ensure we have up-to-date values. */ atomic_add_acq_int(&smp_rv_waiters[0], 1); while (smp_rv_waiters[0] < smp_rv_ncpus) cpu_spinwait(); - /* setup function */ + /* Fetch rendezvous parameters after acquire barrier. */ + local_func_arg = smp_rv_func_arg; + local_setup_func = smp_rv_setup_func; + local_action_func = smp_rv_action_func; + local_teardown_func = smp_rv_teardown_func; + generation = smp_rv_generation; + + /* + * If requested, run a setup function before the main action + * function. Ensure all CPUs have completed the setup + * function before moving on to the action function. + */ if (local_setup_func != smp_no_rendevous_barrier) { if (smp_rv_setup_func != NULL) smp_rv_setup_func(smp_rv_func_arg); - - /* spin on entry rendezvous */ atomic_add_int(&smp_rv_waiters[1], 1); while (smp_rv_waiters[1] < smp_rv_ncpus) cpu_spinwait(); } - /* action function */ if (local_action_func != NULL) local_action_func(local_func_arg); - /* spin on exit rendezvous */ + /* + * Signal that the main action has been completed. If a + * full exit rendezvous is requested, then all CPUs will + * wait here until all CPUs have finished the main action. + * + * Note that the write by the last CPU to finish the action + * may become visible to different CPUs at different times. + * As a result, the CPU that initiated the rendezvous may + * exit the rendezvous and drop the lock allowing another + * rendezvous to be initiated on the same CPU or a different + * CPU. In that case the exit sentinel may be cleared before + * all CPUs have noticed causing those CPUs to hang forever. + * Workaround this by using a generation count to notice when + * this race occurs and to exit the rendezvous in that case. + */ + MPASS(generation == smp_rv_generation); atomic_add_int(&smp_rv_waiters[2], 1); if (local_teardown_func == smp_no_rendevous_barrier) return; - while (smp_rv_waiters[2] < smp_rv_ncpus) + while (smp_rv_waiters[2] < smp_rv_ncpus && + generation == smp_rv_generation) cpu_spinwait(); - /* teardown function */ if (local_teardown_func != NULL) local_teardown_func(local_func_arg); } @@ -373,10 +398,11 @@ smp_rendezvous_cpus(cpumask_t map, if (ncpus == 0) panic("ncpus is 0 with map=0x%x", map); - /* obtain rendezvous lock */ mtx_lock_spin(&smp_ipi_mtx); - /* set static function pointers */ + atomic_add_acq_int(&smp_rv_generation, 1); + + /* Pass rendezvous parameters via global variables. */ smp_rv_ncpus = ncpus; smp_rv_setup_func = setup_func; smp_rv_action_func = action_func; @@ -386,18 +412,25 @@ smp_rendezvous_cpus(cpumask_t map, smp_rv_waiters[2] = 0; atomic_store_rel_int(&smp_rv_waiters[0], 0); - /* signal other processors, which will enter the IPI with interrupts off */ + /* + * Signal other processors, which will enter the IPI with + * interrupts off. + */ ipi_selected(map & ~(1 << curcpu), IPI_RENDEZVOUS); /* Check if the current CPU is in the map */ if ((map & (1 << curcpu)) != 0) smp_rendezvous_action(); + /* + * If the caller did not request an exit barrier to be enforced + * on each CPU, ensure that this CPU waits for all the other + * CPUs to finish the rendezvous. + */ if (teardown_func == smp_no_rendevous_barrier) while (atomic_load_acq_int(&smp_rv_waiters[2]) < ncpus) cpu_spinwait(); - /* release lock */ mtx_unlock_spin(&smp_ipi_mtx); } From 09eed402a241ee5ac91525bd4394c12401e398cc Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 17:37:58 +0000 Subject: [PATCH 062/200] Bump shlib version Instigate symbol versioning Pray that I don't break the build. --- lib/libsbuf/Makefile | 11 ++++++++--- lib/libsbuf/Symbol.map | 24 ++++++++++++++++++++++++ lib/libsbuf/Version.def | 6 ++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 lib/libsbuf/Symbol.map create mode 100644 lib/libsbuf/Version.def diff --git a/lib/libsbuf/Makefile b/lib/libsbuf/Makefile index 5d96c0e983e6..79d3fe973e05 100644 --- a/lib/libsbuf/Makefile +++ b/lib/libsbuf/Makefile @@ -1,8 +1,13 @@ # $FreeBSD$ -LIB= sbuf -SHLIBDIR?= /lib -SRCS= subr_sbuf.c +LIB= sbuf +SHLIBDIR?= /lib +SRCS= subr_sbuf.c + +SHLIB_MAJOR = 6 + +SYMBOL_MAPS= ${.CURDIR}/Symbol.map +VERSION_DEF= ${.CURDIR}/Version.def .PATH: ${.CURDIR}/../../sys/kern diff --git a/lib/libsbuf/Symbol.map b/lib/libsbuf/Symbol.map new file mode 100644 index 000000000000..75af55838871 --- /dev/null +++ b/lib/libsbuf/Symbol.map @@ -0,0 +1,24 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.2 { + sbuf_new; + sbuf_clear; + sbuf_setpos; + sbuf_bcat; + sbuf_bcpy; + sbuf_cat; + sbuf_cpy; + sbuf_printf; + sbuf_vprintf; + sbuf_putc; + sbuf_set_drain; + sbuf_trim; + sbuf_error; + sbuf_finish; + sbuf_data; + sbuf_len; + sbuf_done; + sbuf_delete; +}; diff --git a/lib/libsbuf/Version.def b/lib/libsbuf/Version.def new file mode 100644 index 000000000000..cf8a7d41d29b --- /dev/null +++ b/lib/libsbuf/Version.def @@ -0,0 +1,6 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.2 { +}; From 6ab7244a4dce57de8e59a16d6d3285af0cf1b07e Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 18:24:59 +0000 Subject: [PATCH 063/200] Try to explain what sbufs do and add an example to show it. Clarify return values. --- share/man/man9/sbuf.9 | 45 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/share/man/man9/sbuf.9 b/share/man/man9/sbuf.9 index 4b93df58ee5e..500bfbdc9e98 100644 --- a/share/man/man9/sbuf.9 +++ b/share/man/man9/sbuf.9 @@ -52,7 +52,7 @@ .Nm sbuf_len , .Nm sbuf_done , .Nm sbuf_delete -.Nd safe string formatting +.Nd safe string composition .Sh SYNOPSIS .In sys/types.h .In sys/sbuf.h @@ -106,14 +106,20 @@ .Sh DESCRIPTION The .Nm -family of functions allows one to safely allocate, construct and -release bounded NUL-terminated strings in kernel space. +family of functions allows one to safely allocate, compose and +release strings in kernel or user space. +.Pp Instead of arrays of characters, these functions operate on structures called .Fa sbufs , defined in .In sys/sbuf.h . .Pp +Any errors encountered during the allocation or composition of the +string will be latched in the data structure, +making a single error test at the end of the composition +sufficient to determine success or failure of the entire process. +.Pp The .Fn sbuf_new function initializes the @@ -468,14 +474,35 @@ The function returns \-1 if copying string from userland failed, and number of bytes copied otherwise. +.Pp The -.Fn sbuf_finish -function returns ENOMEM if the sbuf overflowed before being finished, +.Fn sbuf_finish 9 +function (the kernel version) returns ENOMEM if the sbuf overflowed before +being finished, or returns the error code from the drain if one is attached. -When used as -.Xr sbuf_finish 3 , -.Fn sbuf_finish -will return \-1 and set errno on error instead. +.Pp +The +.Fn sbuf_finish 3 +function (the userland version) +will return zero for success and \-1 and set errno on error. +.Sh EXAMPLES +.Bd -literal -compact +#include + +struct sbuf *sb; + +sb = sbuf_new_auto(); +sbuf_cat("Customers found:\en"); +TAILQ_FOREACH(foo, &foolist, list) { + sbuf_printf(" %4d %s\en", foo->index, foo->name); + sbuf_printf(" Address: %s\en", foo->address); + sbuf_printf(" Zip: %s\en", foo->zipcode); +} +if (sbuf_finish(sb)) + err(1,"Could not generate message"); +transmit_msg(sbuf_data(sb), sbuf_len(sb)); +sbuf_delete(sb); +.Ed .Sh SEE ALSO .Xr printf 3 , .Xr strcat 3 , From 2eb4b00cbb86ee4591b3a60e96b94e51085c3939 Mon Sep 17 00:00:00 2001 From: Florent Thoumie Date: Tue, 17 May 2011 19:11:47 +0000 Subject: [PATCH 064/200] Backout libinstall.a -> libpkg commit. Discussed with: erwin, brooks, bapt --- Makefile.inc1 | 5 +- lib/Makefile | 5 -- lib/libpkg/Makefile | 47 ---------- lib/libpkg/pkgwrap.c | 90 ------------------- share/mk/bsd.libnames.mk | 1 - usr.sbin/pkg_install/Makefile | 4 +- usr.sbin/pkg_install/Makefile.inc | 13 ++- usr.sbin/pkg_install/add/Makefile | 7 +- usr.sbin/pkg_install/add/extract.c | 2 +- usr.sbin/pkg_install/add/futil.c | 2 +- usr.sbin/pkg_install/add/main.c | 4 +- usr.sbin/pkg_install/add/perform.c | 2 +- usr.sbin/pkg_install/create/Makefile | 6 +- usr.sbin/pkg_install/create/main.c | 4 +- usr.sbin/pkg_install/create/perform.c | 2 +- usr.sbin/pkg_install/create/pl.c | 2 +- usr.sbin/pkg_install/delete/Makefile | 5 ++ usr.sbin/pkg_install/delete/main.c | 4 +- usr.sbin/pkg_install/delete/perform.c | 2 +- usr.sbin/pkg_install/info/Makefile | 6 +- usr.sbin/pkg_install/info/info.h | 39 ++++---- usr.sbin/pkg_install/info/main.c | 14 +-- usr.sbin/pkg_install/info/perform.c | 2 +- usr.sbin/pkg_install/info/show.c | 2 +- usr.sbin/pkg_install/lib/Makefile | 11 +++ .../pkg_install/lib}/deps.c | 2 +- .../pkg_install/lib}/exec.c | 2 +- .../pkg_install/lib}/file.c | 2 +- .../pkg_install/lib}/global.c | 2 +- .../pkg.h => usr.sbin/pkg_install/lib/lib.h | 12 +-- .../pkg_install/lib}/match.c | 4 +- .../libpkg => usr.sbin/pkg_install/lib}/msg.c | 9 +- .../libpkg => usr.sbin/pkg_install/lib}/pen.c | 17 ++-- usr.sbin/pkg_install/lib/pkgwrap.c | 89 ++++++++++++++++++ .../pkg_install/lib}/plist.c | 2 +- .../libpkg => usr.sbin/pkg_install/lib}/str.c | 2 +- .../libpkg => usr.sbin/pkg_install/lib}/url.c | 4 +- .../pkg_install/lib}/version.c | 14 +-- usr.sbin/pkg_install/updating/Makefile | 5 ++ usr.sbin/pkg_install/updating/main.c | 4 +- usr.sbin/pkg_install/version/Makefile | 5 ++ usr.sbin/pkg_install/version/main.c | 4 +- usr.sbin/pkg_install/version/perform.c | 2 +- 43 files changed, 211 insertions(+), 251 deletions(-) delete mode 100644 lib/libpkg/Makefile delete mode 100644 lib/libpkg/pkgwrap.c create mode 100644 usr.sbin/pkg_install/lib/Makefile rename {lib/libpkg => usr.sbin/pkg_install/lib}/deps.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/exec.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/file.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/global.c (98%) rename lib/libpkg/pkg.h => usr.sbin/pkg_install/lib/lib.h (96%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/match.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/msg.c (91%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/pen.c (90%) create mode 100644 usr.sbin/pkg_install/lib/pkgwrap.c rename {lib/libpkg => usr.sbin/pkg_install/lib}/plist.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/str.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/url.c (98%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/version.c (98%) diff --git a/Makefile.inc1 b/Makefile.inc1 index 907cdce7d5bf..4aa53da83d2f 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1205,7 +1205,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \ ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ ${_kerberos5_lib_libroken} \ lib/libbz2 lib/libcom_err lib/libcrypt \ - lib/libexpat lib/libfetch \ + lib/libexpat \ ${_lib_libgssapi} ${_lib_libipx} \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd \ lib/ncurses/ncurses lib/ncurses/ncursesw \ @@ -1238,7 +1238,6 @@ _cddl_lib= cddl/lib _secure_lib_libcrypto= secure/lib/libcrypto _secure_lib_libssl= secure/lib/libssl lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L -lib/libfetch__L: secure/lib/libcrypto__L secure/lib/libssl__L lib/libmd__L .if ${MK_OPENSSH} != "no" _secure_lib_libssh= secure/lib/libssh secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L @@ -1274,7 +1273,7 @@ _lib_libypclnt= lib/libypclnt .endif .if ${MK_OPENSSL} == "no" -lib/libfetch__L lib/libradius__L: lib/libmd__L +lib/libradius__L: lib/libmd__L .endif .for _lib in ${_prereq_libs} diff --git a/lib/Makefile b/lib/Makefile index 7be186fca21c..eef204899cde 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -89,7 +89,6 @@ SUBDIR= ${SUBDIR_ORDERED} \ libopie \ libpam \ libpcap \ - ${_libpkg} \ ${_libpmc} \ ${_libproc} \ libprocstat \ @@ -215,10 +214,6 @@ _libmp= libmp _libpmc= libpmc .endif -.if ${MK_PKGTOOLS} != "no" -_libpkg= libpkg -.endif - .if ${MK_SENDMAIL} != "no" _libmilter= libmilter _libsm= libsm diff --git a/lib/libpkg/Makefile b/lib/libpkg/Makefile deleted file mode 100644 index 8f2b325f0980..000000000000 --- a/lib/libpkg/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# $FreeBSD$ - -.include - -LIB= pkg - -SHLIBDIR?= /usr/lib -SHLIB_MAJOR= 0 - -SRCS= deps.c \ - exec.c \ - file.c \ - global.c \ - match.c \ - msg.c \ - pen.c \ - pkgwrap.c \ - plist.c \ - str.c \ - url.c \ - version.c -INCS= pkg.h - -CFLAGS+= -DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE - -DPADD= ${LIBFETCH} ${LIBMD} ${LIBUTIL} -LDADD= -lfetch -lmd -lutil - -.if ${MK_OPENSSL} != "no" -DPADD+= ${LIBSSL} ${LIBCRYPTO} -LDADD+= -lssl -lcrypto -.endif - -WARNS?= 3 - -DATE!= grep LIBPKG_VERSION ${.CURDIR}/pkg.h | sed 's|.*[ ]||' - -distfile: clean - @(cd ${.CURDIR}/..; \ - cp -r libpkg libpkg-${DATE}; \ - tar -czf libpkg/libpkg-${DATE}.tar.gz \ - --exclude .#* --exclude *~ --exclude CVS \ - --exclude .svn --exclude libpkg-*.tar.gz \ - libpkg-${DATE}; \ - rm -rf libpkg-${DATE}) - -.include diff --git a/lib/libpkg/pkgwrap.c b/lib/libpkg/pkgwrap.c deleted file mode 100644 index 9c8c0c3d0a26..000000000000 --- a/lib/libpkg/pkgwrap.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * FreeBSD install - a package for the installation and maintenance - * of non-core utilities. - * - * 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. - * - * Maxim Sobolev - * 8 September 2002 - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "pkg.h" -#include -#include -#include -#include - -extern char **environ; - -void -pkg_wrap(long curver, char **argv) -{ - FILE* f; - char ver[9]; /* Format is: 'YYYYMMDD\0' */ - char buffer[FILENAME_MAX+10]; /* Format is: 'YYYYMMDD ' */ - char cmd[FILENAME_MAX+5]; /* Format is: ' -PPq' */ - char *path, *cp; - long ptver, lpver; - - if (getenv("PKG_NOWRAP") != NULL) - goto nowrap; - - setenv("PKG_NOWRAP", "1", 1); - - /* Get alternative location for package tools. */ - if ((f = fopen(PKG_WRAPCONF_FNAME, "r")) == NULL) { - goto nowrap; - } else { - if (get_string(buffer, FILENAME_MAX+9, f) == NULL) { - goto nowrap; - } else { - if ((path = strrchr(buffer, ' ')) == NULL) { - goto nowrap; - } else { - *path++ = '\0'; - } - } - } - - if ((cp = strrchr(argv[0], '/')) == NULL) { - cp = argv[0]; - } else { - cp++; - } - - /* Get version of the other pkg_install and libpkg */ - snprintf(cmd, FILENAME_MAX+10, "%s/%s -PPq", path, cp); - if ((f = popen(cmd, "r")) == NULL) { - perror("popen()"); - goto nowrap; - } else { - if (get_string(ver, 9, f) == NULL) - goto nowrap; - else - ptver = strtol(ver, NULL, 10); - if (get_string(ver, 9, f) == NULL) - goto nowrap; - else - lpver = strtol(ver, NULL, 10); - pclose(f); - } - - if ((lpver >= LIBPKG_VERSION) && (ptver > curver)) { - snprintf(cmd, FILENAME_MAX, "%s/%s", path, cp); - execve(cmd, argv, environ); - } - -nowrap: - unsetenv("PKG_NOWRAP"); -} diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk index 9a948ff4bbef..d3fb51a9a73f 100644 --- a/share/mk/bsd.libnames.mk +++ b/share/mk/bsd.libnames.mk @@ -129,7 +129,6 @@ MINUSLPAM+= -lypclnt LIBPANEL?= ${DESTDIR}${LIBDIR}/libpanel.a LIBPCAP?= ${DESTDIR}${LIBDIR}/libpcap.a -LIBPKG?= ${DESTDIR}${LIBDIR}/libpkg.a LIBPMC?= ${DESTDIR}${LIBDIR}/libpmc.a LIBPROC?= ${DESTDIR}${LIBDIR}/libproc.a LIBPTHREAD?= ${DESTDIR}${LIBDIR}/libpthread.a diff --git a/usr.sbin/pkg_install/Makefile b/usr.sbin/pkg_install/Makefile index 0aa19415441b..bf1a2135cc79 100644 --- a/usr.sbin/pkg_install/Makefile +++ b/usr.sbin/pkg_install/Makefile @@ -2,11 +2,11 @@ .include -SUBDIR= add create delete info updating version +SUBDIR= lib add create delete info updating version .include -DATE!= grep PKG_INSTALL_VERSION ${.CURDIR}/Makefile.inc | sed 's|.*=||' +DATE!= grep PKG_INSTALL_VERSION ${.CURDIR}/lib/lib.h | sed 's|.*[ ]||' distfile: clean @(cd ${.CURDIR}/..; \ diff --git a/usr.sbin/pkg_install/Makefile.inc b/usr.sbin/pkg_install/Makefile.inc index d929f2457009..2fa20aa1c394 100644 --- a/usr.sbin/pkg_install/Makefile.inc +++ b/usr.sbin/pkg_install/Makefile.inc @@ -2,11 +2,16 @@ .include -CFLAGS+= -DPKG_INSTALL_VERSION=20101012 -CFLAGS+= -DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE +LIBINSTALL= ${.OBJDIR}/../lib/libinstall.a -DPADD+= ${LIBPKG} -LDADD+= -lpkg +DPADD+= ${LIBUTIL} +LDADD+= -lutil + +.if ${MK_OPENSSL} != "no" && \ + defined(LDADD) && ${LDADD:M-lfetch} != "" +DPADD+= ${LIBSSL} ${LIBCRYPTO} +LDADD+= -lssl -lcrypto +.endif # Inherit BINDIR from one level up. .include "../Makefile.inc" diff --git a/usr.sbin/pkg_install/add/Makefile b/usr.sbin/pkg_install/add/Makefile index 03a43f068b76..89988e78b220 100644 --- a/usr.sbin/pkg_install/add/Makefile +++ b/usr.sbin/pkg_install/add/Makefile @@ -1,11 +1,14 @@ # $FreeBSD$ -.include - PROG= pkg_add SRCS= main.c perform.c futil.c extract.c +CFLAGS+= -I${.CURDIR}/../lib + WARNS?= 3 WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd + .include diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c index 6c2c4fc7b92b..732a13fea441 100644 --- a/usr.sbin/pkg_install/add/extract.c +++ b/usr.sbin/pkg_install/add/extract.c @@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c index c5253202ca5e..ca095ea7ae2e 100644 --- a/usr.sbin/pkg_install/add/futil.c +++ b/usr.sbin/pkg_install/add/futil.c @@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include "lib.h" #include "add.h" /* diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index b8b9b54bcf63..f73312a626e5 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" char *Prefix = NULL; @@ -132,8 +132,6 @@ main(int argc, char **argv) static char temppackageroot[MAXPATHLEN]; static char pkgaddpath[MAXPATHLEN]; - pkg_wrap(PKG_INSTALL_VERSION, argv); - if (*argv[0] != '/' && strchr(argv[0], '/') != NULL) PkgAddCmd = realpath(argv[0], pkgaddpath); else diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index 653a1d6296fe..b23cd5232a32 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" #include diff --git a/usr.sbin/pkg_install/create/Makefile b/usr.sbin/pkg_install/create/Makefile index 333403778fe3..42718c6f9273 100644 --- a/usr.sbin/pkg_install/create/Makefile +++ b/usr.sbin/pkg_install/create/Makefile @@ -3,10 +3,12 @@ PROG= pkg_create SRCS= main.c perform.c pl.c +CFLAGS+= -I${.CURDIR}/../lib + WARNS?= 3 WFORMAT?= 1 -DPADD= ${LIBMD} -LDADD= -lmd +DPADD= ${LIBINSTALL} ${LIBMD} +LDADD= ${LIBINSTALL} -lmd .include diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index 5e999dae3350..e4af62128ae0 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -15,7 +15,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "create.h" match_t MatchType = MATCH_GLOB; @@ -72,8 +72,6 @@ main(int argc, char **argv) int ch; char **pkgs, **start, *tmp; - pkg_wrap(PKG_INSTALL_VERSION, argv); - pkgs = start = argv; while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) switch(ch) { diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index 149bcbd08513..45786b62b87c 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "create.h" #include diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c index fe62d421014e..18bbaf24734b 100644 --- a/usr.sbin/pkg_install/create/pl.c +++ b/usr.sbin/pkg_install/create/pl.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "create.h" #include #include diff --git a/usr.sbin/pkg_install/delete/Makefile b/usr.sbin/pkg_install/delete/Makefile index 4f3b3906e63c..c9a0fdebea22 100644 --- a/usr.sbin/pkg_install/delete/Makefile +++ b/usr.sbin/pkg_install/delete/Makefile @@ -3,6 +3,11 @@ PROG= pkg_delete SRCS= main.c perform.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBMD} +LDADD= ${LIBINSTALL} -lmd + .include diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index 7677fe9d44bc..f09a432f2bb4 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "delete.h" char *Prefix = NULL; @@ -67,8 +67,6 @@ main(int argc, char **argv) const char *tmp; struct stat stat_s; - pkg_wrap(PKG_INSTALL_VERSION, argv); - pkgs = start = argv; while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) switch(ch) { diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index 02f9717a0919..2557dbcd105d 100644 --- a/usr.sbin/pkg_install/delete/perform.c +++ b/usr.sbin/pkg_install/delete/perform.c @@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include "lib.h" #include "delete.h" static int pkg_do(char *); diff --git a/usr.sbin/pkg_install/info/Makefile b/usr.sbin/pkg_install/info/Makefile index ba3909d17da7..485cb2263210 100644 --- a/usr.sbin/pkg_install/info/Makefile +++ b/usr.sbin/pkg_install/info/Makefile @@ -3,9 +3,11 @@ PROG= pkg_info SRCS= main.c perform.c show.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 -DPADD= ${LIBMD} -LDADD= -lmd +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd .include diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h index 68ec7107a3c3..46e29b1202dd 100644 --- a/usr.sbin/pkg_install/info/info.h +++ b/usr.sbin/pkg_install/info/info.h @@ -33,26 +33,25 @@ #define MAXNAMESIZE 20 #endif -#define SHOW_COMMENT 0x000001 -#define SHOW_DESC 0x000002 -#define SHOW_PLIST 0x000004 -#define SHOW_INSTALL 0x000008 -#define SHOW_DEINSTALL 0x000010 -#define SHOW_REQUIRE 0x000020 -#define SHOW_PREFIX 0x000040 -#define SHOW_INDEX 0x000080 -#define SHOW_FILES 0x000100 -#define SHOW_DISPLAY 0x000200 -#define SHOW_REQBY 0x000400 -#define SHOW_MTREE 0x000800 -#define SHOW_SIZE 0x001000 -#define SHOW_ORIGIN 0x002000 -#define SHOW_CKSUM 0x004000 -#define SHOW_FMTREV 0x008000 -#define SHOW_PTREV 0x010000 -#define SHOW_DEPEND 0x020000 -#define SHOW_PKGNAME 0x040000 -#define SHOW_LPREV 0x100000 +#define SHOW_COMMENT 0x00001 +#define SHOW_DESC 0x00002 +#define SHOW_PLIST 0x00004 +#define SHOW_INSTALL 0x00008 +#define SHOW_DEINSTALL 0x00010 +#define SHOW_REQUIRE 0x00020 +#define SHOW_PREFIX 0x00040 +#define SHOW_INDEX 0x00080 +#define SHOW_FILES 0x00100 +#define SHOW_DISPLAY 0x00200 +#define SHOW_REQBY 0x00400 +#define SHOW_MTREE 0x00800 +#define SHOW_SIZE 0x01000 +#define SHOW_ORIGIN 0x02000 +#define SHOW_CKSUM 0x04000 +#define SHOW_FMTREV 0x08000 +#define SHOW_PTREV 0x10000 +#define SHOW_DEPEND 0x20000 +#define SHOW_PKGNAME 0x40000 struct which_entry { TAILQ_ENTRY(which_entry) next; diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c index ca4e477f9995..2de638e4cad3 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "info.h" int Flags = 0; @@ -68,8 +68,6 @@ main(int argc, char **argv) char **pkgs, **start; char *pkgs_split; - pkg_wrap(PKG_INSTALL_VERSION, argv); - whead = malloc(sizeof(struct which_head)); if (whead == NULL) err(2, NULL); @@ -227,10 +225,7 @@ main(int argc, char **argv) } case 'P': - if (Flags & SHOW_PTREV) - Flags |= SHOW_LPREV; - else - Flags = SHOW_PTREV; + Flags = SHOW_PTREV; break; case 'h': @@ -247,11 +242,6 @@ main(int argc, char **argv) if (!Quiet) printf("Package tools revision: "); printf("%d\n", PKG_INSTALL_VERSION); - if (Flags & SHOW_LPREV) { - if (!Quiet) - printf("Libpkg revision: "); - printf("%d\n", libpkg_version()); - } exit(0); } diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c index d2956120822a..09cad78ad3f2 100644 --- a/usr.sbin/pkg_install/info/perform.c +++ b/usr.sbin/pkg_install/info/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "info.h" #include #include diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c index 0d3b4ad73d2e..c65c312a5062 100644 --- a/usr.sbin/pkg_install/info/show.c +++ b/usr.sbin/pkg_install/info/show.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "info.h" #include #include diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile new file mode 100644 index 000000000000..84a41b8d7f15 --- /dev/null +++ b/usr.sbin/pkg_install/lib/Makefile @@ -0,0 +1,11 @@ +# $FreeBSD$ + +LIB= install +INTERNALLIB= +SRCS= file.c msg.c plist.c str.c exec.c global.c pen.c match.c \ + deps.c version.c pkgwrap.c url.c + +WARNS?= 3 +WFORMAT?= 1 + +.include diff --git a/lib/libpkg/deps.c b/usr.sbin/pkg_install/lib/deps.c similarity index 99% rename from lib/libpkg/deps.c rename to usr.sbin/pkg_install/lib/deps.c index 101d04602192..66f44a9c6fea 100644 --- a/lib/libpkg/deps.c +++ b/usr.sbin/pkg_install/lib/deps.c @@ -22,7 +22,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include diff --git a/lib/libpkg/exec.c b/usr.sbin/pkg_install/lib/exec.c similarity index 99% rename from lib/libpkg/exec.c rename to usr.sbin/pkg_install/lib/exec.c index 04891d3cc09a..fc8220c5f399 100644 --- a/lib/libpkg/exec.c +++ b/usr.sbin/pkg_install/lib/exec.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include /* diff --git a/lib/libpkg/file.c b/usr.sbin/pkg_install/lib/file.c similarity index 99% rename from lib/libpkg/file.c rename to usr.sbin/pkg_install/lib/file.c index 7c95f995a2fe..c7ab9d6b2977 100644 --- a/lib/libpkg/file.c +++ b/usr.sbin/pkg_install/lib/file.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include diff --git a/lib/libpkg/global.c b/usr.sbin/pkg_install/lib/global.c similarity index 98% rename from lib/libpkg/global.c rename to usr.sbin/pkg_install/lib/global.c index 8103126e6935..e136ec86a6f2 100644 --- a/lib/libpkg/global.c +++ b/usr.sbin/pkg_install/lib/global.c @@ -22,7 +22,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" /* These are global for all utils */ Boolean Quiet = FALSE; diff --git a/lib/libpkg/pkg.h b/usr.sbin/pkg_install/lib/lib.h similarity index 96% rename from lib/libpkg/pkg.h rename to usr.sbin/pkg_install/lib/lib.h index 12e35623bc8a..089bfa3630b9 100644 --- a/lib/libpkg/pkg.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -23,10 +23,6 @@ #ifndef _INST_LIB_LIB_H_ #define _INST_LIB_LIB_H_ -#ifndef YES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE -#error "You obviously have no idea what you're doing." -#endif - /* Includes */ #include #include @@ -100,12 +96,13 @@ #define PKG_PREFIX_VNAME "PKG_PREFIX" /* - * Version of the package library - increase whenever you make a change + * Version of the package tools - increase whenever you make a change * in the code that is not cosmetic only. */ -#define LIBPKG_VERSION 20100423 +#define PKG_INSTALL_VERSION 20100403 #define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf" +#define main(argc, argv) real_main(argc, argv) /* Version numbers to assist with changes in package file format */ #define PLIST_FMT_VER_MAJOR 1 @@ -217,7 +214,7 @@ Boolean make_preserve_name(char *, int, const char *, const char *); /* For all */ int pkg_perform(char **); -void pkg_wrap(long, char **); +int real_main(int, char **); /* Query installed packages */ char **matchinstalled(match_t, char **, int *); @@ -232,7 +229,6 @@ int chkifdepends(const char *, const char *); int requiredby(const char *, struct reqr_by_head **, Boolean, Boolean); /* Version */ -int libpkg_version(void); int verscmp(Package *, int, int); int version_cmp(const char *, const char *); diff --git a/lib/libpkg/match.c b/usr.sbin/pkg_install/lib/match.c similarity index 99% rename from lib/libpkg/match.c rename to usr.sbin/pkg_install/lib/match.c index ba6544224dcf..6c1b2bfcf003 100644 --- a/lib/libpkg/match.c +++ b/usr.sbin/pkg_install/lib/match.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -292,7 +292,7 @@ matchallbyorigin(const char **origins, int *retval) break; } } - if (cmd != PLIST_ORIGIN && 0 != strncmp("bsdpan-", installed[i], 7)) + if (cmd != PLIST_ORIGIN && ( Verbose || 0 != strncmp("bsdpan-", installed[i], 7 ) ) ) warnx("package %s has no origin recorded", installed[i]); fclose(fp); } diff --git a/lib/libpkg/msg.c b/usr.sbin/pkg_install/lib/msg.c similarity index 91% rename from lib/libpkg/msg.c rename to usr.sbin/pkg_install/lib/msg.c index 0d25ad199007..5b17624016d0 100644 --- a/lib/libpkg/msg.c +++ b/usr.sbin/pkg_install/lib/msg.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include @@ -61,7 +61,12 @@ y_or_n(Boolean def, const char *msg, ...) else fprintf(stderr, " [no]? "); fflush(stderr); - ch = toupper(fgetc(tty)); + if (AutoAnswer) { + ch = (AutoAnswer == YES) ? 'Y' : 'N'; + fprintf(stderr, "%c\n", ch); + } + else + ch = toupper(fgetc(tty)); if (ch == '\n') ch = (def) ? 'Y' : 'N'; } diff --git a/lib/libpkg/pen.c b/usr.sbin/pkg_install/lib/pen.c similarity index 90% rename from lib/libpkg/pen.c rename to usr.sbin/pkg_install/lib/pen.c index 6e30445b7594..2b405a3a43a8 100644 --- a/lib/libpkg/pen.c +++ b/usr.sbin/pkg_install/lib/pen.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -103,7 +103,7 @@ popPen(char *pen) const char * make_playpen(char *pen, off_t sz) { - char humbuf[6]; + char humbuf1[6], humbuf2[6]; char cwd[FILENAME_MAX]; if (!find_play_pen(pen, sz)) @@ -114,15 +114,22 @@ make_playpen(char *pen, off_t sz) errx(2, "%s: can't mktemp '%s'", __func__, pen); } - humanize_number(humbuf, sizeof humbuf, sz, "", HN_AUTOSCALE, HN_NOSPACE); + if (Verbose) { + if (sz) { + humanize_number(humbuf1, sizeof humbuf1, sz, "", HN_AUTOSCALE, + HN_NOSPACE); + humanize_number(humbuf2, sizeof humbuf2, min_free(pen), + "", HN_AUTOSCALE, HN_NOSPACE); + fprintf(stderr, "Requested space: %s bytes, free space: %s bytes in %s\n", humbuf1, humbuf2, pen); + } + } if (min_free(pen) < sz) { rmdir(pen); cleanup(0); errx(2, "%s: not enough free space to create '%s'.\n" "Please set your PKG_TMPDIR environment variable to a location\n" - "with at least %s and try the command again", - __func__, humbuf, pen); + "with more space and\ntry the command again", __func__, pen); } if (!getcwd(cwd, FILENAME_MAX)) { diff --git a/usr.sbin/pkg_install/lib/pkgwrap.c b/usr.sbin/pkg_install/lib/pkgwrap.c new file mode 100644 index 000000000000..cbd15cd7b445 --- /dev/null +++ b/usr.sbin/pkg_install/lib/pkgwrap.c @@ -0,0 +1,89 @@ +/* + * FreeBSD install - a package for the installation and maintenance + * of non-core utilities. + * + * 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. + * + * Maxim Sobolev + * 8 September 2002 + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "lib.h" +#include +#include +#include +#include + +#undef main + +#define SEPARATORS " \t" + +extern char **environ; + +int +main(int argc, char **argv) +{ + FILE *f; + char buffer[FILENAME_MAX], *cp, *verstr; + int len; + + if (getenv("PKG_NOWRAP") != NULL) + goto nowrap; + f = fopen(PKG_WRAPCONF_FNAME, "r"); + if (f == NULL) + goto nowrap; + cp = fgets(buffer, 256, f); + fclose(f); + if (cp == NULL) + goto nowrap; + len = strlen(cp); + if (cp[len - 1] == '\n') + cp[len - 1] = '\0'; + while (strchr(SEPARATORS, *cp) != NULL) + cp++; + verstr = cp; + cp = strpbrk(cp, SEPARATORS); + if (cp == NULL) + goto nowrap; + *cp = '\0'; + for (cp = verstr; *cp != '\0'; cp++) + if (isdigit(*cp) == 0) + goto nowrap; + if (atoi(verstr) < PKG_INSTALL_VERSION) + goto nowrap; + cp++; + while (*cp != '\0' && strchr(SEPARATORS, *cp) != NULL) + cp++; + if (*cp == '\0') + goto nowrap; + bcopy(cp, buffer, strlen(cp) + 1); + cp = strpbrk(buffer, SEPARATORS); + if (cp != NULL) + *cp = '\0'; + if (!isdir(buffer)) + goto nowrap; + cp = strrchr(argv[0], '/'); + if (cp == NULL) + cp = argv[0]; + else + cp++; + strlcat(buffer, "/", sizeof(buffer)); + strlcat(buffer, cp, sizeof(buffer)); + setenv("PKG_NOWRAP", "1", 1); + execve(buffer, argv, environ); + +nowrap: + unsetenv("PKG_NOWRAP"); + return(real_main(argc, argv)); +} diff --git a/lib/libpkg/plist.c b/usr.sbin/pkg_install/lib/plist.c similarity index 99% rename from lib/libpkg/plist.c rename to usr.sbin/pkg_install/lib/plist.c index b14ac20aafc0..545b541c3f18 100644 --- a/lib/libpkg/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include diff --git a/lib/libpkg/str.c b/usr.sbin/pkg_install/lib/str.c similarity index 99% rename from lib/libpkg/str.c rename to usr.sbin/pkg_install/lib/str.c index c26e6cce6605..0d9e288b7579 100644 --- a/lib/libpkg/str.c +++ b/usr.sbin/pkg_install/lib/str.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" char * strconcat(const char *s1, const char *s2) diff --git a/lib/libpkg/url.c b/usr.sbin/pkg_install/lib/url.c similarity index 98% rename from lib/libpkg/url.c rename to usr.sbin/pkg_install/lib/url.c index 4c1084994283..8c5534711997 100644 --- a/lib/libpkg/url.c +++ b/usr.sbin/pkg_install/lib/url.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -109,7 +109,7 @@ fileGetURL(const char *base, const char *spec, int keep_package) printf("Error: Unable to get %s: %s\n", fname, fetchLastErrString); /* If the fetch fails, yank the package. */ - if (keep_package && unlink(pkg) < 0) { + if (keep_package && unlink(pkg) < 0 && Verbose) { warnx("failed to remove partially fetched package: %s", pkg); } return NULL; diff --git a/lib/libpkg/version.c b/usr.sbin/pkg_install/lib/version.c similarity index 98% rename from lib/libpkg/version.c rename to usr.sbin/pkg_install/lib/version.c index 123fd5d20e57..d9c4fe7e070c 100644 --- a/lib/libpkg/version.c +++ b/usr.sbin/pkg_install/lib/version.c @@ -19,19 +19,9 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include -/* - * This routine could easily go somewhere else. - * - */ -int -libpkg_version(void) -{ - return LIBPKG_VERSION; -} - /* * Routines to assist with PLIST_FMT_VER numbers in the packing * lists. @@ -76,7 +66,7 @@ split_version(const char *pkgname, const char **endname, unsigned long *epoch, u if (pkgname == NULL) errx(2, "%s: Passed NULL pkgname.", __func__); - /* Look for the last '-' the pkgname */ + /* Look for the last '-' the the pkgname */ ch = strrchr(pkgname, '-'); /* Cheat if we are just passed a version, not a valid package name */ versionstr = ch ? ch + 1 : pkgname; diff --git a/usr.sbin/pkg_install/updating/Makefile b/usr.sbin/pkg_install/updating/Makefile index f5b7525ddb51..b0d3689779e6 100644 --- a/usr.sbin/pkg_install/updating/Makefile +++ b/usr.sbin/pkg_install/updating/Makefile @@ -3,6 +3,11 @@ PROG= pkg_updating SRCS= main.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd + .include diff --git a/usr.sbin/pkg_install/updating/main.c b/usr.sbin/pkg_install/updating/main.c index 993ccd523104..0ab2ec0fe8ea 100644 --- a/usr.sbin/pkg_install/updating/main.c +++ b/usr.sbin/pkg_install/updating/main.c @@ -19,7 +19,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "pathnames.h" typedef struct installedport { @@ -87,8 +87,6 @@ main(int argc, char *argv[]) DIR *dir; FILE *fd; - pkg_wrap(PKG_INSTALL_VERSION, argv); - while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) { switch (ch) { case 'd': diff --git a/usr.sbin/pkg_install/version/Makefile b/usr.sbin/pkg_install/version/Makefile index fb079e34c7ad..3e1d7a522f27 100644 --- a/usr.sbin/pkg_install/version/Makefile +++ b/usr.sbin/pkg_install/version/Makefile @@ -3,8 +3,13 @@ PROG= pkg_version SRCS= main.c perform.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd + test: sh ${.CURDIR}/test-pkg_version.sh diff --git a/usr.sbin/pkg_install/version/main.c b/usr.sbin/pkg_install/version/main.c index 42384970603b..cad8583c23bf 100644 --- a/usr.sbin/pkg_install/version/main.c +++ b/usr.sbin/pkg_install/version/main.c @@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "version.h" char *LimitChars = NULL; @@ -58,8 +58,6 @@ main(int argc, char **argv) { int ch, cmp = 0; - pkg_wrap(PKG_INSTALL_VERSION, argv); - if (argc == 4 && !strcmp(argv[1], "-t")) { cmp = version_cmp(argv[2], argv[3]); printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n")); diff --git a/usr.sbin/pkg_install/version/perform.c b/usr.sbin/pkg_install/version/perform.c index 79575a32ba28..dc85696cfc15 100644 --- a/usr.sbin/pkg_install/version/perform.c +++ b/usr.sbin/pkg_install/version/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "version.h" #include #include From cb315db5989ed2a9a37e44f294478454027f0671 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 19:20:32 +0000 Subject: [PATCH 065/200] Ok, so we use different comment conventions in Symbol.map and Version.def "#notimpressed" as my twittering friends would say. --- lib/libsbuf/Version.def | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/libsbuf/Version.def b/lib/libsbuf/Version.def index cf8a7d41d29b..ab673d917713 100644 --- a/lib/libsbuf/Version.def +++ b/lib/libsbuf/Version.def @@ -1,6 +1,4 @@ -/* - * $FreeBSD$ - */ +# $FreeBSD$ FBSD_1.2 { }; From 7a18096ceacb88e0804cac1c0175300f60bc6a08 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Tue, 17 May 2011 21:03:34 +0000 Subject: [PATCH 066/200] mq_setattr(2): Add missing const to man page. The declaration in the header file is correct. MFC after: 1 week --- lib/libc/sys/mq_setattr.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/sys/mq_setattr.2 b/lib/libc/sys/mq_setattr.2 index 2e5a6b1ad043..79e523d6dd75 100644 --- a/lib/libc/sys/mq_setattr.2 +++ b/lib/libc/sys/mq_setattr.2 @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 29, 2005 +.Dd May 17, 2011 .Dt MQ_SETATTR 2 .Os .Sh NAME @@ -50,7 +50,7 @@ .Ft int .Fo mq_setattr .Fa "mqd_t mqdes" -.Fa "struct mq_attr *restrict mqstat" +.Fa "const struct mq_attr *restrict mqstat" .Fa "struct mq_attr *restrict omqstat" .Fc .Sh DESCRIPTION From 96b7988f12c163e1a9cc6a2597341ecf3dafb007 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 17 May 2011 22:07:45 +0000 Subject: [PATCH 067/200] Add support for "LED" enclosure management messages, defined by the AHCI. When supported by hardware, this allows to control per-port activity, locate and fault LEDs via the led(4) API for localization and status reporting purposes. Supporting AHCI controllers may transmit that information to the backplane controllers via SGPIO interface. Backplane controllers interpret received statuses in some way (IBPI standard) to report them using present indicators. --- share/man/man4/ahci.4 | 20 +++++++++++- sys/dev/ahci/ahci.c | 71 +++++++++++++++++++++++++++++++++++++++++++ sys/dev/ahci/ahci.h | 12 ++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) diff --git a/share/man/man4/ahci.4 b/share/man/man4/ahci.4 index 144d64b831a1..68aea35b6676 100644 --- a/share/man/man4/ahci.4 +++ b/share/man/man4/ahci.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 28, 2010 +.Dd May 17, 2011 .Dt AHCI 4 .Os .Sh NAME @@ -121,6 +121,15 @@ hardware command queues (up to 32 commands per port), Native Command Queuing, SATA interface Power Management, device hot-plug and Message Signaled Interrupts. .Pp +Driver supports "LED" enclosure management messages, defined by the AHCI. +When supported by hardware, it allows to control per-port activity, locate +and fault LEDs via the +.Xr led 4 +API for localization and status reporting purposes. +Supporting AHCI controllers may transmit that information to the backplane +controllers via SGPIO interface. Backplane controllers interpret received +statuses in some way (IBPI standard) to report them using present indicators. +.Pp AHCI hardware is also supported by ataahci driver from .Xr ata 4 subsystem. @@ -135,6 +144,15 @@ subclass 6 (SATA) and programming interface 1 (AHCI). Also, in cooperation with atamarvell and atajmicron drivers of ata(4), it supports AHCI part of legacy-PATA + AHCI-SATA combined controllers, such as JMicron JMB36x and Marvell 88SX61xx. +.Sh FILES +.Bl -tag -width /dev/led/ahcich*.locate +.It Pa /dev/led/ahcich*.act +activity LED device nodes +.It Pa /dev/led/ahcich*.fault +fault LED device nodes +.It Pa /dev/led/ahcich*.locate +locate LED device nodes +.El .Sh SEE ALSO .Xr ada 4 , .Xr ata 4 , diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index 6ff8f9d72ef4..2a064923cf3c 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include "ahci.h" @@ -68,6 +69,7 @@ static int ahci_ch_resume(device_t dev); static void ahci_ch_pm(void *arg); static void ahci_ch_intr_locked(void *data); static void ahci_ch_intr(void *data); +static void ahci_ch_led(void *priv, int onoff); static int ahci_ctlr_reset(device_t dev); static int ahci_ctlr_setup(device_t dev); static void ahci_begin_transaction(device_t dev, union ccb *ccb); @@ -418,6 +420,8 @@ ahci_attach(device_t dev) ctlr->caps &= ~AHCI_CAP_SNCQ; if ((ctlr->caps & AHCI_CAP_CCCS) == 0) ctlr->ccc = 0; + mtx_init(&ctlr->em_mtx, "AHCI EM lock", NULL, MTX_DEF); + ctlr->emloc = ATA_INL(ctlr->r_mem, AHCI_EM_LOC); ahci_ctlr_setup(dev); /* Setup interrupts. */ if (ahci_setup_interrupt(dev)) { @@ -521,6 +525,7 @@ ahci_detach(device_t dev) rman_fini(&ctlr->sc_iomem); if (ctlr->r_mem) bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, ctlr->r_mem); + mtx_destroy(&ctlr->em_mtx); return (0); } @@ -887,6 +892,7 @@ ahci_ch_attach(device_t dev) struct cam_devq *devq; int rid, error, i, sata_rev = 0; u_int32_t version; + char buf[32]; ch->dev = dev; ch->unit = (intptr_t)device_get_ivars(dev); @@ -995,6 +1001,25 @@ ahci_ch_attach(device_t dev) ahci_ch_pm, dev); } mtx_unlock(&ch->mtx); + if ((ch->caps & AHCI_CAP_EMS) && + (ctlr->capsem & AHCI_EM_LED)) { + for (i = 0; i < AHCI_NUM_LEDS; i++) { + ch->leds[i].dev = dev; + ch->leds[i].num = i; + } + if ((ctlr->capsem & AHCI_EM_ALHD) == 0) { + snprintf(buf, sizeof(buf), "%s.act", + device_get_nameunit(dev)); + ch->leds[0].led = led_create(ahci_ch_led, + &ch->leds[0], buf); + } + snprintf(buf, sizeof(buf), "%s.locate", + device_get_nameunit(dev)); + ch->leds[1].led = led_create(ahci_ch_led, &ch->leds[1], buf); + snprintf(buf, sizeof(buf), "%s.fault", + device_get_nameunit(dev)); + ch->leds[2].led = led_create(ahci_ch_led, &ch->leds[2], buf); + } return (0); err3: @@ -1014,7 +1039,12 @@ static int ahci_ch_detach(device_t dev) { struct ahci_channel *ch = device_get_softc(dev); + int i; + for (i = 0; i < AHCI_NUM_LEDS; i++) { + if (ch->leds[i].led) + led_destroy(ch->leds[i].led); + } mtx_lock(&ch->mtx); xpt_async(AC_LOST_DEVICE, ch->path, NULL); /* Forget about reset. */ @@ -1137,6 +1167,47 @@ static driver_t ahcich_driver = { }; DRIVER_MODULE(ahcich, ahci, ahcich_driver, ahcich_devclass, 0, 0); +static void +ahci_ch_setleds(device_t dev) +{ + struct ahci_channel *ch; + struct ahci_controller *ctlr; + size_t buf; + int i, timeout; + int16_t val; + + ctlr = device_get_softc(device_get_parent(dev)); + ch = device_get_softc(dev); + + val = 0; + for (i = 0; i < AHCI_NUM_LEDS; i++) + val |= ch->leds[i].state << (i * 3); + + buf = (ctlr->emloc & 0xffff0000) >> 14; + mtx_lock(&ctlr->em_mtx); + timeout = 1000; + while (ATA_INL(ctlr->r_mem, AHCI_EM_CTL) & (AHCI_EM_TM | AHCI_EM_RST) && + --timeout > 0) + DELAY(1000); + if (timeout == 0) + device_printf(dev, "EM timeout\n"); + ATA_OUTL(ctlr->r_mem, buf, (1 << 8) | (0 << 16) | (0 << 24)); + ATA_OUTL(ctlr->r_mem, buf + 4, ch->unit | (val << 16)); + ATA_OUTL(ctlr->r_mem, AHCI_EM_CTL, AHCI_EM_TM); + mtx_unlock(&ctlr->em_mtx); +} + +static void +ahci_ch_led(void *priv, int onoff) +{ + struct ahci_led *led; + + led = (struct ahci_led *)priv; + + led->state = onoff; + ahci_ch_setleds(led->dev); +} + struct ahci_dc_cb_args { bus_addr_t maddr; int error; diff --git a/sys/dev/ahci/ahci.h b/sys/dev/ahci/ahci.h index cd5356a3f622..3ace69fff925 100644 --- a/sys/dev/ahci/ahci.h +++ b/sys/dev/ahci/ahci.h @@ -376,6 +376,15 @@ struct ahci_device { u_int caps; }; +struct ahci_led { + device_t dev; /* Device handle */ + struct cdev *led; + uint8_t num; /* Number of this led */ + uint8_t state; /* State of this led */ +}; + +#define AHCI_NUM_LEDS 3 + /* structure describing an ATA channel */ struct ahci_channel { device_t dev; /* Device handle */ @@ -386,6 +395,7 @@ struct ahci_channel { struct ata_dma dma; /* DMA data */ struct cam_sim *sim; struct cam_path *path; + struct ahci_led leds[3]; uint32_t caps; /* Controller capabilities */ uint32_t caps2; /* Controller capabilities */ uint32_t chcaps; /* Channel capabilities */ @@ -443,6 +453,7 @@ struct ahci_controller { uint32_t caps; /* Controller capabilities */ uint32_t caps2; /* Controller capabilities */ uint32_t capsem; /* Controller capabilities */ + uint32_t emloc; /* EM buffer location */ int quirks; int numirqs; int channels; @@ -453,6 +464,7 @@ struct ahci_controller { void (*function)(void *); void *argument; } interrupt[AHCI_MAX_PORTS]; + struct mtx em_mtx; /* EM access lock */ }; enum ahci_err_type { From a0a43452ae8f658aa1a6906f432845333d72b1a3 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Tue, 17 May 2011 22:14:00 +0000 Subject: [PATCH 068/200] Merge r221285 from largeSMP project: - Remove the following sysctl: kern.sched.ipiwakeup.onecpu kern.sched.ipiwakeup.htt2 Because they are absolutely obsolete. Probabilly the whole wakeup forward mechanism should be revisited for a better fitting in modern hw, in the future. - As map2 variable is no longer used rename map3 to map2 - Fix a string by making more informative the msg and removing the arguments passing. Reviewed by: julian Tested by: several --- sys/kern/sched_4bsd.c | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 668ecd165e52..fef9e256f6bb 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -235,16 +235,6 @@ SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, useloop, CTLFLAG_RW, &forward_wakeup_use_loop, 0, "Use a loop to find idle cpus"); -static int forward_wakeup_use_single = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, onecpu, CTLFLAG_RW, - &forward_wakeup_use_single, 0, - "Only signal one idle cpu"); - -static int forward_wakeup_use_htt = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, htt2, CTLFLAG_RW, - &forward_wakeup_use_htt, 0, - "account for htt"); - #endif #if 0 static int sched_followon = 0; @@ -1064,7 +1054,7 @@ static int forward_wakeup(int cpunum) { struct pcpu *pc; - cpumask_t dontuse, id, map, map2, map3, me; + cpumask_t dontuse, id, map, map2, me; mtx_assert(&sched_lock, MA_OWNED); @@ -1089,13 +1079,13 @@ forward_wakeup(int cpunum) return (0); dontuse = me | stopped_cpus | hlt_cpus_mask; - map3 = 0; + map2 = 0; if (forward_wakeup_use_loop) { SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { id = pc->pc_cpumask; if ((id & dontuse) == 0 && pc->pc_curthread == pc->pc_idlethread) { - map3 |= id; + map2 |= id; } } } @@ -1106,33 +1096,19 @@ forward_wakeup(int cpunum) /* If they are both on, compare and use loop if different. */ if (forward_wakeup_use_loop) { - if (map != map3) { - printf("map (%02X) != map3 (%02X)\n", map, - map3); - map = map3; + if (map != map2) { + printf("map != map2, loop method preferred\n"); + map = map2; } } } else { - map = map3; + map = map2; } /* If we only allow a specific CPU, then mask off all the others. */ if (cpunum != NOCPU) { KASSERT((cpunum <= mp_maxcpus),("forward_wakeup: bad cpunum.")); map &= (1 << cpunum); - } else { - /* Try choose an idle die. */ - if (forward_wakeup_use_htt) { - map2 = (map & (map >> 1)) & 0x5555; - if (map2) { - map = map2; - } - } - - /* Set only one bit. */ - if (forward_wakeup_use_single) { - map = map & ((~map) + 1); - } } if (map) { forward_wakeups_delivered++; From 179efac924d0edf66e84c551b2aec4cbcbdfb9f1 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Tue, 17 May 2011 22:15:53 +0000 Subject: [PATCH 069/200] Remove an unused typedef. Tested by: sbruno, pluknet --- sys/i386/include/xen/xenvar.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/i386/include/xen/xenvar.h b/sys/i386/include/xen/xenvar.h index 4f8c857fb36d..365930a7960a 100644 --- a/sys/i386/include/xen/xenvar.h +++ b/sys/i386/include/xen/xenvar.h @@ -99,7 +99,6 @@ void xpq_init(void); (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] -typedef struct { DECLARE_BITMAP(bits, NR_CPUS); } xen_cpumask_t; int xen_create_contiguous_region(vm_page_t pages, int npages); From 2b052e43be6a1e94b620193c6244542fdaa835e9 Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Tue, 17 May 2011 22:36:16 +0000 Subject: [PATCH 070/200] Update CPUID bits to reflect AMD Bulldozer and Intel Sandy Bridge features. Note AMD dropped SSE5 extensions in order to avoid ISA overlap with Intel AVX instructions. The SSE5 bit was recycled as XOP extended instruction bit, CVT16 was deprecated in favor of F16C (half-precision float conversion instructions for AVX), and the remaining FMA4 (4-operand FMA instructions) gained a separate CPUID bit. Replace non-existent references with today's CPUID specifications. --- sys/amd64/amd64/identcpu.c | 53 +++++++++++++++++----------------- sys/amd64/include/specialreg.h | 13 ++++++++- sys/i386/i386/identcpu.c | 52 ++++++++++++++++----------------- sys/i386/include/specialreg.h | 13 ++++++++- 4 files changed, 75 insertions(+), 56 deletions(-) diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c index 1da4181f5ea4..805ba1e3dce4 100644 --- a/sys/amd64/amd64/identcpu.c +++ b/sys/amd64/amd64/identcpu.c @@ -216,6 +216,14 @@ printcpuinfo(void) printf(" Family = %x", CPUID_TO_FAMILY(cpu_id)); printf(" Model = %x", CPUID_TO_MODEL(cpu_id)); printf(" Stepping = %u", cpu_id & CPUID_STEPPING); + + /* + * AMD CPUID Specification + * http://support.amd.com/us/Embedded_TechDocs/25481.pdf + * + * Intel Processor Identification and CPUID Instruction + * http://www.intel.com/assets/pdf/appnote/241618.pdf + */ if (cpu_high > 0) { /* @@ -277,38 +285,29 @@ printcpuinfo(void) "\012SSSE3" /* SSSE3 */ "\013CNXT-ID" /* L1 context ID available */ "\014" - "\015" + "\015FMA" /* Fused Multiply Add */ "\016CX16" /* CMPXCHG16B Instruction */ "\017xTPR" /* Send Task Priority Messages*/ "\020PDCM" /* Perf/Debug Capability MSR */ "\021" - "\022PCID" /* Process-context Identifiers */ + "\022PCID" /* Process-context Identifiers*/ "\023DCA" /* Direct Cache Access */ - "\024SSE4.1" - "\025SSE4.2" + "\024SSE4.1" /* SSE 4.1 */ + "\025SSE4.2" /* SSE 4.2 */ "\026x2APIC" /* xAPIC Extensions */ - "\027MOVBE" - "\030POPCNT" - "\031" - "\032AESNI" /* AES Crypto*/ - "\033XSAVE" - "\034OSXSAVE" - "\035" - "\036" + "\027MOVBE" /* MOVBE Instruction */ + "\030POPCNT" /* POPCNT Instruction */ + "\031TSCDLT" /* TSC-Deadline Timer */ + "\032AESNI" /* AES Crypto */ + "\033XSAVE" /* XSAVE/XRSTOR States */ + "\034OSXSAVE" /* OS-Enabled State Management*/ + "\035AVX" /* Advanced Vector Extensions */ + "\036F16C" /* Half-precision conversions */ "\037" "\040HV" /* Hypervisor */ ); } - /* - * AMD64 Architecture Programmer's Manual Volume 3: - * General-Purpose and System Instructions - * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24594.pdf - * - * IA-32 Intel Architecture Software Developer's Manual, - * Volume 2A: Instruction Set Reference, A-M - * ftp://download.intel.com/design/Pentium4/manuals/25366617.pdf - */ if (amd_feature != 0) { printf("\n AMD Features=0x%b", amd_feature, "\020" /* in hex */ @@ -361,18 +360,18 @@ printcpuinfo(void) "\011Prefetch" /* 3DNow! Prefetch/PrefetchW */ "\012OSVW" /* OS visible workaround */ "\013IBS" /* Instruction based sampling */ - "\014SSE5" /* SSE5 */ + "\014XOP" /* XOP extended instructions */ "\015SKINIT" /* SKINIT/STGI */ "\016WDT" /* Watchdog timer */ "\017" - "\020" - "\021" + "\020LWP" /* Lightweight Profiling */ + "\021FMA4" /* 4-operand FMA instructions */ "\022" "\023" - "\024" + "\024NodeId" /* NodeId MSR support */ "\025" - "\026" - "\027" + "\026TBM" /* Trailing Bit Manipulation */ + "\027Topology" /* Topology Extensions */ "\030" "\031" "\032" diff --git a/sys/amd64/include/specialreg.h b/sys/amd64/include/specialreg.h index ac5206358b5e..4c501660909a 100644 --- a/sys/amd64/include/specialreg.h +++ b/sys/amd64/include/specialreg.h @@ -123,6 +123,7 @@ #define CPUID2_TM2 0x00000100 #define CPUID2_SSSE3 0x00000200 #define CPUID2_CNXTID 0x00000400 +#define CPUID2_FMA 0x00001000 #define CPUID2_CX16 0x00002000 #define CPUID2_XTPR 0x00004000 #define CPUID2_PDCM 0x00008000 @@ -133,7 +134,12 @@ #define CPUID2_X2APIC 0x00200000 #define CPUID2_MOVBE 0x00400000 #define CPUID2_POPCNT 0x00800000 +#define CPUID2_TSCDLT 0x01000000 #define CPUID2_AESNI 0x02000000 +#define CPUID2_XSAVE 0x04000000 +#define CPUID2_OSXSAVE 0x08000000 +#define CPUID2_AVX 0x10000000 +#define CPUID2_F16C 0x20000000 #define CPUID2_HV 0x80000000 /* @@ -170,9 +176,14 @@ #define AMDID2_PREFETCH 0x00000100 #define AMDID2_OSVW 0x00000200 #define AMDID2_IBS 0x00000400 -#define AMDID2_SSE5 0x00000800 +#define AMDID2_XOP 0x00000800 #define AMDID2_SKINIT 0x00001000 #define AMDID2_WDT 0x00002000 +#define AMDID2_LWP 0x00008000 +#define AMDID2_FMA4 0x00010000 +#define AMDID2_NODE_ID 0x00080000 +#define AMDID2_TBM 0x00200000 +#define AMDID2_TOPOLOGY 0x00400000 /* * CPUID instruction 1 eax info diff --git a/sys/i386/i386/identcpu.c b/sys/i386/i386/identcpu.c index cd90d478ee43..de0ee09a8ce2 100644 --- a/sys/i386/i386/identcpu.c +++ b/sys/i386/i386/identcpu.c @@ -693,6 +693,13 @@ printcpuinfo(void) printf(" Stepping = %u", cpu_id & CPUID_STEPPING); if (cpu_vendor_id == CPU_VENDOR_CYRIX) printf("\n DIR=0x%04x", cyrix_did); + /* + * AMD CPUID Specification + * http://support.amd.com/us/Embedded_TechDocs/25481.pdf + * + * Intel Processor Identification and CPUID Instruction + * http://www.intel.com/assets/pdf/appnote/241618.pdf + */ if (cpu_high > 0) { /* @@ -754,38 +761,29 @@ printcpuinfo(void) "\012SSSE3" /* SSSE3 */ "\013CNXT-ID" /* L1 context ID available */ "\014" - "\015" + "\015FMA" /* Fused Multiply Add */ "\016CX16" /* CMPXCHG16B Instruction */ "\017xTPR" /* Send Task Priority Messages*/ "\020PDCM" /* Perf/Debug Capability MSR */ "\021" - "\022PCID" /* Process-context Identifiers */ + "\022PCID" /* Process-context Identifiers*/ "\023DCA" /* Direct Cache Access */ - "\024SSE4.1" - "\025SSE4.2" + "\024SSE4.1" /* SSE 4.1 */ + "\025SSE4.2" /* SSE 4.2 */ "\026x2APIC" /* xAPIC Extensions */ - "\027MOVBE" - "\030POPCNT" - "\031" - "\032AESNI" /* AES Crypto*/ - "\033XSAVE" - "\034OSXSAVE" - "\035" - "\036" + "\027MOVBE" /* MOVBE Instruction */ + "\030POPCNT" /* POPCNT Instruction */ + "\031TSCDLT" /* TSC-Deadline Timer */ + "\032AESNI" /* AES Crypto */ + "\033XSAVE" /* XSAVE/XRSTOR States */ + "\034OSXSAVE" /* OS-Enabled State Management*/ + "\035AVX" /* Advanced Vector Extensions */ + "\036F16C" /* Half-precision conversions */ "\037" "\040HV" /* Hypervisor */ ); } - /* - * AMD64 Architecture Programmer's Manual Volume 3: - * General-Purpose and System Instructions - * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24594.pdf - * - * IA-32 Intel Architecture Software Developer's Manual, - * Volume 2A: Instruction Set Reference, A-M - * ftp://download.intel.com/design/Pentium4/manuals/25366617.pdf - */ if (amd_feature != 0) { printf("\n AMD Features=0x%b", amd_feature, "\020" /* in hex */ @@ -838,18 +836,18 @@ printcpuinfo(void) "\011Prefetch" /* 3DNow! Prefetch/PrefetchW */ "\012OSVW" /* OS visible workaround */ "\013IBS" /* Instruction based sampling */ - "\014SSE5" /* SSE5 */ + "\014XOP" /* XOP extended instructions */ "\015SKINIT" /* SKINIT/STGI */ "\016WDT" /* Watchdog timer */ "\017" - "\020" - "\021" + "\020LWP" /* Lightweight Profiling */ + "\021FMA4" /* 4-operand FMA instructions */ "\022" "\023" - "\024" + "\024NodeId" /* NodeId MSR support */ "\025" - "\026" - "\027" + "\026TBM" /* Trailing Bit Manipulation */ + "\027Topology" /* Topology Extensions */ "\030" "\031" "\032" diff --git a/sys/i386/include/specialreg.h b/sys/i386/include/specialreg.h index adccaf4483f9..e3199f7a1a36 100644 --- a/sys/i386/include/specialreg.h +++ b/sys/i386/include/specialreg.h @@ -120,6 +120,7 @@ #define CPUID2_TM2 0x00000100 #define CPUID2_SSSE3 0x00000200 #define CPUID2_CNXTID 0x00000400 +#define CPUID2_FMA 0x00001000 #define CPUID2_CX16 0x00002000 #define CPUID2_XTPR 0x00004000 #define CPUID2_PDCM 0x00008000 @@ -130,7 +131,12 @@ #define CPUID2_X2APIC 0x00200000 #define CPUID2_MOVBE 0x00400000 #define CPUID2_POPCNT 0x00800000 +#define CPUID2_TSCDLT 0x01000000 #define CPUID2_AESNI 0x02000000 +#define CPUID2_XSAVE 0x04000000 +#define CPUID2_OSXSAVE 0x08000000 +#define CPUID2_AVX 0x10000000 +#define CPUID2_F16C 0x20000000 #define CPUID2_HV 0x80000000 /* @@ -167,9 +173,14 @@ #define AMDID2_PREFETCH 0x00000100 #define AMDID2_OSVW 0x00000200 #define AMDID2_IBS 0x00000400 -#define AMDID2_SSE5 0x00000800 +#define AMDID2_XOP 0x00000800 #define AMDID2_SKINIT 0x00001000 #define AMDID2_WDT 0x00002000 +#define AMDID2_LWP 0x00008000 +#define AMDID2_FMA4 0x00010000 +#define AMDID2_NODE_ID 0x00080000 +#define AMDID2_TBM 0x00200000 +#define AMDID2_TOPOLOGY 0x00400000 /* * CPUID instruction 1 eax info From 369589482c4752eb75f2bbd58c345b0e2f950cfd Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 18 May 2011 07:20:30 +0000 Subject: [PATCH 071/200] Modify the sample rate control algorithm to only select/sample HT rates for HT nodes. --- sys/dev/ath/ath_rate/sample/sample.c | 34 +++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/sys/dev/ath/ath_rate/sample/sample.c b/sys/dev/ath/ath_rate/sample/sample.c index 312623e05660..27bb98cf8739 100644 --- a/sys/dev/ath/ath_rate/sample/sample.c +++ b/sys/dev/ath/ath_rate/sample/sample.c @@ -161,9 +161,10 @@ dot11rate_label(const HAL_RATE_TABLE *rt, int rix) * or -1 if all the average_tx_times are 0. */ static __inline int -pick_best_rate(struct sample_node *sn, const HAL_RATE_TABLE *rt, +pick_best_rate(struct ath_node *an, const HAL_RATE_TABLE *rt, int size_bin, int require_acked_before) { + struct sample_node *sn = ATH_NODE_SAMPLE(an); int best_rate_rix, best_rate_tt; uint32_t mask; int rix, tt; @@ -174,6 +175,12 @@ pick_best_rate(struct sample_node *sn, const HAL_RATE_TABLE *rt, if ((mask & 1) == 0) /* not a supported rate */ continue; + /* Don't pick a non-HT rate for a HT node */ + if ((an->an_node.ni_flags & IEEE80211_NODE_HT) && + (rt->info[rix].phy != IEEE80211_T_HT)) { + continue; + } + tt = sn->stats[size_bin][rix].average_tx_time; if (tt <= 0 || (require_acked_before && @@ -196,11 +203,12 @@ pick_best_rate(struct sample_node *sn, const HAL_RATE_TABLE *rt, * Pick a good "random" bit-rate to sample other than the current one. */ static __inline int -pick_sample_rate(struct sample_softc *ssc , struct sample_node *sn, +pick_sample_rate(struct sample_softc *ssc , struct ath_node *an, const HAL_RATE_TABLE *rt, int size_bin) { #define DOT11RATE(ix) (rt->info[ix].dot11Rate & IEEE80211_RATE_VAL) #define MCS(ix) (rt->info[ix].dot11Rate | IEEE80211_RATE_MCS) + struct sample_node *sn = ATH_NODE_SAMPLE(an); int current_rix, rix; unsigned current_tt; uint32_t mask; @@ -208,6 +216,7 @@ pick_sample_rate(struct sample_softc *ssc , struct sample_node *sn, current_rix = sn->current_rix[size_bin]; if (current_rix < 0) { /* no successes yet, send at the lowest bit-rate */ + /* XXX should return MCS0 if HT */ return 0; } @@ -223,6 +232,13 @@ pick_sample_rate(struct sample_softc *ssc , struct sample_node *sn, continue; } + /* if the node is HT and the rate isn't HT, don't bother sample */ + if ((an->an_node.ni_flags & IEEE80211_NODE_HT) && + (rt->info[rix].phy != IEEE80211_T_HT)) { + mask &= ~(1<stats[size_bin][rix].perfect_tx_time > current_tt) { mask &= ~(1< 11M */ - if (DOT11RATE(rix) > 2*11 && rix > current_rix + 2) { - mask &= ~(1< 11M for non-HT rates */ + if (! (an->an_node.ni_flags & IEEE80211_NODE_HT)) { + if (DOT11RATE(rix) > 2*11 && rix > current_rix + 2) { + mask &= ~(1<last_sample_rix[size_bin] = rix; @@ -327,7 +345,7 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, /* XXX TODO: this doesn't know about 11gn vs 11g protection; teach it */ mrr = sc->sc_mrretry && !(ic->ic_flags & IEEE80211_F_USEPROT); - best_rix = pick_best_rate(sn, rt, size_bin, !mrr); + best_rix = pick_best_rate(an, rt, size_bin, !mrr); if (best_rix >= 0) { average_tx_time = sn->stats[size_bin][best_rix].average_tx_time; } else { @@ -338,7 +356,7 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, * rates to sample_rate% of the total transmission time. */ if (sn->sample_tt[size_bin] < average_tx_time * (sn->packets_since_sample[size_bin]*ssc->sample_rate/100)) { - rix = pick_sample_rate(ssc, sn, rt, size_bin); + rix = pick_sample_rate(ssc, an, rt, size_bin); IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, &an->an_node, "size %u sample rate %d current rate %d", bin_to_size(size_bin), RATE(rix), From a5c44f92bfe1540bdfc14080933465e5cf2510e8 Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Wed, 18 May 2011 07:37:02 +0000 Subject: [PATCH 072/200] Restore old (v15) behaviour for a recursive snapshot destroy. (zfs destroy -r pool/dataset@snapshot) To destroy all descendent snapshots with the same name the top level snapshot was not required to exist. So if the top level snapshot does not exist, check permissions of the parent dataset instead. Filed as Illumos Bug #1043 Reviewed by: delphij Approved by: pjd MFC after: together with v28 --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c index f8912ca4e29f..ba13747ddb38 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c @@ -689,6 +689,9 @@ zfs_secpolicy_destroy(zfs_cmd_t *zc, cred_t *cr) * and destroying snapshots requires descendent permissions, a successfull * check of the top level snapshot applies to snapshots of all descendent * datasets as well. + * + * The top level snapshot may not exist when doing a recursive destroy. + * In this case fallback to permissions of the parent dataset. */ static int zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, cred_t *cr) @@ -700,6 +703,9 @@ zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, cred_t *cr) error = zfs_secpolicy_destroy_perms(dsname, cr); + if (error == ENOENT) + error = zfs_secpolicy_destroy_perms(zc->zc_name, cr); + strfree(dsname); return (error); } From cd10bffa61fbecc3f1a8563bf8e773e780ed581b Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Wed, 18 May 2011 07:40:12 +0000 Subject: [PATCH 073/200] usb: change to one-pass probing of device drivers This brings USB bus more in line with how newbus is supposed to be used. Also, because of the two-pass probing the following message was produced by devd in default configuration when almost any USB device was connected: Unknown USB device: vendor <> product <> bus <> This should be fixed now. Note that many USB device drivers pass some information from probe method to attach method via ivars. For this to continue working we rely on the fact that the subr_bus code calls probe method of a winning driver again before calling its attach method in the case where multiple drivers claim to support a device. This is done because device description is set in successful probe methods and we want to get a correct device description from a winning driver. So now this logic is re-used for setting ivars too. Reviewed by: hselasky MFC after: 1 month --- sys/dev/sound/usb/uaudio.c | 7 ++----- sys/dev/usb/input/uhid.c | 4 ---- sys/dev/usb/input/ukbd.c | 4 ++-- sys/dev/usb/input/ums.c | 4 ++-- sys/dev/usb/storage/umass.c | 5 +---- sys/dev/usb/storage/ustorage_fs.c | 6 +----- sys/dev/usb/usb_device.c | 11 ----------- sys/dev/usb/usbdi.h | 1 - 8 files changed, 8 insertions(+), 34 deletions(-) diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 8fbb7a6bdfec..4f8670a5213e 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -539,9 +539,6 @@ uaudio_probe(device_t dev) if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - if (uaa->use_generic == 0) - return (ENXIO); - /* lookup non-standard device */ if (uaa->info.bInterfaceClass != UICLASS_AUDIO) { @@ -555,7 +552,7 @@ uaudio_probe(device_t dev) if (usb_test_quirk(uaa, UQ_BAD_AUDIO)) return (ENXIO); else - return (0); + return (BUS_PROBE_GENERIC); } /* check for MIDI stream */ @@ -564,7 +561,7 @@ uaudio_probe(device_t dev) if (usb_test_quirk(uaa, UQ_BAD_MIDI)) return (ENXIO); else - return (0); + return (BUS_PROBE_GENERIC); } return (ENXIO); } diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c index 8b33f83c860f..a7fd899c6fe0 100644 --- a/sys/dev/usb/input/uhid.c +++ b/sys/dev/usb/input/uhid.c @@ -617,10 +617,6 @@ uhid_probe(device_t dev) if (uaa->usb_mode != USB_MODE_HOST) { return (ENXIO); } - if (uaa->use_generic == 0) { - /* give Mouse and Keyboard drivers a try first */ - return (ENXIO); - } if (uaa->info.bInterfaceClass != UICLASS_HID) { /* the Xbox 360 gamepad doesn't use the HID class */ diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index 201523338485..918266389a49 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -771,7 +771,7 @@ ukbd_probe(device_t dev) if (usb_test_quirk(uaa, UQ_KBD_IGNORE)) return (ENXIO); else - return (BUS_PROBE_GENERIC); + return (BUS_PROBE_DEFAULT); } error = usbd_req_get_hid_desc(uaa->device, NULL, @@ -793,7 +793,7 @@ ukbd_probe(device_t dev) if (usb_test_quirk(uaa, UQ_KBD_IGNORE)) error = ENXIO; else - error = BUS_PROBE_GENERIC; + error = BUS_PROBE_DEFAULT; } else error = ENXIO; diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c index af4bfc9fc0af..af9aa1f3a980 100644 --- a/sys/dev/usb/input/ums.c +++ b/sys/dev/usb/input/ums.c @@ -373,7 +373,7 @@ ums_probe(device_t dev) if ((uaa->info.bInterfaceSubClass == UISUBCLASS_BOOT) && (uaa->info.bInterfaceProtocol == UIPROTO_MOUSE)) - return (BUS_PROBE_GENERIC); + return (BUS_PROBE_DEFAULT); error = usbd_req_get_hid_desc(uaa->device, NULL, &d_ptr, &d_len, M_TEMP, uaa->info.bIfaceIndex); @@ -383,7 +383,7 @@ ums_probe(device_t dev) if (hid_is_collection(d_ptr, d_len, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE))) - error = BUS_PROBE_GENERIC; + error = BUS_PROBE_DEFAULT; else error = ENXIO; diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c index de6ad9da9a92..158d8432d7db 100644 --- a/sys/dev/usb/storage/umass.c +++ b/sys/dev/usb/storage/umass.c @@ -782,6 +782,7 @@ umass_probe_proto(device_t dev, struct usb_attach_arg *uaa) uint32_t proto = umass_get_proto(uaa->iface); memset(&ret, 0, sizeof(ret)); + ret.error = BUS_PROBE_GENERIC; /* Search for protocol enforcement */ @@ -870,10 +871,6 @@ umass_probe(device_t dev) if (uaa->usb_mode != USB_MODE_HOST) { return (ENXIO); } - if (uaa->use_generic == 0) { - /* give other drivers a try first */ - return (ENXIO); - } temp = umass_probe_proto(dev, uaa); return (temp.error); diff --git a/sys/dev/usb/storage/ustorage_fs.c b/sys/dev/usb/storage/ustorage_fs.c index c62c96b74cc2..dbf025ab895e 100644 --- a/sys/dev/usb/storage/ustorage_fs.c +++ b/sys/dev/usb/storage/ustorage_fs.c @@ -334,10 +334,6 @@ ustorage_fs_probe(device_t dev) if (uaa->usb_mode != USB_MODE_DEVICE) { return (ENXIO); } - if (uaa->use_generic == 0) { - /* give other drivers a try first */ - return (ENXIO); - } /* Check for a standards compliant device */ id = usbd_get_interface_descriptor(uaa->iface); if ((id == NULL) || @@ -346,7 +342,7 @@ ustorage_fs_probe(device_t dev) (id->bInterfaceProtocol != UIPROTO_MASS_BBB)) { return (ENXIO); } - return (0); + return (BUS_PROBE_GENERIC); } static int diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index a8b79a84b781..893e79dba07f 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -1334,7 +1334,6 @@ usb_probe_and_attach(struct usb_device *udev, uint8_t iface_index) uaa.info.bIfaceIndex = i; uaa.info.bIfaceNum = iface->idesc->bInterfaceNumber; - uaa.use_generic = 0; uaa.driver_info = 0; /* reset driver_info */ DPRINTFN(2, "iclass=%u/%u/%u iindex=%u/%u\n", @@ -1344,16 +1343,6 @@ usb_probe_and_attach(struct usb_device *udev, uint8_t iface_index) uaa.info.bIfaceIndex, uaa.info.bIfaceNum); - /* try specific interface drivers first */ - - if (usb_probe_and_attach_sub(udev, &uaa)) { - /* ignore */ - } - /* try generic interface drivers last */ - - uaa.use_generic = 1; - uaa.driver_info = 0; /* reset driver_info */ - if (usb_probe_and_attach_sub(udev, &uaa)) { /* ignore */ } diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index 9bd326e70709..8f6da7c68c81 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -357,7 +357,6 @@ struct usb_attach_arg { struct usb_interface *iface; /* current interface */ enum usb_hc_mode usb_mode; /* host or device mode */ uint8_t port; - uint8_t use_generic; /* hint for generic drivers */ uint8_t dev_state; #define UAA_DEV_READY 0 #define UAA_DEV_DISABLED 1 From d7b666ae97435451e040737b6c8e779958150e58 Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Wed, 18 May 2011 10:04:54 +0000 Subject: [PATCH 074/200] Release allocated memory in procstat_close(). Reviewed by: stass --- lib/libprocstat/libprocstat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 8440bec2cbc6..384fe735e643 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -132,6 +132,7 @@ procstat_close(struct procstat *procstat) assert(procstat); if (procstat->type == PROCSTAT_KVM) kvm_close(procstat->kd); + free(procstat); } struct procstat * From db18c342da790302fd549fd726c03fc30fd030aa Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 18 May 2011 11:28:23 +0000 Subject: [PATCH 075/200] This isn't needed any longer, it's defined in ah_internal.h. --- sys/dev/ath/ath_hal/ar5416/ar5416_reset.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c index e45a8293e1fa..d2ae351f7306 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c @@ -1368,10 +1368,6 @@ ar5416UpdateChainMasks(struct ath_hal *ah, HAL_BOOL is_ht) AH5416(ah)->ah_rx_chainmask); } -#ifndef IS_5GHZ_FAST_CLOCK_EN -#define IS_5GHZ_FAST_CLOCK_EN(ah, chan) AH_FALSE -#endif - void ar5416InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan) { From a5db8fd19e563ac2a63309a867b91017ad5f01f3 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Wed, 18 May 2011 11:38:36 +0000 Subject: [PATCH 076/200] usb: fix a missed use of use_generic in r222051 Submitted by: gcooper Pointyhat to: avg MFC after: 1 month X-MFC with: r222051 --- sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c index ee7fc35ab756..a13ef4d05f96 100644 --- a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c +++ b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c @@ -409,6 +409,7 @@ static int ubt_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); + int error; if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); @@ -416,14 +417,14 @@ ubt_probe(device_t dev) if (uaa->info.bIfaceIndex != 0) return (ENXIO); - if (uaa->use_generic == 0) - return (ENXIO); - if (usbd_lookup_id_by_uaa(ubt_ignore_devs, sizeof(ubt_ignore_devs), uaa) == 0) return (ENXIO); - return (usbd_lookup_id_by_uaa(ubt_devs, sizeof(ubt_devs), uaa)); + error = usbd_lookup_id_by_uaa(ubt_devs, sizeof(ubt_devs), uaa); + if (error == 0) + return (BUS_PROBE_GENERIC); + return (error); } /* ubt_probe */ /* From 3a0318e055cbc7d4173c9d62e828bbe3f4f6d3a3 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Wed, 18 May 2011 16:07:30 +0000 Subject: [PATCH 077/200] Merge part of r221322 from largeSMP project: Sync XEN support with i386 about the usage of ipi_send_cpu() Tested by: pluknet MFC after: 2 weeks --- sys/i386/xen/mp_machdep.c | 70 +++++++++++++++------------------------ 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 1bfc0e9dbe1d..2919570b647e 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -959,6 +959,30 @@ start_ap(int apic_id) return 0; /* return FAILURE */ } +/* + * send an IPI to a specific CPU. + */ +static void +ipi_send_cpu(int cpu, u_int ipi) +{ + u_int bitmap, old_pending, new_pending; + + if (IPI_IS_BITMAPED(ipi)) { + bitmap = 1 << ipi; + ipi = IPI_BITMAP_VECTOR; + do { + old_pending = cpu_ipi_pending[cpu]; + new_pending = old_pending | bitmap; + } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], + old_pending, new_pending)); + if (!old_pending) + ipi_pcpu(cpu, RESCHEDULE_VECTOR); + } else { + KASSERT(call_data != NULL, ("call_data not set")); + ipi_pcpu(cpu, CALL_FUNCTION_VECTOR); + } +} + /* * Flush the TLB on all other CPU's */ @@ -1101,14 +1125,6 @@ void ipi_selected(cpumask_t cpus, u_int ipi) { int cpu; - u_int bitmap = 0; - u_int old_pending; - u_int new_pending; - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - } /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit @@ -1118,23 +1134,11 @@ ipi_selected(cpumask_t cpus, u_int ipi) if (ipi == IPI_STOP_HARD) atomic_set_int(&ipi_nmi_pending, cpus); - CTR3(KTR_SMP, "%s: cpus: %x ipi: %x", __func__, cpus, ipi); while ((cpu = ffs(cpus)) != 0) { cpu--; cpus &= ~(1 << cpu); - - if (bitmap) { - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (!old_pending) - ipi_pcpu(cpu, RESCHEDULE_VECTOR); - } else { - KASSERT(call_data != NULL, ("call_data not set")); - ipi_pcpu(cpu, CALL_FUNCTION_VECTOR); - } + CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); + ipi_send_cpu(cpu, ipi); } } @@ -1144,14 +1148,6 @@ ipi_selected(cpumask_t cpus, u_int ipi) void ipi_cpu(int cpu, u_int ipi) { - u_int bitmap = 0; - u_int old_pending; - u_int new_pending; - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - } /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit @@ -1162,19 +1158,7 @@ ipi_cpu(int cpu, u_int ipi) atomic_set_int(&ipi_nmi_pending, 1 << cpu); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); - - if (bitmap) { - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (!old_pending) - ipi_pcpu(cpu, RESCHEDULE_VECTOR); - } else { - KASSERT(call_data != NULL, ("call_data not set")); - ipi_pcpu(cpu, CALL_FUNCTION_VECTOR); - } + ipi_send_cpu(cpu, ipi); } /* From db4b2ef5a2d64df17a5a584ed96df76fad48b988 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Wed, 18 May 2011 16:41:38 +0000 Subject: [PATCH 078/200] Fix newly introduced code. Reported by: sbruno --- sys/powerpc/booke/platform_bare.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/powerpc/booke/platform_bare.c b/sys/powerpc/booke/platform_bare.c index 8e03bd32d460..de26128c49f3 100644 --- a/sys/powerpc/booke/platform_bare.c +++ b/sys/powerpc/booke/platform_bare.c @@ -241,7 +241,7 @@ bare_smp_start_cpu(platform_t plat, struct pcpu *pc) int timeout; eebpcr = ccsr_read4(OCP85XX_EEBPCR); - if ((eebpcr & (pc->pc_cpumask << 24)) != 0) { + if ((eebpcr & (1 << (pc->pc_cpuid + 24))) != 0) { printf("%s: CPU=%d already out of hold-off state!\n", __func__, pc->pc_cpuid); return (ENXIO); @@ -259,7 +259,8 @@ bare_smp_start_cpu(platform_t plat, struct pcpu *pc) /* * Release AP from hold-off state */ - eebpcr |= (pc->pc_cpumask << 24); + + eebpcr |= (1 << (pc->pc_cpuid + 24)); ccsr_write4(OCP85XX_EEBPCR, eebpcr); __asm __volatile("isync; msync"); From 1a203896c32f7ee5897cdf63c9906727040ef009 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Wed, 18 May 2011 16:42:01 +0000 Subject: [PATCH 079/200] Fix warning spit out. Reported by: sbruno --- sys/powerpc/booke/pmap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c index 2fffa3f14b96..11be68efb996 100644 --- a/sys/powerpc/booke/pmap.c +++ b/sys/powerpc/booke/pmap.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -1228,7 +1229,7 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_offset_t kernelend) PTE_VALID; } /* Mark kernel_pmap active on all CPUs */ - kernel_pmap->pm_active = ~0; + CPU_FILL(&kernel_pmap->pm_active); /*******************************************************/ /* Final setup */ @@ -1483,7 +1484,7 @@ mmu_booke_pinit(mmu_t mmu, pmap_t pmap) PMAP_LOCK_INIT(pmap); for (i = 0; i < MAXCPU; i++) pmap->pm_tid[i] = TID_NONE; - pmap->pm_active = 0; + CPU_ZERO(&kernel_pmap->pm_active); bzero(&pmap->pm_stats, sizeof(pmap->pm_stats)); bzero(&pmap->pm_pdir, sizeof(pte_t *) * PDIR_NENTRIES); TAILQ_INIT(&pmap->pm_ptbl_list); @@ -1838,7 +1839,7 @@ mmu_booke_activate(mmu_t mmu, struct thread *td) mtx_lock_spin(&sched_lock); - atomic_set_int(&pmap->pm_active, PCPU_GET(cpumask)); + CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); PCPU_SET(curpmap, pmap); if (pmap->pm_tid[PCPU_GET(cpuid)] == TID_NONE) @@ -1867,7 +1868,9 @@ mmu_booke_deactivate(mmu_t mmu, struct thread *td) CTR5(KTR_PMAP, "%s: td=%p, proc = '%s', id = %d, pmap = 0x%08x", __func__, td, td->td_proc->p_comm, td->td_proc->p_pid, pmap); - atomic_clear_int(&pmap->pm_active, PCPU_GET(cpumask)); + sched_pin(); + CPU_NAND_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); + sched_unpin(); PCPU_SET(curpmap, NULL); } From c98b35868fa5649379b0f5e3a7900820fe53f8f6 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Wed, 18 May 2011 16:50:13 +0000 Subject: [PATCH 080/200] Revert r222069,222068 as they were intended to be committed to the largeSMP branch. Reported by: pluknet --- sys/powerpc/booke/platform_bare.c | 5 ++--- sys/powerpc/booke/pmap.c | 11 ++++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/sys/powerpc/booke/platform_bare.c b/sys/powerpc/booke/platform_bare.c index de26128c49f3..8e03bd32d460 100644 --- a/sys/powerpc/booke/platform_bare.c +++ b/sys/powerpc/booke/platform_bare.c @@ -241,7 +241,7 @@ bare_smp_start_cpu(platform_t plat, struct pcpu *pc) int timeout; eebpcr = ccsr_read4(OCP85XX_EEBPCR); - if ((eebpcr & (1 << (pc->pc_cpuid + 24))) != 0) { + if ((eebpcr & (pc->pc_cpumask << 24)) != 0) { printf("%s: CPU=%d already out of hold-off state!\n", __func__, pc->pc_cpuid); return (ENXIO); @@ -259,8 +259,7 @@ bare_smp_start_cpu(platform_t plat, struct pcpu *pc) /* * Release AP from hold-off state */ - - eebpcr |= (1 << (pc->pc_cpuid + 24)); + eebpcr |= (pc->pc_cpumask << 24); ccsr_write4(OCP85XX_EEBPCR, eebpcr); __asm __volatile("isync; msync"); diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c index 11be68efb996..2fffa3f14b96 100644 --- a/sys/powerpc/booke/pmap.c +++ b/sys/powerpc/booke/pmap.c @@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -1229,7 +1228,7 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_offset_t kernelend) PTE_VALID; } /* Mark kernel_pmap active on all CPUs */ - CPU_FILL(&kernel_pmap->pm_active); + kernel_pmap->pm_active = ~0; /*******************************************************/ /* Final setup */ @@ -1484,7 +1483,7 @@ mmu_booke_pinit(mmu_t mmu, pmap_t pmap) PMAP_LOCK_INIT(pmap); for (i = 0; i < MAXCPU; i++) pmap->pm_tid[i] = TID_NONE; - CPU_ZERO(&kernel_pmap->pm_active); + pmap->pm_active = 0; bzero(&pmap->pm_stats, sizeof(pmap->pm_stats)); bzero(&pmap->pm_pdir, sizeof(pte_t *) * PDIR_NENTRIES); TAILQ_INIT(&pmap->pm_ptbl_list); @@ -1839,7 +1838,7 @@ mmu_booke_activate(mmu_t mmu, struct thread *td) mtx_lock_spin(&sched_lock); - CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); + atomic_set_int(&pmap->pm_active, PCPU_GET(cpumask)); PCPU_SET(curpmap, pmap); if (pmap->pm_tid[PCPU_GET(cpuid)] == TID_NONE) @@ -1868,9 +1867,7 @@ mmu_booke_deactivate(mmu_t mmu, struct thread *td) CTR5(KTR_PMAP, "%s: td=%p, proc = '%s', id = %d, pmap = 0x%08x", __func__, td, td->td_proc->p_comm, td->td_proc->p_pid, pmap); - sched_pin(); - CPU_NAND_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); - sched_unpin(); + atomic_clear_int(&pmap->pm_active, PCPU_GET(cpumask)); PCPU_SET(curpmap, NULL); } From 4b7e61167509e9e546c6b0a2958734228956c2ca Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 18 May 2011 17:06:11 +0000 Subject: [PATCH 081/200] Clean up a loose end from the conversion from gnu ar/ranlib to the BSD one. Without this, we don't have ar or randlib in the tool path, leading to much pain for some users. This pain is exposed by the external toolchain enhancements that I'm working on. Submitted by: John Hein (ages ago, and dropped on the floor by me: sorry) --- Makefile.inc1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 4aa53da83d2f..1e613affecda 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1552,7 +1552,8 @@ _xb-build-tools: _xb-cross-tools: .for _tool in \ gnu/usr.bin/binutils \ - gnu/usr.bin/cc + gnu/usr.bin/cc \ + usr.bin/ar ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ obj; \ @@ -1577,7 +1578,8 @@ _xi-cross-tools: @echo "_xi-cross-tools" .for _tool in \ gnu/usr.bin/binutils \ - gnu/usr.bin/cc + gnu/usr.bin/cc \ + usr.bin/ar ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR} From 0bd47e8362e1eee02d034e0479dd79673ec06bcc Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Wed, 18 May 2011 17:39:28 +0000 Subject: [PATCH 082/200] As requested by many people, with final prodding from Jason Hall, fix this so that running make release causes make obj to be run before doing anything. This fixes a bug wherein, when run for the first time, and without -DNOSRC, make release would attempt to recursively tar up the src directory including its own output and enter an infinite loop. While here, make the cross-building stuff work a little more the way it should if only one of TARGET/TARGET_ARCH is specified. --- release/Makefile | 10 ++++++---- release/generate-release.sh | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/release/Makefile b/release/Makefile index 1dde3b106149..081cdbf75115 100644 --- a/release/Makefile +++ b/release/Makefile @@ -25,11 +25,11 @@ PORTSDIR?= /usr/ports DOCDIR?= /usr/doc RELNOTES_LANG?= en_US.ISO8859-1 -TARGET_ARCH?= ${MACHINE_ARCH} -.if ${TARGET_ARCH} == ${MACHINE_ARCH} TARGET?= ${MACHINE} +.if ${TARGET} == ${MACHINE} +TARGET_ARCH?= ${MACHINE_ARCH} .else -TARGET?= ${TARGET_ARCH} +TARGET_ARCH?= ${TARGET} .endif IMAKE= ${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} DISTDIR= ${.OBJDIR}/dist @@ -169,7 +169,9 @@ ftp: packagesystem mkdir ftp cp *.txz MANIFEST ftp -release: obj ${RELEASE_TARGETS} +release: + ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj + ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} clean: chflags -R noschg ${.OBJDIR} diff --git a/release/generate-release.sh b/release/generate-release.sh index 62d052813f55..080512a89ee8 100755 --- a/release/generate-release.sh +++ b/release/generate-release.sh @@ -63,7 +63,6 @@ if [ -d $2/usr/doc ]; then fi chroot $2 make -C /usr/src $MAKE_FLAGS buildworld buildkernel -chroot $2 make -C /usr/src/release obj chroot $2 make -C /usr/src/release release chroot $2 make -C /usr/src/release install DESTDIR=/R From b70cddba44edd768b7ee4c659a6dbdf189c98fb3 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Wed, 18 May 2011 18:36:40 +0000 Subject: [PATCH 083/200] Add a sanity check for the existence of an "addr" option to both NFS clients. This avoids the crash reported by Sergey Kandaurov (pluknet@gmail.com) to the freebsd-fs@ list with subject "[old nfsclient] different nmount() args passed from mount vs mount_nfs" dated May 17, 2011. Tested by: pluknet at gmail.com (old nfs client) MFC after: 2 weeks --- sys/fs/nfsclient/nfs_clvfsops.c | 20 +++++++++++++------- sys/nfsclient/nfs_vfsops.c | 4 ++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index b062d2cd46c6..8dc5b0b4b0f2 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -1079,15 +1079,21 @@ nfs_mount(struct mount *mp) dirpath[0] = '\0'; dirlen = strlen(dirpath); - if (has_nfs_args_opt == 0 && vfs_getopt(mp->mnt_optnew, "addr", - (void **)&args.addr, &args.addrlen) == 0) { - if (args.addrlen > SOCK_MAXADDRLEN) { - error = ENAMETOOLONG; + if (has_nfs_args_opt == 0) { + if (vfs_getopt(mp->mnt_optnew, "addr", + (void **)&args.addr, &args.addrlen) == 0) { + if (args.addrlen > SOCK_MAXADDRLEN) { + error = ENAMETOOLONG; + goto out; + } + nam = malloc(args.addrlen, M_SONAME, M_WAITOK); + bcopy(args.addr, nam, args.addrlen); + nam->sa_len = args.addrlen; + } else { + vfs_mount_error(mp, "No server address"); + error = EINVAL; goto out; } - nam = malloc(args.addrlen, M_SONAME, M_WAITOK); - bcopy(args.addr, nam, args.addrlen); - nam->sa_len = args.addrlen; } args.fh = nfh; diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index 04fd37500669..79659d04ddba 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -1149,6 +1149,10 @@ nfs_mount(struct mount *mp) goto out; } } + } else if (has_addr_opt == 0) { + vfs_mount_error(mp, "No server address"); + error = EINVAL; + goto out; } error = mountnfs(&args, mp, nam, args.hostname, &vp, curthread->td_ucred, negnametimeo); From b7e08865e8437cb1638bc842f70aa3428438ab38 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Wed, 18 May 2011 19:49:39 +0000 Subject: [PATCH 084/200] Unbreak INET-less build. Reported by bz@ MFC after: 1 week --- sys/netinet/sctp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index aea43b2dbe37..a7d22bdf241b 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -3129,8 +3129,8 @@ sctp_choose_boundall(struct sctp_inpcb *inp, } #endif out: - if (sifa) { #ifdef INET + if (sifa) { if (retried == 1) { LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { if (dest_is_loop == 0 && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) { From 278ea85a0386cadbb16be8fc77b99c8726d988cd Mon Sep 17 00:00:00 2001 From: Josh Paetzel Date: Wed, 18 May 2011 20:29:07 +0000 Subject: [PATCH 085/200] Extracting optional components requires mounting devfs Submitted by: Kris Moore Approved by: kib (mentor) Sponsored by: iXsystems --- usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh index c46c9c53959e..05e4d49c36e2 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh @@ -120,9 +120,11 @@ COMPTMPDIR=\"${COMPTMPDIR}\" export COMPTMPDIR CFILE=\"${CFILE}\" export CFILE +mount -t devfs devfs /dev sh ${COMPTMPDIR}/install.sh +umount /dev " >${FSMNT}/.componentwrapper.sh chmod 755 ${FSMNT}/.componentwrapper.sh From 098c92cc133163a010706c98aa97e782d2c65828 Mon Sep 17 00:00:00 2001 From: Josh Paetzel Date: Wed, 18 May 2011 20:38:28 +0000 Subject: [PATCH 086/200] Wipeout the end of disks, home to things like gmirror metadata, backup GPT tables, and other potential evil. Submitted by: Kris Moore Approved by: kib (mentor) Sponsored by: iXsystems --- usr.sbin/pc-sysinstall/backend/functions-disk.sh | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh index 94fb436792dc..c63f7afd7ecf 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh @@ -582,17 +582,9 @@ stop_gjournal() # Function to wipe the potential backup gpt table from a disk clear_backup_gpt_table() { - # Get the disk block size - local dSize="`gpart show $1 | grep $1 | tr -s ' ' | cut -d ' ' -f 3`" - - # Make sure this is a valid number - is_num "${dSize}" >/dev/null 2>/dev/null - [ $? -ne 0 ] && return - - # Die backup label, DIE echo_log "Clearing gpt backup table location on disk" - rc_nohalt "dd if=/dev/zero of=${1} bs=512 seek=${dSize}" - + rc_nohalt "dd if=/dev/zero of=${1} bs=1m count=1" + rc_nohalt "dd if=/dev/zero of=${1} bs=1m oseek=`diskinfo ${1} | awk '{print int($3 / (1024*1024)) - 4;}'`" } ; From 9bde021a87c14ad5f680d8427e0f124325091f42 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Wed, 18 May 2011 20:52:52 +0000 Subject: [PATCH 087/200] Fix clang warnings. Note: these were actually bugs (printf with no format string). Approved by: philip (mentor) --- usr.bin/rpcgen/rpc_hout.c | 2 +- usr.bin/rpcgen/rpc_svcout.c | 2 +- usr.bin/rpcgen/rpc_tblout.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.bin/rpcgen/rpc_hout.c b/usr.bin/rpcgen/rpc_hout.c index 7607ef74d6c9..6aa6ff7b4667 100644 --- a/usr.bin/rpcgen/rpc_hout.c +++ b/usr.bin/rpcgen/rpc_hout.c @@ -500,7 +500,7 @@ pdeclaration(const char *name, declaration *dec, int tab, const char *separator) break; } } - f_print(fout, separator); + fputs(separator, fout); } static int diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c index 40fc61cb9ec4..122408b720fc 100644 --- a/usr.bin/rpcgen/rpc_svcout.c +++ b/usr.bin/rpcgen/rpc_svcout.c @@ -349,7 +349,7 @@ write_real_program(definition *def) f_print(fout, "("); /* arg name */ if (proc->arg_num > 1) - f_print(fout, proc->args.argname); + fputs(proc->args.argname, fout); else ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 0); diff --git a/usr.bin/rpcgen/rpc_tblout.c b/usr.bin/rpcgen/rpc_tblout.c index f96bdfcbc187..618d1f998bbe 100644 --- a/usr.bin/rpcgen/rpc_tblout.c +++ b/usr.bin/rpcgen/rpc_tblout.c @@ -103,7 +103,7 @@ write_table(definition *def) expected = 0; } else { expected = 1; - f_print(fout, null_entry); + fputs(null_entry, fout); } for (proc = vp->procs; proc != NULL; proc = proc->next) { current = atoi(proc->proc_num); @@ -141,7 +141,7 @@ write_table(definition *def) } /* print the table trailer */ - f_print(fout, tbl_end); + fputs(tbl_end, fout); f_print(fout, tbl_nproc, progvers, progvers, progvers); } } From 198a158f99bb44be9ac17615a61542b41836e63e Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Wed, 18 May 2011 20:57:23 +0000 Subject: [PATCH 088/200] Fix clang warning (why is there nowhere yyparse() is declared?). Approved by: philip (mentor) --- crypto/heimdal/lib/sl/slc-gram.y | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/heimdal/lib/sl/slc-gram.y b/crypto/heimdal/lib/sl/slc-gram.y index 7d9fadcb55bd..d58edfbf2867 100644 --- a/crypto/heimdal/lib/sl/slc-gram.y +++ b/crypto/heimdal/lib/sl/slc-gram.y @@ -49,6 +49,7 @@ RCSID("$Id: slc-gram.y 20767 2007-06-01 11:24:52Z lha $"); #include "slc.h" extern FILE *yyin; extern struct assignment *assignment; +extern int yyparse(void); %} %union { From 7f49567fa480d5dac34816fc3395fd81137e5184 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Wed, 18 May 2011 21:00:27 +0000 Subject: [PATCH 089/200] Fix clang warnings. Approved by: philip (mentor) --- contrib/gcc/genmodes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/gcc/genmodes.c b/contrib/gcc/genmodes.c index 0a70dea23e6f..5a91a50edef3 100644 --- a/contrib/gcc/genmodes.c +++ b/contrib/gcc/genmodes.c @@ -787,7 +787,7 @@ calc_wider_mode (void) #define tagged_printf(FMT, ARG, TAG) do { \ int count_; \ - printf (" " FMT ",%n", ARG, &count_); \ + count_ = printf (" " FMT ",", ARG); \ printf ("%*s/* %s */\n", 27 - count_, "", TAG); \ } while (0) @@ -822,7 +822,7 @@ enum machine_mode\n{"); for (m = modes[c]; m; m = m->next) { int count_; - printf (" %smode,%n", m->name, &count_); + count_ = printf (" %smode,", m->name); printf ("%*s/* %s:%d */\n", 27 - count_, "", trim_filename (m->file), m->line); } From d74336e632308cae12c544d430b7e663c71c57a0 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Wed, 18 May 2011 21:04:29 +0000 Subject: [PATCH 090/200] Fix clang warnings. Note: possible minor security issues fixed (untrusted string used as printf format string). Approved by: philip (mentor) --- contrib/groff/src/devices/grohtml/post-html.cpp | 2 +- contrib/groff/src/libs/libdriver/input.cpp | 2 +- contrib/groff/src/roff/troff/mtsm.cpp | 6 ++++-- contrib/groff/src/roff/troff/node.cpp | 2 +- contrib/groff/src/utils/hpftodit/hpftodit.cpp | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/contrib/groff/src/devices/grohtml/post-html.cpp b/contrib/groff/src/devices/grohtml/post-html.cpp index 1283e06139a7..6834e844f801 100644 --- a/contrib/groff/src/devices/grohtml/post-html.cpp +++ b/contrib/groff/src/devices/grohtml/post-html.cpp @@ -1587,7 +1587,7 @@ void header_desc::write_headings (FILE *f, int force) buffer += as_string(h); buffer += '\0'; - fprintf(f, buffer.contents()); + fputs(buffer.contents(), f); } else fputs(g->text_string, f); h++; diff --git a/contrib/groff/src/libs/libdriver/input.cpp b/contrib/groff/src/libs/libdriver/input.cpp index bf8a74e1066c..c2b262af8f03 100644 --- a/contrib/groff/src/libs/libdriver/input.cpp +++ b/contrib/groff/src/libs/libdriver/input.cpp @@ -995,7 +995,7 @@ next_command(void) inline bool odd(const int n) { - return (n & 1 == 1) ? true : false; + return ((n & 1) == 1) ? true : false; } ////////////////////////////////////////////////////////////////////// diff --git a/contrib/groff/src/roff/troff/mtsm.cpp b/contrib/groff/src/roff/troff/mtsm.cpp index 630e973209cd..38efc0a343a5 100644 --- a/contrib/groff/src/roff/troff/mtsm.cpp +++ b/contrib/groff/src/roff/troff/mtsm.cpp @@ -611,14 +611,16 @@ int state_set::is_in(int_value_state i) return (intset & (1 << (int)i)) != 0; } +// Note: this used to have a bug s.t. it always tested for bit 0 (benl 18/5/11) int state_set::is_in(units_value_state u) { - return (unitsset & (1 << (int)u) != 0); + return (unitsset & (1 << (int)u)) != 0; } +// Note: this used to have a bug s.t. it always tested for bit 0 (benl 18/5/11) int state_set::is_in(string_value_state s) { - return (stringset & (1 << (int)s) != 0); + return (stringset & (1 << (int)s)) != 0; } void state_set::add(units_value_state, int n) diff --git a/contrib/groff/src/roff/troff/node.cpp b/contrib/groff/src/roff/troff/node.cpp index 0d874d35758d..0e440b210580 100644 --- a/contrib/groff/src/roff/troff/node.cpp +++ b/contrib/groff/src/roff/troff/node.cpp @@ -2157,7 +2157,7 @@ void glyph_node::debug_node() if (c) fprintf(stderr, "%c", c); else - fprintf(stderr, ci->nm.contents()); + fputs(ci->nm.contents(), stderr); if (push_state) fprintf(stderr, " "); if (state) diff --git a/contrib/groff/src/utils/hpftodit/hpftodit.cpp b/contrib/groff/src/utils/hpftodit/hpftodit.cpp index 5910fb2f39e6..d5d524fdf1b2 100644 --- a/contrib/groff/src/utils/hpftodit/hpftodit.cpp +++ b/contrib/groff/src/utils/hpftodit/hpftodit.cpp @@ -870,9 +870,9 @@ output_charset(const int tfm_type) else if (!all_flag) continue; else if (tfm_type == MSL) - printf(hp_msl_to_ucode_name(charcode)); + fputs(hp_msl_to_ucode_name(charcode), stdout); else - printf(unicode_to_ucode_name(charcode)); + fputs(unicode_to_ucode_name(charcode), stdout); printf("\t%d,%d", scale(char_table[i].width), scale(char_table[i].ascent)); From 8b8c683f2254f04f0416fd1e1028c3084d99b673 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Wed, 18 May 2011 21:06:20 +0000 Subject: [PATCH 091/200] Fix clang warnings. Approved by: philip (mentor) --- contrib/gperf/src/gen-perf.cc | 2 +- contrib/gperf/src/key-list.cc | 48 +++++++++++++++++------------------ contrib/gperf/src/options.cc | 2 +- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/contrib/gperf/src/gen-perf.cc b/contrib/gperf/src/gen-perf.cc index 0b5109d4ff4d..8840dc60040f 100644 --- a/contrib/gperf/src/gen-perf.cc +++ b/contrib/gperf/src/gen-perf.cc @@ -246,7 +246,7 @@ Gen_Perf::change (List_Node *prior, List_Node *curr) { if (option[DEBUG]) { - fprintf (stderr, " by changing asso_value['%c'] (char #%d) to %d\n", + fprintf (stderr, " by changing asso_value['%c'] (char #%zd) to %d\n", *p, p - union_set + 1, asso_values[(unsigned char)(*p)]); fflush (stderr); } diff --git a/contrib/gperf/src/key-list.cc b/contrib/gperf/src/key-list.cc index 1c941a453579..2461470177c4 100644 --- a/contrib/gperf/src/key-list.cc +++ b/contrib/gperf/src/key-list.cc @@ -497,8 +497,8 @@ Key_List::merge (List_Node *list1, List_Node *list2) *resultp = list1; break; } - if (occurrence_sort && list1->occurrence < list2->occurrence - || hash_sort && list1->hash_value > list2->hash_value) + if ((occurrence_sort && list1->occurrence < list2->occurrence) + || (hash_sort && list1->hash_value > list2->hash_value)) { *resultp = list2; resultp = &list2->next; list2 = list1; list1 = *resultp; @@ -1035,17 +1035,16 @@ Key_List::output_hash_function (void) if (option[CPLUSPLUS]) printf ("%s::", option.get_class_name ()); printf ("%s ", option.get_hash_name ()); - printf (option[KRC] ? - "(str, len)\n" - " register char *str;\n" - " register unsigned int len;\n" : - option[C] ? - "(str, len)\n" - " register const char *str;\n" - " register unsigned int len;\n" : - option[ANSIC] | option[CPLUSPLUS] ? - "(register const char *str, register unsigned int len)\n" : - ""); + if (option[KRC] || option[C] || option [ANSIC] || option[CPLUSPLUS]) + printf (option[KRC] ? + "(str, len)\n" + " register char *str;\n" + " register unsigned int len;\n" : + option[C] ? + "(str, len)\n" + " register const char *str;\n" + " register unsigned int len;\n" : + "(register const char *str, register unsigned int len)\n"); /* Note that when the hash function is called, it has already been verified that min_key_len <= len <= max_key_len. */ @@ -1442,7 +1441,7 @@ Key_List::output_lookup_array (void) if (option[DEBUG]) fprintf (stderr, - "dup_ptr[%d]: hash_value = %d, index = %d, count = %d\n", + "dup_ptr[%zd]: hash_value = %d, index = %d, count = %d\n", dup_ptr - duplicates, dup_ptr->hash_value, dup_ptr->index, dup_ptr->count); @@ -1986,17 +1985,16 @@ Key_List::output_lookup_function (void) if (option[CPLUSPLUS]) printf ("%s::", option.get_class_name ()); printf ("%s ", option.get_function_name ()); - printf (option[KRC] ? - "(str, len)\n" - " register char *str;\n" - " register unsigned int len;\n" : - option[C] ? - "(str, len)\n" - " register const char *str;\n" - " register unsigned int len;\n" : - option[ANSIC] | option[CPLUSPLUS] ? - "(register const char *str, register unsigned int len)\n" : - ""); + if (option[KRC] || option[C] || option[ANSIC] || option[CPLUSPLUS]) + printf (option[KRC] ? + "(str, len)\n" + " register char *str;\n" + " register unsigned int len;\n" : + option[C] ? + "(str, len)\n" + " register const char *str;\n" + " register unsigned int len;\n" : + "(register const char *str, register unsigned int len)\n"); /* Output the function's body. */ printf ("{\n"); diff --git a/contrib/gperf/src/options.cc b/contrib/gperf/src/options.cc index d15e21cee8ce..77068480cf5b 100644 --- a/contrib/gperf/src/options.cc +++ b/contrib/gperf/src/options.cc @@ -237,7 +237,7 @@ Options::print_options (void) { putchar (*arg); arg++; - if (*arg >= 'A' && *arg <= 'Z' || *arg >= 'a' && *arg <= 'z') + if ((*arg >= 'A' && *arg <= 'Z') || (*arg >= 'a' && *arg <= 'z')) { putchar (*arg); arg++; From bc14b14d62d03e69cb35e20e604a425c56ef67d8 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Wed, 18 May 2011 22:09:04 +0000 Subject: [PATCH 092/200] - Enable per-channel congestion notification. - Enable PCIe relaxed ordering for all egress queues and rx data buffers. MFC after: 3 days --- sys/dev/cxgbe/t4_main.c | 9 ++++++++- sys/dev/cxgbe/t4_sge.c | 24 +++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index e336566d3804..e9516814c5a1 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -366,7 +366,13 @@ t4_attach(device_t dev) sc->mbox = sc->pf; pci_enable_busmaster(dev); - pci_set_max_read_req(dev, 4096); + if (pci_find_cap(dev, PCIY_EXPRESS, &i) == 0) { + pci_set_max_read_req(dev, 4096); + v = pci_read_config(dev, i + PCIR_EXPRESS_DEVICE_CTL, 2); + v |= PCIM_EXP_CTL_RELAXED_ORD_ENABLE; + pci_write_config(dev, i + PCIR_EXPRESS_DEVICE_CTL, v, 2); + } + snprintf(sc->lockname, sizeof(sc->lockname), "%s", device_get_nameunit(dev)); mtx_init(&sc->sc_lock, sc->lockname, 0, MTX_DEF); @@ -3206,6 +3212,7 @@ filter_rpl(struct adapter *sc, const struct cpl_set_tcb_rpl *rpl) } } +/* XXX: use pci_find_cap */ int t4_os_find_pci_capability(struct adapter *sc, int cap) { diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 5f59db63343f..a0ef17226eb4 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -100,7 +100,7 @@ static int alloc_ring(struct adapter *, size_t, bus_dma_tag_t *, bus_dmamap_t *, static int free_ring(struct adapter *, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, void *); static int alloc_iq_fl(struct port_info *, struct sge_iq *, struct sge_fl *, - int); + int, int); static int free_iq_fl(struct port_info *, struct sge_iq *, struct sge_fl *); static int alloc_iq(struct sge_iq *, int); static int free_iq(struct sge_iq *); @@ -1104,7 +1104,7 @@ free_ring(struct adapter *sc, bus_dma_tag_t tag, bus_dmamap_t map, */ static int alloc_iq_fl(struct port_info *pi, struct sge_iq *iq, struct sge_fl *fl, - int intr_idx) + int intr_idx, int cong) { int rc, i, cntxt_id; size_t len; @@ -1155,6 +1155,8 @@ alloc_iq_fl(struct port_info *pi, struct sge_iq *iq, struct sge_fl *fl, V_FW_IQ_CMD_IQESIZE(ilog2(iq->esize) - 4)); c.iqsize = htobe16(iq->qsize); c.iqaddr = htobe64(iq->ba); + if (cong >= 0) + c.iqns_to_fl0congen = htobe32(F_FW_IQ_CMD_IQFLINTCONGEN); if (fl) { mtx_init(&fl->fl_lock, fl->lockname, NULL, MTX_DEF); @@ -1198,7 +1200,15 @@ alloc_iq_fl(struct port_info *pi, struct sge_iq *iq, struct sge_fl *fl, fl->needed = fl->cap; c.iqns_to_fl0congen = - htobe32(V_FW_IQ_CMD_FL0HOSTFCMODE(X_HOSTFCMODE_NONE)); + htobe32(V_FW_IQ_CMD_FL0HOSTFCMODE(X_HOSTFCMODE_NONE) | + F_FW_IQ_CMD_FL0FETCHRO | F_FW_IQ_CMD_FL0DATARO | + F_FW_IQ_CMD_FL0PADEN); + if (cong >= 0) { + c.iqns_to_fl0congen |= + htobe32(V_FW_IQ_CMD_FL0CNGCHMAP(cong) | + F_FW_IQ_CMD_FL0CONGCIF | + F_FW_IQ_CMD_FL0CONGEN); + } c.fl0dcaen_to_fl0cidxfthresh = htobe16(V_FW_IQ_CMD_FL0FBMIN(X_FETCHBURSTMIN_64B) | V_FW_IQ_CMD_FL0FBMAX(X_FETCHBURSTMAX_512B)); @@ -1325,7 +1335,7 @@ free_iq_fl(struct port_info *pi, struct sge_iq *iq, struct sge_fl *fl) static int alloc_iq(struct sge_iq *iq, int intr_idx) { - return alloc_iq_fl(NULL, iq, NULL, intr_idx); + return alloc_iq_fl(NULL, iq, NULL, intr_idx, -1); } static int @@ -1342,7 +1352,7 @@ alloc_rxq(struct port_info *pi, struct sge_rxq *rxq, int intr_idx, int idx) struct sysctl_oid_list *children; char name[16]; - rc = alloc_iq_fl(pi, &rxq->iq, &rxq->fl, intr_idx); + rc = alloc_iq_fl(pi, &rxq->iq, &rxq->fl, intr_idx, 1 << pi->tx_chan); if (rc != 0) return (rc); @@ -1436,7 +1446,7 @@ alloc_ctrlq(struct adapter *sc, struct sge_ctrlq *ctrlq, int idx) c.physeqid_pkd = htobe32(0); c.fetchszm_to_iqid = htobe32(V_FW_EQ_CTRL_CMD_HOSTFCMODE(X_HOSTFCMODE_STATUS_PAGE) | - V_FW_EQ_CTRL_CMD_PCIECHN(idx) | + V_FW_EQ_CTRL_CMD_PCIECHN(idx) | F_FW_EQ_CTRL_CMD_FETCHRO | V_FW_EQ_CTRL_CMD_IQID(eq->iqid)); c.dcaen_to_eqsize = htobe32(V_FW_EQ_CTRL_CMD_FBMIN(X_FETCHBURSTMIN_64B) | @@ -1561,7 +1571,7 @@ alloc_txq(struct port_info *pi, struct sge_txq *txq, int idx) c.viid_pkd = htobe32(V_FW_EQ_ETH_CMD_VIID(pi->viid)); c.fetchszm_to_iqid = htobe32(V_FW_EQ_ETH_CMD_HOSTFCMODE(X_HOSTFCMODE_STATUS_PAGE) | - V_FW_EQ_ETH_CMD_PCIECHN(pi->tx_chan) | + V_FW_EQ_ETH_CMD_PCIECHN(pi->tx_chan) | F_FW_EQ_ETH_CMD_FETCHRO | V_FW_EQ_ETH_CMD_IQID(eq->iqid)); c.dcaen_to_eqsize = htobe32(V_FW_EQ_ETH_CMD_FBMIN(X_FETCHBURSTMIN_64B) | V_FW_EQ_ETH_CMD_FBMAX(X_FETCHBURSTMAX_512B) | From dbe66680b0eeca111740b149fac4ed45b0fdbf09 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 18 May 2011 22:36:58 +0000 Subject: [PATCH 093/200] The CDP_ACTIVE flag is cleared at the beginning of destroy_devl(), and destroy_devl() drops dev_mtx. The protection against the race with dev_rel(), introduced in r163328, should be extended to cover destroy_devl() calls for the children of the destroyed dev. Reported and tested by: joerg MFC after: 1 week --- sys/kern/kern_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index b2be5cc12d1a..59b876c18e55 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -981,6 +981,8 @@ destroy_devl(struct cdev *dev) /* Remove name marking */ dev->si_flags &= ~SI_NAMED; + dev->si_refcount++; /* Avoid race with dev_rel() */ + /* If we are a child, remove us from the parents list */ if (dev->si_flags & SI_CHILD) { LIST_REMOVE(dev, si_siblings); @@ -997,7 +999,6 @@ destroy_devl(struct cdev *dev) dev->si_flags &= ~SI_CLONELIST; } - dev->si_refcount++; /* Avoid race with dev_rel() */ csw = dev->si_devsw; dev->si_devsw = NULL; /* already NULL for SI_ALIAS */ while (csw != NULL && csw->d_purge != NULL && dev->si_threadcount) { From 0855e42386b6846ae819eaae298257d2f8a70286 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Wed, 18 May 2011 22:43:56 +0000 Subject: [PATCH 094/200] - Add support for AF_INET6 sockets for %S format character. - Use inet_ntop(3) instead of reimplementing it. - Use %hhu for unsigned char instead of casting it to unsigned int and using %u. MFC after: 1 week --- sbin/hastd/pjdlog.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/sbin/hastd/pjdlog.c b/sbin/hastd/pjdlog.c index 59d3ffac0023..16ecf4d9c8cc 100644 --- a/sbin/hastd/pjdlog.c +++ b/sbin/hastd/pjdlog.c @@ -31,8 +31,10 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include +#include #include #include @@ -103,22 +105,39 @@ pjdlog_printf_render_sockaddr(struct __printf_io *io, switch (ss->ss_family) { case AF_INET: { + char addr[INET_ADDRSTRLEN]; const struct sockaddr_in *sin; - in_addr_t ip; unsigned int port; sin = (const struct sockaddr_in *)ss; - ip = ntohl(sin->sin_addr.s_addr); port = ntohs(sin->sin_port); + if (inet_ntop(ss->ss_family, &sin->sin_addr, addr, + sizeof(addr)) == NULL) { + PJDLOG_ABORT("inet_ntop(AF_INET) failed: %s.", + strerror(errno)); + } + snprintf(buf, sizeof(buf), "%s:%u", addr, port); + break; + } + case AF_INET6: + { + char addr[INET6_ADDRSTRLEN]; + const struct sockaddr_in6 *sin; + unsigned int port; - snprintf(buf, sizeof(buf), "%u.%u.%u.%u:%u", - ((ip >> 24) & 0xff), ((ip >> 16) & 0xff), - ((ip >> 8) & 0xff), (ip & 0xff), port); + sin = (const struct sockaddr_in6 *)ss; + port = ntohs(sin->sin6_port); + if (inet_ntop(ss->ss_family, &sin->sin6_addr, addr, + sizeof(addr)) == NULL) { + PJDLOG_ABORT("inet_ntop(AF_INET6) failed: %s.", + strerror(errno)); + } + snprintf(buf, sizeof(buf), "[%s]:%u", addr, port); break; } default: - snprintf(buf, sizeof(buf), "[unsupported family %u]", - (unsigned int)ss->ss_family); + snprintf(buf, sizeof(buf), "[unsupported family %hhu]", + ss->ss_family); break; } ret = __printf_out(io, pi, buf, strlen(buf)); From 0163af236079a6c999635d270ff92f9c3519f22b Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 19 May 2011 05:13:25 +0000 Subject: [PATCH 095/200] Implement WITH{,OUT}_{GCC,BINUTILS} to provide finer-grained control over building gcc and binutils. They default to true, unless MK_TOOLCHAIN is no. Reviewed by: ru@ --- Makefile.inc1 | 12 ++++++++++-- gnu/usr.bin/Makefile | 6 ++++-- share/mk/bsd.own.mk | 4 ++++ tools/build/options/WITHOUT_BINUTILS | 7 +++++++ tools/build/options/WITHOUT_GCC | 6 ++++++ 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 tools/build/options/WITHOUT_BINUTILS create mode 100644 tools/build/options/WITHOUT_GCC diff --git a/Makefile.inc1 b/Makefile.inc1 index 1e613affecda..9ebc1e34a73b 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1132,6 +1132,10 @@ _kgzip= usr.sbin/kgzip .endif .endif +.if ${MK_BINUTILS} != "no" +_binutils= gnu/usr.bin/binutils +.endif + .if ${MK_CLANG} != "no" .if ${CC:T:Mclang} == "clang" _clang= usr.bin/clang @@ -1139,12 +1143,16 @@ _clang_libs= lib/clang .endif .endif +.if ${MK_GCC} != "no" +_cc= gnu/usr.bin/cc +.endif + cross-tools: .for _tool in \ ${_clang_libs} \ ${_clang} \ - gnu/usr.bin/binutils \ - gnu/usr.bin/cc \ + ${_binutils} \ + ${_cc} \ usr.bin/xlint/lint1 usr.bin/xlint/lint2 usr.bin/xlint/xlint \ ${_btxld} \ ${_crunchide} \ diff --git a/gnu/usr.bin/Makefile b/gnu/usr.bin/Makefile index 7eaad9f590f1..0ee257f9867c 100644 --- a/gnu/usr.bin/Makefile +++ b/gnu/usr.bin/Makefile @@ -47,12 +47,14 @@ _texinfo= texinfo _rcs= rcs .endif -.if ${MK_TOOLCHAIN} != "no" +.if ${MK_BINUTILS} != "no" _binutils= binutils +.endif +.if ${MK_GCC} != "no" _cc= cc +.endif .if ${MK_GDB} != "no" _gdb= gdb .endif -.endif .include diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index cbbe7c92d71e..3669fac9e416 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -297,6 +297,7 @@ __DEFAULT_YES_OPTIONS = \ BIND_MTREE \ BIND_NAMED \ BIND_UTILS \ + BINUTILS \ BLUETOOTH \ BOOT \ BSD_CPIO \ @@ -317,6 +318,7 @@ __DEFAULT_YES_OPTIONS = \ FP_LIBC \ FREEBSD_UPDATE \ GAMES \ + GCC \ GCOV \ GDB \ GNU \ @@ -529,7 +531,9 @@ MK_GROFF:= no .endif .if ${MK_TOOLCHAIN} == "no" +MK_BINUTILS:= no MK_CLANG:= no +MK_GCC:= no MK_GDB:= no .endif diff --git a/tools/build/options/WITHOUT_BINUTILS b/tools/build/options/WITHOUT_BINUTILS new file mode 100644 index 000000000000..9d57c62d000c --- /dev/null +++ b/tools/build/options/WITHOUT_BINUTILS @@ -0,0 +1,7 @@ +.\" $FreeBSD$ +Set to not install binutils (as, c++-filt, gconv, gnu-ar, gnu-randlib, +ld, nm, objcopy, objdump, readelf, size and strip) +.Bf -symbolic +The option does not generally work for build targets, unless some alternative +toolchain is enabled. +.Ef diff --git a/tools/build/options/WITHOUT_GCC b/tools/build/options/WITHOUT_GCC new file mode 100644 index 000000000000..5717f64019e6 --- /dev/null +++ b/tools/build/options/WITHOUT_GCC @@ -0,0 +1,6 @@ +.\" $FreeBSD$ +Set to not install gcc and g++. +.Bf -symbolic +The option does not generally work for build targets, unless some alternative +toolchain is enabled. +.Ef From 10414b71e348d2397f254f22af4771596ea9b5df Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 19 May 2011 11:41:12 +0000 Subject: [PATCH 096/200] Add support for the SIIG Cyber 2S PCIe adapter. It is based on an Oxford Semiconductor OX16PCI954 but uses only two ports with a non-default clock rate. PR: kern/152034 Tested by: Hans Fiedler hans of hermes louisville edu MFC after: 1 week --- sys/dev/puc/pucdata.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/dev/puc/pucdata.c b/sys/dev/puc/pucdata.c index 6b1dedaa5aef..83b02eafd6ab 100644 --- a/sys/dev/puc/pucdata.c +++ b/sys/dev/puc/pucdata.c @@ -656,6 +656,12 @@ const struct puc_cfg puc_pci_devices[] = { PUC_PORT_4S, 0x10, 0, 8, }, + { 0x1415, 0x950a, 0x131f, 0x2030, + "SIIG Cyber 2S PCIe", + DEFAULT_RCLK * 10, + PUC_PORT_2S, 0x10, 0, 8, + }, + { 0x1415, 0x950a, 0xffff, 0, "Oxford Semiconductor OX16PCI954 UARTs", DEFAULT_RCLK, From dac74062036c5ffc66a62a50664b34b0599488f0 Mon Sep 17 00:00:00 2001 From: Edwin Groothuis Date: Thu, 19 May 2011 13:09:39 +0000 Subject: [PATCH 097/200] Put AN back after finding out that tzsetup(1) will complain that it doesn't exist. It will be removed again once the tzdata distribution files have been updated with the replacements for AN. --- share/misc/iso3166 | 1 + 1 file changed, 1 insertion(+) diff --git a/share/misc/iso3166 b/share/misc/iso3166 index 23c9bd65e312..d8d5972c9cb3 100644 --- a/share/misc/iso3166 +++ b/share/misc/iso3166 @@ -176,6 +176,7 @@ NA NAM 516 Namibia NR NRU 520 Nauru NP NPL 524 Nepal NL NLD 528 Netherlands +AN ANT 530 Netherlands Antilles NC NCL 540 New Caledonia NZ NZL 554 New Zealand NI NIC 558 Nicaragua From c920aa7a9dac734af63c90ff1fd6cf561342dd52 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Thu, 19 May 2011 13:42:19 +0000 Subject: [PATCH 098/200] When adding examples to man-pages, try to make them at least look like they might work. Prodded by: Vadim Goncharov --- share/man/man9/sbuf.9 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/man/man9/sbuf.9 b/share/man/man9/sbuf.9 index 500bfbdc9e98..0e6da36b417c 100644 --- a/share/man/man9/sbuf.9 +++ b/share/man/man9/sbuf.9 @@ -492,13 +492,13 @@ will return zero for success and \-1 and set errno on error. struct sbuf *sb; sb = sbuf_new_auto(); -sbuf_cat("Customers found:\en"); +sbuf_cat(sb, "Customers found:\en"); TAILQ_FOREACH(foo, &foolist, list) { - sbuf_printf(" %4d %s\en", foo->index, foo->name); - sbuf_printf(" Address: %s\en", foo->address); - sbuf_printf(" Zip: %s\en", foo->zipcode); + sbuf_printf(sb, " %4d %s\en", foo->index, foo->name); + sbuf_printf(sb, " Address: %s\en", foo->address); + sbuf_printf(sb, " Zip: %s\en", foo->zipcode); } -if (sbuf_finish(sb)) +if (sbuf_finish(sb)) /* Check for any and all errors */ err(1,"Could not generate message"); transmit_msg(sbuf_data(sb), sbuf_len(sb)); sbuf_delete(sb); From a5b05a8d85b0a836bc8f5970ce71cabf2a78c71f Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Thu, 19 May 2011 15:18:35 +0000 Subject: [PATCH 099/200] Fix clang warnings. Approved by: philip (mentor) --- contrib/gcc/genattrtab.c | 2 +- contrib/gcc/genautomata.c | 26 +++++++++++++------------- contrib/gcc/gengtype-lex.l | 2 +- share/misc/committers-src.dot | 4 ++++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/contrib/gcc/genattrtab.c b/contrib/gcc/genattrtab.c index f11532f19bea..2555e10750ae 100644 --- a/contrib/gcc/genattrtab.c +++ b/contrib/gcc/genattrtab.c @@ -1652,7 +1652,7 @@ simplify_cond (rtx exp, int insn_code, int insn_index) rtx ret; /* This lets us free all storage allocated below, if appropriate. */ - obstack_finish (rtl_obstack); + (void) obstack_finish (rtl_obstack); memcpy (tests, XVEC (exp, 0)->elem, len * sizeof (rtx)); diff --git a/contrib/gcc/genautomata.c b/contrib/gcc/genautomata.c index fd8edebcea84..8434030d54f5 100644 --- a/contrib/gcc/genautomata.c +++ b/contrib/gcc/genautomata.c @@ -1099,7 +1099,7 @@ create_node (size_t size) obstack_blank (&irp, size); result = obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); /* Default values of members are NULL and zero. */ memset (result, 0, size); return result; @@ -1170,7 +1170,7 @@ next_sep_el (const char **pstr, int sep, int par_flag) } obstack_1grow (&irp, '\0'); out_str = obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); *pstr = p; if (**pstr == sep) @@ -1221,7 +1221,7 @@ get_str_vect (const char *str, int *els_num, int sep, int paren_p) return NULL; obstack_blank (&irp, sizeof (char *) * (*els_num + 1)); vect = (char **) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); pstr = &str; for (i = 0; i < *els_num; i++) vect [i] = next_sep_el (pstr, sep, paren_p); @@ -3343,7 +3343,7 @@ alloc_empty_reserv_sets (void) obstack_blank (&irp, els_in_reservs * sizeof (set_el_t)); result = (reserv_sets_t) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); memset (result, 0, els_in_reservs * sizeof (set_el_t)); return result; } @@ -4117,10 +4117,10 @@ initiate_excl_sets (void) obstack_blank (&irp, els_in_cycle_reserv * sizeof (set_el_t)); excl_set = (reserv_sets_t) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); obstack_blank (&irp, description->units_num * sizeof (reserv_sets_t)); unit_excl_set_table = (reserv_sets_t *) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); /* Evaluate unit exclusion sets. */ for (i = 0; i < description->decls_num; i++) { @@ -4129,7 +4129,7 @@ initiate_excl_sets (void) { obstack_blank (&irp, els_in_cycle_reserv * sizeof (set_el_t)); unit_excl_set = (reserv_sets_t) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); memset (unit_excl_set, 0, els_in_cycle_reserv * sizeof (set_el_t)); for (el = DECL_UNIT (decl)->excl_list; el != NULL; @@ -4224,16 +4224,16 @@ initiate_presence_absence_pattern_sets (void) obstack_blank (&irp, description->units_num * sizeof (pattern_reserv_t)); unit_presence_set_table = (pattern_reserv_t *) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); obstack_blank (&irp, description->units_num * sizeof (pattern_reserv_t)); unit_final_presence_set_table = (pattern_reserv_t *) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); obstack_blank (&irp, description->units_num * sizeof (pattern_reserv_t)); unit_absence_set_table = (pattern_reserv_t *) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); obstack_blank (&irp, description->units_num * sizeof (pattern_reserv_t)); unit_final_absence_set_table = (pattern_reserv_t *) obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); /* Evaluate unit presence/absence sets. */ for (i = 0; i < description->decls_num; i++) { @@ -4935,7 +4935,7 @@ store_alt_unit_usage (regexp_t regexp, regexp_t unit, int cycle, obstack_blank (&unit_usages, sizeof (struct unit_usage)); unit_usage_ptr = (struct unit_usage *) obstack_base (&unit_usages); - obstack_finish (&unit_usages); + (void) obstack_finish (&unit_usages); unit_usage_ptr->unit_decl = unit_decl; index = cycle * REGEXP_ONEOF (regexp)->regexps_num + alt_num; unit_usage_ptr->next = VEC_index (unit_usage_t, cycle_alt_unit_usages, index); @@ -8975,7 +8975,7 @@ initiate_automaton_gen (int argc, char **argv) strlen (STANDARD_OUTPUT_DESCRIPTION_FILE_SUFFIX) + 1); obstack_1grow (&irp, '\0'); output_description_file_name = obstack_base (&irp); - obstack_finish (&irp); + (void) obstack_finish (&irp); } /* The following function checks existence at least one arc marked by diff --git a/contrib/gcc/gengtype-lex.l b/contrib/gcc/gengtype-lex.l index 51cd95a63103..ebe66675c2de 100644 --- a/contrib/gcc/gengtype-lex.l +++ b/contrib/gcc/gengtype-lex.l @@ -590,7 +590,7 @@ macro_input (char *buffer, unsigned size) void yyerror (const char *s) { - error_at_line (&lexer_line, s); + error_at_line (&lexer_line, "%s", s); } void diff --git a/share/misc/committers-src.dot b/share/misc/committers-src.dot index 2199590c7f83..d450c8a2d677 100644 --- a/share/misc/committers-src.dot +++ b/share/misc/committers-src.dot @@ -100,6 +100,7 @@ antoine [label="Antoine Brodin\nantoine@FreeBSD.org\n2008/02/03"] ariff [label="Ariff Abdullah\nariff@FreeBSD.org\n2005/11/14"] art [label="Artem Belevich\nart@FreeBSD.org\n2011/03/29"] avg [label="Andriy Gapon\navg@FreeBSD.org\n2009/02/18"] +benl [label="Ben Laurie\nbenl@FreeBSD.org\n2011/05/18"] benno [label="Benno Rice\nbenno@FreeBSD.org\n2000/11/02"] bms [label="Bruce M Simpson\nbms@FreeBSD.org\n2003/08/06"] brian [label="Brian Somers\nbrian@FreeBSD.org\n1996/12/16"] @@ -486,6 +487,7 @@ peter -> asmodai peter -> jayanth peter -> ps +philip -> benl philip -> ed philip -> jls philip -> matteo @@ -546,6 +548,8 @@ sheldonh -> iedowse shin -> ume +simon -> benl + sos -> marcel thompsa -> weongyo From a1e9b6750c103eb93140fd8a494ccd16d8d9fc17 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 19 May 2011 17:22:48 +0000 Subject: [PATCH 100/200] Style fixes: - Sort forward declarations of structures. - Prefer uint64_t to u_int64_t. --- sys/sys/proc.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index e74da83176ad..4d7b540c2e6b 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -157,21 +157,21 @@ struct pargs { * either lock is sufficient for read access, but both locks must be held * for write access. */ -struct racct; -struct kaudit_record; -struct td_sched; -struct nlminfo; +struct cpuset; struct kaioinfo; +struct kaudit_record; +struct kdtrace_proc; +struct kdtrace_thread; +struct mqueue_notifier; +struct nlminfo; struct p_sched; struct proc; +struct racct; struct sleepqueue; +struct td_sched; struct thread; struct trapframe; struct turnstile; -struct mqueue_notifier; -struct kdtrace_proc; -struct kdtrace_thread; -struct cpuset; /* * XXX: Does this belong in resource.h or resourcevar.h instead? @@ -185,13 +185,13 @@ struct cpuset; * Locking for td_rux: (t) for all fields. */ struct rusage_ext { - u_int64_t rux_runtime; /* (cj) Real time. */ - u_int64_t rux_uticks; /* (cj) Statclock hits in user mode. */ - u_int64_t rux_sticks; /* (cj) Statclock hits in sys mode. */ - u_int64_t rux_iticks; /* (cj) Statclock hits in intr mode. */ - u_int64_t rux_uu; /* (c) Previous user time in usec. */ - u_int64_t rux_su; /* (c) Previous sys time in usec. */ - u_int64_t rux_tu; /* (c) Previous total time in usec. */ + uint64_t rux_runtime; /* (cj) Real time. */ + uint64_t rux_uticks; /* (cj) Statclock hits in user mode. */ + uint64_t rux_sticks; /* (cj) Statclock hits in sys mode. */ + uint64_t rux_iticks; /* (cj) Statclock hits in intr mode. */ + uint64_t rux_uu; /* (c) Previous user time in usec. */ + uint64_t rux_su; /* (c) Previous sys time in usec. */ + uint64_t rux_tu; /* (c) Previous total time in usec. */ }; /* From b0775aef7700ba06d72cea4bc170dbe00fcbdc0c Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Thu, 19 May 2011 19:37:41 +0000 Subject: [PATCH 101/200] Simplify t4_os_find_pci_capability. MFC after: 3 days --- sys/dev/cxgbe/t4_main.c | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index e9516814c5a1..469af8d506c5 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -3212,45 +3212,12 @@ filter_rpl(struct adapter *sc, const struct cpl_set_tcb_rpl *rpl) } } -/* XXX: use pci_find_cap */ int t4_os_find_pci_capability(struct adapter *sc, int cap) { - device_t dev; - struct pci_devinfo *dinfo; - pcicfgregs *cfg; - uint32_t status; - uint8_t ptr; + int i; - dev = sc->dev; - dinfo = device_get_ivars(dev); - cfg = &dinfo->cfg; - - status = pci_read_config(dev, PCIR_STATUS, 2); - if (!(status & PCIM_STATUS_CAPPRESENT)) - return (0); - - switch (cfg->hdrtype & PCIM_HDRTYPE) { - case 0: - case 1: - ptr = PCIR_CAP_PTR; - break; - case 2: - ptr = PCIR_CAP_PTR_2; - break; - default: - return (0); - break; - } - ptr = pci_read_config(dev, ptr, 1); - - while (ptr != 0) { - if (pci_read_config(dev, ptr + PCICAP_ID, 1) == cap) - return (ptr); - ptr = pci_read_config(dev, ptr + PCICAP_NEXTPTR, 1); - } - - return (0); + return (pci_find_cap(sc->dev, cap, &i) == 0 ? i : 0); } int From b2bf146e3e3ef526b82b435c80a344299ff6e1ed Mon Sep 17 00:00:00 2001 From: Benedict Reuschling Date: Thu, 19 May 2011 20:35:40 +0000 Subject: [PATCH 102/200] Fix typos in comments, no functional changes. Found by: codespell Reviewed by: alfred MFC after: 1 week --- usr.bin/truss/amd64-fbsd.c | 2 +- usr.bin/truss/amd64-fbsd32.c | 2 +- usr.bin/truss/i386-fbsd.c | 2 +- usr.bin/truss/ia64-fbsd.c | 2 +- usr.bin/truss/main.c | 2 +- usr.bin/truss/powerpc-fbsd.c | 2 +- usr.bin/truss/powerpc64-fbsd.c | 2 +- usr.bin/truss/sparc64-fbsd.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.bin/truss/amd64-fbsd.c b/usr.bin/truss/amd64-fbsd.c index a4e531173218..6ed3812e65f3 100644 --- a/usr.bin/truss/amd64-fbsd.c +++ b/usr.bin/truss/amd64-fbsd.c @@ -128,7 +128,7 @@ amd64_syscall_entry(struct trussinfo *trussinfo, int nargs) { /* * FreeBSD has two special kinds of system call redirctions -- * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basicly; the latter is for quad-aligned arguments. + * routine, basically; the latter is for quad-aligned arguments. */ reg = 0; syscall_num = regs.r_rax; diff --git a/usr.bin/truss/amd64-fbsd32.c b/usr.bin/truss/amd64-fbsd32.c index b25b8182c60d..c3dd18357bb4 100644 --- a/usr.bin/truss/amd64-fbsd32.c +++ b/usr.bin/truss/amd64-fbsd32.c @@ -136,7 +136,7 @@ amd64_fbsd32_syscall_entry(struct trussinfo *trussinfo, int nargs) { /* * FreeBSD has two special kinds of system call redirctions -- * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basicly; the latter is for quad-aligned arguments. + * routine, basically; the latter is for quad-aligned arguments. */ syscall_num = regs.r_rax; switch (syscall_num) { diff --git a/usr.bin/truss/i386-fbsd.c b/usr.bin/truss/i386-fbsd.c index 70b051c5412c..82f1db0765b9 100644 --- a/usr.bin/truss/i386-fbsd.c +++ b/usr.bin/truss/i386-fbsd.c @@ -131,7 +131,7 @@ i386_syscall_entry(struct trussinfo *trussinfo, int nargs) { /* * FreeBSD has two special kinds of system call redirctions -- * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basicly; the latter is for quad-aligned arguments. + * routine, basically; the latter is for quad-aligned arguments. */ syscall_num = regs.r_eax; switch (syscall_num) { diff --git a/usr.bin/truss/ia64-fbsd.c b/usr.bin/truss/ia64-fbsd.c index 285e31400731..8fc06c60c366 100644 --- a/usr.bin/truss/ia64-fbsd.c +++ b/usr.bin/truss/ia64-fbsd.c @@ -128,7 +128,7 @@ ia64_syscall_entry(struct trussinfo *trussinfo, int nargs) { /* * FreeBSD has two special kinds of system call redirctions -- * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basicly; the latter is for quad-aligned arguments. + * routine, basically; the latter is for quad-aligned arguments. */ syscall_num = regs.r_scratch.gr15; /* XXX double-check. */ if (syscall_num == SYS_syscall || syscall_num == SYS___syscall) diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index e828046abee5..a74fe1c5e7e8 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$"); /* - * The main module for truss. Suprisingly simple, but, then, the other + * The main module for truss. Surprisingly simple, but, then, the other * files handle the bulk of the work. And, of course, the kernel has to * do a lot of the work :). */ diff --git a/usr.bin/truss/powerpc-fbsd.c b/usr.bin/truss/powerpc-fbsd.c index 5643f72d3551..285b10a61f4f 100644 --- a/usr.bin/truss/powerpc-fbsd.c +++ b/usr.bin/truss/powerpc-fbsd.c @@ -137,7 +137,7 @@ powerpc_syscall_entry(struct trussinfo *trussinfo, int nargs) { /* * FreeBSD has two special kinds of system call redirctions -- * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basicly; the latter is for quad-aligned arguments. + * routine, basically; the latter is for quad-aligned arguments. */ regargs = NARGREG; syscall_num = regs.fixreg[0]; diff --git a/usr.bin/truss/powerpc64-fbsd.c b/usr.bin/truss/powerpc64-fbsd.c index f072544bab6d..145c330fb8c9 100644 --- a/usr.bin/truss/powerpc64-fbsd.c +++ b/usr.bin/truss/powerpc64-fbsd.c @@ -129,7 +129,7 @@ powerpc64_syscall_entry(struct trussinfo *trussinfo, int nargs) { /* * FreeBSD has two special kinds of system call redirctions -- * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basicly; the latter is for quad-aligned arguments. + * routine, basically; the latter is for quad-aligned arguments. */ regargs = NARGREG; syscall_num = regs.fixreg[0]; diff --git a/usr.bin/truss/sparc64-fbsd.c b/usr.bin/truss/sparc64-fbsd.c index 779d6d8cc556..47302cc3de06 100644 --- a/usr.bin/truss/sparc64-fbsd.c +++ b/usr.bin/truss/sparc64-fbsd.c @@ -135,7 +135,7 @@ sparc64_syscall_entry(struct trussinfo *trussinfo, int nargs) { /* * FreeBSD has two special kinds of system call redirctions -- * SYS_syscall, and SYS___syscall. The former is the old syscall() - * routine, basicly; the latter is for quad-aligned arguments. + * routine, basically; the latter is for quad-aligned arguments. */ syscall_num = regs.r_global[1]; if (syscall_num == SYS_syscall || syscall_num == SYS___syscall) { From 83ad330dd5a0179c32b49c58443d78f6db04df36 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Thu, 19 May 2011 23:13:08 +0000 Subject: [PATCH 103/200] Fix typo. Submitted by: brad at OpenBSD --- sys/dev/alc/if_alcreg.h | 4 ++-- sys/dev/ale/if_alereg.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/alc/if_alcreg.h b/sys/dev/alc/if_alcreg.h index 93dc66445ccc..3011abff9a79 100644 --- a/sys/dev/alc/if_alcreg.h +++ b/sys/dev/alc/if_alcreg.h @@ -17,12 +17,12 @@ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMATES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * 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 DAMATE. + * SUCH DAMAGE. * * $FreeBSD$ */ diff --git a/sys/dev/ale/if_alereg.h b/sys/dev/ale/if_alereg.h index 896b0abb441f..445af99dafe2 100644 --- a/sys/dev/ale/if_alereg.h +++ b/sys/dev/ale/if_alereg.h @@ -17,12 +17,12 @@ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMATES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * 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 DAMATE. + * SUCH DAMAGE. * * $FreeBSD$ */ From d4cb6369e6099777436677a4179888686dc95694 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Thu, 19 May 2011 23:18:42 +0000 Subject: [PATCH 104/200] In preparation for IPv6 support allow to specify multiple addresses to listen on. MFC after: 3 weeks --- sbin/hastd/hast.conf.5 | 3 +- sbin/hastd/hast.h | 27 +++++---- sbin/hastd/hastd.c | 133 ++++++++++++++++++++++++++++++----------- sbin/hastd/parse.y | 120 ++++++++++++++++++++++++++++++------- 4 files changed, 215 insertions(+), 68 deletions(-) diff --git a/sbin/hastd/hast.conf.5 b/sbin/hastd/hast.conf.5 index c4d5cc4accd2..ead9234b3947 100644 --- a/sbin/hastd/hast.conf.5 +++ b/sbin/hastd/hast.conf.5 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 2, 2011 +.Dd May 20, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -159,6 +159,7 @@ tcp4://0.0.0.0 tcp4://0.0.0.0:8457 .Ed .Pp +Multiple listen addresses can be specified. The default value is .Pa tcp4://0.0.0.0:8457 . .It Ic replication Aq mode diff --git a/sbin/hastd/hast.h b/sbin/hastd/hast.h index df581e33e4ba..6768d4ca1dd9 100644 --- a/sbin/hastd/hast.h +++ b/sbin/hastd/hast.h @@ -82,12 +82,13 @@ #define HIO_FLUSH 4 #define HIO_KEEPALIVE 5 -#define HAST_USER "hast" -#define HAST_TIMEOUT 20 -#define HAST_CONFIG "/etc/hast.conf" -#define HAST_CONTROL "/var/run/hastctl" -#define HASTD_LISTEN "tcp4://0.0.0.0:8457" -#define HASTD_PIDFILE "/var/run/hastd.pid" +#define HAST_USER "hast" +#define HAST_TIMEOUT 20 +#define HAST_CONFIG "/etc/hast.conf" +#define HAST_CONTROL "/var/run/hastctl" +#define HASTD_LISTEN_IPV4 "tcp4://0.0.0.0:8457" +#define HASTD_LISTEN_IPV6 "tcp6://[::]:8457" +#define HASTD_PIDFILE "/var/run/hastd.pid" /* Default extent size. */ #define HAST_EXTENTSIZE 2097152 @@ -100,6 +101,14 @@ /* Number of seconds to sleep between reconnect retries or keepalive packets. */ #define HAST_KEEPALIVE 10 +struct hastd_listen { + /* Address to listen on. */ + char hl_addr[HAST_ADDRSIZE]; + /* Protocol-specific data. */ + struct proto_conn *hl_conn; + TAILQ_ENTRY(hastd_listen) hl_next; +}; + struct hastd_config { /* Address to communicate with hastctl(8). */ char hc_controladdr[HAST_ADDRSIZE]; @@ -107,10 +116,8 @@ struct hastd_config { struct proto_conn *hc_controlconn; /* Incoming control connection. */ struct proto_conn *hc_controlin; - /* Address to listen on. */ - char hc_listenaddr[HAST_ADDRSIZE]; - /* Protocol-specific data. */ - struct proto_conn *hc_listenconn; + /* List of addresses to listen on. */ + TAILQ_HEAD(, hastd_listen) hc_listen; /* List of resources. */ TAILQ_HEAD(, hast_resource) hc_resources; }; diff --git a/sbin/hastd/hastd.c b/sbin/hastd/hastd.c index bc5fbc276aca..6518f0cf57fd 100644 --- a/sbin/hastd/hastd.c +++ b/sbin/hastd/hastd.c @@ -98,6 +98,7 @@ void descriptors_cleanup(struct hast_resource *res) { struct hast_resource *tres; + struct hastd_listen *lst; TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) { if (tres == res) { @@ -120,7 +121,10 @@ descriptors_cleanup(struct hast_resource *res) if (cfg->hc_controlin != NULL) proto_close(cfg->hc_controlin); proto_close(cfg->hc_controlconn); - proto_close(cfg->hc_listenconn); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (lst->hl_conn != NULL) + proto_close(lst->hl_conn); + } (void)pidfile_close(pfh); hook_fini(); pjdlog_fini(); @@ -462,6 +466,8 @@ hastd_reload(void) { struct hastd_config *newcfg; struct hast_resource *nres, *cres, *tres; + struct hastd_listen *nlst, *clst; + unsigned int nlisten; uint8_t role; pjdlog_info("Reloading configuration..."); @@ -483,19 +489,37 @@ hastd_reload(void) } } /* - * Check if listen address has changed. + * Check if any listen address has changed. */ - if (strcmp(cfg->hc_listenaddr, newcfg->hc_listenaddr) != 0) { - if (proto_server(newcfg->hc_listenaddr, - &newcfg->hc_listenconn) < 0) { - pjdlog_errno(LOG_ERR, "Unable to listen on address %s", - newcfg->hc_listenaddr); - goto failed; + nlisten = 0; + TAILQ_FOREACH(nlst, &newcfg->hc_listen, hl_next) { + TAILQ_FOREACH(clst, &cfg->hc_listen, hl_next) { + if (strcmp(nlst->hl_addr, clst->hl_addr) == 0) + break; + } + if (clst != NULL && clst->hl_conn != NULL) { + pjdlog_info("Keep listening on address %s.", + nlst->hl_addr); + nlst->hl_conn = clst->hl_conn; + nlisten++; + } else if (proto_server(nlst->hl_addr, &nlst->hl_conn) == 0) { + pjdlog_info("Listening on new address %s.", + nlst->hl_addr); + nlisten++; + } else { + pjdlog_errno(LOG_WARNING, + "Unable to listen on address %s", nlst->hl_addr); } } + if (nlisten == 0) { + pjdlog_error("No addresses to listen on."); + goto failed; + } + + /* No failures from now on. */ + /* - * Only when both control and listen sockets are successfully - * initialized switch them to new configuration. + * Switch to new control socket. */ if (newcfg->hc_controlconn != NULL) { pjdlog_info("Control socket changed from %s to %s.", @@ -506,15 +530,23 @@ hastd_reload(void) strlcpy(cfg->hc_controladdr, newcfg->hc_controladdr, sizeof(cfg->hc_controladdr)); } - if (newcfg->hc_listenconn != NULL) { - pjdlog_info("Listen socket changed from %s to %s.", - cfg->hc_listenaddr, newcfg->hc_listenaddr); - proto_close(cfg->hc_listenconn); - cfg->hc_listenconn = newcfg->hc_listenconn; - newcfg->hc_listenconn = NULL; - strlcpy(cfg->hc_listenaddr, newcfg->hc_listenaddr, - sizeof(cfg->hc_listenaddr)); + /* + * Switch to new listen addresses. Close all that were removed. + */ + while ((clst = TAILQ_FIRST(&cfg->hc_listen)) != NULL) { + TAILQ_FOREACH(nlst, &newcfg->hc_listen, hl_next) { + if (strcmp(nlst->hl_addr, clst->hl_addr) == 0) + break; + } + if (nlst == NULL && clst->hl_conn != NULL) { + proto_close(clst->hl_conn); + pjdlog_info("No longer listening on address %s.", + clst->hl_addr); + } + TAILQ_REMOVE(&cfg->hc_listen, clst, hl_next); + free(clst); } + TAILQ_CONCAT(&cfg->hc_listen, &newcfg->hc_listen, hl_next); /* * Stop and remove resources that were removed from the configuration. @@ -607,8 +639,20 @@ hastd_reload(void) if (newcfg != NULL) { if (newcfg->hc_controlconn != NULL) proto_close(newcfg->hc_controlconn); - if (newcfg->hc_listenconn != NULL) - proto_close(newcfg->hc_listenconn); + while ((nlst = TAILQ_FIRST(&newcfg->hc_listen)) != NULL) { + if (nlst->hl_conn != NULL) { + TAILQ_FOREACH(clst, &cfg->hc_listen, hl_next) { + if (strcmp(nlst->hl_addr, + clst->hl_addr) == 0) { + break; + } + } + if (clst == NULL || clst->hl_conn == NULL) + proto_close(nlst->hl_conn); + } + TAILQ_REMOVE(&newcfg->hc_listen, nlst, hl_next); + free(nlst); + } yy_config_free(newcfg); } pjdlog_warning("Configuration not reloaded."); @@ -634,7 +678,7 @@ terminate_workers(void) } static void -listen_accept(void) +listen_accept(struct hastd_listen *lst) { struct hast_resource *res; struct proto_conn *conn; @@ -646,10 +690,10 @@ listen_accept(void) pid_t pid; int status; - proto_local_address(cfg->hc_listenconn, laddr, sizeof(laddr)); + proto_local_address(lst->hl_conn, laddr, sizeof(laddr)); pjdlog_debug(1, "Accepting connection to %s.", laddr); - if (proto_accept(cfg->hc_listenconn, &conn) < 0) { + if (proto_accept(lst->hl_conn, &conn) < 0) { pjdlog_errno(LOG_ERR, "Unable to accept connection %s", laddr); return; } @@ -943,6 +987,7 @@ static void main_loop(void) { struct hast_resource *res; + struct hastd_listen *lst; struct timeval seltimeout; int fd, maxfd, ret; time_t lastcheck, now; @@ -952,9 +997,6 @@ main_loop(void) seltimeout.tv_sec = REPORT_INTERVAL; seltimeout.tv_usec = 0; - pjdlog_info("Started successfully, running protocol version %d.", - HAST_PROTO_VERSION); - for (;;) { check_signals(); @@ -963,10 +1005,14 @@ main_loop(void) maxfd = fd = proto_descriptor(cfg->hc_controlconn); PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); - fd = proto_descriptor(cfg->hc_listenconn); - PJDLOG_ASSERT(fd >= 0); - FD_SET(fd, &rfds); - maxfd = fd > maxfd ? fd : maxfd; + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (lst->hl_conn == NULL) + continue; + fd = proto_descriptor(lst->hl_conn); + PJDLOG_ASSERT(fd >= 0); + FD_SET(fd, &rfds); + maxfd = fd > maxfd ? fd : maxfd; + } TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; @@ -1014,8 +1060,12 @@ main_loop(void) if (FD_ISSET(proto_descriptor(cfg->hc_controlconn), &rfds)) control_handle(cfg); - if (FD_ISSET(proto_descriptor(cfg->hc_listenconn), &rfds)) - listen_accept(); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (lst->hl_conn == NULL) + continue; + if (FD_ISSET(proto_descriptor(lst->hl_conn), &rfds)) + listen_accept(lst); + } TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; @@ -1053,6 +1103,7 @@ dummy_sighandler(int sig __unused) int main(int argc, char *argv[]) { + struct hastd_listen *lst; const char *pidfile; pid_t otherpid; bool foreground; @@ -1136,10 +1187,12 @@ main(int argc, char *argv[]) cfg->hc_controladdr); } /* Listen for remote connections. */ - if (proto_server(cfg->hc_listenaddr, &cfg->hc_listenconn) < 0) { - KEEP_ERRNO((void)pidfile_remove(pfh)); - pjdlog_exit(EX_OSERR, "Unable to listen on address %s", - cfg->hc_listenaddr); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) { + if (proto_server(lst->hl_addr, &lst->hl_conn) < 0) { + KEEP_ERRNO((void)pidfile_remove(pfh)); + pjdlog_exit(EX_OSERR, "Unable to listen on address %s", + lst->hl_addr); + } } if (!foreground) { @@ -1158,6 +1211,14 @@ main(int argc, char *argv[]) } } + pjdlog_info("Started successfully, running protocol version %d.", + HAST_PROTO_VERSION); + + pjdlog_debug(1, "Listening on control address %s.", + cfg->hc_controladdr); + TAILQ_FOREACH(lst, &cfg->hc_listen, hl_next) + pjdlog_info("Listening on address %s.", lst->hl_addr); + hook_init(); main_loop(); diff --git a/sbin/hastd/parse.y b/sbin/hastd/parse.y index a04b6868b46c..221df50612e5 100644 --- a/sbin/hastd/parse.y +++ b/sbin/hastd/parse.y @@ -33,12 +33,14 @@ #include /* MAXHOSTNAMELEN */ #include +#include #include #include #include #include +#include #include #include #include @@ -59,7 +61,9 @@ static struct hast_resource *curres; static bool mynode, hadmynode; static char depth0_control[HAST_ADDRSIZE]; -static char depth0_listen[HAST_ADDRSIZE]; +static char depth0_listen_ipv4[HAST_ADDRSIZE]; +static char depth0_listen_ipv6[HAST_ADDRSIZE]; +static TAILQ_HEAD(, hastd_listen) depth0_listen; static int depth0_replication; static int depth0_checksum; static int depth0_compression; @@ -114,6 +118,19 @@ isitme(const char *name) return (0); } +static bool +family_supported(int family) +{ + int sock; + + sock = socket(family, SOCK_STREAM, 0); + if (sock == -1 && errno == EPROTONOSUPPORT) + return (false); + if (sock >= 0) + (void)close(sock); + return (true); +} + static int node_names(char **namesp) { @@ -175,7 +192,11 @@ yy_config_parse(const char *config, bool exitonerror) depth0_checksum = HAST_CHECKSUM_NONE; depth0_compression = HAST_COMPRESSION_HOLE; strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control)); - strlcpy(depth0_listen, HASTD_LISTEN, sizeof(depth0_listen)); + TAILQ_INIT(&depth0_listen); + strlcpy(depth0_listen_ipv4, HASTD_LISTEN_IPV4, + sizeof(depth0_listen_ipv4)); + strlcpy(depth0_listen_ipv6, HASTD_LISTEN_IPV6, + sizeof(depth0_listen_ipv6)); depth0_exec[0] = '\0'; lconfig = calloc(1, sizeof(*lconfig)); @@ -186,6 +207,7 @@ yy_config_parse(const char *config, bool exitonerror) return (NULL); } + TAILQ_INIT(&lconfig->hc_listen); TAILQ_INIT(&lconfig->hc_resources); yyin = fopen(config, "r"); @@ -214,9 +236,52 @@ yy_config_parse(const char *config, bool exitonerror) strlcpy(lconfig->hc_controladdr, depth0_control, sizeof(lconfig->hc_controladdr)); } - if (lconfig->hc_listenaddr[0] == '\0') { - strlcpy(lconfig->hc_listenaddr, depth0_listen, - sizeof(lconfig->hc_listenaddr)); + if (!TAILQ_EMPTY(&depth0_listen)) + TAILQ_CONCAT(&lconfig->hc_listen, &depth0_listen, hl_next); + if (TAILQ_EMPTY(&lconfig->hc_listen)) { + struct hastd_listen *lst; + + if (family_supported(AF_INET)) { + lst = calloc(1, sizeof(*lst)); + if (lst == NULL) { + pjdlog_error("Unable to allocate memory for listen address."); + yy_config_free(lconfig); + if (exitonerror) + exit(EX_TEMPFAIL); + return (NULL); + } + (void)strlcpy(lst->hl_addr, depth0_listen_ipv4, + sizeof(lst->hl_addr)); + TAILQ_INSERT_TAIL(&lconfig->hc_listen, lst, hl_next); + } else { + pjdlog_debug(1, + "No IPv4 support in the kernel, not listening on IPv4 address."); + } +#ifdef notyet + if (family_supported(AF_INET6)) { + lst = calloc(1, sizeof(*lst)); + if (lst == NULL) { + pjdlog_error("Unable to allocate memory for listen address."); + yy_config_free(lconfig); + if (exitonerror) + exit(EX_TEMPFAIL); + return (NULL); + } + (void)strlcpy(lst->hl_addr, depth0_listen_ipv6, + sizeof(lst->hl_addr)); + TAILQ_INSERT_TAIL(&lconfig->hc_listen, lst, hl_next); + } else { + pjdlog_debug(1, + "No IPv6 support in the kernel, not listening on IPv6 address."); + } +#endif + if (TAILQ_EMPTY(&lconfig->hc_listen)) { + pjdlog_error("No address to listen on."); + yy_config_free(lconfig); + if (exitonerror) + exit(EX_TEMPFAIL); + return (NULL); + } } TAILQ_FOREACH(curres, &lconfig->hc_resources, hr_next) { assert(curres->hr_provname[0] != '\0'); @@ -274,8 +339,17 @@ yy_config_parse(const char *config, bool exitonerror) void yy_config_free(struct hastd_config *config) { + struct hastd_listen *lst; struct hast_resource *res; + while ((lst = TAILQ_FIRST(&depth0_listen)) != NULL) { + TAILQ_REMOVE(&depth0_listen, lst, hl_next); + free(lst); + } + while ((lst = TAILQ_FIRST(&config->hc_listen)) != NULL) { + TAILQ_REMOVE(&config->hc_listen, lst, hl_next); + free(lst); + } while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) { TAILQ_REMOVE(&config->hc_resources, res, hr_next); free(res); @@ -362,26 +436,30 @@ control_statement: CONTROL STR listen_statement: LISTEN STR { + struct hastd_listen *lst; + + lst = calloc(1, sizeof(*lst)); + if (lst == NULL) { + pjdlog_error("Unable to allocate memory for listen address."); + free($2); + return (1); + } + if (strlcpy(lst->hl_addr, $2, sizeof(lst->hl_addr)) >= + sizeof(lst->hl_addr)) { + pjdlog_error("listen argument is too long."); + free($2); + free(lst); + return (1); + } switch (depth) { case 0: - if (strlcpy(depth0_listen, $2, - sizeof(depth0_listen)) >= - sizeof(depth0_listen)) { - pjdlog_error("listen argument is too long."); - free($2); - return (1); - } + TAILQ_INSERT_TAIL(&depth0_listen, lst, hl_next); break; case 1: - if (!mynode) - break; - if (strlcpy(lconfig->hc_listenaddr, $2, - sizeof(lconfig->hc_listenaddr)) >= - sizeof(lconfig->hc_listenaddr)) { - pjdlog_error("listen argument is too long."); - free($2); - return (1); - } + if (mynode) + TAILQ_INSERT_TAIL(&depth0_listen, lst, hl_next); + else + free(lst); break; default: assert(!"listen at wrong depth level"); From 933728eea230f73d4733e3d763bef68aa5246b32 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 20 May 2011 11:06:17 +0000 Subject: [PATCH 105/200] Rename proto_tcp4.c to proto_tcp.c in preparation for IPv6 support. MFC after: 2 weeks --- sbin/hastd/Makefile | 2 +- sbin/hastd/{proto_tcp4.c => proto_tcp.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename sbin/hastd/{proto_tcp4.c => proto_tcp.c} (100%) diff --git a/sbin/hastd/Makefile b/sbin/hastd/Makefile index e6aff0792514..5ac5639cd993 100644 --- a/sbin/hastd/Makefile +++ b/sbin/hastd/Makefile @@ -12,7 +12,7 @@ SRCS+= metadata.c SRCS+= nv.c SRCS+= secondary.c SRCS+= parse.y pjdlog.c primary.c -SRCS+= proto.c proto_common.c proto_socketpair.c proto_tcp4.c proto_uds.c +SRCS+= proto.c proto_common.c proto_socketpair.c proto_tcp.c proto_uds.c SRCS+= rangelock.c SRCS+= subr.c SRCS+= token.l diff --git a/sbin/hastd/proto_tcp4.c b/sbin/hastd/proto_tcp.c similarity index 100% rename from sbin/hastd/proto_tcp4.c rename to sbin/hastd/proto_tcp.c From bdbd046b35f111958809338a2c0fff1fd4f1cdcf Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 20 May 2011 11:09:02 +0000 Subject: [PATCH 106/200] Rename tcp4 to tcp in preparation for IPv6 support. MFC after: 3 weeks --- sbin/hastd/Makefile | 2 +- sbin/hastd/proto_tcp.c | 184 ++++++++++++++++++++--------------------- 2 files changed, 93 insertions(+), 93 deletions(-) diff --git a/sbin/hastd/Makefile b/sbin/hastd/Makefile index 5ac5639cd993..1ffd0a244bc3 100644 --- a/sbin/hastd/Makefile +++ b/sbin/hastd/Makefile @@ -20,7 +20,7 @@ SRCS+= y.tab.h MAN= hastd.8 hast.conf.5 NO_WFORMAT= -CFLAGS+=-DPROTO_TCP4_DEFAULT_PORT=8457 +CFLAGS+=-DPROTO_TCP_DEFAULT_PORT=8457 CFLAGS+=-I${.CURDIR} CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" diff --git a/sbin/hastd/proto_tcp.c b/sbin/hastd/proto_tcp.c index 555fbe69c3b8..56c08ecf7582 100644 --- a/sbin/hastd/proto_tcp.c +++ b/sbin/hastd/proto_tcp.c @@ -51,19 +51,19 @@ __FBSDID("$FreeBSD$"); #include "proto_impl.h" #include "subr.h" -#define TCP4_CTX_MAGIC 0x7c441c -struct tcp4_ctx { +#define TCP_CTX_MAGIC 0x7c441c +struct tcp_ctx { int tc_magic; struct sockaddr_in tc_sin; int tc_fd; int tc_side; -#define TCP4_SIDE_CLIENT 0 -#define TCP4_SIDE_SERVER_LISTEN 1 -#define TCP4_SIDE_SERVER_WORK 2 +#define TCP_SIDE_CLIENT 0 +#define TCP_SIDE_SERVER_LISTEN 1 +#define TCP_SIDE_SERVER_WORK 2 }; -static int tcp4_connect_wait(void *ctx, int timeout); -static void tcp4_close(void *ctx); +static int tcp_connect_wait(void *ctx, int timeout); +static void tcp_close(void *ctx); static in_addr_t str2ip(const char *str) @@ -114,7 +114,7 @@ numfromstr(const char *str, intmax_t minnum, intmax_t maxnum, intmax_t *nump) } static int -tcp4_addr(const char *addr, int defport, struct sockaddr_in *sinp) +tcp_addr(const char *addr, int defport, struct sockaddr_in *sinp) { char iporhost[MAXHOSTNAMELEN]; const char *pp; @@ -124,13 +124,13 @@ tcp4_addr(const char *addr, int defport, struct sockaddr_in *sinp) if (addr == NULL) return (-1); - if (strncasecmp(addr, "tcp4://", 7) == 0) + if (strncasecmp(addr, "tcp://", 7) == 0) addr += 7; else if (strncasecmp(addr, "tcp://", 6) == 0) addr += 6; else { /* - * Because TCP4 is the default assume IP or host is given without + * Because TCP is the default assume IP or host is given without * prefix. */ } @@ -170,14 +170,14 @@ tcp4_addr(const char *addr, int defport, struct sockaddr_in *sinp) } static int -tcp4_setup_new(const char *addr, int side, void **ctxp) +tcp_setup_new(const char *addr, int side, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; int ret, nodelay; PJDLOG_ASSERT(addr != NULL); - PJDLOG_ASSERT(side == TCP4_SIDE_CLIENT || - side == TCP4_SIDE_SERVER_LISTEN); + PJDLOG_ASSERT(side == TCP_SIDE_CLIENT || + side == TCP_SIDE_SERVER_LISTEN); PJDLOG_ASSERT(ctxp != NULL); tctx = malloc(sizeof(*tctx)); @@ -185,7 +185,7 @@ tcp4_setup_new(const char *addr, int side, void **ctxp) return (errno); /* Parse given address. */ - if ((ret = tcp4_addr(addr, PROTO_TCP4_DEFAULT_PORT, + if ((ret = tcp_addr(addr, PROTO_TCP_DEFAULT_PORT, &tctx->tc_sin)) != 0) { free(tctx); return (ret); @@ -210,20 +210,20 @@ tcp4_setup_new(const char *addr, int side, void **ctxp) } tctx->tc_side = side; - tctx->tc_magic = TCP4_CTX_MAGIC; + tctx->tc_magic = TCP_CTX_MAGIC; *ctxp = tctx; return (0); } static int -tcp4_setup_wrap(int fd, int side, void **ctxp) +tcp_setup_wrap(int fd, int side, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; PJDLOG_ASSERT(fd >= 0); - PJDLOG_ASSERT(side == TCP4_SIDE_CLIENT || - side == TCP4_SIDE_SERVER_WORK); + PJDLOG_ASSERT(side == TCP_SIDE_CLIENT || + side == TCP_SIDE_SERVER_WORK); PJDLOG_ASSERT(ctxp != NULL); tctx = malloc(sizeof(*tctx)); @@ -233,47 +233,47 @@ tcp4_setup_wrap(int fd, int side, void **ctxp) tctx->tc_fd = fd; tctx->tc_sin.sin_family = AF_UNSPEC; tctx->tc_side = side; - tctx->tc_magic = TCP4_CTX_MAGIC; + tctx->tc_magic = TCP_CTX_MAGIC; *ctxp = tctx; return (0); } static int -tcp4_client(const char *srcaddr, const char *dstaddr, void **ctxp) +tcp_client(const char *srcaddr, const char *dstaddr, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; struct sockaddr_in sin; int ret; - ret = tcp4_setup_new(dstaddr, TCP4_SIDE_CLIENT, ctxp); + ret = tcp_setup_new(dstaddr, TCP_SIDE_CLIENT, ctxp); if (ret != 0) return (ret); tctx = *ctxp; if (srcaddr == NULL) return (0); - ret = tcp4_addr(srcaddr, 0, &sin); + ret = tcp_addr(srcaddr, 0, &sin); if (ret != 0) { - tcp4_close(tctx); + tcp_close(tctx); return (ret); } if (bind(tctx->tc_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { ret = errno; - tcp4_close(tctx); + tcp_close(tctx); return (ret); } return (0); } static int -tcp4_connect(void *ctx, int timeout) +tcp_connect(void *ctx, int timeout) { - struct tcp4_ctx *tctx = ctx; + struct tcp_ctx *tctx = ctx; int error, flags; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); - PJDLOG_ASSERT(tctx->tc_side == TCP4_SIDE_CLIENT); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_side == TCP_SIDE_CLIENT); PJDLOG_ASSERT(tctx->tc_fd >= 0); PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); PJDLOG_ASSERT(timeout >= -1); @@ -309,7 +309,7 @@ tcp4_connect(void *ctx, int timeout) } if (timeout == -1) return (0); - return (tcp4_connect_wait(ctx, timeout)); + return (tcp_connect_wait(ctx, timeout)); done: flags &= ~O_NONBLOCK; if (fcntl(tctx->tc_fd, F_SETFL, flags) == -1) { @@ -322,17 +322,17 @@ tcp4_connect(void *ctx, int timeout) } static int -tcp4_connect_wait(void *ctx, int timeout) +tcp_connect_wait(void *ctx, int timeout) { - struct tcp4_ctx *tctx = ctx; + struct tcp_ctx *tctx = ctx; struct timeval tv; fd_set fdset; socklen_t esize; int error, flags, ret; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); - PJDLOG_ASSERT(tctx->tc_side == TCP4_SIDE_CLIENT); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_side == TCP_SIDE_CLIENT); PJDLOG_ASSERT(tctx->tc_fd >= 0); PJDLOG_ASSERT(timeout >= 0); @@ -387,12 +387,12 @@ tcp4_connect_wait(void *ctx, int timeout) } static int -tcp4_server(const char *addr, void **ctxp) +tcp_server(const char *addr, void **ctxp) { - struct tcp4_ctx *tctx; + struct tcp_ctx *tctx; int ret, val; - ret = tcp4_setup_new(addr, TCP4_SIDE_SERVER_LISTEN, ctxp); + ret = tcp_setup_new(addr, TCP_SIDE_SERVER_LISTEN, ctxp); if (ret != 0) return (ret); @@ -408,12 +408,12 @@ tcp4_server(const char *addr, void **ctxp) if (bind(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sin, sizeof(tctx->tc_sin)) < 0) { ret = errno; - tcp4_close(tctx); + tcp_close(tctx); return (ret); } if (listen(tctx->tc_fd, 8) < 0) { ret = errno; - tcp4_close(tctx); + tcp_close(tctx); return (ret); } @@ -421,16 +421,16 @@ tcp4_server(const char *addr, void **ctxp) } static int -tcp4_accept(void *ctx, void **newctxp) +tcp_accept(void *ctx, void **newctxp) { - struct tcp4_ctx *tctx = ctx; - struct tcp4_ctx *newtctx; + struct tcp_ctx *tctx = ctx; + struct tcp_ctx *newtctx; socklen_t fromlen; int ret; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); - PJDLOG_ASSERT(tctx->tc_side == TCP4_SIDE_SERVER_LISTEN); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_side == TCP_SIDE_SERVER_LISTEN); PJDLOG_ASSERT(tctx->tc_fd >= 0); PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); @@ -447,28 +447,28 @@ tcp4_accept(void *ctx, void **newctxp) return (ret); } - newtctx->tc_side = TCP4_SIDE_SERVER_WORK; - newtctx->tc_magic = TCP4_CTX_MAGIC; + newtctx->tc_side = TCP_SIDE_SERVER_WORK; + newtctx->tc_magic = TCP_CTX_MAGIC; *newctxp = newtctx; return (0); } static int -tcp4_wrap(int fd, bool client, void **ctxp) +tcp_wrap(int fd, bool client, void **ctxp) { - return (tcp4_setup_wrap(fd, - client ? TCP4_SIDE_CLIENT : TCP4_SIDE_SERVER_WORK, ctxp)); + return (tcp_setup_wrap(fd, + client ? TCP_SIDE_CLIENT : TCP_SIDE_SERVER_WORK, ctxp)); } static int -tcp4_send(void *ctx, const unsigned char *data, size_t size, int fd) +tcp_send(void *ctx, const unsigned char *data, size_t size, int fd) { - struct tcp4_ctx *tctx = ctx; + struct tcp_ctx *tctx = ctx; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); PJDLOG_ASSERT(tctx->tc_fd >= 0); PJDLOG_ASSERT(fd == -1); @@ -476,12 +476,12 @@ tcp4_send(void *ctx, const unsigned char *data, size_t size, int fd) } static int -tcp4_recv(void *ctx, unsigned char *data, size_t size, int *fdp) +tcp_recv(void *ctx, unsigned char *data, size_t size, int *fdp) { - struct tcp4_ctx *tctx = ctx; + struct tcp_ctx *tctx = ctx; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); PJDLOG_ASSERT(tctx->tc_fd >= 0); PJDLOG_ASSERT(fdp == NULL); @@ -489,28 +489,28 @@ tcp4_recv(void *ctx, unsigned char *data, size_t size, int *fdp) } static int -tcp4_descriptor(const void *ctx) +tcp_descriptor(const void *ctx) { - const struct tcp4_ctx *tctx = ctx; + const struct tcp_ctx *tctx = ctx; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); return (tctx->tc_fd); } static bool -tcp4_address_match(const void *ctx, const char *addr) +tcp_address_match(const void *ctx, const char *addr) { - const struct tcp4_ctx *tctx = ctx; + const struct tcp_ctx *tctx = ctx; struct sockaddr_in sin; socklen_t sinlen; in_addr_t ip1, ip2; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); - if (tcp4_addr(addr, PROTO_TCP4_DEFAULT_PORT, &sin) != 0) + if (tcp_addr(addr, PROTO_TCP_DEFAULT_PORT, &sin) != 0) return (false); ip1 = sin.sin_addr.s_addr; @@ -523,48 +523,48 @@ tcp4_address_match(const void *ctx, const char *addr) } static void -tcp4_local_address(const void *ctx, char *addr, size_t size) +tcp_local_address(const void *ctx, char *addr, size_t size) { - const struct tcp4_ctx *tctx = ctx; + const struct tcp_ctx *tctx = ctx; struct sockaddr_in sin; socklen_t sinlen; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); sinlen = sizeof(sin); if (getsockname(tctx->tc_fd, (struct sockaddr *)&sin, &sinlen) < 0) { PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } - PJDLOG_VERIFY(snprintf(addr, size, "tcp4://%S", &sin) < (ssize_t)size); + PJDLOG_VERIFY(snprintf(addr, size, "tcp://%S", &sin) < (ssize_t)size); } static void -tcp4_remote_address(const void *ctx, char *addr, size_t size) +tcp_remote_address(const void *ctx, char *addr, size_t size) { - const struct tcp4_ctx *tctx = ctx; + const struct tcp_ctx *tctx = ctx; struct sockaddr_in sin; socklen_t sinlen; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); sinlen = sizeof(sin); if (getpeername(tctx->tc_fd, (struct sockaddr *)&sin, &sinlen) < 0) { PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } - PJDLOG_VERIFY(snprintf(addr, size, "tcp4://%S", &sin) < (ssize_t)size); + PJDLOG_VERIFY(snprintf(addr, size, "tcp://%S", &sin) < (ssize_t)size); } static void -tcp4_close(void *ctx) +tcp_close(void *ctx) { - struct tcp4_ctx *tctx = ctx; + struct tcp_ctx *tctx = ctx; PJDLOG_ASSERT(tctx != NULL); - PJDLOG_ASSERT(tctx->tc_magic == TCP4_CTX_MAGIC); + PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); if (tctx->tc_fd >= 0) close(tctx->tc_fd); @@ -572,26 +572,26 @@ tcp4_close(void *ctx) free(tctx); } -static struct proto tcp4_proto = { - .prt_name = "tcp4", - .prt_client = tcp4_client, - .prt_connect = tcp4_connect, - .prt_connect_wait = tcp4_connect_wait, - .prt_server = tcp4_server, - .prt_accept = tcp4_accept, - .prt_wrap = tcp4_wrap, - .prt_send = tcp4_send, - .prt_recv = tcp4_recv, - .prt_descriptor = tcp4_descriptor, - .prt_address_match = tcp4_address_match, - .prt_local_address = tcp4_local_address, - .prt_remote_address = tcp4_remote_address, - .prt_close = tcp4_close +static struct proto tcp_proto = { + .prt_name = "tcp", + .prt_client = tcp_client, + .prt_connect = tcp_connect, + .prt_connect_wait = tcp_connect_wait, + .prt_server = tcp_server, + .prt_accept = tcp_accept, + .prt_wrap = tcp_wrap, + .prt_send = tcp_send, + .prt_recv = tcp_recv, + .prt_descriptor = tcp_descriptor, + .prt_address_match = tcp_address_match, + .prt_local_address = tcp_local_address, + .prt_remote_address = tcp_remote_address, + .prt_close = tcp_close }; static __constructor void -tcp4_ctor(void) +tcp_ctor(void) { - proto_register(&tcp4_proto, true); + proto_register(&tcp_proto, true); } From 496a87aa3080dc407e5a0c89766d50e97fec9e31 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 20 May 2011 11:10:39 +0000 Subject: [PATCH 107/200] Allow [ ] characters in strings. They might be used in IPv6 addresses. MFC after: 3 weeks --- sbin/hastd/token.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/hastd/token.l b/sbin/hastd/token.l index 389dfedf6e2a..67c1e130e69d 100644 --- a/sbin/hastd/token.l +++ b/sbin/hastd/token.l @@ -68,7 +68,7 @@ sha256 { DP; return SHA256; } hole { DP; return HOLE; } lzf { DP; return LZF; } [0-9]+ { DP; yylval.num = atoi(yytext); return NUM; } -[a-zA-Z0-9\.\-_/\:]+ { DP; yylval.str = strdup(yytext); return STR; } +[a-zA-Z0-9\.\-_/\:\[\]]+ { DP; yylval.str = strdup(yytext); return STR; } \{ { DP; depth++; return OB; } \} { DP; depth--; return CB; } #.*$ /* ignore comments */; From dc18c8ae6cd3cc98b1195ef3d9331663d361c001 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 20 May 2011 11:14:05 +0000 Subject: [PATCH 108/200] Now that hell is fully frozen it is good time to add IPv6 support to HAST. MFC after: 3 weeks --- sbin/hastd/proto_tcp.c | 191 +++++++++++++++++++++++++---------------- 1 file changed, 116 insertions(+), 75 deletions(-) diff --git a/sbin/hastd/proto_tcp.c b/sbin/hastd/proto_tcp.c index 56c08ecf7582..8f0f157cf020 100644 --- a/sbin/hastd/proto_tcp.c +++ b/sbin/hastd/proto_tcp.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -51,10 +52,10 @@ __FBSDID("$FreeBSD$"); #include "proto_impl.h" #include "subr.h" -#define TCP_CTX_MAGIC 0x7c441c +#define TCP_CTX_MAGIC 0x7c41c struct tcp_ctx { int tc_magic; - struct sockaddr_in tc_sin; + struct sockaddr_storage tc_sa; int tc_fd; int tc_side; #define TCP_SIDE_CLIENT 0 @@ -65,24 +66,6 @@ struct tcp_ctx { static int tcp_connect_wait(void *ctx, int timeout); static void tcp_close(void *ctx); -static in_addr_t -str2ip(const char *str) -{ - struct hostent *hp; - in_addr_t ip; - - ip = inet_addr(str); - if (ip != INADDR_NONE) { - /* It is a valid IP address. */ - return (ip); - } - /* Check if it is a valid host name. */ - hp = gethostbyname(str); - if (hp == NULL) - return (INADDR_NONE); - return (((struct in_addr *)(void *)hp->h_addr)->s_addr); -} - /* * Function converts the given string to unsigned number. */ @@ -114,57 +97,93 @@ numfromstr(const char *str, intmax_t minnum, intmax_t maxnum, intmax_t *nump) } static int -tcp_addr(const char *addr, int defport, struct sockaddr_in *sinp) +tcp_addr(const char *addr, int defport, struct sockaddr_storage *sap) { - char iporhost[MAXHOSTNAMELEN]; + char iporhost[MAXHOSTNAMELEN], portstr[6]; + struct addrinfo hints; + struct addrinfo *res; const char *pp; + intmax_t port; size_t size; - in_addr_t ip; + int error; if (addr == NULL) return (-1); - if (strncasecmp(addr, "tcp://", 7) == 0) + bzero(&hints, sizeof(hints)); + hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + + if (strncasecmp(addr, "tcp4://", 7) == 0) { addr += 7; - else if (strncasecmp(addr, "tcp://", 6) == 0) + hints.ai_family = PF_INET; + } else if (strncasecmp(addr, "tcp6://", 7) == 0) { + addr += 7; + hints.ai_family = PF_INET6; + } else if (strncasecmp(addr, "tcp://", 6) == 0) { addr += 6; - else { + } else { /* * Because TCP is the default assume IP or host is given without * prefix. */ } - sinp->sin_family = AF_INET; - sinp->sin_len = sizeof(*sinp); - /* Extract optional port. */ - pp = strrchr(addr, ':'); + /* + * Extract optional port. + * There are three cases to consider. + * 1. hostname with port, eg. freefall.freebsd.org:8457 + * 2. IPv4 address with port, eg. 192.168.0.101:8457 + * 3. IPv6 address with port, eg. [fe80::1]:8457 + * We discover IPv6 address by checking for two colons and if port is + * given, the address has to start with [. + */ + pp = NULL; + if (strchr(addr, ':') != strrchr(addr, ':')) { + if (addr[0] == '[') + pp = strrchr(addr, ':'); + } else { + pp = strrchr(addr, ':'); + } if (pp == NULL) { /* Port not given, use the default. */ - sinp->sin_port = htons(defport); + port = defport; } else { - intmax_t port; - if (numfromstr(pp + 1, 1, 65535, &port) < 0) return (errno); - sinp->sin_port = htons(port); } + (void)snprintf(portstr, sizeof(portstr), "%jd", (intmax_t)port); /* Extract host name or IP address. */ if (pp == NULL) { size = sizeof(iporhost); if (strlcpy(iporhost, addr, size) >= size) return (ENAMETOOLONG); + } else if (addr[0] == '[' && pp[-1] == ']') { + size = (size_t)(pp - addr - 2 + 1); + if (size > sizeof(iporhost)) + return (ENAMETOOLONG); + (void)strlcpy(iporhost, addr + 1, size); } else { size = (size_t)(pp - addr + 1); if (size > sizeof(iporhost)) return (ENAMETOOLONG); (void)strlcpy(iporhost, addr, size); } - /* Convert string (IP address or host name) to in_addr_t. */ - ip = str2ip(iporhost); - if (ip == INADDR_NONE) + + error = getaddrinfo(iporhost, portstr, &hints, &res); + if (error != 0) { + pjdlog_debug(1, "getaddrinfo(%s, %s) failed: %s.", iporhost, + portstr, gai_strerror(error)); return (EINVAL); - sinp->sin_addr.s_addr = ip; + } + if (res == NULL) + return (ENOENT); + + memcpy(sap, res->ai_addr, res->ai_addrlen); + + freeaddrinfo(res); return (0); } @@ -185,22 +204,21 @@ tcp_setup_new(const char *addr, int side, void **ctxp) return (errno); /* Parse given address. */ - if ((ret = tcp_addr(addr, PROTO_TCP_DEFAULT_PORT, - &tctx->tc_sin)) != 0) { + if ((ret = tcp_addr(addr, PROTO_TCP_DEFAULT_PORT, &tctx->tc_sa)) != 0) { free(tctx); return (ret); } - PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); + PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); - tctx->tc_fd = socket(AF_INET, SOCK_STREAM, 0); + tctx->tc_fd = socket(tctx->tc_sa.ss_family, SOCK_STREAM, 0); if (tctx->tc_fd == -1) { ret = errno; free(tctx); return (ret); } - PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); + PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); /* Socket settings. */ nodelay = 1; @@ -231,7 +249,7 @@ tcp_setup_wrap(int fd, int side, void **ctxp) return (errno); tctx->tc_fd = fd; - tctx->tc_sin.sin_family = AF_UNSPEC; + tctx->tc_sa.ss_family = AF_UNSPEC; tctx->tc_side = side; tctx->tc_magic = TCP_CTX_MAGIC; *ctxp = tctx; @@ -243,7 +261,7 @@ static int tcp_client(const char *srcaddr, const char *dstaddr, void **ctxp) { struct tcp_ctx *tctx; - struct sockaddr_in sin; + struct sockaddr_storage sa; int ret; ret = tcp_setup_new(dstaddr, TCP_SIDE_CLIENT, ctxp); @@ -252,12 +270,12 @@ tcp_client(const char *srcaddr, const char *dstaddr, void **ctxp) tctx = *ctxp; if (srcaddr == NULL) return (0); - ret = tcp_addr(srcaddr, 0, &sin); + ret = tcp_addr(srcaddr, 0, &sa); if (ret != 0) { tcp_close(tctx); return (ret); } - if (bind(tctx->tc_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { + if (bind(tctx->tc_fd, (struct sockaddr *)&sa, sa.ss_len) < 0) { ret = errno; tcp_close(tctx); return (ret); @@ -275,7 +293,7 @@ tcp_connect(void *ctx, int timeout) PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); PJDLOG_ASSERT(tctx->tc_side == TCP_SIDE_CLIENT); PJDLOG_ASSERT(tctx->tc_fd >= 0); - PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); + PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); PJDLOG_ASSERT(timeout >= -1); flags = fcntl(tctx->tc_fd, F_GETFL); @@ -295,8 +313,8 @@ tcp_connect(void *ctx, int timeout) return (errno); } - if (connect(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sin, - sizeof(tctx->tc_sin)) == 0) { + if (connect(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sa, + tctx->tc_sa.ss_len) == 0) { if (timeout == -1) return (0); error = 0; @@ -403,10 +421,10 @@ tcp_server(const char *addr, void **ctxp) (void)setsockopt(tctx->tc_fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); - PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); + PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); - if (bind(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sin, - sizeof(tctx->tc_sin)) < 0) { + if (bind(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sa, + tctx->tc_sa.ss_len) < 0) { ret = errno; tcp_close(tctx); return (ret); @@ -432,14 +450,14 @@ tcp_accept(void *ctx, void **newctxp) PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); PJDLOG_ASSERT(tctx->tc_side == TCP_SIDE_SERVER_LISTEN); PJDLOG_ASSERT(tctx->tc_fd >= 0); - PJDLOG_ASSERT(tctx->tc_sin.sin_family != AF_UNSPEC); + PJDLOG_ASSERT(tctx->tc_sa.ss_family != AF_UNSPEC); newtctx = malloc(sizeof(*newtctx)); if (newtctx == NULL) return (errno); - fromlen = sizeof(tctx->tc_sin); - newtctx->tc_fd = accept(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sin, + fromlen = tctx->tc_sa.ss_len; + newtctx->tc_fd = accept(tctx->tc_fd, (struct sockaddr *)&tctx->tc_sa, &fromlen); if (newtctx->tc_fd < 0) { ret = errno; @@ -503,59 +521,82 @@ static bool tcp_address_match(const void *ctx, const char *addr) { const struct tcp_ctx *tctx = ctx; - struct sockaddr_in sin; - socklen_t sinlen; - in_addr_t ip1, ip2; + struct sockaddr_storage sa1, sa2; + socklen_t salen; PJDLOG_ASSERT(tctx != NULL); PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); - if (tcp_addr(addr, PROTO_TCP_DEFAULT_PORT, &sin) != 0) + if (tcp_addr(addr, PROTO_TCP_DEFAULT_PORT, &sa1) != 0) return (false); - ip1 = sin.sin_addr.s_addr; - sinlen = sizeof(sin); - if (getpeername(tctx->tc_fd, (struct sockaddr *)&sin, &sinlen) < 0) + salen = sizeof(sa2); + if (getpeername(tctx->tc_fd, (struct sockaddr *)&sa2, &salen) < 0) return (false); - ip2 = sin.sin_addr.s_addr; - return (ip1 == ip2); + if (sa1.ss_family != sa2.ss_family || sa1.ss_len != sa2.ss_len) + return (false); + + switch (sa1.ss_family) { + case AF_INET: + { + struct sockaddr_in *sin1, *sin2; + + sin1 = (struct sockaddr_in *)&sa1; + sin2 = (struct sockaddr_in *)&sa2; + + return (memcmp(&sin1->sin_addr, &sin2->sin_addr, + sizeof(sin1->sin_addr)) == 0); + } + case AF_INET6: + { + struct sockaddr_in6 *sin1, *sin2; + + sin1 = (struct sockaddr_in6 *)&sa1; + sin2 = (struct sockaddr_in6 *)&sa2; + + return (memcmp(&sin1->sin6_addr, &sin2->sin6_addr, + sizeof(sin1->sin6_addr)) == 0); + } + default: + return (false); + } } static void tcp_local_address(const void *ctx, char *addr, size_t size) { const struct tcp_ctx *tctx = ctx; - struct sockaddr_in sin; - socklen_t sinlen; + struct sockaddr_storage sa; + socklen_t salen; PJDLOG_ASSERT(tctx != NULL); PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); - sinlen = sizeof(sin); - if (getsockname(tctx->tc_fd, (struct sockaddr *)&sin, &sinlen) < 0) { + salen = sizeof(sa); + if (getsockname(tctx->tc_fd, (struct sockaddr *)&sa, &salen) < 0) { PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } - PJDLOG_VERIFY(snprintf(addr, size, "tcp://%S", &sin) < (ssize_t)size); + PJDLOG_VERIFY(snprintf(addr, size, "tcp://%S", &sa) < (ssize_t)size); } static void tcp_remote_address(const void *ctx, char *addr, size_t size) { const struct tcp_ctx *tctx = ctx; - struct sockaddr_in sin; - socklen_t sinlen; + struct sockaddr_storage sa; + socklen_t salen; PJDLOG_ASSERT(tctx != NULL); PJDLOG_ASSERT(tctx->tc_magic == TCP_CTX_MAGIC); - sinlen = sizeof(sin); - if (getpeername(tctx->tc_fd, (struct sockaddr *)&sin, &sinlen) < 0) { + salen = sizeof(sa); + if (getpeername(tctx->tc_fd, (struct sockaddr *)&sa, &salen) < 0) { PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } - PJDLOG_VERIFY(snprintf(addr, size, "tcp://%S", &sin) < (ssize_t)size); + PJDLOG_VERIFY(snprintf(addr, size, "tcp://%S", &sa) < (ssize_t)size); } static void From a87399ba7fd76109b0dcc7bd6fd0a1f5468863f1 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 20 May 2011 11:15:27 +0000 Subject: [PATCH 109/200] Rename ipv4/ipv6 to tcp4/tcp6. MFC after: 3 weeks --- sbin/hastd/hast.h | 4 ++-- sbin/hastd/parse.y | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sbin/hastd/hast.h b/sbin/hastd/hast.h index 6768d4ca1dd9..3f2616228352 100644 --- a/sbin/hastd/hast.h +++ b/sbin/hastd/hast.h @@ -86,8 +86,8 @@ #define HAST_TIMEOUT 20 #define HAST_CONFIG "/etc/hast.conf" #define HAST_CONTROL "/var/run/hastctl" -#define HASTD_LISTEN_IPV4 "tcp4://0.0.0.0:8457" -#define HASTD_LISTEN_IPV6 "tcp6://[::]:8457" +#define HASTD_LISTEN_TCP4 "tcp4://0.0.0.0:8457" +#define HASTD_LISTEN_TCP6 "tcp6://[::]:8457" #define HASTD_PIDFILE "/var/run/hastd.pid" /* Default extent size. */ diff --git a/sbin/hastd/parse.y b/sbin/hastd/parse.y index 221df50612e5..7a725fe90e75 100644 --- a/sbin/hastd/parse.y +++ b/sbin/hastd/parse.y @@ -61,8 +61,8 @@ static struct hast_resource *curres; static bool mynode, hadmynode; static char depth0_control[HAST_ADDRSIZE]; -static char depth0_listen_ipv4[HAST_ADDRSIZE]; -static char depth0_listen_ipv6[HAST_ADDRSIZE]; +static char depth0_listen_tcp4[HAST_ADDRSIZE]; +static char depth0_listen_tcp6[HAST_ADDRSIZE]; static TAILQ_HEAD(, hastd_listen) depth0_listen; static int depth0_replication; static int depth0_checksum; @@ -193,10 +193,10 @@ yy_config_parse(const char *config, bool exitonerror) depth0_compression = HAST_COMPRESSION_HOLE; strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control)); TAILQ_INIT(&depth0_listen); - strlcpy(depth0_listen_ipv4, HASTD_LISTEN_IPV4, - sizeof(depth0_listen_ipv4)); - strlcpy(depth0_listen_ipv6, HASTD_LISTEN_IPV6, - sizeof(depth0_listen_ipv6)); + strlcpy(depth0_listen_tcp4, HASTD_LISTEN_TCP4, + sizeof(depth0_listen_tcp4)); + strlcpy(depth0_listen_tcp6, HASTD_LISTEN_TCP6, + sizeof(depth0_listen_tcp6)); depth0_exec[0] = '\0'; lconfig = calloc(1, sizeof(*lconfig)); @@ -250,7 +250,7 @@ yy_config_parse(const char *config, bool exitonerror) exit(EX_TEMPFAIL); return (NULL); } - (void)strlcpy(lst->hl_addr, depth0_listen_ipv4, + (void)strlcpy(lst->hl_addr, depth0_listen_tcp4, sizeof(lst->hl_addr)); TAILQ_INSERT_TAIL(&lconfig->hc_listen, lst, hl_next); } else { @@ -267,7 +267,7 @@ yy_config_parse(const char *config, bool exitonerror) exit(EX_TEMPFAIL); return (NULL); } - (void)strlcpy(lst->hl_addr, depth0_listen_ipv6, + (void)strlcpy(lst->hl_addr, depth0_listen_tcp6, sizeof(lst->hl_addr)); TAILQ_INSERT_TAIL(&lconfig->hc_listen, lst, hl_next); } else { From 89bad89a5969f768de90daa3c7e81427c0f2f3a2 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 20 May 2011 11:16:25 +0000 Subject: [PATCH 110/200] If no listen address is specified, bind by default to: tcp4://0.0.0.0:8457 tcp6://[::]:8457 MFC after: 3 weeks --- sbin/hastd/parse.y | 2 -- 1 file changed, 2 deletions(-) diff --git a/sbin/hastd/parse.y b/sbin/hastd/parse.y index 7a725fe90e75..6e8351d243d5 100644 --- a/sbin/hastd/parse.y +++ b/sbin/hastd/parse.y @@ -257,7 +257,6 @@ yy_config_parse(const char *config, bool exitonerror) pjdlog_debug(1, "No IPv4 support in the kernel, not listening on IPv4 address."); } -#ifdef notyet if (family_supported(AF_INET6)) { lst = calloc(1, sizeof(*lst)); if (lst == NULL) { @@ -274,7 +273,6 @@ yy_config_parse(const char *config, bool exitonerror) pjdlog_debug(1, "No IPv6 support in the kernel, not listening on IPv6 address."); } -#endif if (TAILQ_EMPTY(&lconfig->hc_listen)) { pjdlog_error("No address to listen on."); yy_config_free(lconfig); From 588e8623d0a6f9488bb44c84ed2f0d6761848c3b Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 20 May 2011 11:21:39 +0000 Subject: [PATCH 111/200] Document IPv6 support. MFC after: 3 weeks --- sbin/hastd/hast.conf.5 | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/sbin/hastd/hast.conf.5 b/sbin/hastd/hast.conf.5 index ead9234b3947..f53e6e3a69e5 100644 --- a/sbin/hastd/hast.conf.5 +++ b/sbin/hastd/hast.conf.5 @@ -160,8 +160,13 @@ tcp4://0.0.0.0:8457 .Ed .Pp Multiple listen addresses can be specified. -The default value is -.Pa tcp4://0.0.0.0:8457 . +By default +.Nm hastd +listens on +.Pa tcp4://0.0.0.0:8457 +and +.Pa tcp6://[::]:8457 +if kernel supports IPv4 and IPv6 respectively. .It Ic replication Aq mode .Pp Replication mode should be one of the following: @@ -365,26 +370,35 @@ daemon. .Sh EXAMPLES The example configuration file can look as follows: .Bd -literal -offset indent +listen tcp://0.0.0.0 + +on hasta { + listen tcp://2001:db8::1/64 +} +on hastb { + listen tcp://2001:db8::2/64 +} + resource shared { local /dev/da0 on hasta { - remote tcp4://10.0.0.2 + remote tcp://10.0.0.2 } on hastb { - remote tcp4://10.0.0.1 + remote tcp://10.0.0.1 } } resource tank { on hasta { local /dev/mirror/tanka - source tcp4://10.0.0.1 - remote tcp4://10.0.0.2 + source tcp://10.0.0.1 + remote tcp://10.0.0.2 } on hastb { local /dev/mirror/tankb - source tcp4://10.0.0.2 - remote tcp4://10.0.0.1 + source tcp://10.0.0.2 + remote tcp://10.0.0.1 } } .Ed From 6bef5d286510e3f7d0b79e330804d8c7e1500180 Mon Sep 17 00:00:00 2001 From: Benedict Reuschling Date: Fri, 20 May 2011 11:29:09 +0000 Subject: [PATCH 112/200] Correct typos in comments, no functional changes. Found by: codespell Reviewed by: kaiw MFC after: 1 week --- usr.bin/ar/acpyacc.y | 4 ++-- usr.bin/ar/ar.c | 2 +- usr.bin/ar/write.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.bin/ar/acpyacc.y b/usr.bin/ar/acpyacc.y index e1a6e6d517c5..99a23c755c33 100644 --- a/usr.bin/ar/acpyacc.y +++ b/usr.bin/ar/acpyacc.y @@ -358,7 +358,7 @@ arscp_copy(int ifd, int ofd) /* * Add all modules of archive to current archive, if list != NULL, - * only those modules speicifed in 'list' will be added. + * only those modules specified in 'list' will be added. */ static void arscp_addlib(char *archive, struct list *list) @@ -545,7 +545,7 @@ arscp_end(int eval) } /* - * Check if target spcified, i.e, whether OPEN or CREATE has been + * Check if target specified, i.e, whether OPEN or CREATE has been * issued by user. */ static int diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c index bb53aa43d939..4b1b7a0550f6 100644 --- a/usr.bin/ar/ar.c +++ b/usr.bin/ar/ar.c @@ -109,7 +109,7 @@ main(int argc, char **argv) bsdar->progname = "ar"; /* Act like ranlib if our name ends in "ranlib"; this - * accomodates arm-freebsd7.1-ranlib, bsdranlib, etc. */ + * accommodates arm-freebsd7.1-ranlib, bsdranlib, etc. */ len = strlen(bsdar->progname); if (len >= strlen("ranlib") && strcmp(bsdar->progname + len - strlen("ranlib"), "ranlib") == 0) { diff --git a/usr.bin/ar/write.c b/usr.bin/ar/write.c index d27a767049f8..5b6d36953e12 100644 --- a/usr.bin/ar/write.c +++ b/usr.bin/ar/write.c @@ -113,7 +113,7 @@ ar_mode_A(struct bsdar *bsdar) /* * Create object from file, return created obj upon success, or NULL * when an error occurs or the member is not newer than existing - * one while -u is specifed. + * one while -u is specified. */ static struct ar_obj * create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime) @@ -220,7 +220,7 @@ insert_obj(struct bsdar *bsdar, struct ar_obj *obj, struct ar_obj *pos) if (pos == NULL || obj == pos) /* - * If the object to move happens to be the posistion obj, + * If the object to move happens to be the position obj, * or if there is not a pos obj, move it to tail. */ goto tail; @@ -418,7 +418,7 @@ write_archive(struct bsdar *bsdar, char mode) if (mode == 'A') { /* * Read objects from the target archive of ADDLIB command. - * If there are members spcified in argv, read those members + * If there are members specified in argv, read those members * only, otherwise the entire archive will be read. */ read_objs(bsdar, bsdar->addlib, 1); @@ -438,7 +438,7 @@ write_archive(struct bsdar *bsdar, char mode) /* * If can't find `pos' specified by user, - * sliently insert objects at tail. + * silently insert objects at tail. */ if (pos == NULL) bsdar->options &= ~(AR_A | AR_B); @@ -699,7 +699,7 @@ create_symtab_entry(struct bsdar *bsdar, void *maddr, size_t size) return; } if (elf_kind(e) != ELF_K_ELF) { - /* Sliently ignore non-elf member. */ + /* Silently ignore non-elf member. */ elf_end(e); return; } From 0d6948299432f0597e9da008888b5a9d4acfafd1 Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Fri, 20 May 2011 14:07:08 +0000 Subject: [PATCH 113/200] Fix the description of the "paddr" keyword. It shows a process pointer just like a dublicating "uprocp". MFC after: 1 week --- bin/ps/ps.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index bfafae087706..48bbc7e1356b 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -549,7 +549,7 @@ wait channel (as an address) total blocks written (alias .Cm oublock ) .It Cm paddr -swap address +process pointer .It Cm pagein pageins (same as majflt) .It Cm pgid From 9abcf93a910e48057131b23881595c64e1f7472c Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Fri, 20 May 2011 14:32:28 +0000 Subject: [PATCH 114/200] Spelling in P_HADTHREADS. MFC after: 1 week --- bin/ps/ps.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 48bbc7e1356b..2465df3acb26 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -301,7 +301,7 @@ the include file .It Dv "P_PPWAIT" Ta No "0x00010 Parent is waiting for child to exec/exit" .It Dv "P_PROFIL" Ta No "0x00020 Has started profiling" .It Dv "P_STOPPROF" Ta No "0x00040 Has thread in requesting to stop prof" -.It Dv "P_HASTHREADS" Ta No "0x00080 Has had threads (no cleanup shortcuts)" +.It Dv "P_HADTHREADS" Ta No "0x00080 Has had threads (no cleanup shortcuts)" .It Dv "P_SUGID" Ta No "0x00100 Had set id privileges since last exec" .It Dv "P_SYSTEM" Ta No "0x00200 System proc: no sigs, stats or swapping" .It Dv "P_SINGLE_EXIT" Ta No "0x00400 Threads suspending should exit, not wait" From df1bc9de7c37b49ca58c88cc20f6871b30c2b35b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 20 May 2011 15:26:31 +0000 Subject: [PATCH 115/200] Eliminate a redundant #include. ("vm/vm_param.h" already includes "machine/vmparam.h".) --- sys/vm/uma_core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 4434cdf5b3fd..7fb120afc711 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -86,8 +86,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include - #include /* From 85307c9ed9cfe02c2c19551f41495d97ef5b8ffb Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 20 May 2011 16:03:36 +0000 Subject: [PATCH 116/200] sh: Allow terminating a heredoc with a terminator at EOF without a newline. This is sometimes used with eval or old-style command substitution, and most shells other than ash derivatives allow it. It can also be used with scripts that violate POSIX's requirement on the application that they end in a newline (scripts must be text files except that line length is unlimited). Example: v=`cat < Date: Fri, 20 May 2011 17:01:22 +0000 Subject: [PATCH 117/200] Remove unnecessary controller reinitialization by checking IFF_DRV_RUNNING flag. Previously running dhclient or adding alias addresses reinitialized controller and it resulted in unnecessary link flips. Reviewed by: marius --- sys/dev/gem/if_gem.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c index 814c9a853f54..9ee43f2e7705 100644 --- a/sys/dev/gem/if_gem.c +++ b/sys/dev/gem/if_gem.c @@ -739,8 +739,10 @@ gem_reset_rxdma(struct gem_softc *sc) { int i; - if (gem_reset_rx(sc) != 0) + if (gem_reset_rx(sc) != 0) { + sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; return (gem_init_locked(sc)); + } for (i = 0; i < GEM_NRXDESC; i++) if (sc->sc_rxsoft[i].rxs_mbuf != NULL) GEM_UPDATE_RXDESC(sc, i); @@ -924,6 +926,9 @@ gem_init_locked(struct gem_softc *sc) GEM_LOCK_ASSERT(sc, MA_OWNED); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; + #ifdef GEM_DEBUG CTR2(KTR_GEM, "%s: %s: calling stop", device_get_name(sc->sc_dev), __func__); @@ -1762,6 +1767,7 @@ gem_intr(void *v) if ((status2 & (GEM_MAC_TX_UNDERRUN | GEM_MAC_TX_PKT_TOO_LONG)) != 0) { sc->sc_ifp->if_oerrors++; + sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; gem_init_locked(sc); } } @@ -1814,6 +1820,7 @@ gem_watchdog(struct gem_softc *sc) ++ifp->if_oerrors; /* Try to get more packets going. */ + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; gem_init_locked(sc); gem_start_locked(ifp); return (EJUSTRETURN); From d9b2153b4eea0b7932433a38c7d39b5bab4ba00f Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Fri, 20 May 2011 17:03:23 +0000 Subject: [PATCH 118/200] Add missing header file. MFC after: 1 week --- usr.bin/top/machine.c | 1 + 1 file changed, 1 insertion(+) diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index bd0f7d81d0be..f98f64eb766b 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include From 59d7277f4a32516fea3874ad5ede972ed5e10032 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 20 May 2011 17:28:00 +0000 Subject: [PATCH 119/200] Fix spelling errors. --- sys/vm/uma_int.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h index 77135933ee3f..ae3e2ff33c68 100644 --- a/sys/vm/uma_int.h +++ b/sys/vm/uma_int.h @@ -45,7 +45,7 @@ * * The uma_slab_t may be embedded in a UMA_SLAB_SIZE chunk of memory or it may * be allocated off the page from a special slab zone. The free list within a - * slab is managed with a linked list of indexes, which are 8 bit values. If + * slab is managed with a linked list of indices, which are 8 bit values. If * UMA_SLAB_SIZE is defined to be too large I will have to switch to 16bit * values. Currently on alpha you can get 250 or so 32 byte items and on x86 * you can get 250 or so 16byte items. For item sizes that would yield more @@ -56,9 +56,9 @@ * wasted between items due to alignment problems. This may yield a much better * memory footprint for certain sizes of objects. Another alternative is to * increase the UMA_SLAB_SIZE, or allow for dynamic slab sizes. I prefer - * dynamic slab sizes because we could stick with 8 bit indexes and only use + * dynamic slab sizes because we could stick with 8 bit indices and only use * large slab sizes for zones with a lot of waste per slab. This may create - * ineffeciencies in the vm subsystem due to fragmentation in the address space. + * inefficiencies in the vm subsystem due to fragmentation in the address space. * * The only really gross cases, with regards to memory waste, are for those * items that are just over half the page size. You can get nearly 50% waste, From 81046d3cb345a6b5052d212db4bc995d3f7dc00f Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Fri, 20 May 2011 17:35:10 +0000 Subject: [PATCH 120/200] - add missing options and arguments to program's usage() and sync it with manpage's SYNOPSIS - generally clean up a manpage's formatting Reviewed by: edwin --- usr.sbin/tzsetup/tzsetup.8 | 49 +++++++++++++++++++++----------------- usr.sbin/tzsetup/tzsetup.c | 3 ++- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/usr.sbin/tzsetup/tzsetup.8 b/usr.sbin/tzsetup/tzsetup.8 index 4d548fdb968d..727207ec3609 100644 --- a/usr.sbin/tzsetup/tzsetup.8 +++ b/usr.sbin/tzsetup/tzsetup.8 @@ -23,7 +23,8 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd July 4, 2009 +.\" +.Dd October 21, 2009 .Dt TZSETUP 8 .Os .Sh NAME @@ -32,8 +33,8 @@ .Sh SYNOPSIS .Nm .Op Fl nrs -.Op Fl C Ar chroot directory -.Op Ar zoneinfo file | zoneinfo name +.Op Fl C Ar chroot_directory +.Op Ar zoneinfo_file | zoneinfo_name .Sh DESCRIPTION The .Nm @@ -50,24 +51,25 @@ the hardware clock does not keep .Pp The following option is available: .Bl -tag -offset indent -width Fl -.It Fl C Ar chroot directory +.It Fl C Ar chroot_directory Open all files and directories relative to -.Ar chroot directory . +.Ar chroot_directory . .It Fl n Do not create or copy files. .It Fl r -Reinstall the zoneinfo file installed last time. The name is obtained from +Reinstall the zoneinfo file installed last time. +The name is obtained from .Pa /var/db/zoneinfo . -.It Fl s +.It Fl s Skip the initial question about adjusting the clock if not set to .Tn UTC . .El .Pp It is possible to short-circuit the menu system by specifying the location of a -.Ar zoneinfo file +.Ar zoneinfo_file or the name of the -.Ar zoneinfo name +.Ar zoneinfo_name on the command line; this is intended mainly for pre-configured installation scripts or people who know which zoneinfo they want to install. .Sh TIMEZONE DATABASE @@ -101,38 +103,41 @@ The source code to the database contains many additional comments and documentation references for the historically minded. .Sh FILES -.Bl -tag -width /usr/share/zoneinfo/zone.tab -compact +.Bl -tag -width ".Pa /usr/share/zoneinfo/zone.tab" -compact .It Pa /etc/localtime -current time zone file. +current time zone file .It Pa /etc/wall_cmos_clock see -.Xr adjkerntz 8 . +.Xr adjkerntz 8 .It Pa /usr/share/misc/iso3166 mapping of .Tn ISO -3166 territory codes to names. +3166 territory codes to names .It Pa /usr/share/zoneinfo -directory for zoneinfo files. +directory for zoneinfo files .It Pa /usr/share/zoneinfo/zone.tab -mapping of timezone file to country and location. +mapping of timezone file to country and location .It Pa /var/db/zoneinfo -saved name of the timezone file installed last. +saved name of the timezone file installed last .El .Sh EXAMPLES Normal usage, to select the right zoneinfo file via the dialog-based user interface: -.Dl # tzsetup +.Dl tzsetup +.Pp Install the file .Pa /usr/share/zoneinfo/Australia/Sydney : -.Dl # tzsetup /usr/share/zoneinfo/Australia/Sydney +.Dl "tzsetup /usr/share/zoneinfo/Australia/Sydney" +.Pp Install the zoneinfo file for Australia/Sydney, assumed to be located in .Pa /usr/share/zoneinfo : -.Dl # tzsetup Australia/Sydney +.Dl "tzsetup Australia/Sydney" +.Pp After a reinstall of the zoneinfo files, you can reinstall the -latest installed zoneinfo file: (as specified in -.Pa /var/db/zoneinfo ) -.Dl # tzsetup -r +latest installed zoneinfo file (as specified in +.Pa /var/db/zoneinfo ) : +.Dl "tzsetup -r" .Sh SEE ALSO .Xr date 1 , .Xr adjtime 2 , diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c index 316220087f3b..825147053fba 100644 --- a/usr.sbin/tzsetup/tzsetup.c +++ b/usr.sbin/tzsetup/tzsetup.c @@ -731,7 +731,8 @@ static void usage(void) { - fprintf(stderr, "usage: tzsetup [-nrs] [zoneinfo file]\n"); + fprintf(stderr, "usage: tzsetup [-nrs] [-C chroot_directory]" + " [zoneinfo_file | zoneinfo_name]\n"); exit(1); } From 7ba75dc4e9abb4f4ae2230d34381d50152c2342e Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Fri, 20 May 2011 18:27:13 +0000 Subject: [PATCH 121/200] Datasheet says vge(4) controllers support DAC but it seems that's not true on old PCI based controllers. DAC configuration is read from EEPROM in device reset phase and driver can override DAC configuration. However I guess there is an undocumented reason why EEPROM configuration does not enable DAC so do not blindly override DAC configuration. Recent PCIe based controllers are supposed to support 64bit DMA so allow 64bit DMA only on PCIe based controllers. PR: kern/157184 MFC after: 1 week --- sys/dev/vge/if_vge.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sys/dev/vge/if_vge.c b/sys/dev/vge/if_vge.c index 4549bb08bca9..d9a58cce5b82 100644 --- a/sys/dev/vge/if_vge.c +++ b/sys/dev/vge/if_vge.c @@ -685,7 +685,18 @@ vge_dma_alloc(struct vge_softc *sc) bus_addr_t lowaddr, tx_ring_end, rx_ring_end; int error, i; - lowaddr = BUS_SPACE_MAXADDR; + /* + * It seems old PCI controllers do not support DAC. DAC + * configuration can be enabled by accessing VGE_CHIPCFG3 + * register but honor EEPROM configuration instead of + * blindly overriding DAC configuration. PCIe based + * controllers are supposed to support 64bit DMA so enable + * 64bit DMA on these controllers. + */ + if ((sc->vge_flags & VGE_FLAG_PCIE) != 0) + lowaddr = BUS_SPACE_MAXADDR; + else + lowaddr = BUS_SPACE_MAXADDR_32BIT; again: /* Create parent ring tag. */ @@ -802,10 +813,14 @@ vge_dma_alloc(struct vge_softc *sc) goto again; } + if ((sc->vge_flags & VGE_FLAG_PCIE) != 0) + lowaddr = VGE_BUF_DMA_MAXADDR; + else + lowaddr = BUS_SPACE_MAXADDR_32BIT; /* Create parent buffer tag. */ error = bus_dma_tag_create(bus_get_dma_tag(sc->vge_dev),/* parent */ 1, 0, /* algnmnt, boundary */ - VGE_BUF_DMA_MAXADDR, /* lowaddr */ + lowaddr, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ From 5b84dc789a31a30200b8d7292752ef3b447a74e9 Mon Sep 17 00:00:00 2001 From: Qing Li Date: Fri, 20 May 2011 19:12:20 +0000 Subject: [PATCH 122/200] The statically configured (permanent) ARP entries are removed when an interface is brought down, even though the interface address is still valid. This patch maintains the permanent ARP entries as long as the interface address (having the same prefix as that of the ARP entries) is valid. Reviewed by: delphij MFC after: 5 days --- sys/net/if_llatbl.c | 5 +++-- sys/net/if_llatbl.h | 5 +++-- sys/netinet/in.c | 40 ++++++++++++++++++++++++---------------- sys/netinet/in_var.h | 2 +- sys/netinet/raw_ip.c | 9 ++++++++- sys/netinet6/in6.c | 10 ++++++++-- 6 files changed, 47 insertions(+), 24 deletions(-) diff --git a/sys/net/if_llatbl.c b/sys/net/if_llatbl.c index 910d366059dc..b19a0a4cab43 100644 --- a/sys/net/if_llatbl.c +++ b/sys/net/if_llatbl.c @@ -228,7 +228,8 @@ lltable_drain(int af) #endif void -lltable_prefix_free(int af, struct sockaddr *prefix, struct sockaddr *mask) +lltable_prefix_free(int af, struct sockaddr *prefix, struct sockaddr *mask, + u_int flags) { struct lltable *llt; @@ -237,7 +238,7 @@ lltable_prefix_free(int af, struct sockaddr *prefix, struct sockaddr *mask) if (llt->llt_af != af) continue; - llt->llt_prefix_free(llt, prefix, mask); + llt->llt_prefix_free(llt, prefix, mask, flags); } LLTABLE_RUNLOCK(); } diff --git a/sys/net/if_llatbl.h b/sys/net/if_llatbl.h index 9ed09f437d59..1f30f37bafc2 100644 --- a/sys/net/if_llatbl.h +++ b/sys/net/if_llatbl.h @@ -155,7 +155,8 @@ struct lltable { void (*llt_free)(struct lltable *, struct llentry *); void (*llt_prefix_free)(struct lltable *, const struct sockaddr *prefix, - const struct sockaddr *mask); + const struct sockaddr *mask, + u_int flags); struct llentry * (*llt_lookup)(struct lltable *, u_int flags, const struct sockaddr *l3addr); int (*llt_rtcheck)(struct ifnet *, u_int flags, @@ -184,7 +185,7 @@ MALLOC_DECLARE(M_LLTABLE); struct lltable *lltable_init(struct ifnet *, int); void lltable_free(struct lltable *); void lltable_prefix_free(int, struct sockaddr *, - struct sockaddr *); + struct sockaddr *, u_int); #if 0 void lltable_drain(int); #endif diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 1012012822c9..684d808b9a8e 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -70,7 +70,7 @@ static int in_lifaddr_ioctl(struct socket *, u_long, caddr_t, struct ifnet *, struct thread *); static int in_addprefix(struct in_ifaddr *, int); -static int in_scrubprefix(struct in_ifaddr *); +static int in_scrubprefix(struct in_ifaddr *, u_int); static void in_socktrim(struct sockaddr_in *); static int in_ifinit(struct ifnet *, struct in_ifaddr *, struct sockaddr_in *, int); @@ -548,7 +548,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, * is the same as before, then the call is * un-necessarily executed here. */ - in_ifscrub(ifp, ia); + in_ifscrub(ifp, ia, 0); ia->ia_sockmask = ifra->ifra_mask; ia->ia_sockmask.sin_family = AF_INET; ia->ia_subnetmask = @@ -557,7 +557,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, } if ((ifp->if_flags & IFF_POINTOPOINT) && (ifra->ifra_dstaddr.sin_family == AF_INET)) { - in_ifscrub(ifp, ia); + in_ifscrub(ifp, ia, 0); ia->ia_dstaddr = ifra->ifra_dstaddr; maskIsNew = 1; /* We lie; but the effect's the same */ } @@ -585,7 +585,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, /* * in_ifscrub kills the interface route. */ - in_ifscrub(ifp, ia); + in_ifscrub(ifp, ia, LLE_STATIC); /* * in_ifadown gets rid of all the rest of @@ -829,10 +829,10 @@ in_lifaddr_ioctl(struct socket *so, u_long cmd, caddr_t data, * Delete any existing route for an interface. */ void -in_ifscrub(struct ifnet *ifp, struct in_ifaddr *ia) +in_ifscrub(struct ifnet *ifp, struct in_ifaddr *ia, u_int flags) { - in_scrubprefix(ia); + in_scrubprefix(ia, flags); } /* @@ -887,7 +887,7 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin, splx(s); if (scrub) { ia->ia_ifa.ifa_addr = (struct sockaddr *)&oldaddr; - in_ifscrub(ifp, ia); + in_ifscrub(ifp, ia, LLE_STATIC); ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; } if (IN_CLASSA(i)) @@ -1095,7 +1095,7 @@ extern void arp_ifscrub(struct ifnet *ifp, uint32_t addr); * otherwise. */ static int -in_scrubprefix(struct in_ifaddr *target) +in_scrubprefix(struct in_ifaddr *target, u_int flags) { struct in_ifaddr *ia; struct in_addr prefix, mask, p; @@ -1130,13 +1130,15 @@ in_scrubprefix(struct in_ifaddr *target) RT_REMREF(ia_ro.ro_rt); RTFREE_LOCKED(ia_ro.ro_rt); } - if (freeit) + if (freeit && (flags & LLE_STATIC)) { error = ifa_del_loopback_route((struct ifaddr *)target, (struct sockaddr *)&target->ia_addr); - if (error == 0) - target->ia_flags &= ~IFA_RTSELF; - /* remove arp cache */ - arp_ifscrub(target->ia_ifp, IA_SIN(target)->sin_addr.s_addr); + if (error == 0) + target->ia_flags &= ~IFA_RTSELF; + } + if (flags & LLE_STATIC) + /* remove arp cache */ + arp_ifscrub(target->ia_ifp, IA_SIN(target)->sin_addr.s_addr); } if (rtinitflags(target)) @@ -1203,7 +1205,7 @@ in_scrubprefix(struct in_ifaddr *target) mask0.sin_family = AF_INET; mask0.sin_addr.s_addr = target->ia_subnetmask; lltable_prefix_free(AF_INET, (struct sockaddr *)&prefix0, - (struct sockaddr *)&mask0); + (struct sockaddr *)&mask0, flags); /* * As no-one seem to have this prefix, we can remove the route. @@ -1362,7 +1364,8 @@ in_lltable_free(struct lltable *llt, struct llentry *lle) static void in_lltable_prefix_free(struct lltable *llt, const struct sockaddr *prefix, - const struct sockaddr *mask) + const struct sockaddr *mask, + u_int flags) { const struct sockaddr_in *pfx = (const struct sockaddr_in *)prefix; const struct sockaddr_in *msk = (const struct sockaddr_in *)mask; @@ -1373,8 +1376,13 @@ in_lltable_prefix_free(struct lltable *llt, for (i=0; i < LLTBL_HASHTBL_SIZE; i++) { LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) { + /* + * (flags & LLE_STATIC) means deleting all entries + * including static ARP entries + */ if (IN_ARE_MASKED_ADDR_EQUAL((struct sockaddr_in *)L3_ADDR(lle), - pfx, msk)) { + pfx, msk) && + ((flags & LLE_STATIC) || !(lle->la_flags & LLE_STATIC))) { int canceled; canceled = callout_drain(&lle->la_timer); diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index cd1d90438e4d..5be07c151040 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -447,7 +447,7 @@ int in_control(struct socket *, u_long, caddr_t, struct ifnet *, void in_rtqdrain(void); void ip_input(struct mbuf *); int in_ifadown(struct ifaddr *ifa, int); -void in_ifscrub(struct ifnet *, struct in_ifaddr *); +void in_ifscrub(struct ifnet *, struct in_ifaddr *, u_int); struct mbuf *ip_fastforward(struct mbuf *); void *in_domifattach(struct ifnet *); void in_domifdetach(struct ifnet *, void *); diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index b196de2d554a..be099a8081ba 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -721,7 +722,7 @@ rip_ctlinput(int cmd, struct sockaddr *sa, void *vip) /* * in_ifscrub kills the interface route. */ - in_ifscrub(ia->ia_ifp, ia); + in_ifscrub(ia->ia_ifp, ia, 0); /* * in_ifadown gets rid of all the rest of the * routes. This is not quite the right thing @@ -756,12 +757,18 @@ rip_ctlinput(int cmd, struct sockaddr *sa, void *vip) || (ifp->if_flags & IFF_POINTOPOINT)) flags |= RTF_HOST; + err = ifa_del_loopback_route((struct ifaddr *)ia, sa); + if (err == 0) + ia->ia_flags &= ~IFA_RTSELF; + err = rtinit(&ia->ia_ifa, RTM_ADD, flags); if (err == 0) ia->ia_flags |= IFA_ROUTE; + err = ifa_add_loopback_route((struct ifaddr *)ia, sa); if (err == 0) ia->ia_flags |= IFA_RTSELF; + ifa_free(&ia->ia_ifa); break; } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index c5224224dcc2..9e8e5cd12475 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -2376,19 +2376,25 @@ in6_lltable_free(struct lltable *llt, struct llentry *lle) static void in6_lltable_prefix_free(struct lltable *llt, const struct sockaddr *prefix, - const struct sockaddr *mask) + const struct sockaddr *mask, + u_int flags) { const struct sockaddr_in6 *pfx = (const struct sockaddr_in6 *)prefix; const struct sockaddr_in6 *msk = (const struct sockaddr_in6 *)mask; struct llentry *lle, *next; register int i; + /* + * (flags & LLE_STATIC) means deleting all entries + * including static ND6 entries + */ for (i=0; i < LLTBL_HASHTBL_SIZE; i++) { LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) { if (IN6_ARE_MASKED_ADDR_EQUAL( &((struct sockaddr_in6 *)L3_ADDR(lle))->sin6_addr, &pfx->sin6_addr, - &msk->sin6_addr)) { + &msk->sin6_addr) && + ((flags & LLE_STATIC) || !(lle->la_flags & LLE_STATIC))) { int canceled; canceled = callout_drain(&lle->la_timer); From dd4aae65f179458def8e21be6ad2d7b786aa345e Mon Sep 17 00:00:00 2001 From: Xin LI Date: Fri, 20 May 2011 22:36:17 +0000 Subject: [PATCH 123/200] Add a new knob to atkbd(4) to enable typematic rate detection on boot, which is now disabled by default. The detection is known to cause hangs on boot with some new Lenovo laptops on FreeBSD/amd64. Reported by: gnn Discussed with: jkim MFC after: 3 months --- share/man/man4/atkbd.4 | 7 ++++++- sys/dev/atkbdc/atkbd.c | 3 +++ sys/dev/atkbdc/atkbdreg.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/share/man/man4/atkbd.4 b/share/man/man4/atkbd.4 index 73831c2bb538..0c486e2eefbc 100644 --- a/share/man/man4/atkbd.4 +++ b/share/man/man4/atkbd.4 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 29, 2008 +.Dd May 20, 2011 .Dt ATKBD 4 .Os .Sh NAME @@ -176,6 +176,11 @@ When this option is given, the .Nm driver will not test the keyboard port during the probe routine. Some machines hang during boot when this test is performed. +.It bit 4 (PROBE_TYPEMATIC) +When this option is given, the +.Nm +driver will try to probe the keyboard typematic rate on boot. +Some machines hang during boot when this test is performed. .El .\".Sh FILES .Sh EXAMPLES diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index 600020fae6de..643554d1f4dd 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -1097,6 +1097,9 @@ get_typematic(keyboard_t *kbd) x86regs_t regs; uint8_t *p; + if (!(kbd->kb_config & KB_CONF_PROBE_TYPEMATIC)) + return (ENODEV); + if (x86bios_get_intr(0x15) == 0 || x86bios_get_intr(0x16) == 0) return (ENODEV); diff --git a/sys/dev/atkbdc/atkbdreg.h b/sys/dev/atkbdc/atkbdreg.h index cf7ee6b31280..3d54b4d70228 100644 --- a/sys/dev/atkbdc/atkbdreg.h +++ b/sys/dev/atkbdc/atkbdreg.h @@ -36,6 +36,7 @@ #define KB_CONF_NO_RESET (1 << 1) /* don't reset the keyboard */ #define KB_CONF_ALT_SCANCODESET (1 << 2) /* assume the XT type keyboard */ #define KB_CONF_NO_PROBE_TEST (1 << 3) /* don't test keyboard during probe */ +#define KB_CONF_PROBE_TYPEMATIC (1 << 4) /* probe keyboard typematic */ #ifdef _KERNEL From d6ee26ad02c9c77085ffe3ac04fd3903e340e37f Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 20 May 2011 22:55:18 +0000 Subject: [PATCH 124/200] sh: Implement the cd -e flag proposed for the next POSIX issue. This reflects failure to determine the pathname of the new directory in the exit status (1). Normally, cd returns successfully if it did chdir() and the call was successful. In POSIX, -e only has meaning with -P; because our -L is not entirely compliant and may fall back to -P mode, -e has some effect with -L as well. --- bin/sh/cd.c | 25 +++++++++++------ bin/sh/sh.1 | 13 +++++++-- tools/regression/bin/sh/builtins/cd3.0 | 21 ++++++++++++++ tools/regression/bin/sh/builtins/cd4.0 | 38 ++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 tools/regression/bin/sh/builtins/cd3.0 create mode 100644 tools/regression/bin/sh/builtins/cd4.0 diff --git a/bin/sh/cd.c b/bin/sh/cd.c index 041d6b4545c3..776bdbaf9051 100644 --- a/bin/sh/cd.c +++ b/bin/sh/cd.c @@ -84,12 +84,16 @@ cdcmd(int argc, char **argv) const char *path; char *p; struct stat statb; - int ch, phys, print = 0; + int ch, phys, print = 0, getcwderr = 0; + int rc; optreset = 1; optind = 1; opterr = 0; /* initialize getopt */ phys = Pflag; - while ((ch = getopt(argc, argv, "LP")) != -1) { + while ((ch = getopt(argc, argv, "eLP")) != -1) { switch (ch) { + case 'e': + getcwderr = 1; + break; case 'L': phys = 0; break; @@ -131,8 +135,9 @@ cdcmd(int argc, char **argv) else print = strcmp(p, dest); } - if (docd(p, print, phys) >= 0) - return 0; + rc = docd(p, print, phys); + if (rc >= 0) + return getcwderr ? rc : 0; } } error("can't cd to %s", dest); @@ -148,17 +153,18 @@ cdcmd(int argc, char **argv) static int docd(char *dest, int print, int phys) { + int rc; TRACE(("docd(\"%s\", %d, %d) called\n", dest, print, phys)); /* If logical cd fails, fall back to physical. */ - if ((phys || cdlogical(dest) < 0) && cdphysical(dest) < 0) + if ((phys || (rc = cdlogical(dest)) < 0) && (rc = cdphysical(dest)) < 0) return (-1); if (print && iflag && curdir) out1fmt("%s\n", curdir); - return 0; + return (rc); } static int @@ -216,6 +222,7 @@ static int cdphysical(char *dest) { char *p; + int rc = 0; INTOFF; if (chdir(dest) < 0) { @@ -223,11 +230,13 @@ cdphysical(char *dest) return (-1); } p = findcwd(NULL); - if (p == NULL) + if (p == NULL) { warning("warning: failed to get name of current directory"); + rc = 1; + } updatepwd(p); INTON; - return (0); + return (rc); } /* diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index 838cafeccf79..a74e67776d8c 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd May 8, 2011 +.Dd May 20, 2011 .Dt SH 1 .Os .Sh NAME @@ -1729,7 +1729,7 @@ Execute the specified built-in command, .Ar cmd . This is useful when the user wishes to override a shell function with the same name as a built-in command. -.It Ic cd Oo Fl L | P Oc Op Ar directory +.It Ic cd Oo Fl L | P Oc Oo Fl e Oc Op Ar directory Switch to the specified .Ar directory , or to the directory specified in the @@ -1778,6 +1778,15 @@ option is specified, .Pa .. is handled logically. This is the default. +.Pp +The +.Fl e +option causes +.Ic cd +to return exit status 1 if the full pathname of the new directory +cannot be determined reliably or at all. +Normally this is not considered an error, +although a warning is printed. .It Ic chdir A synonym for the .Ic cd diff --git a/tools/regression/bin/sh/builtins/cd3.0 b/tools/regression/bin/sh/builtins/cd3.0 new file mode 100644 index 000000000000..7729c54a6895 --- /dev/null +++ b/tools/regression/bin/sh/builtins/cd3.0 @@ -0,0 +1,21 @@ +# $FreeBSD$ + +# If fully successful, cd -Pe must be like cd -P. + +set -e + +cd "${TMPDIR:-/tmp}" +cd -Pe / +[ "$PWD" = / ] +[ "$(pwd)" = / ] +cd "${TMPDIR:-/tmp}" +cd -eP / +[ "$PWD" = / ] +[ "$(pwd)" = / ] + +set +e + +# If cd -Pe cannot chdir, the exit status must be greater than 1. + +v=$( (cd -Pe /var/empty/nonexistent) 2>&1 >/dev/null) +[ $? -gt 1 ] && [ -n "$v" ] diff --git a/tools/regression/bin/sh/builtins/cd4.0 b/tools/regression/bin/sh/builtins/cd4.0 new file mode 100644 index 000000000000..df3a9a48961c --- /dev/null +++ b/tools/regression/bin/sh/builtins/cd4.0 @@ -0,0 +1,38 @@ +# $FreeBSD$ + +# This test assumes that whatever mechanism cd -P uses to determine the +# pathname to the current directory if it is longer than PATH_MAX requires +# read permission on all parent directories. It also works if this +# requirement always applies. + +set -e +L=$(getconf PATH_MAX / 2>/dev/null) || L=4096 +[ "$L" -lt 100000 ] 2>/dev/null || L=4096 +L=$((L+100)) +T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX) +trap 'chmod u+r ${T}; rm -rf ${T}' 0 +cd -Pe $T +D=$(pwd) +chmod u-r "$D" +if [ -r "$D" ]; then + # Running as root, cannot test. + exit 0 +fi +set +e +while [ ${#D} -lt $L ]; do + mkdir veryverylongdirectoryname || exit + cd -Pe veryverylongdirectoryname 2>/dev/null + r=$? + [ $r -gt 1 ] && exit $r + if [ $r -eq 1 ]; then + # Verify that the directory was changed correctly. + cd -Pe .. || exit + [ "$(pwd)" = "$D" ] || exit + # Verify that omitting -e results in success. + cd -P veryverylongdirectoryname 2>/dev/null || exit + exit 0 + fi + D=$D/veryverylongdirectoryname +done +echo "cd -Pe never returned 1" +exit 0 From cd50bf427a3dbc5b32cf7893917f08c724ac71a3 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sat, 21 May 2011 09:23:18 +0000 Subject: [PATCH 125/200] The Merlin analog register bank is from 0x7800 -> 0x78fc; fix the code to reflect this. --- sys/dev/ath/ath_hal/ah.c | 2 +- sys/dev/ath/ath_hal/ar9002/ar9280_attach.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/ath/ath_hal/ah.c b/sys/dev/ath/ath_hal/ah.c index 2cc1e08391eb..13a59f1e92e2 100644 --- a/sys/dev/ath/ath_hal/ah.c +++ b/sys/dev/ath/ath_hal/ah.c @@ -1069,7 +1069,7 @@ ath_hal_ini_write(struct ath_hal *ah, const HAL_INI_ARRAY *ia, HAL_INI_VAL(ia, r, col)); /* Analog shift register delay seems needed for Merlin - PR kern/154220 */ - if (HAL_INI_VAL(ia, r, 0) >= 0x7800 && HAL_INI_VAL(ia, r, 0) < 0x78a0) + if (HAL_INI_VAL(ia, r, 0) >= 0x7800 && HAL_INI_VAL(ia, r, 0) < 0x7900) OS_DELAY(100); DMA_YIELD(regWr); diff --git a/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c b/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c index 5869c03f9cbd..3351edbc6d18 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9280_attach.c @@ -430,7 +430,7 @@ ar9280WriteIni(struct ath_hal *ah, const struct ieee80211_channel *chan) OS_REG_WRITE(ah, reg, val); /* Analog shift register delay seems needed for Merlin - PR kern/154220 */ - if (reg >= 0x7800 && reg < 0x78a0) + if (reg >= 0x7800 && reg < 0x7900) OS_DELAY(100); DMA_YIELD(regWrites); From 47fb896960a78aa63ee3f8e7621f77cc3e95eb97 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 21 May 2011 14:52:26 +0000 Subject: [PATCH 126/200] sh: Add test for positional parameters with more than one digit. This also passes on stable/8. --- tools/regression/bin/sh/parameters/positional1.0 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tools/regression/bin/sh/parameters/positional1.0 diff --git a/tools/regression/bin/sh/parameters/positional1.0 b/tools/regression/bin/sh/parameters/positional1.0 new file mode 100644 index 000000000000..67d19516a5d9 --- /dev/null +++ b/tools/regression/bin/sh/parameters/positional1.0 @@ -0,0 +1,13 @@ +# $FreeBSD$ + +set -- a b c d e f g h i j +[ "$1" = a ] || echo "error at line $LINENO" +[ "${1}" = a ] || echo "error at line $LINENO" +[ "${1-foo}" = a ] || echo "error at line $LINENO" +[ "${1+foo}" = foo ] || echo "error at line $LINENO" +[ "$1+foo" = a+foo ] || echo "error at line $LINENO" +[ "$10" = a0 ] || echo "error at line $LINENO" +[ "$100" = a00 ] || echo "error at line $LINENO" +[ "${10}" = j ] || echo "error at line $LINENO" +[ "${10-foo}" = j ] || echo "error at line $LINENO" +[ "${100-foo}" = foo ] || echo "error at line $LINENO" From 12732d309cde28a2b2c123c3b1893761fa626c05 Mon Sep 17 00:00:00 2001 From: Bernhard Schmidt Date: Sat, 21 May 2011 16:34:53 +0000 Subject: [PATCH 127/200] Fix a typo, it is MPDU not MDPU. --- sys/modules/wlan/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/modules/wlan/Makefile b/sys/modules/wlan/Makefile index 682aab3cfa9c..f96ad32a3c1e 100644 --- a/sys/modules/wlan/Makefile +++ b/sys/modules/wlan/Makefile @@ -18,7 +18,7 @@ SRCS+= bus_if.h device_if.h opt_inet.h opt_inet6.h opt_ipx.h opt_wlan.h \ .if !defined(KERNBUILDDIR) opt_wlan.h: echo "#define IEEE80211_DEBUG 1" > ${.TARGET} - echo "#define IEEE80211_AMDPU_AGE 1" >> ${.TARGET} + echo "#define IEEE80211_AMPDU_AGE 1" >> ${.TARGET} echo "#define IEEE80211_SUPPORT_MESH 1" >> ${.TARGET} opt_inet.h: echo "#define INET 1" > ${.TARGET} From ddea9b626d8396a83bd44dff6a4674fb6401214d Mon Sep 17 00:00:00 2001 From: Bernhard Schmidt Date: Sat, 21 May 2011 16:41:41 +0000 Subject: [PATCH 128/200] Fix typo, it is MPDU not MDPU. --- sys/net80211/ieee80211_var.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 236883d2fed6..39cf3477747f 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -578,7 +578,7 @@ MALLOC_DECLARE(M_80211_VAP); #define IEEE80211_FHT_BITS \ "\20\1NONHT_PR" \ - "\23GF\24HT\25AMDPU_TX\26AMPDU_TX" \ + "\23GF\24HT\25AMPDU_TX\26AMPDU_TX" \ "\27AMSDU_TX\30AMSDU_RX\31USEHT40\32PUREN\33SHORTGI20\34SHORTGI40" \ "\35HTCOMPAT\36RIFS\37STBC_TX\40STBC_RX" From 342f1793ba7a0733efdc5065d90de51c5e569601 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 21 May 2011 17:43:43 +0000 Subject: [PATCH 129/200] 1. Prior to r214782, UMA did not support multipage allocations before uma_startup2() was called. Thus, setting the variable "booted" to true in uma_startup() was ok on machines with UMA_MD_SMALL_ALLOC defined, because any allocations made after uma_startup() but before uma_startup2() could be satisfied by uma_small_alloc(). Now, however, some multipage allocations are necessary before uma_startup2() just to allocate zone structures on machines with a large number of processors. Thus, a Boolean can no longer effectively describe the state of the UMA allocator. Instead, make "booted" have three values to describe how far initialization has progressed. This allows multipage allocations to continue using startup_alloc() until uma_startup2(), but single-page allocations may begin using uma_small_alloc() after uma_startup(). 2. With the aforementioned change, only a modest increase in boot pages is necessary to boot UMA on a large number of processors. 3. Retire UMA_MD_SMALL_ALLOC_NEEDS_VM. It has only been used between r182028 and r204128. Reviewed by: attilio [1], nwhitehorn [3] Tested by: sbruno --- sys/vm/uma_core.c | 15 ++++++++------- sys/vm/uma_int.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 7fb120afc711..f96954700612 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -134,6 +134,8 @@ static struct mtx uma_boot_pages_mtx; /* Is the VM done starting up? */ static int booted = 0; +#define UMA_STARTUP 1 +#define UMA_STARTUP2 2 /* Maximum number of allowed items-per-slab if the slab header is OFFPAGE */ static u_int uma_max_ipers; @@ -959,7 +961,7 @@ startup_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait) return (tmps->us_data); } mtx_unlock(&uma_boot_pages_mtx); - if (booted == 0) + if (booted < UMA_STARTUP2) panic("UMA: Increase vm.boot_pages"); /* * Now that we've booted reset these users to their real allocator. @@ -1317,9 +1319,10 @@ keg_ctor(void *mem, int size, void *udata, int flags) keg->uk_allocf = uma_small_alloc; keg->uk_freef = uma_small_free; #endif - if (booted == 0) + if (booted < UMA_STARTUP) keg->uk_allocf = startup_alloc; - } else if (booted == 0 && (keg->uk_flags & UMA_ZFLAG_INTERNAL)) + } else if (booted < UMA_STARTUP2 && + (keg->uk_flags & UMA_ZFLAG_INTERNAL)) keg->uk_allocf = startup_alloc; /* @@ -1752,9 +1755,7 @@ uma_startup(void *bootmem, int boot_pages) bucket_init(); -#if defined(UMA_MD_SMALL_ALLOC) && !defined(UMA_MD_SMALL_ALLOC_NEEDS_VM) - booted = 1; -#endif + booted = UMA_STARTUP; #ifdef UMA_DEBUG printf("UMA startup complete.\n"); @@ -1765,7 +1766,7 @@ uma_startup(void *bootmem, int boot_pages) void uma_startup2(void) { - booted = 1; + booted = UMA_STARTUP2; bucket_enable(); #ifdef UMA_DEBUG printf("UMA startup2 complete.\n"); diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h index ae3e2ff33c68..b2b5bac07fbc 100644 --- a/sys/vm/uma_int.h +++ b/sys/vm/uma_int.h @@ -118,7 +118,7 @@ #define UMA_SLAB_MASK (PAGE_SIZE - 1) /* Mask to get back to the page */ #define UMA_SLAB_SHIFT PAGE_SHIFT /* Number of bits PAGE_MASK */ -#define UMA_BOOT_PAGES 48 /* Pages allocated for startup */ +#define UMA_BOOT_PAGES 64 /* Pages allocated for startup */ /* Max waste before going to off page slab management */ #define UMA_MAX_WASTE (UMA_SLAB_SIZE / 10) From aa27d9ef943344b9cbbb7746b224b307c35d7a3e Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 21 May 2011 20:21:20 +0000 Subject: [PATCH 130/200] Recognize HIO_FLUSH requests. MFC after: 1 week --- sbin/hastd/secondary.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c index 58b8f696edf0..176d0470eedb 100644 --- a/sbin/hastd/secondary.c +++ b/sbin/hastd/secondary.c @@ -514,6 +514,7 @@ requnpack(struct hast_resource *res, struct hio *hio) goto end; } switch (hio->hio_cmd) { + case HIO_FLUSH: case HIO_KEEPALIVE: break; case HIO_READ: From 05a447d0b9b86ef8de263ef18da269f2c1e57f88 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 21 May 2011 22:03:06 +0000 Subject: [PATCH 131/200] sh: Expand aliases after assignments and redirections. --- bin/sh/eval.c | 12 +++--------- bin/sh/parser.c | 22 ++++++++++++++++++++++ bin/sh/parser.h | 1 + bin/sh/sh.1 | 6 +++--- tools/regression/bin/sh/parser/alias4.0 | 5 +++++ tools/regression/bin/sh/parser/alias5.0 | 5 +++++ 6 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 tools/regression/bin/sh/parser/alias4.0 create mode 100644 tools/regression/bin/sh/parser/alias5.0 diff --git a/bin/sh/eval.c b/bin/sh/eval.c index b19c24f81a91..a50c53fdcb90 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -714,15 +714,9 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) oexitstatus = exitstatus; exitstatus = 0; for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) { - char *p = argp->narg.text; - if (varflag && is_name(*p)) { - do { - p++; - } while (is_in_name(*p)); - if (*p == '=') { - expandarg(argp, &varlist, EXP_VARTILDE); - continue; - } + if (varflag && isassignment(argp->narg.text)) { + expandarg(argp, &varlist, EXP_VARTILDE); + continue; } expandarg(argp, &arglist, EXP_FULL | EXP_TILDE); varflag = 0; diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 192769b076c4..151970b79d08 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -619,6 +619,7 @@ simplecmd(union node **rpp, union node *redir) union node **orig_rpp = rpp; union node *n = NULL; int special; + int savecheckkwd; /* If we don't have any redirections already, then we must reset */ /* rpp to be the address of the local redir variable. */ @@ -634,7 +635,10 @@ simplecmd(union node **rpp, union node *redir) */ orig_rpp = rpp; + savecheckkwd = CHKALIAS; + for (;;) { + checkkwd = savecheckkwd; if (readtoken() == TWORD) { n = (union node *)stalloc(sizeof (struct narg)); n->type = NARG; @@ -642,6 +646,8 @@ simplecmd(union node **rpp, union node *redir) n->narg.backquote = backquotelist; *app = n; app = &n->narg.next; + if (savecheckkwd != 0 && !isassignment(wordtext)) + savecheckkwd = 0; } else if (lasttoken == TREDIR) { *rpp = n = redirnode; rpp = &n->nfile.next; @@ -1859,6 +1865,22 @@ goodname(const char *name) } +int +isassignment(const char *p) +{ + if (!is_name(*p)) + return 0; + p++; + for (;;) { + if (*p == '=') + return 1; + else if (!is_in_name(*p)) + return 0; + p++; + } +} + + /* * Called when an unexpected token is read during the parse. The argument * is the token that is expected, or -1 if more than one type of token can diff --git a/bin/sh/parser.h b/bin/sh/parser.h index dfbda861e0c8..e213e2140617 100644 --- a/bin/sh/parser.h +++ b/bin/sh/parser.h @@ -80,4 +80,5 @@ extern const char *const parsekwd[]; union node *parsecmd(int); void fixredir(union node *, const char *, int); int goodname(const char *); +int isassignment(const char *); char *getprompt(void *); diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index a74e67776d8c..42e55d391b3e 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd May 20, 2011 +.Dd May 21, 2011 .Dt SH 1 .Os .Sh NAME @@ -506,8 +506,8 @@ The following are keywords: An alias is a name and corresponding value set using the .Ic alias built-in command. -Whenever a keyword may occur (see above), -and after checking for keywords, the shell +Wherever the command word of a simple command may occur, +and after checking for keywords if a keyword may occur, the shell checks the word to see if it matches an alias. If it does, it replaces it in the input stream with its value. For example, if there is an alias called diff --git a/tools/regression/bin/sh/parser/alias4.0 b/tools/regression/bin/sh/parser/alias4.0 new file mode 100644 index 000000000000..19332ed09056 --- /dev/null +++ b/tools/regression/bin/sh/parser/alias4.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +alias alias0=exit +eval 'x=1 alias0 0' +exit 1 diff --git a/tools/regression/bin/sh/parser/alias5.0 b/tools/regression/bin/sh/parser/alias5.0 new file mode 100644 index 000000000000..3d0205fd2332 --- /dev/null +++ b/tools/regression/bin/sh/parser/alias5.0 @@ -0,0 +1,5 @@ +# $FreeBSD$ + +alias alias0=exit +eval ' Date: Sun, 22 May 2011 01:07:54 +0000 Subject: [PATCH 132/200] Add a lock flags argument to the VFS_FHTOVP() file system method, so that callers can indicate the minimum vnode locking requirement. This will allow some file systems to choose to return a LK_SHARED locked vnode when LK_SHARED is specified for the flags argument. This patch only adds the flag. It does not change any file system to use it and all callers specify LK_EXCLUSIVE, so file system semantics are not changed. Reviewed by: kib --- .../contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c | 4 ++-- sys/fs/cd9660/cd9660_vfsops.c | 3 ++- sys/fs/ext2fs/ext2_vfsops.c | 2 +- sys/fs/hpfs/hpfs_vfsops.c | 1 + sys/fs/msdosfs/msdosfs_vfsops.c | 2 +- sys/fs/nfsserver/nfs_nfsdport.c | 4 ++-- sys/fs/ntfs/ntfs_vfsops.c | 1 + sys/fs/nullfs/null_vfsops.c | 6 ++++-- sys/fs/tmpfs/tmpfs_vfsops.c | 6 ++++-- sys/fs/udf/udf_vfsops.c | 2 +- sys/fs/unionfs/union_vfsops.c | 3 ++- sys/gnu/fs/reiserfs/reiserfs_vfsops.c | 3 ++- sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c | 3 ++- sys/kern/vfs_default.c | 3 ++- sys/kern/vfs_syscalls.c | 6 +++--- sys/nfsserver/nfs_srvsubs.c | 2 +- sys/nlm/nlm_prot_impl.c | 2 +- sys/sys/mount.h | 7 ++++--- sys/sys/param.h | 2 +- sys/ufs/ffs/ffs_vfsops.c | 5 +++-- sys/ufs/ufs/ufs_extern.h | 2 +- sys/ufs/ufs/ufs_vfsops.c | 3 ++- 22 files changed, 43 insertions(+), 29 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index e9a956ce4bb4..85e3d44d39a6 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -93,7 +93,7 @@ static int zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp); static int zfs_sync(vfs_t *vfsp, int waitfor); static int zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, struct ucred **credanonp, int *numsecflavors, int **secflavors); -static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vnode_t **vpp); +static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp); static void zfs_objset_close(zfsvfs_t *zfsvfs); static void zfs_freevfs(vfs_t *vfsp); @@ -2007,7 +2007,7 @@ CTASSERT(SHORT_FID_LEN <= sizeof(struct fid)); CTASSERT(LONG_FID_LEN <= sizeof(struct fid)); static int -zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, vnode_t **vpp) +zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) { zfsvfs_t *zfsvfs = vfsp->vfs_data; znode_t *zp; diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index 77757f2c64fc..0ad57ecb785f 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -586,9 +586,10 @@ cd9660_statfs(mp, sbp) /* ARGSUSED */ static int -cd9660_fhtovp(mp, fhp, vpp) +cd9660_fhtovp(mp, fhp, flags, vpp) struct mount *mp; struct fid *fhp; + int flags; struct vnode **vpp; { struct ifid ifh; diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 5c807dc327d3..1b47e912fec2 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -973,7 +973,7 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) * those rights via. exflagsp and credanonp */ static int -ext2_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +ext2_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) { struct inode *ip; struct ufid *ufhp; diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c index 676b5c711edc..866004eeb549 100644 --- a/sys/fs/hpfs/hpfs_vfsops.c +++ b/sys/fs/hpfs/hpfs_vfsops.c @@ -417,6 +417,7 @@ static int hpfs_fhtovp( struct mount *mp, struct fid *fhp, + int flags, struct vnode **vpp) { struct vnode *nvp; diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index e04ef9c14e82..e347640bb5dc 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -963,7 +963,7 @@ msdosfs_sync(struct mount *mp, int waitfor) } static int -msdosfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +msdosfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) { struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); struct defid *defhp = (struct defid *) fhp; diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 11c287f52529..d62be99a1768 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -2551,7 +2551,7 @@ nfsvno_fhtovp(struct mount *mp, fhandle_t *fhp, struct sockaddr *nam, if (VFS_NEEDSGIANT(mp)) error = ESTALE; else - error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp); + error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, vpp); if (error != 0) /* Make sure the server replies ESTALE to the client. */ error = ESTALE; @@ -2834,7 +2834,7 @@ nfsvno_getvp(fhandle_t *fhp) mp = vfs_busyfs(&fhp->fh_fsid); if (mp == NULL) return (NULL); - error = VFS_FHTOVP(mp, &fhp->fh_fid, &vp); + error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, &vp); vfs_unbusy(mp); if (error) return (NULL); diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c index b5e024be9932..d3468af2f022 100644 --- a/sys/fs/ntfs/ntfs_vfsops.c +++ b/sys/fs/ntfs/ntfs_vfsops.c @@ -616,6 +616,7 @@ static int ntfs_fhtovp( struct mount *mp, struct fid *fhp, + int flags, struct vnode **vpp) { struct vnode *nvp; diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c index 7bd4ab7d2794..e39dd8f892c4 100644 --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -321,13 +321,15 @@ nullfs_vget(mp, ino, flags, vpp) } static int -nullfs_fhtovp(mp, fidp, vpp) +nullfs_fhtovp(mp, fidp, flags, vpp) struct mount *mp; struct fid *fidp; + int flags; struct vnode **vpp; { int error; - error = VFS_FHTOVP(MOUNTTONULLMOUNT(mp)->nullm_vfs, fidp, vpp); + error = VFS_FHTOVP(MOUNTTONULLMOUNT(mp)->nullm_vfs, fidp, LK_EXCLUSIVE, + vpp); if (error) return (error); diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 356be5e30815..9d23bd212ffb 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -71,7 +71,8 @@ MALLOC_DEFINE(M_TMPFSNAME, "tmpfs name", "tmpfs file names"); static int tmpfs_mount(struct mount *); static int tmpfs_unmount(struct mount *, int); static int tmpfs_root(struct mount *, int flags, struct vnode **); -static int tmpfs_fhtovp(struct mount *, struct fid *, struct vnode **); +static int tmpfs_fhtovp(struct mount *, struct fid *, int, + struct vnode **); static int tmpfs_statfs(struct mount *, struct statfs *); /* --------------------------------------------------------------------- */ @@ -341,7 +342,8 @@ tmpfs_root(struct mount *mp, int flags, struct vnode **vpp) /* --------------------------------------------------------------------- */ static int -tmpfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +tmpfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, + struct vnode **vpp) { boolean_t found; struct tmpfs_fid *tfhp; diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c index 7be538436ce5..bb2c09d31c5b 100644 --- a/sys/fs/udf/udf_vfsops.c +++ b/sys/fs/udf/udf_vfsops.c @@ -722,7 +722,7 @@ udf_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) } static int -udf_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +udf_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) { struct ifid *ifhp; struct vnode *nvp; diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index e11219c1d026..96258fb88649 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -454,7 +454,8 @@ unionfs_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) } static int -unionfs_fhtovp(struct mount *mp, struct fid *fidp, struct vnode **vpp) +unionfs_fhtovp(struct mount *mp, struct fid *fidp, int flags, + struct vnode **vpp) { return (EOPNOTSUPP); } diff --git a/sys/gnu/fs/reiserfs/reiserfs_vfsops.c b/sys/gnu/fs/reiserfs/reiserfs_vfsops.c index 1b5ce88eef9c..9b7ccd94aa7b 100644 --- a/sys/gnu/fs/reiserfs/reiserfs_vfsops.c +++ b/sys/gnu/fs/reiserfs/reiserfs_vfsops.c @@ -335,7 +335,8 @@ reiserfs_statfs(struct mount *mp, struct statfs *sbp) * those rights via. exflagsp and credanonp */ static int -reiserfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +reiserfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, + struct vnode **vpp) { int error; struct rfid *rfhp; diff --git a/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c b/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c index f89618e93d02..e9ccfc902761 100644 --- a/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c +++ b/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c @@ -370,9 +370,10 @@ _xfs_vget(mp, ino, flags, vpp) } static int -_xfs_fhtovp(mp, fidp, vpp) +_xfs_fhtovp(mp, fidp, flags, vpp) struct mount *mp; struct fid *fidp; + int flags; struct vnode **vpp; { printf("xfs_fhtovp\n"); diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index e5f1254fd6f2..b89d990ffe7c 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1081,9 +1081,10 @@ vfs_stdvget (mp, ino, flags, vpp) } int -vfs_stdfhtovp (mp, fhp, vpp) +vfs_stdfhtovp (mp, fhp, flags, vpp) struct mount *mp; struct fid *fhp; + int flags; struct vnode **vpp; { diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 33f7c5b63752..b48c6e796958 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4405,7 +4405,7 @@ fhopen(td, uap) return (ESTALE); vfslocked = VFS_LOCK_GIANT(mp); /* now give me my vnode, it gets returned to me locked */ - error = VFS_FHTOVP(mp, &fhp.fh_fid, &vp); + error = VFS_FHTOVP(mp, &fhp.fh_fid, LK_EXCLUSIVE, &vp); vfs_unbusy(mp); if (error) goto out; @@ -4581,7 +4581,7 @@ fhstat(td, uap) if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL) return (ESTALE); vfslocked = VFS_LOCK_GIANT(mp); - error = VFS_FHTOVP(mp, &fh.fh_fid, &vp); + error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp); vfs_unbusy(mp); if (error) { VFS_UNLOCK_GIANT(vfslocked); @@ -4641,7 +4641,7 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf) if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL) return (ESTALE); vfslocked = VFS_LOCK_GIANT(mp); - error = VFS_FHTOVP(mp, &fh.fh_fid, &vp); + error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp); if (error) { vfs_unbusy(mp); VFS_UNLOCK_GIANT(vfslocked); diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c index 5a923762380f..66a85c4bb8e3 100644 --- a/sys/nfsserver/nfs_srvsubs.c +++ b/sys/nfsserver/nfs_srvsubs.c @@ -1128,7 +1128,7 @@ nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp, goto out; } } - error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp); + error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, vpp); if (error) { /* Make sure the server replies ESTALE to the client. */ error = ESTALE; diff --git a/sys/nlm/nlm_prot_impl.c b/sys/nlm/nlm_prot_impl.c index 070fdf9ad78a..afbb9ddd809c 100644 --- a/sys/nlm/nlm_prot_impl.c +++ b/sys/nlm/nlm_prot_impl.c @@ -1797,7 +1797,7 @@ nlm_get_vfs_state(struct nlm_host *host, struct svc_req *rqstp, goto out; } - error = VFS_FHTOVP(vs->vs_mp, &fhp->fh_fid, &vs->vs_vp); + error = VFS_FHTOVP(vs->vs_mp, &fhp->fh_fid, LK_EXCLUSIVE, &vs->vs_vp); if (error) goto out; vs->vs_vnlocked = TRUE; diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 231e3d69f0f4..d6366071b91a 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -566,7 +566,8 @@ typedef int vfs_statfs_t(struct mount *mp, struct statfs *sbp); typedef int vfs_sync_t(struct mount *mp, int waitfor); typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags, struct vnode **vpp); -typedef int vfs_fhtovp_t(struct mount *mp, struct fid *fhp, struct vnode **vpp); +typedef int vfs_fhtovp_t(struct mount *mp, struct fid *fhp, + int flags, struct vnode **vpp); typedef int vfs_checkexp_t(struct mount *mp, struct sockaddr *nam, int *extflagsp, struct ucred **credanonp, int *numsecflavors, int **secflavors); @@ -610,8 +611,8 @@ vfs_statfs_t __vfs_statfs; #define VFS_SYNC(MP, WAIT) (*(MP)->mnt_op->vfs_sync)(MP, WAIT) #define VFS_VGET(MP, INO, FLAGS, VPP) \ (*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP) -#define VFS_FHTOVP(MP, FIDP, VPP) \ - (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP) +#define VFS_FHTOVP(MP, FIDP, FLAGS, VPP) \ + (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, FLAGS, VPP) #define VFS_CHECKEXP(MP, NAM, EXFLG, CRED, NUMSEC, SEC) \ (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED, NUMSEC, SEC) #define VFS_EXTATTRCTL(MP, C, FN, NS, N) \ diff --git a/sys/sys/param.h b/sys/sys/param.h index 7fbcde54fb43..838769fcaba1 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 900037 /* Master, propagated to newvers */ +#define __FreeBSD_version 900038 /* Master, propagated to newvers */ #ifdef _KERNEL #define P_OSREL_SIGSEGV 700004 diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 573c364cc33d..68b961910bdc 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1640,9 +1640,10 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) * those rights via. exflagsp and credanonp */ static int -ffs_fhtovp(mp, fhp, vpp) +ffs_fhtovp(mp, fhp, flags, vpp) struct mount *mp; struct fid *fhp; + int flags; struct vnode **vpp; { struct ufid *ufhp; @@ -1653,7 +1654,7 @@ ffs_fhtovp(mp, fhp, vpp) if (ufhp->ufid_ino < ROOTINO || ufhp->ufid_ino >= fs->fs_ncg * fs->fs_ipg) return (ESTALE); - return (ufs_fhtovp(mp, ufhp, vpp)); + return (ufs_fhtovp(mp, ufhp, flags, vpp)); } /* diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index 528b03bc5f28..c590748f7ff0 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -56,7 +56,7 @@ extern struct vop_vector ufs_vnodeops; int ufs_bmap(struct vop_bmap_args *); int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *, struct buf *, int *, int *); -int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **); +int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **); int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *); void ufs_dirbad(struct inode *, doff_t, char *); int ufs_dirbadentry(struct vnode *, struct direct *, int); diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 0eeb14fc54e8..b71fc169a366 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -208,9 +208,10 @@ ufs_uninit(vfsp) * Call the VFS_CHECKEXP beforehand to verify access. */ int -ufs_fhtovp(mp, ufhp, vpp) +ufs_fhtovp(mp, ufhp, flags, vpp) struct mount *mp; struct ufid *ufhp; + int flags; struct vnode **vpp; { struct inode *ip; From c5917de726fa76fecd15587dc8c879eeb34f7e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sun, 22 May 2011 09:48:25 +0000 Subject: [PATCH 133/200] Update URLs and fix regex to work with current version of the files. --- tools/tools/iso/check-iso3166.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/tools/iso/check-iso3166.pl b/tools/tools/iso/check-iso3166.pl index b85c1883a62d..a8baf4ee6a78 100755 --- a/tools/tools/iso/check-iso3166.pl +++ b/tools/tools/iso/check-iso3166.pl @@ -4,8 +4,8 @@ # $FreeBSD$ # # This script compares the file iso3166 (from head/share/misc) with the files -# list-en1-semic-2.txt (from -# http://www.iso.org/iso/list-en1-semic-2.txt) and iso3166-countrycodes.txt +# list-en1-semic-3.txt (from +# http://www.iso.org/iso/list-en1-semic-3.txt) and iso3166-countrycodes.txt # (from ftp://ftp.ripe.net/) to see if there any differences. # # Created by Edwin Groothuis for the FreeBSD project. @@ -41,7 +41,7 @@ my %old = (); my %new1 = (); { - open(FIN, "iso3166-countrycodes.txt") or die "Cannot open iso3166-countrycodes.txt, which can be retrieved from ftp://ftp.ripe.net/"; + open(FIN, "iso3166-countrycodes.txt") or die "Cannot open iso3166-countrycodes.txt, which can be retrieved from ftp://ftp.ripe.net/iso3166-countrycodes.txt"; my @lines = ; close(FIN); chomp(@lines); @@ -56,7 +56,7 @@ my %new1 = (); next if ($l eq ""); die "Invalid line: $l\n" - if ($l !~ /^(.+?)[\t ][\t ]+([A-Z]{2})[\t ]+([A-Z]{3})[\t ]+(\d+)[\t ]*$/); + if ($l !~ /^(.+?)[\t ]+([A-Z]{2})[\t ]+([A-Z]{3})[\t ]+(\d+)[\t ]*$/); my $two = $2; my $three = $3; my $number = $4; @@ -71,7 +71,7 @@ my %new1 = (); my %new2 = (); { - open(FIN, "list-en1-semic-2.txt") or die "Cannot open list-en1-semic-2.txt, which can be retrieved from http://www.iso.org/iso/list-en1-semic-2.txt"; + open(FIN, "list-en1-semic-3.txt") or die "Cannot open list-en1-semic-3.txt, which can be retrieved from http://www.iso.org/iso/list-en1-semic-3.txt"; my @lines = ; close(FIN); chomp(@lines); From 1cb2359e6f548192974d9d12c0ebc4c2d1354597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sun, 22 May 2011 09:58:48 +0000 Subject: [PATCH 134/200] Fix typo in unused function name Submitted by: arundel --- sys/gnu/fs/xfs/FreeBSD/support/kdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/gnu/fs/xfs/FreeBSD/support/kdb.c b/sys/gnu/fs/xfs/FreeBSD/support/kdb.c index 274f23d25b16..b133dfe5f35f 100644 --- a/sys/gnu/fs/xfs/FreeBSD/support/kdb.c +++ b/sys/gnu/fs/xfs/FreeBSD/support/kdb.c @@ -56,7 +56,7 @@ kdb_getarea_size(void *res, unsigned long addr, size_t size) } int -db_putarea_size(unsigned long addr, void *res, size_t size) +kdb_putarea_size(unsigned long addr, void *res, size_t size) { return 0; } From c9e93e6739230e8036c5a8818658d960c2c4efe2 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 22 May 2011 12:12:28 +0000 Subject: [PATCH 135/200] sh: Fix bss-based buffer overflow in . builtin. If the length of a directory in PATH together with the given filename exceeded FILENAME_MAX (which may happen even for pathnames that work), a static buffer was overflown. The static buffer is unnecessary, we can use the stalloc() stack. Obtained from: NetBSD MFC after: 1 week --- bin/sh/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/sh/main.c b/bin/sh/main.c index d9629204647b..408d37c1b11b 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -281,7 +281,6 @@ readcmdfile(const char *name) static char * find_dot_file(char *basename) { - static char localname[FILENAME_MAX+1]; char *fullname; const char *path = pathval(); struct stat statb; @@ -291,10 +290,14 @@ find_dot_file(char *basename) return basename; while ((fullname = padvance(&path, basename)) != NULL) { - strcpy(localname, fullname); + if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode)) { + /* + * Don't bother freeing here, since it will + * be freed by the caller. + */ + return fullname; + } stunalloc(fullname); - if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode)) - return localname; } return basename; } From 4d79e0296a0d0aa9fc4d5936c54a1605355bfdf3 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 22 May 2011 12:15:14 +0000 Subject: [PATCH 136/200] sh: Add test for r222173. --- tools/regression/bin/sh/builtins/dot4.0 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tools/regression/bin/sh/builtins/dot4.0 diff --git a/tools/regression/bin/sh/builtins/dot4.0 b/tools/regression/bin/sh/builtins/dot4.0 new file mode 100644 index 000000000000..b898131c0e1c --- /dev/null +++ b/tools/regression/bin/sh/builtins/dot4.0 @@ -0,0 +1,12 @@ +# $FreeBSD$ + +v=abcd +v=$v$v$v$v +v=$v$v$v$v +v=$v$v$v$v +v=$v$v$v$v +v=$v$v$v$v +r=$( ( + trap 'exit 0' 0 + . "$v" +) 2>&1 >/dev/null) && [ -n "$r" ] From fcdf51e372ccc5c66ca085126833a64c0694dac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sun, 22 May 2011 14:03:21 +0000 Subject: [PATCH 137/200] Remove typos, tabs-after-spaces and EOL whitespace. Convert to UTF-8. --- share/examples/libvgl/demo.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/share/examples/libvgl/demo.c b/share/examples/libvgl/demo.c index 781f6a1a063b..c2edfbc7b074 100644 --- a/share/examples/libvgl/demo.c +++ b/share/examples/libvgl/demo.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1991-1997 Søren Schmidt + * Copyright (c) 1991-1997 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,15 +42,15 @@ main(int argc, char **argv) // set graphics mode, here 320x240 256 colors // supported modes are (from ): - // SW_VGA_CG320: std VGA 320x200 256 colors - // SW_VGA_MODEX: Modex VGA 320x240 256 colors - // SW_VGA_VG640: std VGA 640x480 16 colors + // SW_VGA_CG320: std VGA 320x200 256 colors + // SW_VGA_MODEX: Modex VGA 320x240 256 colors + // SW_VGA_VG640: std VGA 640x480 16 colors VGLInit(SW_VGA_MODEX); // initialize mouse and show pointer VGLMouseInit(VGL_MOUSESHOW); - // VGLDisplay is a ptr to a struct Bitmap defined and initialized by + // VGLDisplay is a ptr to a struct Bitmap defined and initialized by // libvgl. The Bitmap points directly to screen memory etc. xsize=VGLDisplay->Xsize; ysize=VGLDisplay->Ysize; @@ -61,7 +61,7 @@ main(int argc, char **argv) VGLClear(tmp, 0); // fill the screen with colored lines - for (y=0; yBitmap[i+256*j] = i%16; @@ -106,12 +106,12 @@ main(int argc, char **argv) // loop around drawing and copying while (++i) { VGLBitmapCopy(VGLDisplay, rand()%xsize, rand()%ysize, - VGLDisplay, rand()%xsize, rand()%ysize, - rand()%xsize, rand()%ysize); + VGLDisplay, rand()%xsize, rand()%ysize, + rand()%xsize, rand()%ysize); VGLLine(VGLDisplay, rand()%xsize, rand()%ysize, rand()%xsize, rand()%ysize, rand()%256); VGLEllipse(VGLDisplay, rand()%xsize, rand()%ysize, - rand()%xsize/2, rand()%ysize/2, rand()%256); + rand()%xsize/2, rand()%ysize/2, rand()%256); rand(); if (i > 1000) break; } @@ -120,4 +120,3 @@ main(int argc, char **argv) VGLEnd(); return 0; } - From 6e18fca127408a1811778eda5cc686116e131143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sun, 22 May 2011 14:03:30 +0000 Subject: [PATCH 138/200] Re-encode files from ISO-8859-1 to UTF-8 --- sbin/atacontrol/atacontrol.8 | 2 +- sbin/atacontrol/atacontrol.c | 2 +- sbin/mount_reiserfs/mount_reiserfs.8 | 2 +- sbin/mount_reiserfs/mount_reiserfs.c | 2 +- share/man/man4/aio.4 | 2 +- share/man/man4/ata.4 | 2 +- share/man/man4/coretemp.4 | 2 +- share/man/man4/ichwd.4 | 2 +- share/man/man4/pst.4 | 2 +- share/man/man4/ucycom.4 | 2 +- share/man/man5/reiserfs.5 | 2 +- share/man/man9/LOCK_PROFILING.9 | 2 +- share/man/man9/pseudofs.9 | 2 +- share/man/man9/sbuf.9 | 2 +- share/man/man9/zone.9 | 2 +- share/misc/bsd-family-tree | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sbin/atacontrol/atacontrol.8 b/sbin/atacontrol/atacontrol.8 index 9ee6c2b5c718..6c446872293d 100644 --- a/sbin/atacontrol/atacontrol.8 +++ b/sbin/atacontrol/atacontrol.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2000,2001,2002 Søren Schmidt +.\" Copyright (c) 2000,2001,2002 Søren Schmidt .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c index 4354ddfb7633..7b67821c8eac 100644 --- a/sbin/atacontrol/atacontrol.c +++ b/sbin/atacontrol/atacontrol.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2000 - 2006 Søren Schmidt + * Copyright (c) 2000 - 2006 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sbin/mount_reiserfs/mount_reiserfs.8 b/sbin/mount_reiserfs/mount_reiserfs.8 index a63dfdffa494..f2464754cb62 100644 --- a/sbin/mount_reiserfs/mount_reiserfs.8 +++ b/sbin/mount_reiserfs/mount_reiserfs.8 @@ -1,7 +1,7 @@ .\" .\" Copyright (c) 1993,1994 Christopher G. Demetriou .\" Copyright (c) 1999 Semen Ustimenko -.\" Copyright (c) 2005 Jean-Sébastien Pédron +.\" Copyright (c) 2005 Jean-Sébastien Pédron .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/sbin/mount_reiserfs/mount_reiserfs.c b/sbin/mount_reiserfs/mount_reiserfs.c index 5c4e6fcff628..5fccfbe9950c 100644 --- a/sbin/mount_reiserfs/mount_reiserfs.c +++ b/sbin/mount_reiserfs/mount_reiserfs.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2005 Jean-Sébastien Pédron + * Copyright (c) 2005 Jean-Sébastien Pédron * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/share/man/man4/aio.4 b/share/man/man4/aio.4 index 3ea71b05d77c..8e773d96ee02 100644 --- a/share/man/man4/aio.4 +++ b/share/man/man4/aio.4 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2002 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2002 Dag-Erling Coïdan Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man4/ata.4 b/share/man/man4/ata.4 index 44973f1baac2..05e03d6dd1ad 100644 --- a/share/man/man4/ata.4 +++ b/share/man/man4/ata.4 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2003 Søren Schmidt +.\" Copyright (c) 2003 Søren Schmidt .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man4/coretemp.4 b/share/man/man4/coretemp.4 index ce4eb36f1a59..efae020a152c 100644 --- a/share/man/man4/coretemp.4 +++ b/share/man/man4/coretemp.4 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2007 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2007 Dag-Erling Coïdan Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man4/ichwd.4 b/share/man/man4/ichwd.4 index 497712c7c5de..25b6dbb52e75 100644 --- a/share/man/man4/ichwd.4 +++ b/share/man/man4/ichwd.4 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2007 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2007 Dag-Erling Coïdan Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man4/pst.4 b/share/man/man4/pst.4 index f207e2d111e1..3ce95d858890 100644 --- a/share/man/man4/pst.4 +++ b/share/man/man4/pst.4 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2001,2002 Søren Schmidt +.\" Copyright (c) 2001,2002 Søren Schmidt .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man4/ucycom.4 b/share/man/man4/ucycom.4 index 92764624dff6..6d76564ffa25 100644 --- a/share/man/man4/ucycom.4 +++ b/share/man/man4/ucycom.4 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2004 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2004 Dag-Erling Coïdan Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man5/reiserfs.5 b/share/man/man5/reiserfs.5 index eda70288915e..dd7757cecf1e 100644 --- a/share/man/man5/reiserfs.5 +++ b/share/man/man5/reiserfs.5 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2005 Jean-Sébastien Pédron +.\" Copyright (c) 2005 Jean-Sébastien Pédron .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man9/LOCK_PROFILING.9 b/share/man/man9/LOCK_PROFILING.9 index cdb78b315a21..94b2246e7eb3 100644 --- a/share/man/man9/LOCK_PROFILING.9 +++ b/share/man/man9/LOCK_PROFILING.9 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2004 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2004 Dag-Erling Coïdan Smørgrav .\" Copyright (c) 2005 Robert N. M. Watson .\" Copyright (c) 2006 Kip Macy .\" All rights reserved. diff --git a/share/man/man9/pseudofs.9 b/share/man/man9/pseudofs.9 index b0b22ff917ce..5d394961dc57 100644 --- a/share/man/man9/pseudofs.9 +++ b/share/man/man9/pseudofs.9 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2001 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2001 Dag-Erling Coïdan Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man9/sbuf.9 b/share/man/man9/sbuf.9 index 0e6da36b417c..d17b34ca477b 100644 --- a/share/man/man9/sbuf.9 +++ b/share/man/man9/sbuf.9 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2000 Poul-Henning Kamp and Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2000 Poul-Henning Kamp and Dag-Erling Coïdan Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/man/man9/zone.9 b/share/man/man9/zone.9 index a2132b5ea3b0..32531bb4ade1 100644 --- a/share/man/man9/zone.9 +++ b/share/man/man9/zone.9 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2001 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2001 Dag-Erling Coïdan Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree index 1d20448f2ffd..1f4ec119df4f 100644 --- a/share/misc/bsd-family-tree +++ b/share/misc/bsd-family-tree @@ -562,7 +562,7 @@ Australian Computer Society, Hobart, August 1993. Peter H. Salus. Unix at 25. Byte Magazine, October 1994. URL: http://www.byte.com/art/9410/sec8/art3.htm -Andreas Klemm, Lars Köller. If you're going to San Francisco ... +Andreas Klemm, Lars Köller. If you're going to San Francisco ... Die freien BSD-Varianten von Unix. c't April 1997, page 368ff. BSD Release Announcements collection. From 01c9917634f4a0a193ee292474ae75b6e899a9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sun, 22 May 2011 14:03:38 +0000 Subject: [PATCH 139/200] Fix a bunch of typos and a couple of whitespace nits. Helped by: codespell and vim's spellchecker --- bin/pax/ar_io.c | 18 +++++++++--------- bin/pax/ar_subs.c | 4 ++-- bin/pax/buf_subs.c | 28 ++++++++++++++-------------- bin/pax/cpio.c | 8 ++++---- bin/pax/file_subs.c | 16 ++++++++-------- bin/pax/ftree.c | 4 ++-- bin/pax/options.c | 2 +- bin/pax/pat_rep.c | 2 +- bin/pax/pax.c | 2 +- bin/pax/sel_subs.c | 2 +- bin/pax/tables.c | 6 +++--- bin/pax/tar.c | 2 +- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c index 0946a8884c5f..c3b35a7d4836 100644 --- a/bin/pax/ar_io.c +++ b/bin/pax/ar_io.c @@ -204,7 +204,7 @@ ar_open(const char *name) /* * set default blksz on read. APPNDs writes rdblksz on the last volume * On all new archive volumes, we shift to wrblksz (if the user - * specified one, otherwize we will continue to use rdblksz). We + * specified one, otherwise we will continue to use rdblksz). We * must to set blocksize based on what kind of device the archive is * stored. */ @@ -381,7 +381,7 @@ ar_close(void) /* * If we have not determined the format yet, we just say how many bytes - * we have skipped over looking for a header to id. there is no way we + * we have skipped over looking for a header to id. There is no way we * could have written anything yet. */ if (frmt == NULL) { @@ -595,7 +595,7 @@ ar_read(char *buf, int cnt) * Return: * Number of bytes written. 0 indicates end of volume reached and with no * flaws (as best that can be detected). A -1 indicates an unrecoverable - * error in the archive occured. + * error in the archive occurred. */ int @@ -679,7 +679,7 @@ ar_write(char *buf, int bsz) * if this is a block aligned archive format, we may have a bad archive * if the format wants the header to start at a BLKMULT boundary. While * we can deal with the mis-aligned data, it violates spec and other - * archive readers will likely fail. if the format is not block + * archive readers will likely fail. If the format is not block * aligned, the user may be lucky (and the archive is ok). */ if (res >= 0) { @@ -794,7 +794,7 @@ ar_rdsync(void) /* * ar_fow() - * Move the I/O position within the archive foward the specified number of + * Move the I/O position within the archive forward the specified number of * bytes as supported by the device. If we cannot move the requested * number of bytes, return the actual number of bytes moved in skipped. * Return: @@ -813,7 +813,7 @@ ar_fow(off_t sksz, off_t *skipped) return(0); /* - * we cannot move foward at EOF or error + * we cannot move forward at EOF or error */ if (lstrval <= 0) return(lstrval); @@ -822,7 +822,7 @@ ar_fow(off_t sksz, off_t *skipped) * Safer to read forward on devices where it is hard to find the end of * the media without reading to it. With tapes we cannot be sure of the * number of physical blocks to skip (we do not know physical block - * size at this point), so we must only read foward on tapes! + * size at this point), so we must only read forward on tapes! */ if (artyp != ISREG) return(0); @@ -907,7 +907,7 @@ ar_rev(off_t sksz) /* * we may try to go backwards past the start when the archive - * is only a single record. If this hapens and we are on a + * is only a single record. If this happens and we are on a * multi volume archive, we need to go to the end of the * previous volume and continue our movement backwards from * there. @@ -1046,7 +1046,7 @@ get_phys(void) } /* - * read foward to the file mark, then back up in front of the filemark + * read forward to the file mark, then back up in front of the filemark * (this is a bit paranoid, but should be safe to do). */ while ((res = read(arfd, scbuf, sizeof(scbuf))) > 0) diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c index da275c2dacb0..bc808ab45bf9 100644 --- a/bin/pax/ar_subs.c +++ b/bin/pax/ar_subs.c @@ -854,7 +854,7 @@ copy(void) } /* - * Non standard -Y and -Z flag. When the exisiting file is + * Non standard -Y and -Z flag. When the existing file is * same age or newer skip */ if ((Yflag || Zflag) && ((lstat(arcn->name, &sb) == 0))) { @@ -1096,7 +1096,7 @@ next_head(ARCHD *arcn) } /* - * ok got a valid header, check for trailer if format encodes it in the + * ok got a valid header, check for trailer if format encodes it in * the header. */ if (frmt->inhead && ((*frmt->trail_cpio)(arcn) == 0)) { diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c index 1d01d4e5090a..995e34c88809 100644 --- a/bin/pax/buf_subs.c +++ b/bin/pax/buf_subs.c @@ -145,7 +145,7 @@ rd_start(void) } if (wrblksz % BLKMULT) { paxwarn(1, "Write block size %d is not a %d byte multiple", - wrblksz, BLKMULT); + wrblksz, BLKMULT); return(-1); } } @@ -182,13 +182,13 @@ cp_start(void) * the start of the header of the first file added to the archive. The * format specific end read function tells us how many bytes to move * backwards in the archive to be positioned BEFORE the trailer. Two - * different postions have to be adjusted, the O.S. file offset (e.g. the + * different positions have to be adjusted, the O.S. file offset (e.g. the * position of the tape head) and the write point within the data we have * stored in the read (soon to become write) buffer. We may have to move * back several records (the number depends on the size of the archive * record and the size of the format trailer) to read up the record where * the first byte of the trailer is recorded. Trailers may span (and - * overlap) record boundries. + * overlap) record boundaries. * We first calculate which record has the first byte of the trailer. We * move the OS file offset back to the start of this record and read it * up. We set the buffer write pointer to be at this byte (the byte where @@ -196,10 +196,10 @@ cp_start(void) * start of this record so a flush of this buffer will replace the record * in the archive. * A major problem is rewriting this last record. For archives stored - * on disk files, this is trival. However, many devices are really picky + * on disk files, this is trivial. However, many devices are really picky * about the conditions under which they will allow a write to occur. * Often devices restrict the conditions where writes can be made writes, - * so it may not be feasable to append archives stored on all types of + * so it may not be feasible to append archives stored on all types of * devices. * Return: * 0 for success, -1 for failure @@ -365,7 +365,7 @@ rd_sync(void) * pback() * push the data used during the archive id phase back into the I/O * buffer. This is required as we cannot be sure that the header does NOT - * overlap a block boundry (as in the case we are trying to recover a + * overlap a block boundary (as in the case we are trying to recover a * flawed archived). This was not designed to be used for any other * purpose. (What software engineering, HA!) * WARNING: do not even THINK of pback greater than BLKMULT, unless the @@ -382,7 +382,7 @@ pback(char *pt, int cnt) /* * rd_skip() - * skip foward in the archive during an archive read. Used to get quickly + * skip forward in the archive during an archive read. Used to get quickly * past file data and padding for files the user did NOT select. * Return: * 0 if ok, -1 failure, and 1 when EOF on the archive volume was detected. @@ -396,7 +396,7 @@ rd_skip(off_t skcnt) off_t skipped = 0; /* - * consume what data we have in the buffer. If we have to move foward + * consume what data we have in the buffer. If we have to move forward * whole records, we call the low level skip function to see if we can * move within the archive without doing the expensive reads on data we * do not want. @@ -453,7 +453,7 @@ rd_skip(off_t skcnt) * wr_fin() * flush out any data (and pad if required) the last block. We always pad * with zero (even though we do not have to). Padding with 0 makes it a - * lot easier to recover if the archive is damaged. zero paddding SHOULD + * lot easier to recover if the archive is damaged. zero padding SHOULD * BE a requirement.... */ @@ -530,7 +530,7 @@ rd_wrbuf(char *in, int cpcnt) /* * read error, return what we got (or the error if * no data was copied). The caller must know that an - * error occured and has the best knowledge what to + * error occurred and has the best knowledge what to * do with it */ if ((res = cpcnt - incnt) > 0) @@ -584,7 +584,7 @@ wr_skip(off_t skcnt) /* * wr_rdfile() - * fill write buffer with the contents of a file. We are passed an open + * fill write buffer with the contents of a file. We are passed an open * file descriptor to the file and the archive structure that describes the * file we are storing. The variable "left" is modified to contain the * number of bytes of the file we were NOT able to write to the archive. @@ -671,7 +671,7 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *left) int isem = 1; int rem; int sz = MINFBSZ; - struct stat sb; + struct stat sb; u_long crc = 0L; /* @@ -884,7 +884,7 @@ buf_flush(int bufcnt) /* * if we have reached the user specified byte count for each archive - * volume, prompt for the next volume. (The non-standrad -R flag). + * volume, prompt for the next volume. (The non-standard -R flag). * NOTE: If the wrlimit is smaller than wrcnt, we will always write * at least one record. We always round limit UP to next blocksize. */ @@ -944,7 +944,7 @@ buf_flush(int bufcnt) } else if (cnt > 0) { /* * Oh drat we got a partial write! - * if format doesnt care about alignment let it go, + * if format doesn't care about alignment let it go, * we warned the user in ar_write().... but this means * the last record on this volume violates pax spec.... */ diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c index 67602fa87455..0d9cc9fdc326 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -627,7 +627,7 @@ vcpio_rd(ARCHD *arcn, char *buf) return(-1); /* - * skip padding. header + filename is aligned to 4 byte boundries + * skip padding. header + filename is aligned to 4 byte boundaries */ if (rd_skip((off_t)(VCPIO_PAD(sizeof(HD_VCPIO) + nsz))) < 0) return(-1); @@ -942,7 +942,7 @@ bcpio_rd(ARCHD *arcn, char *buf) return(-1); /* - * header + file name are aligned to 2 byte boundries, skip if needed + * header + file name are aligned to 2 byte boundaries, skip if needed */ if (rd_skip((off_t)(BCPIO_PAD(sizeof(HD_BCPIO) + nsz))) < 0) return(-1); @@ -989,8 +989,8 @@ bcpio_endrd(void) * bcpio_wr() * copy the data in the ARCHD to buffer in old binary cpio format * There is a real chance of field overflow with this critter. So we - * always check the conversion is ok. nobody in his their right mind - * should write an achive in this format... + * always check that the conversion is ok. nobody in their right mind + * should write an archive in this format... * Return * 0 if file has data to be written after the header, 1 if file has NO * data to write after the header, -1 if archive write failed diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index 0fad68ef64cd..5e4cce151a0b 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -84,9 +84,9 @@ file_creat(ARCHD *arcn) * works. We have to take special handling when the file does exist. To * detect this, we use O_EXCL. For example when trying to create a * file and a character device or fifo exists with the same name, we - * can accidently open the device by mistake (or block waiting to open) - * If we find that the open has failed, then figure spend the effort to - * figure out why. This strategy was found to have better average + * can accidentally open the device by mistake (or block waiting to + * open). If we find that the open has failed, then spend the effort + * to figure out why. This strategy was found to have better average * performance in common use than checking the file (and the path) * first with lstat. */ @@ -559,7 +559,7 @@ chk_path( char *name, uid_t st_uid, gid_t st_gid) for(;;) { /* - * work foward from the first / and check each part of the path + * work forward from the first / and check each part of the path */ spt = strchr(spt, '/'); if (spt == NULL) @@ -600,7 +600,7 @@ chk_path( char *name, uid_t st_uid, gid_t st_gid) (void)set_ids(name, st_uid, st_gid); /* - * make sure the user doen't have some strange umask that + * make sure the user doesn't have some strange umask that * causes this newly created directory to be unusable. We fix * the modes and restore them back to the creation default at * the end of pax @@ -716,11 +716,11 @@ set_pmode(char *fnm, mode_t mode) * uses lseek whenever it detects the input data is all 0 within that * file block. In more detail, the strategy is as follows: * While the input is all zero keep doing an lseek. Keep track of when we - * pass over file block boundries. Only write when we hit a non zero + * pass over file block boundaries. Only write when we hit a non zero * input. once we have written a file block, we continue to write it to * the end (we stop looking at the input). When we reach the start of the * next file block, start checking for zero blocks again. Working on file - * block boundries significantly reduces the overhead when copying files + * block boundaries significantly reduces the overhead when copying files * that are NOT very sparse. This overhead (when compared to a write) is * almost below the measurement resolution on many systems. Without it, * files with holes cannot be safely copied. It does has a side effect as @@ -923,7 +923,7 @@ set_crc(ARCHD *arcn, int fd) /* * safety check. we want to avoid archiving files that are active as - * they can create inconsistant archive copies. + * they can create inconsistent archive copies. */ if (cpcnt != arcn->sb.st_size) paxwarn(1, "File changed size %s", arcn->org_name); diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c index 1fb06ac74c3a..9e07882a96b1 100644 --- a/bin/pax/ftree.c +++ b/bin/pax/ftree.c @@ -101,8 +101,8 @@ ftree_start(void) /* * optional user flags that effect file traversal * -H command line symlink follow only (half follow) - * -L follow sylinks (logical) - * -P do not follow sylinks (physical). This is the default. + * -L follow symlinks (logical) + * -P do not follow symlinks (physical). This is the default. * -X do not cross over mount points * -t preserve access times on files read. * -n select only the first member of a file tree when a match is found diff --git a/bin/pax/options.c b/bin/pax/options.c index 6f43940d1e47..5fd641fc3088 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -887,7 +887,7 @@ tar_options(int argc, char **argv) sawpat = 1; } /* - * if patterns were added, we are doing chdir() + * if patterns were added, we are doing chdir() * on a file-by-file basis, else, just one * global chdir (if any) after opening input. */ diff --git a/bin/pax/pat_rep.c b/bin/pax/pat_rep.c index 62539a2a3a85..7b0797525745 100644 --- a/bin/pax/pat_rep.c +++ b/bin/pax/pat_rep.c @@ -397,7 +397,7 @@ pat_sel(ARCHD *arcn) /* * should never happen.... */ - paxwarn(1, "Pattern list inconsistant"); + paxwarn(1, "Pattern list inconsistent"); return(-1); } *ppt = pt->fow; diff --git a/bin/pax/pax.c b/bin/pax/pax.c index cb19b99b175e..040db744c5b1 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -372,7 +372,7 @@ gen_init(void) /* * signal handling to reset stored directory times and modes. Since * we deal with broken pipes via failed writes we ignore it. We also - * deal with any file size limit thorugh failed writes. Cpu time + * deal with any file size limit thorough failed writes. Cpu time * limits are caught and a cleanup is forced. */ if ((sigemptyset(&s_mask) < 0) || (sigaddset(&s_mask, SIGTERM) < 0) || diff --git a/bin/pax/sel_subs.c b/bin/pax/sel_subs.c index bd5c560afc53..fe131f7329ca 100644 --- a/bin/pax/sel_subs.c +++ b/bin/pax/sel_subs.c @@ -376,7 +376,7 @@ trng_add(char *str) } /* - * by default we only will check file mtime, but usee can specify + * by default we only will check file mtime, but the user can specify * mtime, ctime (inode change time) or both. */ if ((flgpt == NULL) || (*flgpt == '\0')) diff --git a/bin/pax/tables.c b/bin/pax/tables.c index 4e96fea62313..69273fe98827 100644 --- a/bin/pax/tables.c +++ b/bin/pax/tables.c @@ -209,7 +209,7 @@ chk_lnk(ARCHD *arcn) * purg_lnk * remove reference for a file that we may have added to the data base as * a potential source for hard links. We ended up not using the file, so - * we do not want to accidently point another file at it later on. + * we do not want to accidentally point another file at it later on. */ void @@ -306,14 +306,14 @@ lnk_end(void) * An append with an -u must read the archive and store the modification time * for every file on that archive before starting the write phase. It is clear * that this is one HUGE database. To save memory space, the actual file names - * are stored in a scatch file and indexed by an in memory hash table. The + * are stored in a scratch file and indexed by an in memory hash table. The * hash table is indexed by hashing the file path. The nodes in the table store * the length of the filename and the lseek offset within the scratch file * where the actual name is stored. Since there are never any deletions to this * table, fragmentation of the scratch file is never an issue. Lookups seem to * not exhibit any locality at all (files in the database are rarely * looked up more than once...). So caching is just a waste of memory. The - * only limitation is the amount of scatch file space available to store the + * only limitation is the amount of scratch file space available to store the * path names. */ diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 05e8be57ee55..4ee2786a8082 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -291,7 +291,7 @@ tar_chksm(char *blk, int len) /* * tar_id() * determine if a block given to us is a valid tar header (and not a USTAR - * header). We have to be on the lookout for those pesky blocks of all + * header). We have to be on the lookout for those pesky blocks of all * zero's. * Return: * 0 if a tar header, -1 otherwise From bf2fe08eeaf4de76fe97e7510e24c894b87ec902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Sun, 22 May 2011 14:03:46 +0000 Subject: [PATCH 140/200] Fix some typos under bin/ Found by: codespell --- bin/ed/POSIX | 4 ++-- bin/ps/ps.c | 2 +- bin/sh/mkinit.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ed/POSIX b/bin/ed/POSIX index f81bb0ce1a14..dab1a2bc90f3 100644 --- a/bin/ed/POSIX +++ b/bin/ed/POSIX @@ -75,7 +75,7 @@ DEVIATIONS 2) Since the behavior of `u' (undo) within a `g' (global) command list is not specified by POSIX, it follows the behavior of the SunOS ed: undo forces a global command list to be executed only once, rather than - for each line matching a global pattern. In addtion, each instance of + for each line matching a global pattern. In addition, each instance of `u' within a global command undoes all previous commands (including undo's) in the command list. This seems the best way, since the alternatives are either too complicated to implement or too confusing @@ -83,7 +83,7 @@ DEVIATIONS The global/undo combination is useful for masking errors that would otherwise cause a script to fail. For instance, an ed script - to remove any occurences of either `censor1' or `censor2' might be + to remove any occurrences of either `censor1' or `censor2' might be written as: ed - file < Date: Sun, 22 May 2011 14:23:48 +0000 Subject: [PATCH 141/200] Fix more typos to be a good example. Found by: codespell --- share/examples/diskless/README.TEMPLATING | 8 +- share/examples/drivers/make_device_driver.sh | 2 +- share/examples/netgraph/ether.bridge | 2 +- share/examples/netgraph/frame_relay | 10 +- share/examples/netgraph/ngctl | 4 +- share/examples/netgraph/raw | 2 +- share/examples/netgraph/virtual.chain | 125 +++++++++--------- share/examples/netgraph/virtual.lan | 129 +++++++++---------- 8 files changed, 139 insertions(+), 143 deletions(-) diff --git a/share/examples/diskless/README.TEMPLATING b/share/examples/diskless/README.TEMPLATING index b094267ceb26..28edcaed379a 100644 --- a/share/examples/diskless/README.TEMPLATING +++ b/share/examples/diskless/README.TEMPLATING @@ -136,7 +136,7 @@ be useful to set up clients and server for diskless boot. should never be overwritten by the templating copy. - TYPICAL CUSTOMIZED CONFIGRATION SOFTLINKS + TYPICAL CUSTOMIZED CONFIGURATION SOFTLINKS The following files typically need to be turned into softlinks to /conf/ME/: @@ -261,9 +261,9 @@ be useful to set up clients and server for diskless boot. identity.pub WHEN INITIALLY CONVERTING A TARGET MACHINE TO USE TEMPLATING, ALWAYS - MAKE A FULL BACKUP OF THE TARGET MACHINE FIRST! You may accidently delete - files on the target during the conversion due to forgetting to enter - items into appropriate .cpignore files on the source. + MAKE A FULL BACKUP OF THE TARGET MACHINE FIRST! You may accidentally + delete files on the target during the conversion due to forgetting to + enter items into appropriate .cpignore files on the source. SECURITY CONSIDERATIONS WITH NFS ROOT EXPORT FROM TEMPLATE MACHINE SECURITY CONSIDERATIONS WITH NFS USR EXPORT FROM TEMPLATE MACHINE diff --git a/share/examples/drivers/make_device_driver.sh b/share/examples/drivers/make_device_driver.sh index 2acea33d57b7..d7b925937407 100755 --- a/share/examples/drivers/make_device_driver.sh +++ b/share/examples/drivers/make_device_driver.sh @@ -485,7 +485,7 @@ ${1}_isa_probe (device_t device) /*rid*/0, membase, memsize); /* * We found one, return non-positive numbers.. - * Return -N if we cant handle it, but not well. + * Return -N if we can't handle it, but not well. * Return -2 if we would LIKE the device. * Return -1 if we want it a lot. * Return 0 if we MUST get the device. diff --git a/share/examples/netgraph/ether.bridge b/share/examples/netgraph/ether.bridge index 754e7602a5f2..1e405f29a108 100644 --- a/share/examples/netgraph/ether.bridge +++ b/share/examples/netgraph/ether.bridge @@ -40,7 +40,7 @@ BRIDGE_NAME="bnet0" # machine as well then set ${LOCAL_IFACES} as well (they may also be # listed in ${BRIDGE_IFACES}). Of course, any ${LOCAL_IFACE} must # be ifconfig(8)ured separately. If you don't want a ${LOCAL_IFACE} -# then assign it the emtpy string. +# then assign it the empty string. BRIDGE_IFACES="de0 fxp0 fxp1" LOCAL_IFACES="fxp0 fxp1" diff --git a/share/examples/netgraph/frame_relay b/share/examples/netgraph/frame_relay index 0becb471c810..53f643f2b86d 100644 --- a/share/examples/netgraph/frame_relay +++ b/share/examples/netgraph/frame_relay @@ -13,13 +13,13 @@ ngctl mkpeer ${CARD}: frame_relay rawdata downstream # Link management protocol node. ngctl mkpeer ${CARD}:rawdata lmi dlci0 auto0 -# Also attach dlci 1023, as it needs both to try autoconfiguring. +# Also attach dlci 1023, as it needs both to try auto-configuring. # The Link management protocol is now alive and probing.. ngctl connect ${CARD}:rawdata ${CARD}:rawdata.dlci0 dlci1023 auto1023 # Attach the DLCI(channel) the Telco has assigned you to -# a node to hadle whatever protocol encapsulation your peer -# is using. In this case rfc1490 encapsulation. +# a node to handle whatever protocol encapsulation your peer +# is using. In this case RFC1490 encapsulation. ngctl mkpeer ${CARD}:rawdata rfc1490 dlci${DLCI} downstream @@ -34,8 +34,8 @@ ngctl mkpeer ${CARD}:rawdata.dlci${DLCI} iface inet inet # Then use ifconfig on interface ng0 as usual # A variant on this whole set might use the 'name' command to make it more -# readable. but it doesn't work if you have multiple lines or dlcis -# e.g. +# readable. But it doesn't work if you have multiple lines or dlcis +# e.g. # ngctl mkpeer ${CARD}: frame_relay rawdata downstream # ngctl name ${CARD}:rawdata mux # ngctl mkpeer mux: lmi dlci0 auto0 diff --git a/share/examples/netgraph/ngctl b/share/examples/netgraph/ngctl index 80a7f22d13fd..e7b7cd86b04f 100644 --- a/share/examples/netgraph/ngctl +++ b/share/examples/netgraph/ngctl @@ -46,7 +46,7 @@ # Note that we used ngctl's ``name'' command to do this. However, # the following manually constructed netgraph message would have -# acomplished the exact same thing: +# accomplished the exact same thing: + msg foo name { name="fred" } @@ -85,7 +85,7 @@ # As soon as we sent the message, we got back a response. Here # ngctl is telling us that it received a control message with the -# NGF_RESP (response) flag set, the reponse was to a prior ``getname'' +# NGF_RESP (response) flag set, the response was to a prior ``getname'' # control message, that the originator was the node addressable # as ``fred:''. The message arguments field is then displayed to # us in its ASCII form. In this case, what we get back is a struct diff --git a/share/examples/netgraph/raw b/share/examples/netgraph/raw index e0970f3c0b33..6dc39ca4ad7a 100644 --- a/share/examples/netgraph/raw +++ b/share/examples/netgraph/raw @@ -6,7 +6,7 @@ CARD=sr0 # create an interface "ng0" and attach it to the sync port. -# The packets had jolly well better be ip because we are not discriminating. +# The packets had jolly well better be IP because we are not discriminating. ngctl mkpeer ${CARD}: iface rawdata inet # if ng0 already exists, use a CONNECT command instead of a mkpeer. e.g. diff --git a/share/examples/netgraph/virtual.chain b/share/examples/netgraph/virtual.chain index 73a12d61072c..bc6b854e3284 100644 --- a/share/examples/netgraph/virtual.chain +++ b/share/examples/netgraph/virtual.chain @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2010, Yavuz Gokirmak +# Copyright (c) 2010, Yavuz Gokirmak # # All rights reserved. # @@ -14,7 +14,6 @@ # # $FreeBSD$ # -# # This script creates and connects n router like nodes. Complex wide # area topologies can be created with the help of script. # @@ -25,9 +24,9 @@ # # 0. Make your own copy of this example script. # -# 1. Edit the definition of ${TARGET_TOPOLOGY} to define your virtual +# 1. Edit the definition of ${TARGET_TOPOLOGY} to define your virtual # nodes. Virtual topology definition includes node names and their -# IP address. Target top. sytax: ( name|ip<->name|ip ... ) +# IP address. Target top. syntax: ( name|ip<->name|ip ... ) # Example 1: ( n1|10.0.2.1/30<->n2|10.0.2.2/30 ...) # Example 2: ( n1|2001:b90::14a/125<->n1|2001:b90::14b/125 ...) # @@ -35,21 +34,21 @@ # # 3. Add necessary static route commands for each virtual node. For # example assume you have three virtual nodes connected each other -# llike a chain ( n1 is connected to n2, n2 is connecte to n3 ). -# In order to estabklish connectivity among these virtual nodes, +# like a chain (n1 is connected to n2, n2 is connected to n3). +# In order to establish connectivity among these virtual nodes, # you have to add default routes to node n1 and node n3. Example # static route command is: -# STATIC_ROUTE0="jexec n1 route add -inet default 10.0.2.2" -# STATIC_ROUTE1="jexec n3 route add -inet default 10.0.2.5" -# After defining default routes with above format you have to set +# STATIC_ROUTE0="jexec n1 route add -inet default 10.0.2.2" +# STATIC_ROUTE1="jexec n3 route add -inet default 10.0.2.5" +# After defining default routes with above format you have to set # the total number of static route commands as: # STATIC_ROUTE_CNT=2 # # 4. Stop bridging by running this script with "stop" as the # command line argument. -# -# 5. This cript uses a template file in order to carry information -# between start and stop calls. +# +# 5. This script uses a template file in order to carry information +# between start and stop calls. # In the start call, the netgraph interfaces and jails are created. # At the stop phase, all created objects should be removed. # DO NOT delete the temporary file between the start and stop phases. @@ -84,8 +83,8 @@ # # -# List the names of virtual nodes and their IP addresses. Use ':' -# character to seperate node name from node IP address and netmask. +# List the names of virtual nodes and their IP addresses. Use ':' +# character to separate node name from node IP address and netmask. TARGET_TOPOLOGY="n1|10.0.2.1/30<->n2|10.0.2.2/30 n2|10.0.2.5/30<->n3|10.0.2.6/30 n2|10.0.2.9/30<->n4|10.0.2.10/30" STATIC_ROUTE0="jexec n1 route add -inet default 10.0.2.2" @@ -93,10 +92,10 @@ STATIC_ROUTE1="jexec n3 route add -inet default 10.0.2.5" STATIC_ROUTE2="jexec n4 route add -inet default 10.0.2.9" STATIC_ROUTE_CNT=3 -# MAC manifacturer prefix. This can be modified according to needs. -MAC_PREFIX="00:1d:92" +# MAC manufacturer prefix. This can be modified according to needs. +MAC_PREFIX="00:1d:92" -# Temporary file is important for proper execution of script. +# Temporary file is important for proper execution of script. TEMP_FILE="/var/tmp/.virtual.chain.tmp" # Set root directory for jails to be created. @@ -112,7 +111,7 @@ JAIL_PATH="/usr/jails/router" virtual_chain_start() { # Load netgraph KLD's as necessary. - + for KLD in ng_ether ng_bridge ng_eiface; do if ! kldstat -v | grep -qw ${KLD}; then echo -n "Loading ${KLD}.ko... " @@ -122,21 +121,21 @@ virtual_chain_start() { done # Reset all interfaces and jails. If temporary file can not be found - # script assumes that there is no previous configuration. - + # script assumes that there is no previous configuration. + if [ ! -e ${TEMP_FILE} ]; then echo "No previous configuration(${TEMP_FILE}) found to clean-up." else echo -n "Cleaning previous configuration..." virtual_chain_stop echo "done" - fi + fi - # Create temporary file for usage. This file includes generated + # Create temporary file for usage. This file includes generated # interface names and jail names. All bridges, interfaces and jails - # are written to file while created. In clean-up process written - # objects are cleaned (i.e removed) from system. - + # are written to file while created. In clean-up process written + # objects are cleaned (i.e. removed) from system. + if [ -e ${TEMP_FILE} ]; then touch ${TEMP_FILE} fi @@ -144,40 +143,40 @@ virtual_chain_start() { # Attach other interfaces as well. for CONNECTION in ${TARGET_TOPOLOGY}; do - + # Virtual connections are defined in TARGET_TOPOLOGY variable. # They have the form of 'nodeName|IPaddr'. Below two lines split - + PEER1=`echo ${CONNECTION} | awk -F"<->" '{print $1}'` PEER1_NAME=`echo ${PEER1} | awk -F"|" '{print $1}'` PEER1_IP=`echo ${PEER1} | awk -F"|" '{print $2}'` - + PEER2=`echo ${CONNECTION} | awk -F"<->" '{print $2}'` PEER2_NAME=`echo ${PEER2} | awk -F"|" '{print $1}'` PEER2_IP=`echo ${PEER2} | awk -F"|" '{print $2}'` # !!! if not created already.. - # Create virtual node (jail) with given name and using + # Create virtual node (jail) with given name and using # JAIL_PATH as root directory for jail. virtual_chain_create_peer_if_necessary ${PEER1_NAME} virtual_chain_create_peer_if_necessary ${PEER2_NAME} # create an interface for peer with the given peer IP. Get interface - # for future use; you will connect this interface to the other + # for future use; you will connect this interface to the other # peers' (PEER2) interface. virtual_chain_create_interface_with_ip ${PEER1_NAME} ${PEER1_IP} PEER1_INTERFACE=${RET_INTERFACE} - + # create an interface for peer with the given peer IP. Get interface - # for future use; you will connect this interface to the other + # for future use; you will connect this interface to the other # peers' (PEER2) interface. virtual_chain_create_interface_with_ip ${PEER2_NAME} ${PEER2_IP} PEER2_INTERFACE=${RET_INTERFACE} # Connect virtual interface to other interface. Syntax is : # ngctl connect INTERFACE1: INTERFACE2: ether ether. - + echo -n "Connecting ${PEER1_INTERFACE}:ether to ${PEER2_INTERFACE}:ether..." ngctl connect ${PEER1_INTERFACE}: ${PEER2_INTERFACE}: ether ether \ || exit 1 @@ -193,7 +192,7 @@ virtual_chain_start() { i=`expr $i + 1` done - echo "Virtual WAN established succesfully!" + echo "Virtual WAN established successfully!" } virtual_chain_create_interface_with_ip() { @@ -201,35 +200,35 @@ virtual_chain_create_interface_with_ip() { NODE_NAME=$1 NODE_IP=$2 - # Create a ng_eiface object for virtual node. ng_eiface + # Create a ng_eiface object for virtual node. ng_eiface # object has a hook that can be connected to one of bridge - # links. After creating interface get its automatically - # generated name for further usage. + # links. After creating interface get its automatically + # generated name for further usage. echo "Creating eiface interface for virtual node ${NODE_NAME}." ngctl mkpeer eiface ether ether EIFACE=`ngctl l | grep ngeth | tail -n 1| awk '{print $2}'` - echo "Interface ${EIFACE} is created." - + echo "Interface ${EIFACE} is created." + # Write name of the interface to temp file. Clean-up procedure # will use this name to shutdown interface. - + echo "interface ${EIFACE}" >> ${TEMP_FILE} - # Move virtual interface to virtual node. Note that Interface + # Move virtual interface to virtual node. Note that Interface # name will not be changed at the end of this movement. Moved # interface can be seen at the output of ifconfig command in # jail: 'jexec jailname ifconfig' - echo "Moving ${EIFACE} to ${NODE_NAME}" + echo "Moving ${EIFACE} to ${NODE_NAME}" ifconfig ${EIFACE} vnet ${NODE_NAME} - + # Make lo0 interface localhost. jexec ${NODE_NAME} ifconfig lo0 localhost # Generate a random mac address for virtual interface. First # three octets can be changed by user. Last three octets are - # generated randomly. + # generated randomly. M4=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ awk '{ print $1 % 256 }'` M5=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ @@ -244,16 +243,16 @@ virtual_chain_create_interface_with_ip() { echo "Setting MAC address of ${EIFACE} to '${MAC}'" jexec ${NODE_NAME} ifconfig ${EIFACE} link $MAC - # Either IPv4 or IPv6 can be used in this script. Ifconfig + # Either IPv4 or IPv6 can be used in this script. Ifconfig # IP setting syntax differs slightly for two IP versions. # For version 4 'inet' keyword is used whereas for version 6 # 'inet6' is used. Below line tries to decide which IP version - # is given and sets IPVER to 'inet' or 'inet6'. + # is given and sets IPVER to 'inet' or 'inet6'. IPVER=`echo ${NODE_IP} | awk -F"." '{ split($4,last,"/"); \ if( NF==4 && $1>0 && $1<256 && $2<256 && $3<256 && \ last[1]<256) print "inet"; else print "inet6"}'` - + # Set IP address of virtual interface in virtual node. echo "Setting IP address of ${EIFACE} to '${NODE_IP}'" jexec ${NODE_NAME} ifconfig ${EIFACE} ${IPVER} ${NODE_IP} @@ -264,23 +263,22 @@ virtual_chain_create_interface_with_ip() { virtual_chain_create_peer_if_necessary() { if ! grep -q $1 ${TEMP_FILE} ; then - - echo -n "Creating virtual node (jail) ${1}..." + + echo -n "Creating virtual node (jail) ${1}..." jail -c vnet name=${1} host.hostname=${1} \ - path=${JAIL_PATH} persist + path=${JAIL_PATH} persist jexec ${1} sysctl -w net.inet.ip.forwarding=1 jexec ${1} sysctl -w net.inet6.ip6.forwarding=1 echo "done" - - # Write name of the jail to temp file. Clean-up + + # Write name of the jail to temp file. Clean-up # procedure will use this name to remove jail. - + echo "node ${1}" >> ${TEMP_FILE} fi } - # Stop routine. virtual_chain_stop() { @@ -288,31 +286,31 @@ virtual_chain_stop() { echo "Nothing to stop! ${TEMP_FILE}: temp file not found" else - echo -n "Shutdown bridge interface.." + echo -n "Shutdown bridge interface.." OBJECTS=`cat ${TEMP_FILE} | grep bridge | awk '{print $2}'` for BRIDGE in ${OBJECTS}; do ngctl shutdown ${BRIDGE}: >/dev/null 2>&1 done echo "done" - - echo -n "Shutdown all eiface interfaces..." + + echo -n "Shutdown all eiface interfaces..." OBJECTS=`cat ${TEMP_FILE} | grep interface | awk '{print $2}'` for INTERFACE in ${OBJECTS}; do ngctl shutdown ${INTERFACE}: >/dev/null 2>&1 done echo "done" - - echo -n "Removing all jails..." + + echo -n "Removing all jails..." OBJECTS=`cat ${TEMP_FILE} | grep node | awk '{print $2}'` for NODE in ${OBJECTS}; do jail -r ${NODE} done echo "done" - - echo "Removing tempfile ${TEMP_FILE}" + + echo "Removing tempfile ${TEMP_FILE}" rm ${TEMP_FILE} fi - echo "Virtual LAN objects removed succesfully!" + echo "Virtual LAN objects removed successfully!" } @@ -324,7 +322,6 @@ virtual_chain_usage() { # Main entry point. - case $# in 1) case $1 in @@ -340,7 +337,7 @@ case $# in echo " temp file not found" else virtual_chain_stop - fi + fi ;; help) virtual_chain_usage diff --git a/share/examples/netgraph/virtual.lan b/share/examples/netgraph/virtual.lan index bce33e1f9a2f..5e6e3ac5dde8 100644 --- a/share/examples/netgraph/virtual.lan +++ b/share/examples/netgraph/virtual.lan @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2010, Yavuz Gokirmak +# Copyright (c) 2010, Yavuz Gokirmak # # All rights reserved. # @@ -13,13 +13,12 @@ # its use. # # $FreeBSD$ - # -# This script adds virtual nodes to one of the physical interfaces +# This script adds virtual nodes to one of the physical interfaces # visible on your local area network (LAN). Virtual nodes seems real -# to external observers. +# to external observers. # If traceroute is executed to one of virtual nodes, the IP -# address of the physical interface will not be seen in the output. +# address of the physical interface will not be seen in the output. # Virtual nodes are generated via jails and network connections are # established using ng_bridge(4) and ng_eiface(4) node types. # @@ -29,11 +28,11 @@ # # 1. Edit the definition of ${ETHER_INTF} as described below # to define your real interface connected to the LAN. Virtual nodes -# will placed on the same physical network as this interface. +# will placed on the same physical network as this interface. # -# 2. Edit the definition of ${TARGET_TOPOLOGY} to define your virtual +# 2. Edit the definition of ${TARGET_TOPOLOGY} to define your virtual # nodes. Virtual topology definition includes node names and their -# IP address. Target top. sytax: ( node1|ip1/24 node2|ip2/24 ... ) +# IP address. Target top. syntax: ( node1|ip1/24 node2|ip2/24 ... ) # Example 1: ( n1|122.122.122.12/24, n2|122.122.122.13/24 ...) # Example 2: ( n1|2001:b90::14a/125, n1|2001:b90::14b/125 ...) # @@ -41,9 +40,9 @@ # # 4. Stop bridging by running this script with "stop" as the # command line argument. -# -# 5. This cript uses a template file in order to carry information -# between start and stop calls. +# +# 5. This script uses a template file in order to carry information +# between start and stop calls. # In the start call, the netgraph interfaces and jails are created. # At the stop phase, all created objects should be removed. # DO NOT delete the temporary file between the start and stop phases. @@ -80,19 +79,19 @@ # # Give the name of ethernet interface. Virtual nodes will be seen as -# local neighbours of this interface. +# local neighbours of this interface. ETHER_INTF="em0" -# List the names of virtual nodes and their IP addresses. Use ':' -# character to seperate node name from node IP address and netmask. +# List the names of virtual nodes and their IP addresses. Use ':' +# character to separate node name from node IP address and netmask. TARGET_TOPOLOGY="c1|10.0.2.20/24 c2|10.0.2.21/24 c3|10.0.2.22/24" -# MAC manifacturer prefix. This can be modified according to needs. -MAC_PREFIX="00:1d:92" +# MAC manufacturer prefix. This can be modified according to needs. +MAC_PREFIX="00:1d:92" -# Temporary file is important for proper execution of script. +# Temporary file is important for proper execution of script. TEMP_FILE="/var/tmp/.virtual.lan.tmp" # Set root directory for jails to be created. @@ -108,7 +107,7 @@ JAIL_PATH="/usr/jails/node" virtual_lan_start() { # Load netgraph KLD's as necessary. - + for KLD in ng_ether ng_bridge ng_eiface; do if ! kldstat -v | grep -qw ${KLD}; then echo -n "Loading ${KLD}.ko... " @@ -118,21 +117,21 @@ virtual_lan_start() { done # Reset all interfaces and jails. If temporary file can not be found - # script assumes that there is no previous configuration. - + # script assumes that there is no previous configuration. + if [ ! -e ${TEMP_FILE} ]; then echo "No previous configuration(${TEMP_FILE}) found to clean-up." else echo -n "Cleaning previous configuration..." virtual_lan_stop echo "done" - fi + fi - # Create temporary file for usage. This file includes generated + # Create temporary file for usage. This file includes generated # interface names and jail names. All bridges, interfaces and jails - # are written to file while created. In clean-up process written - # objects are cleaned (i.e removed) from system. - + # are written to file while created. In clean-up process written + # objects are cleaned (i.e. removed) from system. + if [ -e ${TEMP_FILE} ]; then touch ${TEMP_FILE} fi @@ -150,20 +149,20 @@ virtual_lan_start() { # is used to create a name for new bridge. BRIDGE_COUNT=`ngctl l | grep bridge | wc -l | sed -e "s/ //g"` BRIDGE_NAME="bridge${BRIDGE_COUNT}" - + # Create new ng_bridge(4) node and attach it to the ethernet interface. # Connect ng_ether:lower hook to bridge:link0 when creating bridge and # connect ng_ether:upper hook to bridge:link1 after bridge name is set. - + echo "Creating bridge interface: ${BRIDGE_NAME}..." ngctl mkpeer ${ETHER_INTF}: bridge lower link0 || exit 1 ngctl name ${ETHER_INTF}:lower ${BRIDGE_NAME} || exit 1 ngctl connect ${ETHER_INTF}: ${BRIDGE_NAME}: upper link1 || exit 1 echo "Bridge ${BRIDGE_NAME} is created and ${ETHER_INTF} is connected." - + # In the above code block two hooks are connected to bridge interface, - # therefore LINKNUM is set to 2 indicating total number of connected - # hooks on the bridge interface. + # therefore LINKNUM is set to 2 indicating total number of connected + # hooks on the bridge interface. LINKNUM=2 # Write name of the bridge to temp file. Clean-up procedure will use @@ -173,7 +172,7 @@ virtual_lan_start() { # Attach other interfaces as well. for NODE in ${TARGET_TOPOLOGY}; do - + # Virtual nodes are defined in TARGET_TOPOLOGY variable. They # have the form of 'nodeName|IPaddr'. Below two lines split # node definition to get node name and node IP. @@ -181,48 +180,48 @@ virtual_lan_start() { NODE_NAME=`echo ${NODE} | awk -F"|" '{print $1}'` NODE_IP=`echo ${NODE} | awk -F"|" '{print $2}'` - # Create virtual node (jail) with given name and using + # Create virtual node (jail) with given name and using # JAIL_PATH as root directory for jail. - echo -n "Creating virtual node (jail) ${NODE_NAME}..." + echo -n "Creating virtual node (jail) ${NODE_NAME}..." jail -c vnet name=${NODE_NAME} host.hostname=${NODE_NAME} \ - path=${JAIL_PATH} persist + path=${JAIL_PATH} persist echo "done" - - # Write name of the jail to temp file. Clean-up procedure will + + # Write name of the jail to temp file. Clean-up procedure will # use this name to remove jail. - + echo "node ${NODE_NAME}" >> ${TEMP_FILE} - # Create a ng_eiface object for virtual node. ng_eiface + # Create a ng_eiface object for virtual node. ng_eiface # object has a hook that can be connected to one of bridge - # links. After creating interface get its automatically - # generated name for further usage. + # links. After creating interface get its automatically + # generated name for further usage. echo "Creating eiface interface for virtual node ${NODE_NAME}." ngctl mkpeer eiface ether ether EIFACE=`ngctl l | grep ngeth | tail -n 1| awk '{print $2}'` - echo "Interface ${EIFACE} is created." - + echo "Interface ${EIFACE} is created." + # Write name of the interface to temp file. Clean-up procedure # will use this name to shutdown interface. - + echo "interface ${EIFACE}" >> ${TEMP_FILE} - - # Move virtual interface to virtual node. Note that Interface + + # Move virtual interface to virtual node. Note that Interface # name will not be changed at the end of this movement. Moved # interface can be seen at the output of ifconfig command in # jail: 'jexec jailname ifconfig' - echo "Moving ${EIFACE} to ${NODE_NAME}" + echo "Moving ${EIFACE} to ${NODE_NAME}" ifconfig ${EIFACE} vnet ${NODE_NAME} - + # Make lo0 interface localhost. jexec ${NODE_NAME} ifconfig lo0 localhost # Generate a random mac address for virtual interface. First # three octets can be changed by user. Last three octets are - # generated randomly. + # generated randomly. M4=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ awk '{ print $1 % 256 }'` M5=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ @@ -237,35 +236,35 @@ virtual_lan_start() { echo "Setting MAC address of ${EIFACE} to '${MAC}'" jexec ${NODE_NAME} ifconfig ${EIFACE} link $MAC - # Either IPv4 or IPv6 can be used in this script. Ifconfig + # Either IPv4 or IPv6 can be used in this script. Ifconfig # IP setting syntax differs slightly for two IP versions. # For version 4 'inet' keyword is used whereas for version 6 # 'inet6' is used. Below line tries to decide which IP version - # is given and sets IPVER to 'inet' or 'inet6'. + # is given and sets IPVER to 'inet' or 'inet6'. IPVER=`echo ${NODE_IP} | awk -F"." '{ split($4,last,"/"); \ if( NF==4 && $1>0 && $1<256 && $2<256 && $3<256 && \ last[1]<256) print "inet"; else print "inet6"}'` - + # Set IP address of virtual interface in virtual node. echo "Setting IP address of ${EIFACE} to '${NODE_IP}'" jexec ${NODE_NAME} ifconfig ${EIFACE} ${IPVER} ${NODE_IP} - + # Connect virtual interface to bridge interface. Syntax is : # ngctl connect INTERFACE: BRIDGE: INTERFACE_HOOK EMPTY_LINK. # Interface has one hook named 'ether' and below line connects - # ether hook to bridge's first unconnected link. - + # ether hook to bridge's first unconnected link. + echo -n "Connecting ${EIFACE}:ether to ${BRIDGE_NAME}:link${LINKNUM}..." ngctl connect ${EIFACE}: ${BRIDGE_NAME}: ether link${LINKNUM} \ || exit 1 echo "done" # Now, bridge has one more connected link thus link count is - # incremented. + # incremented. LINKNUM=`expr ${LINKNUM} + 1` done - echo "Virtual LAN established succesfully!" + echo "Virtual LAN established successfully!" } @@ -276,31 +275,31 @@ virtual_lan_stop() { echo "Nothing to stop! ${TEMP_FILE}: temp file not found" else - echo -n "Shutdown bridge interface.." + echo -n "Shutdown bridge interface.." OBJECTS=`cat ${TEMP_FILE} | grep bridge | awk '{print $2}'` for BRIDGE in ${OBJECTS}; do ngctl shutdown ${BRIDGE}: >/dev/null 2>&1 done echo "done" - - echo -n "Shutdown all eiface interfaces..." + + echo -n "Shutdown all eiface interfaces..." OBJECTS=`cat ${TEMP_FILE} | grep interface | awk '{print $2}'` for INTERFACE in ${OBJECTS}; do ngctl shutdown ${INTERFACE}: >/dev/null 2>&1 done echo "done" - - echo -n "Removing all jails..." + + echo -n "Removing all jails..." OBJECTS=`cat ${TEMP_FILE} | grep node | awk '{print $2}'` for NODE in ${OBJECTS}; do jail -r ${NODE} done echo "done" - - echo "Removing tempfile ${TEMP_FILE}" + + echo "Removing tempfile ${TEMP_FILE}" rm ${TEMP_FILE} fi - echo "Virtual LAN objects removed succesfully!" + echo "Virtual LAN objects removed successfully!" } @@ -327,7 +326,7 @@ case $# in echo " temp file not found" else virtual_lan_stop - fi + fi ;; help) virtual_lan_usage From f3ac36e1517a200e3ef00be72f3b9456e84e6bfa Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 22 May 2011 15:24:56 +0000 Subject: [PATCH 142/200] sh: Remove obsolete token type TENDBQUOTE. This token type was related to Almquist's original version of backquotes that could not nest and fell into disuse fairly soon. --- bin/sh/mktokens | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/sh/mktokens b/bin/sh/mktokens index bdc873e44407..b85c8cb9f4ca 100644 --- a/bin/sh/mktokens +++ b/bin/sh/mktokens @@ -50,7 +50,6 @@ TPIPE 0 "|" TLP 0 "(" TRP 1 ")" TENDCASE 1 ";;" -TENDBQUOTE 1 "`" TREDIR 0 redirection TWORD 0 word TIF 0 "if" From 02003216e8c0d33bfaad500e978e407b0c1736a5 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 22 May 2011 16:32:44 +0000 Subject: [PATCH 143/200] On amd64, change clang's default triple to 'x86_64-unknown-freebsd9.0', similar to what we do for binutils. When clang's default triple starts with 'amd64-', it does not pass a proper -target-cpu option to its first stage. This can lead to problems, for example when structs are memcpy'd, and clang erroneously assumes they are 16-byte aligned. It will then use the 'movaps' SSE instruction to implement the copy, which results in a bus error if the struct is really 8-byte aligned. I encountered this issue when gcc's /usr/libexec/cc1 started crashing with SIGBUS, after rebuilding world with clang ToT, but it also affects the version of clang that we have in the tree. We were just lucky until now, apparently. :) --- lib/clang/clang.build.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk index da5345502547..f443f1d504d3 100644 --- a/lib/clang/clang.build.mk +++ b/lib/clang/clang.build.mk @@ -15,7 +15,7 @@ CFLAGS+= -O1 TARGET_ARCH?= ${MACHINE_ARCH} # XXX: 8.0, to keep __FreeBSD_cc_version happy -CFLAGS+=-DLLVM_HOSTTRIPLE=\"${TARGET_ARCH}-undermydesk-freebsd9.0\" +CFLAGS+=-DLLVM_HOSTTRIPLE=\"${TARGET_ARCH:C/amd64/x86_64/}-unknown-freebsd9.0\" .ifndef LLVM_REQUIRES_EH CXXFLAGS+=-fno-exceptions From 8cd02d00bed3ba8b41166373cb3bf426e3dcdd43 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 22 May 2011 17:46:16 +0000 Subject: [PATCH 144/200] Correct an error in r222163. Unless UMA_MD_SMALL_ALLOC is defined, startup_alloc() must be used until uma_startup2() is called. Reported by: jh --- sys/vm/uma_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index f96954700612..8da5b8eea508 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -1318,9 +1318,13 @@ keg_ctor(void *mem, int size, void *udata, int flags) #ifdef UMA_MD_SMALL_ALLOC keg->uk_allocf = uma_small_alloc; keg->uk_freef = uma_small_free; -#endif + if (booted < UMA_STARTUP) keg->uk_allocf = startup_alloc; +#else + if (booted < UMA_STARTUP2) + keg->uk_allocf = startup_alloc; +#endif } else if (booted < UMA_STARTUP2 && (keg->uk_flags & UMA_ZFLAG_INTERNAL)) keg->uk_allocf = startup_alloc; From d380e0d209c19deb927cc831e2a067bcaa430e4d Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 22 May 2011 18:01:52 +0000 Subject: [PATCH 145/200] Start to usher INSTALL_NODEBUG hack out the door. Add new WITH{OUT,}_KERNEL_SYMBOLS (defaulting to WITH). In the fullness of time, likely around 2020, INSTALL_NODEBUG will be removed. For now, don't print a warning when using INSTALL_NODEBUG, but that will be coming soon. --- share/mk/bsd.own.mk | 1 + sys/conf/kern.post.mk | 4 ++-- sys/conf/kmod.mk | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 3669fac9e416..f7ab5f8703ec 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -335,6 +335,7 @@ __DEFAULT_YES_OPTIONS = \ IPX \ JAIL \ KERBEROS \ + KERNEL_SYMBOLS \ KVM \ LEGACY_CONSOLE \ LIB32 \ diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 80b1bc291e6f..df5a71752387 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -227,7 +227,7 @@ kernel-install: .endif mkdir -p ${DESTDIR}${KODIR} ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR} -.if defined(DEBUG) && !defined(INSTALL_NODEBUG) +.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} == "yes" ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR} .endif .if defined(KERNEL_EXTRA_INSTALL) @@ -239,7 +239,7 @@ kernel-install: kernel-reinstall: @-chflags -R noschg ${DESTDIR}${KODIR} ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR} -.if defined(DEBUG) && !defined(INSTALL_NODEBUG) +.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} == "yes" ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR} .endif diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 6d22e410d337..954db30a13e1 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -286,7 +286,7 @@ realinstall: _kmodinstall _kmodinstall: ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR} -.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) +.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} == "yes" ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ ${_INSTALLFLAGS} ${PROG}.symbols ${DESTDIR}${KMODDIR} .endif From adcdcb73a429e1bdb389d1a8c856f92975928fdd Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 22 May 2011 18:09:51 +0000 Subject: [PATCH 146/200] Backwards compatibility hacks to allow kernels to be built via config wihtout updating world (good transition aide for -current, but also allows kernels to be built on -stable the old way too). This likely should go away around FreeBSD 10.0 or so. --- sys/conf/kern.post.mk | 6 ++++-- sys/conf/kmod.mk | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index df5a71752387..21d9572d8d50 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -227,7 +227,8 @@ kernel-install: .endif mkdir -p ${DESTDIR}${KODIR} ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR} -.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} == "yes" +.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR} .endif .if defined(KERNEL_EXTRA_INSTALL) @@ -239,7 +240,8 @@ kernel-install: kernel-reinstall: @-chflags -R noschg ${DESTDIR}${KODIR} ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR} -.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} == "yes" +.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR} .endif diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 954db30a13e1..b50fc6833fbb 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -286,7 +286,8 @@ realinstall: _kmodinstall _kmodinstall: ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR} -.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} == "yes" +.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ ${_INSTALLFLAGS} ${PROG}.symbols ${DESTDIR}${KMODDIR} .endif From 76036f2bbd48efb263ba9d7d6a9b720b99152785 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 22 May 2011 18:11:41 +0000 Subject: [PATCH 147/200] Eliminate duplicate #include's. --- sys/fs/nfsclient/nfs_clvnops.c | 1 - sys/nfsclient/nfs_vnops.c | 1 - 2 files changed, 2 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index eac9eaa4c19f..1b085821976f 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 61fcb6c5714f..bb81f6b24f3f 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include From becb5566df7e37509d7f9b32fcfa6f981bf87196 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 22 May 2011 18:12:59 +0000 Subject: [PATCH 148/200] Add documentation for WITHOUT_KERNEL_SYMBOLS --- tools/build/options/WITHOUT_KERNEL_SYMBOLS | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tools/build/options/WITHOUT_KERNEL_SYMBOLS diff --git a/tools/build/options/WITHOUT_KERNEL_SYMBOLS b/tools/build/options/WITHOUT_KERNEL_SYMBOLS new file mode 100644 index 000000000000..45fa1331fe72 --- /dev/null +++ b/tools/build/options/WITHOUT_KERNEL_SYMBOLS @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to not install kernel symbol files. +This option is recommended for those people who have small root partitions. + From 3a58f40e09cde18c5efa14a50526de7c2803a84f Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 22 May 2011 18:23:17 +0000 Subject: [PATCH 149/200] Add the description properly... --- tools/build/options/WITHOUT_KERNEL_SYMBOLS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/build/options/WITHOUT_KERNEL_SYMBOLS b/tools/build/options/WITHOUT_KERNEL_SYMBOLS index 45fa1331fe72..e2b3926a6e46 100644 --- a/tools/build/options/WITHOUT_KERNEL_SYMBOLS +++ b/tools/build/options/WITHOUT_KERNEL_SYMBOLS @@ -1,4 +1,5 @@ .\" $FreeBSD$ Set to not install kernel symbol files. +.Bf -symbolic This option is recommended for those people who have small root partitions. - +.Ef From 8664930d011040a7b2dfdccfa9717ffdd25955f6 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 22 May 2011 18:34:11 +0000 Subject: [PATCH 150/200] regen --- share/man/man5/src.conf.5 | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index acae4c03fc82..f0b990599d7e 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 221733 2011-05-10 13:01:11Z ru .\" $FreeBSD$ -.Dd May 17, 2011 +.Dd May 22, 2011 .Dt SRC.CONF 5 .Os .Sh NAME @@ -206,6 +206,14 @@ and .\" from FreeBSD: head/tools/build/options/WITH_BIND_XML 193280 2009-06-01 21:58:59Z dougb Set to enable the http statistics interface for named. This requires ports/textproc/libxml2 to be installed in /usr/local. +.It Va WITHOUT_BINUTILS +.\" from FreeBSD: head/tools/build/options/WITHOUT_BINUTILS 222090 2011-05-19 05:13:25Z imp +Set to not install binutils (as, c++-filt, gconv, gnu-ar, gnu-randlib, +ld, nm, objcopy, objdump, readelf, size and strip) +.Bf -symbolic +The option does not generally work for build targets, unless some alternative +toolchain is enabled. +.Ef .It Va WITHOUT_BLUETOOTH .\" from FreeBSD: head/tools/build/options/WITHOUT_BLUETOOTH 156932 2006-03-21 07:50:50Z ru Set to not build Bluetooth related kernel modules, programs and libraries. @@ -364,6 +372,13 @@ Set to not build .It Va WITHOUT_GAMES .\" from FreeBSD: head/tools/build/options/WITHOUT_GAMES 156932 2006-03-21 07:50:50Z ru Set to not build games. +.It Va WITHOUT_GCC +.\" from FreeBSD: head/tools/build/options/WITHOUT_GCC 222090 2011-05-19 05:13:25Z imp +Set to not install gcc and g++. +.Bf -symbolic +The option does not generally work for build targets, unless some alternative +toolchain is enabled. +.Ef .It Va WITHOUT_GCOV .\" from FreeBSD: head/tools/build/options/WITHOUT_GCOV 156932 2006-03-21 07:50:50Z ru Set to not build the @@ -512,6 +527,12 @@ Set to build some programs without Kerberos support, like .Xr sshd 8 , and .Xr telnetd 8 . +.It Va WITHOUT_KERNEL_SYMBOLS +.\" from FreeBSD: head/tools/build/options/WITHOUT_KERNEL_SYMBOLS 222189 2011-05-22 18:23:17Z imp +Set to not install kernel symbol files. +.Bf -symbolic +This option is recommended for those people who have small root partitions. +.Ef .It Va WITHOUT_KVM .\" from FreeBSD: head/tools/build/options/WITHOUT_KVM 174550 2007-12-12 16:43:17Z ru Set to not build the @@ -884,8 +905,12 @@ When set, it also enforces the following options: .Pp .Bl -item -compact .It +.Va WITHOUT_BINUTILS +.It .Va WITHOUT_CLANG .It +.Va WITHOUT_GCC +.It .Va WITHOUT_GDB .El .It Va WITHOUT_USB From df73c41ac24fa762636d87ca899833af0636c1ca Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 22 May 2011 19:56:14 +0000 Subject: [PATCH 151/200] Add analogs to the -chrp-boot and -prep-boot options to mkisofs. --- usr.sbin/makefs/cd9660.c | 3 + usr.sbin/makefs/cd9660.h | 1 + usr.sbin/makefs/cd9660/cd9660_eltorito.c | 85 +++++++++++++++++++++--- usr.sbin/makefs/makefs.8 | 3 + 4 files changed, 82 insertions(+), 10 deletions(-) diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c index bed764f79e25..59b9ef41b3de 100644 --- a/usr.sbin/makefs/cd9660.c +++ b/usr.sbin/makefs/cd9660.c @@ -207,6 +207,7 @@ cd9660_set_defaults(void) diskStructure.rr_moved_dir = 0; diskStructure.archimedes_enabled = 0; + diskStructure.chrp_boot = 0; diskStructure.include_padding_areas = 1; @@ -391,6 +392,8 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts) diskStructure.rock_ridge_enabled = 1; else if (CD9660_IS_COMMAND_ARG_DUAL(var, "A", "archimedes")) diskStructure.archimedes_enabled = 1; + else if (CD9660_IS_COMMAND_ARG(var, "chrp-boot")) + diskStructure.chrp_boot = 1; else if (CD9660_IS_COMMAND_ARG_DUAL(var, "K", "keep-bad-images")) diskStructure.keep_bad_images = 1; else if (CD9660_IS_COMMAND_ARG(var, "allow-deep-trees")) diff --git a/usr.sbin/makefs/cd9660.h b/usr.sbin/makefs/cd9660.h index 16c0d6415d63..79f0a9d0c1ae 100644 --- a/usr.sbin/makefs/cd9660.h +++ b/usr.sbin/makefs/cd9660.h @@ -285,6 +285,7 @@ typedef struct _iso9660_disk { cd9660node *rr_moved_dir; int archimedes_enabled; + int chrp_boot; /* Spec breaking options */ u_char allow_deep_trees; diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c index 09aa3a5610a0..2f45e9d5176d 100644 --- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c +++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c @@ -32,7 +32,7 @@ * OF SUCH DAMAGE. */ -#include +#include #include "cd9660.h" #include "cd9660_eltorito.h" @@ -500,28 +500,63 @@ cd9660_setup_boot_volume_descriptor(volume_descriptor *bvd) return 1; } +static int +cd9660_write_mbr_partition_entry(FILE *fd, int index, off_t sector_start, + off_t nsectors, int type) +{ + uint8_t val; + uint32_t lba; + + fseeko(fd, (off_t)(index) * 16 + 0x1be, SEEK_SET); + + val = 0x80; /* Bootable */ + fwrite(&val, sizeof(val), 1, fd); + + val = 0xff; /* CHS begin */ + fwrite(&val, sizeof(val), 1, fd); + fwrite(&val, sizeof(val), 1, fd); + fwrite(&val, sizeof(val), 1, fd); + + val = type; /* Part type */ + fwrite(&val, sizeof(val), 1, fd); + + val = 0xff; /* CHS end */ + fwrite(&val, sizeof(val), 1, fd); + fwrite(&val, sizeof(val), 1, fd); + fwrite(&val, sizeof(val), 1, fd); + + /* LBA extent */ + lba = htole32(sector_start); + fwrite(&lba, sizeof(lba), 1, fd); + lba = htole32(nsectors); + fwrite(&lba, sizeof(lba), 1, fd); + + return (0); +} + static int cd9660_write_apm_partition_entry(FILE *fd, int index, int total_partitions, off_t sector_start, off_t nsectors, off_t sector_size, - const char *part_name, const char *part_type) { + const char *part_name, const char *part_type) +{ uint32_t apm32; uint16_t apm16; fseeko(fd, (off_t)(index + 1) * sector_size, SEEK_SET); /* Signature */ - apm16 = htons(0x504d); + apm16 = htobe16(0x504d); fwrite(&apm16, sizeof(apm16), 1, fd); apm16 = 0; fwrite(&apm16, sizeof(apm16), 1, fd); /* Total number of partitions */ - apm32 = htonl(total_partitions); + apm32 = htobe32(total_partitions); fwrite(&apm32, sizeof(apm32), 1, fd); /* Bounds */ - apm32 = htonl(sector_start); + apm32 = htobe32(sector_start); fwrite(&apm32, sizeof(apm32), 1, fd); - apm32 = htonl(nsectors); + apm32 = htobe32(nsectors); fwrite(&apm32, sizeof(apm32), 1, fd); fwrite(part_name, strlen(part_name) + 1, 1, fd); @@ -537,6 +572,7 @@ cd9660_write_boot(FILE *fd) struct boot_catalog_entry *e; struct cd9660_boot_image *t; int apm_partitions = 0; + int mbr_partitions = 0; /* write boot catalog */ if (fseeko(fd, (off_t)diskStructure.boot_catalog_sector * @@ -571,6 +607,35 @@ cd9660_write_boot(FILE *fd) if (t->system == ET_SYS_MAC) apm_partitions++; + if (t->system == ET_SYS_PPC) + mbr_partitions++; + } + + /* some systems need partition tables as well */ + if (mbr_partitions > 0 || diskStructure.chrp_boot) { + uint16_t sig; + + fseek(fd, 0x1fe, SEEK_SET); + sig = htole16(0xaa55); + fwrite(&sig, sizeof(sig), 1, fd); + + mbr_partitions = 0; + + /* Write ISO9660 descriptor, enclosing the whole disk */ + if (diskStructure.chrp_boot) + cd9660_write_mbr_partition_entry(fd, mbr_partitions++, + 0, diskStructure.totalSectors * + (diskStructure.sectorSize / 512), 0x96); + + /* Write all partition entries */ + TAILQ_FOREACH(t, &diskStructure.boot_images, image_list) { + if (t->system != ET_SYS_PPC) + continue; + cd9660_write_mbr_partition_entry(fd, mbr_partitions++, + t->sector * (diskStructure.sectorSize / 512), + t->num_sectors * (diskStructure.sectorSize / 512), + 0x41 /* PReP Boot */); + } } if (apm_partitions > 0) { @@ -580,17 +645,17 @@ cd9660_write_boot(FILE *fd) int total_parts; fseek(fd, 0, SEEK_SET); - apm16 = htons(0x4552); + apm16 = htobe16(0x4552); fwrite(&apm16, sizeof(apm16), 1, fd); /* Device block size */ - apm16 = htons(512); + apm16 = htobe16(512); fwrite(&apm16, sizeof(apm16), 1, fd); /* Device block count */ - apm32 = htonl(diskStructure.totalSectors * + apm32 = htobe32(diskStructure.totalSectors * (diskStructure.sectorSize / 512)); fwrite(&apm32, sizeof(apm32), 1, fd); /* Device type/id */ - apm16 = htons(1); + apm16 = htobe16(1); fwrite(&apm16, sizeof(apm16), 1, fd); fwrite(&apm16, sizeof(apm16), 1, fd); diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8 index 974477c74f98..b9fb10e1acef 100644 --- a/usr.sbin/makefs/makefs.8 +++ b/usr.sbin/makefs/makefs.8 @@ -285,6 +285,9 @@ Use the extension to encode .Tn RISC OS metadata. +.It Sy chrp-boot +Write an MBR partition table to the image to allow older CHRP hardware to +boot. .It Sy boot-load-segment Set load segment for the boot image. .It Sy bootimage From dbed8d1fc8e586b13286a2aa167fdb3a6b9fc2ae Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Sun, 22 May 2011 20:39:07 +0000 Subject: [PATCH 152/200] Fix the ufs/ffs file system so that it uses the lock flags argument added to VFS_FHTOVP() by r222167. Reviewed by: mckusick --- sys/ufs/ufs/ufs_vfsops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index b71fc169a366..74a863a0bc8f 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -218,7 +218,7 @@ ufs_fhtovp(mp, ufhp, flags, vpp) struct vnode *nvp; int error; - error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp); + error = VFS_VGET(mp, ufhp->ufid_ino, flags, &nvp); if (error) { *vpp = NULLVP; return (error); From dc6dc1f573171c3921abe1aa900da3d7f0652365 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Sun, 22 May 2011 20:55:54 +0000 Subject: [PATCH 153/200] Merge r221614,221696,221737,221840 from largeSMP project branch: Rewrite atomic operations for powerpc in order to achieve the following: - Produce a type-clean implementation (in terms of functions arguments and returned values) for the primitives. - Fix errors with _long() atomics where they ended up with the wrong arguments to be accepted. - Follow the sys/type.h specifics that define the numbered types starting from standard C types. - Let _ptr() version to not auto-magically cast arguments, but leave the burden on callers, as _ptr() atomic is intended to be used relatively rarely. Fix cfi in order to support the latest point. In collabouration with: bde Tested by: andreast, nwhitehorn, jceel MFC after: 2 weeks --- sys/dev/cfi/cfi_dev.c | 3 +- sys/powerpc/include/atomic.h | 536 ++++++++++++++++++----------------- 2 files changed, 272 insertions(+), 267 deletions(-) diff --git a/sys/dev/cfi/cfi_dev.c b/sys/dev/cfi/cfi_dev.c index d6357531ab8f..9b232bd064ea 100644 --- a/sys/dev/cfi/cfi_dev.c +++ b/sys/dev/cfi/cfi_dev.c @@ -145,7 +145,8 @@ cfi_devopen(struct cdev *dev, int oflags, int devtype, struct thread *td) sc = dev->si_drv1; /* We allow only 1 open. */ - if (!atomic_cmpset_acq_ptr(&sc->sc_opened, NULL, td->td_proc)) + if (!atomic_cmpset_acq_ptr((uintptr_t *)&sc->sc_opened, + (uintptr_t)NULL, (uintptr_t)td->td_proc)) return (EBUSY); return (0); } diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h index c3dc3cc58afc..77f573233401 100644 --- a/sys/powerpc/include/atomic.h +++ b/sys/powerpc/include/atomic.h @@ -48,13 +48,7 @@ * { *p += v; } */ -#define __ATOMIC_ADD_8(p, v, t) \ - 8-bit atomic_add not implemented - -#define __ATOMIC_ADD_16(p, v, t) \ - 16-bit atomic_add not implemented - -#define __ATOMIC_ADD_32(p, v, t) \ +#define __atomic_add_int(p, v, t) \ __asm __volatile( \ "1: lwarx %0, 0, %2\n" \ " add %0, %3, %0\n" \ @@ -63,10 +57,10 @@ : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_ADD_32 */ + /* __atomic_add_int */ #ifdef __powerpc64__ -#define __ATOMIC_ADD_64(p, v, t) \ +#define __atomic_add_long(p, v, t) \ __asm __volatile( \ "1: ldarx %0, 0, %2\n" \ " add %0, %3, %0\n" \ @@ -75,69 +69,72 @@ : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_ADD_64 */ + /* __atomic_add_long */ #else -#define __ATOMIC_ADD_64(p, v, t) \ - 64-bit atomic_add not implemented +#define __atomic_add_long(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " add %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cc", "memory") \ + /* __atomic_add_long */ #endif -#define _ATOMIC_ADD(width, suffix, type) \ +#define _ATOMIC_ADD(type) \ static __inline void \ - atomic_add_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_ADD_##width(p, v, t); \ + atomic_add_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_add_##type(p, v, t); \ } \ \ static __inline void \ - atomic_add_acq_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_ADD_##width(p, v, t); \ + atomic_add_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_add_##type(p, v, t); \ __ATOMIC_BARRIER; \ } \ \ static __inline void \ - atomic_add_rel_##suffix(volatile type *p, type v) { \ - type t; \ + atomic_add_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ __ATOMIC_BARRIER; \ - __ATOMIC_ADD_##width(p, v, t); \ + __atomic_add_##type(p, v, t); \ } \ /* _ATOMIC_ADD */ -#if 0 -_ATOMIC_ADD(8, 8, uint8_t) -_ATOMIC_ADD(8, char, u_char) -_ATOMIC_ADD(16, 16, uint16_t) -_ATOMIC_ADD(16, short, u_short) -#endif -_ATOMIC_ADD(32, 32, uint32_t) -_ATOMIC_ADD(32, int, u_int) -#ifdef __powerpc64__ -_ATOMIC_ADD(64, 64, uint64_t) -_ATOMIC_ADD(64, long, u_long) -_ATOMIC_ADD(64, ptr, uintptr_t) -#else -_ATOMIC_ADD(32, long, u_long) -_ATOMIC_ADD(32, ptr, uintptr_t) -#endif +_ATOMIC_ADD(int) +_ATOMIC_ADD(long) +#define atomic_add_32 atomic_add_int +#define atomic_add_acq_32 atomic_add_acq_int +#define atomic_add_rel_32 atomic_add_rel_int + +#ifdef __powerpc64__ +#define atomic_add_64 atomic_add_long +#define atomic_add_acq_64 atomic_add_acq_long +#define atomic_add_rel_64 atomic_add_rel_long + +#define atomic_add_ptr atomic_add_long +#define atomic_add_acq_ptr atomic_add_acq_long +#define atomic_add_rel_ptr atomic_add_rel_long +#else +#define atomic_add_ptr atomic_add_int +#define atomic_add_acq_ptr atomic_add_acq_int +#define atomic_add_rel_ptr atomic_add_rel_int +#endif #undef _ATOMIC_ADD -#undef __ATOMIC_ADD_64 -#undef __ATOMIC_ADD_32 -#undef __ATOMIC_ADD_16 -#undef __ATOMIC_ADD_8 +#undef __atomic_add_long +#undef __atomic_add_int /* * atomic_clear(p, v) * { *p &= ~v; } */ -#define __ATOMIC_CLEAR_8(p, v, t) \ - 8-bit atomic_clear not implemented - -#define __ATOMIC_CLEAR_16(p, v, t) \ - 16-bit atomic_clear not implemented - -#define __ATOMIC_CLEAR_32(p, v, t) \ +#define __atomic_clear_int(p, v, t) \ __asm __volatile( \ "1: lwarx %0, 0, %2\n" \ " andc %0, %0, %3\n" \ @@ -146,10 +143,10 @@ _ATOMIC_ADD(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_CLEAR_32 */ + /* __atomic_clear_int */ #ifdef __powerpc64__ -#define __ATOMIC_CLEAR_64(p, v, t) \ +#define __atomic_clear_long(p, v, t) \ __asm __volatile( \ "1: ldarx %0, 0, %2\n" \ " andc %0, %0, %3\n" \ @@ -158,56 +155,66 @@ _ATOMIC_ADD(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_CLEAR_64 */ + /* __atomic_clear_long */ #else -#define __ATOMIC_CLEAR_64(p, v, t) \ - 64-bit atomic_clear not implemented +#define __atomic_clear_long(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " andc %0, %0, %3\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cc", "memory") \ + /* __atomic_clear_long */ #endif -#define _ATOMIC_CLEAR(width, suffix, type) \ +#define _ATOMIC_CLEAR(type) \ static __inline void \ - atomic_clear_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_CLEAR_##width(p, v, t); \ + atomic_clear_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_clear_##type(p, v, t); \ } \ \ static __inline void \ - atomic_clear_acq_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_CLEAR_##width(p, v, t); \ + atomic_clear_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_clear_##type(p, v, t); \ __ATOMIC_BARRIER; \ } \ \ static __inline void \ - atomic_clear_rel_##suffix(volatile type *p, type v) { \ - type t; \ + atomic_clear_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ __ATOMIC_BARRIER; \ - __ATOMIC_CLEAR_##width(p, v, t); \ + __atomic_clear_##type(p, v, t); \ } \ /* _ATOMIC_CLEAR */ -#if 0 -_ATOMIC_CLEAR(8, 8, uint8_t) -_ATOMIC_CLEAR(8, char, u_char) -_ATOMIC_CLEAR(16, 16, uint16_t) -_ATOMIC_CLEAR(16, short, u_short) -#endif -_ATOMIC_CLEAR(32, 32, uint32_t) -_ATOMIC_CLEAR(32, int, u_int) -#ifdef __powerpc64__ -_ATOMIC_CLEAR(64, 64, uint64_t) -_ATOMIC_CLEAR(64, long, u_long) -_ATOMIC_CLEAR(64, ptr, uintptr_t) -#else -_ATOMIC_CLEAR(32, long, u_long) -_ATOMIC_CLEAR(32, ptr, uintptr_t) -#endif +_ATOMIC_CLEAR(int) +_ATOMIC_CLEAR(long) + +#define atomic_clear_32 atomic_clear_int +#define atomic_clear_acq_32 atomic_clear_acq_int +#define atomic_clear_rel_32 atomic_clear_rel_int + +#ifdef __powerpc64__ +#define atomic_clear_64 atomic_clear_long +#define atomic_clear_acq_64 atomic_clear_acq_long +#define atomic_clear_rel_64 atomic_clear_rel_long + +#define atomic_clear_ptr atomic_clear_long +#define atomic_clear_acq_ptr atomic_clear_acq_long +#define atomic_clear_rel_ptr atomic_clear_rel_long +#else +#define atomic_clear_ptr atomic_clear_int +#define atomic_clear_acq_ptr atomic_clear_acq_int +#define atomic_clear_rel_ptr atomic_clear_rel_int +#endif #undef _ATOMIC_CLEAR -#undef __ATOMIC_CLEAR_64 -#undef __ATOMIC_CLEAR_32 -#undef __ATOMIC_CLEAR_16 -#undef __ATOMIC_CLEAR_8 +#undef __atomic_clear_long +#undef __atomic_clear_int /* * atomic_cmpset(p, o, n) @@ -229,13 +236,7 @@ _ATOMIC_CLEAR(32, ptr, uintptr_t) * { *p |= v; } */ -#define __ATOMIC_SET_8(p, v, t) \ - 8-bit atomic_set not implemented - -#define __ATOMIC_SET_16(p, v, t) \ - 16-bit atomic_set not implemented - -#define __ATOMIC_SET_32(p, v, t) \ +#define __atomic_set_int(p, v, t) \ __asm __volatile( \ "1: lwarx %0, 0, %2\n" \ " or %0, %3, %0\n" \ @@ -244,10 +245,10 @@ _ATOMIC_CLEAR(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_SET_32 */ + /* __atomic_set_int */ #ifdef __powerpc64__ -#define __ATOMIC_SET_64(p, v, t) \ +#define __atomic_set_long(p, v, t) \ __asm __volatile( \ "1: ldarx %0, 0, %2\n" \ " or %0, %3, %0\n" \ @@ -256,69 +257,72 @@ _ATOMIC_CLEAR(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_SET_64 */ + /* __atomic_set_long */ #else -#define __ATOMIC_SET_64(p, v, t) \ - 64-bit atomic_set not implemented +#define __atomic_set_long(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " or %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cc", "memory") \ + /* __atomic_set_long */ #endif -#define _ATOMIC_SET(width, suffix, type) \ +#define _ATOMIC_SET(type) \ static __inline void \ - atomic_set_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_SET_##width(p, v, t); \ + atomic_set_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_set_##type(p, v, t); \ } \ \ static __inline void \ - atomic_set_acq_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_SET_##width(p, v, t); \ + atomic_set_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_set_##type(p, v, t); \ __ATOMIC_BARRIER; \ } \ \ static __inline void \ - atomic_set_rel_##suffix(volatile type *p, type v) { \ - type t; \ + atomic_set_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ __ATOMIC_BARRIER; \ - __ATOMIC_SET_##width(p, v, t); \ + __atomic_set_##type(p, v, t); \ } \ /* _ATOMIC_SET */ -#if 0 -_ATOMIC_SET(8, 8, uint8_t) -_ATOMIC_SET(8, char, u_char) -_ATOMIC_SET(16, 16, uint16_t) -_ATOMIC_SET(16, short, u_short) -#endif -_ATOMIC_SET(32, 32, uint32_t) -_ATOMIC_SET(32, int, u_int) -#ifdef __powerpc64__ -_ATOMIC_SET(64, 64, uint64_t) -_ATOMIC_SET(64, long, u_long) -_ATOMIC_SET(64, ptr, uintptr_t) -#else -_ATOMIC_SET(32, long, u_long) -_ATOMIC_SET(32, ptr, uintptr_t) -#endif +_ATOMIC_SET(int) +_ATOMIC_SET(long) +#define atomic_set_32 atomic_set_int +#define atomic_set_acq_32 atomic_set_acq_int +#define atomic_set_rel_32 atomic_set_rel_int + +#ifdef __powerpc64__ +#define atomic_set_64 atomic_set_long +#define atomic_set_acq_64 atomic_set_acq_long +#define atomic_set_rel_64 atomic_set_rel_long + +#define atomic_set_ptr atomic_set_long +#define atomic_set_acq_ptr atomic_set_acq_long +#define atomic_set_rel_ptr atomic_set_rel_long +#else +#define atomic_set_ptr atomic_set_int +#define atomic_set_acq_ptr atomic_set_acq_int +#define atomic_set_rel_ptr atomic_set_rel_int +#endif #undef _ATOMIC_SET -#undef __ATOMIC_SET_64 -#undef __ATOMIC_SET_32 -#undef __ATOMIC_SET_16 -#undef __ATOMIC_SET_8 +#undef __atomic_set_long +#undef __atomic_set_int /* * atomic_subtract(p, v) * { *p -= v; } */ -#define __ATOMIC_SUBTRACT_8(p, v, t) \ - 8-bit atomic_subtract not implemented - -#define __ATOMIC_SUBTRACT_16(p, v, t) \ - 16-bit atomic_subtract not implemented - -#define __ATOMIC_SUBTRACT_32(p, v, t) \ +#define __atomic_subtract_int(p, v, t) \ __asm __volatile( \ "1: lwarx %0, 0, %2\n" \ " subf %0, %3, %0\n" \ @@ -327,10 +331,10 @@ _ATOMIC_SET(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_SUBTRACT_32 */ + /* __atomic_subtract_int */ #ifdef __powerpc64__ -#define __ATOMIC_SUBTRACT_64(p, v, t) \ +#define __atomic_subtract_long(p, v, t) \ __asm __volatile( \ "1: ldarx %0, 0, %2\n" \ " subf %0, %3, %0\n" \ @@ -339,56 +343,65 @@ _ATOMIC_SET(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_SUBTRACT_64 */ + /* __atomic_subtract_long */ #else -#define __ATOMIC_SUBTRACT_64(p, v, t) \ - 64-bit atomic_subtract not implemented +#define __atomic_subtract_long(p, v, t) \ + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " subf %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cc", "memory") \ + /* __atomic_subtract_long */ #endif -#define _ATOMIC_SUBTRACT(width, suffix, type) \ - static __inline void \ - atomic_subtract_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_SUBTRACT_##width(p, v, t); \ - } \ - \ - static __inline void \ - atomic_subtract_acq_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_SUBTRACT_##width(p, v, t); \ - __ATOMIC_BARRIER; \ - } \ - \ - static __inline void \ - atomic_subtract_rel_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_BARRIER; \ - __ATOMIC_SUBTRACT_##width(p, v, t); \ - } \ +#define _ATOMIC_SUBTRACT(type) \ + static __inline void \ + atomic_subtract_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_subtract_##type(p, v, t); \ + } \ + \ + static __inline void \ + atomic_subtract_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_subtract_##type(p, v, t); \ + __ATOMIC_BARRIER; \ + } \ + \ + static __inline void \ + atomic_subtract_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __ATOMIC_BARRIER; \ + __atomic_subtract_##type(p, v, t); \ + } \ /* _ATOMIC_SUBTRACT */ -#if 0 -_ATOMIC_SUBTRACT(8, 8, uint8_t) -_ATOMIC_SUBTRACT(8, char, u_char) -_ATOMIC_SUBTRACT(16, 16, uint16_t) -_ATOMIC_SUBTRACT(16, short, u_short) -#endif -_ATOMIC_SUBTRACT(32, 32, uint32_t) -_ATOMIC_SUBTRACT(32, int, u_int) -#ifdef __powerpc64__ -_ATOMIC_SUBTRACT(64, 64, uint64_t) -_ATOMIC_SUBTRACT(64, long, u_long) -_ATOMIC_SUBTRACT(64, ptr, uintptr_t) -#else -_ATOMIC_SUBTRACT(32, long, u_long) -_ATOMIC_SUBTRACT(32, ptr, uintptr_t) -#endif +_ATOMIC_SUBTRACT(int) +_ATOMIC_SUBTRACT(long) +#define atomic_subtract_32 atomic_subtract_int +#define atomic_subtract_acq_32 atomic_subtract_acq_int +#define atomic_subtract_rel_32 atomic_subtract_rel_int + +#ifdef __powerpc64__ +#define atomic_subtract_64 atomic_subtract_long +#define atomic_subtract_acq_64 atomic_subract_acq_long +#define atomic_subtract_rel_64 atomic_subtract_rel_long + +#define atomic_subtract_ptr atomic_subtract_long +#define atomic_subtract_acq_ptr atomic_subtract_acq_long +#define atomic_subtract_rel_ptr atomic_subtract_rel_long +#else +#define atomic_subtract_ptr atomic_subtract_int +#define atomic_subtract_acq_ptr atomic_subtract_acq_int +#define atomic_subtract_rel_ptr atomic_subtract_rel_int +#endif #undef _ATOMIC_SUBTRACT -#undef __ATOMIC_SUBTRACT_64 -#undef __ATOMIC_SUBTRACT_32 -#undef __ATOMIC_SUBTRACT_16 -#undef __ATOMIC_SUBTRACT_8 +#undef __atomic_subtract_long +#undef __atomic_subtract_int /* * atomic_store_rel(p, v) @@ -399,10 +412,10 @@ _ATOMIC_SUBTRACT(32, ptr, uintptr_t) * Old/original implementations that still need revisiting. */ -static __inline uint32_t -atomic_readandclear_32(volatile uint32_t *addr) +static __inline u_int +atomic_readandclear_int(volatile u_int *addr) { - uint32_t result,temp; + u_int result,temp; #ifdef __GNUCLIKE_ASM __asm __volatile ( @@ -420,10 +433,10 @@ atomic_readandclear_32(volatile uint32_t *addr) } #ifdef __powerpc64__ -static __inline uint64_t -atomic_readandclear_64(volatile uint64_t *addr) +static __inline u_long +atomic_readandclear_long(volatile u_long *addr) { - uint64_t result,temp; + u_long result,temp; #ifdef __GNUCLIKE_ASM __asm __volatile ( @@ -441,37 +454,27 @@ atomic_readandclear_64(volatile uint64_t *addr) } #endif -#define atomic_readandclear_int atomic_readandclear_32 +#define atomic_readandclear_32 atomic_readandclear_int #ifdef __powerpc64__ -#define atomic_readandclear_long atomic_readandclear_64 -#define atomic_readandclear_ptr atomic_readandclear_64 +#define atomic_readandclear_64 atomic_readandclear_long + +#define atomic_readandclear_ptr atomic_readandclear_long #else -#define atomic_readandclear_long atomic_readandclear_32 -#define atomic_readandclear_ptr atomic_readandclear_32 +static __inline u_long +atomic_readandclear_long(volatile u_long *addr) +{ + + return ((u_long)atomic_readandclear_int((volatile u_int *)addr)); +} + +#define atomic_readandclear_ptr atomic_readandclear_int #endif /* * We assume that a = b will do atomic loads and stores. */ -#define ATOMIC_STORE_LOAD(TYPE, WIDTH) \ -static __inline u_##TYPE \ -atomic_load_acq_##WIDTH(volatile u_##TYPE *p) \ -{ \ - u_##TYPE v; \ - \ - v = *p; \ - __ATOMIC_BARRIER; \ - return (v); \ -} \ - \ -static __inline void \ -atomic_store_rel_##WIDTH(volatile u_##TYPE *p, u_##TYPE v) \ -{ \ - __ATOMIC_BARRIER; \ - *p = v; \ -} \ - \ +#define ATOMIC_STORE_LOAD(TYPE) \ static __inline u_##TYPE \ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ { \ @@ -489,25 +492,37 @@ atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) \ *p = v; \ } -ATOMIC_STORE_LOAD(char, 8) -ATOMIC_STORE_LOAD(short, 16) -ATOMIC_STORE_LOAD(int, 32) -#ifdef __powerpc64__ -ATOMIC_STORE_LOAD(long, 64) -#endif +ATOMIC_STORE_LOAD(int) + +#define atomic_load_acq_32 atomic_load_acq_int +#define atomic_store_rel_32 atomic_store_rel_int #ifdef __powerpc64__ -#define atomic_load_acq_long atomic_load_acq_64 -#define atomic_store_rel_long atomic_store_rel_64 -#define atomic_load_acq_ptr atomic_load_acq_64 -#define atomic_store_rel_ptr atomic_store_rel_64 +ATOMIC_STORE_LOAD(long) + +#define atomic_load_acq_64 atomic_load_acq_long +#define atomic_store_rel_64 atomic_store_rel_long + +#define atomic_load_acq_ptr atomic_load_acq_long +#define atomic_store_rel_ptr atomic_store_rel_long #else -#define atomic_load_acq_long atomic_load_acq_32 -#define atomic_store_rel_long atomic_store_rel_32 -#define atomic_load_acq_ptr atomic_load_acq_32 -#define atomic_store_rel_ptr atomic_store_rel_32 -#endif +static __inline u_long +atomic_load_acq_long(volatile u_long *addr) +{ + return ((u_long)atomic_load_acq_int((volatile u_int *)addr)); +} + +static __inline void +atomic_store_rel_long(volatile u_long *addr, u_long val) +{ + + atomic_store_rel_int((volatile u_int *)addr, (u_int)val); +} + +#define atomic_load_acq_ptr atomic_load_acq_int +#define atomic_store_rel_ptr atomic_store_rel_int +#endif #undef ATOMIC_STORE_LOAD /* @@ -516,7 +531,7 @@ ATOMIC_STORE_LOAD(long, 64) * zero if the compare failed, nonzero otherwise. */ static __inline int -atomic_cmpset_32(volatile uint32_t* p, uint32_t cmpval, uint32_t newval) +atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval) { int ret; @@ -540,7 +555,6 @@ atomic_cmpset_32(volatile uint32_t* p, uint32_t cmpval, uint32_t newval) return (ret); } - static __inline int atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) { @@ -552,21 +566,21 @@ atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) "1:\tldarx %0, 0, %2\n\t" /* load old value */ "cmpld %3, %0\n\t" /* compare */ "bne 2f\n\t" /* exit if not equal */ - "stdcx. %4, 0, %2\n\t" /* attempt to store */ + "stdcx. %4, 0, %2\n\t" /* attempt to store */ #else "1:\tlwarx %0, 0, %2\n\t" /* load old value */ "cmplw %3, %0\n\t" /* compare */ "bne 2f\n\t" /* exit if not equal */ - "stwcx. %4, 0, %2\n\t" /* attempt to store */ + "stwcx. %4, 0, %2\n\t" /* attempt to store */ #endif "bne- 1b\n\t" /* spin if failed */ "li %0, 1\n\t" /* success - retval = 1 */ "b 3f\n\t" /* we've succeeded */ "2:\n\t" #ifdef __powerpc64__ - "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ #else - "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ #endif "li %0, 0\n\t" /* failure - retval = 0 */ "3:\n\t" @@ -578,31 +592,21 @@ atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) return (ret); } -#define atomic_cmpset_int atomic_cmpset_32 - -#ifdef __powerpc64__ -#define atomic_cmpset_ptr(dst, old, new) \ - atomic_cmpset_long((volatile u_long *)(dst), (u_long)(old), (u_long)(new)) -#else -#define atomic_cmpset_ptr(dst, old, new) \ - atomic_cmpset_32((volatile u_int *)(dst), (u_int)(old), (u_int)(new)) -#endif - static __inline int -atomic_cmpset_acq_32(volatile uint32_t *p, uint32_t cmpval, uint32_t newval) +atomic_cmpset_acq_int(volatile u_int *p, u_int cmpval, u_int newval) { int retval; - retval = atomic_cmpset_32(p, cmpval, newval); + retval = atomic_cmpset_int(p, cmpval, newval); __ATOMIC_BARRIER; return (retval); } static __inline int -atomic_cmpset_rel_32(volatile uint32_t *p, uint32_t cmpval, uint32_t newval) +atomic_cmpset_rel_int(volatile u_int *p, u_int cmpval, u_int newval) { __ATOMIC_BARRIER; - return (atomic_cmpset_32(p, cmpval, newval)); + return (atomic_cmpset_int(p, cmpval, newval)); } static __inline int @@ -622,39 +626,39 @@ atomic_cmpset_rel_long(volatile u_long *p, u_long cmpval, u_long newval) return (atomic_cmpset_long(p, cmpval, newval)); } -#define atomic_cmpset_acq_int atomic_cmpset_acq_32 -#define atomic_cmpset_rel_int atomic_cmpset_rel_32 +#define atomic_cmpset_32 atomic_cmpset_int +#define atomic_cmpset_acq_32 atomic_cmpset_acq_int +#define atomic_cmpset_rel_32 atomic_cmpset_rel_int #ifdef __powerpc64__ -#define atomic_cmpset_acq_ptr(dst, old, new) \ - atomic_cmpset_acq_long((volatile u_long *)(dst), (u_long)(old), (u_long)(new)) -#define atomic_cmpset_rel_ptr(dst, old, new) \ - atomic_cmpset_rel_long((volatile u_long *)(dst), (u_long)(old), (u_long)(new)) +#define atomic_cmpset_64 atomic_cmpset_long +#define atomic_cmpset_acq_64 atomic_cmpset_acq_long +#define atomic_cmpset_rel_64 atomic_cmpset_rel_long + +#define atomic_cmpset_ptr atomic_cmpset_long +#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long +#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long #else -#define atomic_cmpset_acq_ptr(dst, old, new) \ - atomic_cmpset_acq_32((volatile u_int *)(dst), (u_int)(old), (u_int)(new)) -#define atomic_cmpset_rel_ptr(dst, old, new) \ - atomic_cmpset_rel_32((volatile u_int *)(dst), (u_int)(old), (u_int)(new)) +#define atomic_cmpset_ptr atomic_cmpset_int +#define atomic_cmpset_acq_ptr atomic_cmpset_acq_int +#define atomic_cmpset_rel_ptr atomic_cmpset_rel_int #endif -static __inline uint32_t -atomic_fetchadd_32(volatile uint32_t *p, uint32_t v) +static __inline u_int +atomic_fetchadd_int(volatile u_int *p, u_int v) { - uint32_t value; + u_int value; do { value = *p; - } while (!atomic_cmpset_32(p, value, value + v)); + } while (!atomic_cmpset_int(p, value, value + v)); return (value); } -#define atomic_fetchadd_int atomic_fetchadd_32 - -#ifdef __powerpc64__ -static __inline uint64_t -atomic_fetchadd_64(volatile uint64_t *p, uint64_t v) +static __inline u_long +atomic_fetchadd_long(volatile u_long *p, u_long v) { - uint64_t value; + u_long value; do { value = *p; @@ -662,10 +666,10 @@ atomic_fetchadd_64(volatile uint64_t *p, uint64_t v) return (value); } -#define atomic_fetchadd_long atomic_fetchadd_64 -#else -#define atomic_fetchadd_long(p, v) \ - (u_long)atomic_fetchadd_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_fetchadd_32 atomic_fetchadd_int + +#ifdef __powerpc64__ +#define atomic_fetchadd_64 atomic_fetchadd_long #endif #endif /* ! _MACHINE_ATOMIC_H_ */ From 965e561750fd3f03771384de8e5d6a69305828ad Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Sun, 22 May 2011 21:04:32 +0000 Subject: [PATCH 154/200] Fix the zfs file system so that it uses the lock flags argument added to VFS_FHTOVP() by r222167. Reviewed by: pjd --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index 85e3d44d39a6..fffc181e00ca 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -2069,7 +2069,7 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) VN_HOLD(*vpp); } ZFS_EXIT(zfsvfs); - err = zfs_vnode_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); + err = zfs_vnode_lock(*vpp, flags | LK_RETRY); if (err != 0) *vpp = NULL; return (err); @@ -2096,7 +2096,7 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) *vpp = ZTOV(zp); ZFS_EXIT(zfsvfs); - err = zfs_vnode_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); + err = zfs_vnode_lock(*vpp, flags | LK_RETRY); if (err == 0) vnode_create_vobject(*vpp, zp->z_size, curthread); else From df3f1d68513cd5a89e7aab9bf6c77a84cb6f4fa4 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Sun, 22 May 2011 21:31:36 +0000 Subject: [PATCH 155/200] Merge r221901 from largeSMP project branch: Increase the size of cg_count in order to enable usage of > 127 CPUs. cg_children is also bumped in order to keep the structure naturally padded, even if this is not strictly necessary. Submitted and tested by: sbruno --- sys/sys/smp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 544cb9575f91..f8cce5f11177 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -33,8 +33,8 @@ struct cpu_group { struct cpu_group *cg_parent; /* Our parent group. */ struct cpu_group *cg_child; /* Optional children groups. */ cpumask_t cg_mask; /* Mask of cpus in this group. */ - int8_t cg_count; /* Count of cpus in this group. */ - int8_t cg_children; /* Number of children groups. */ + int32_t cg_count; /* Count of cpus in this group. */ + int16_t cg_children; /* Number of children groups. */ int8_t cg_level; /* Shared cache level. */ int8_t cg_flags; /* Traversal modifiers. */ }; From e3071102d6ba8e827465ce76132e0174258ce895 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Sun, 22 May 2011 21:35:03 +0000 Subject: [PATCH 156/200] Merge r221912 from largeSMP project branch: Fix a long-standing bug in cpuset_thread0() where only the first part of cs_mask is set full. Submitted by: anonymous MFC after: 1 week --- sys/kern/kern_cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index bf9eac79ac8e..6489ffb19e9b 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -676,7 +676,7 @@ cpuset_thread0(void) * cpuset_create() due to NULL parent. */ set = uma_zalloc(cpuset_zone, M_WAITOK | M_ZERO); - set->cs_mask.__bits[0] = -1; + CPU_FILL(&set->cs_mask); LIST_INIT(&set->cs_children); LIST_INSERT_HEAD(&cpuset_ids, set, cs_link); set->cs_ref = 1; From 7d214dd4e21a5d37e873e6eab72a7cf4d7f64382 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Sun, 22 May 2011 22:14:15 +0000 Subject: [PATCH 157/200] Fix clang compile warnings. Approved by: philip (mentor) --- contrib/gcclibs/libiberty/regex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/gcclibs/libiberty/regex.c b/contrib/gcclibs/libiberty/regex.c index fa1df197ce9d..c24026e9e461 100644 --- a/contrib/gcclibs/libiberty/regex.c +++ b/contrib/gcclibs/libiberty/regex.c @@ -149,7 +149,7 @@ char *realloc (); # include # ifndef bzero # ifndef _LIBC -# define bzero(s, n) (memset (s, '\0', n), (s)) +# define bzero(s, n) ((void) (memset (s, '\0', n), (s))) # else # define bzero(s, n) __bzero (s, n) # endif From 479718927acf9fd3fc169d06762d7258c53f65dd Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Sun, 22 May 2011 22:15:16 +0000 Subject: [PATCH 158/200] Fix clang warnings. Approved by: philip (mentor) --- contrib/binutils/binutils/objcopy.c | 3 ++- contrib/binutils/binutils/readelf.c | 2 +- contrib/binutils/binutils/strings.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/binutils/binutils/objcopy.c b/contrib/binutils/binutils/objcopy.c index 06e2946ce349..23a067616a08 100644 --- a/contrib/binutils/binutils/objcopy.c +++ b/contrib/binutils/binutils/objcopy.c @@ -1542,7 +1542,8 @@ copy_object (bfd *ibfd, bfd *obfd) /* Umm, not sure what to do in this case. */ debuglink_vma = 0x1000; - bfd_set_section_vma (obfd, gnu_debuglink_section, debuglink_vma); + (void) bfd_set_section_vma (obfd, gnu_debuglink_section, + debuglink_vma); } } diff --git a/contrib/binutils/binutils/readelf.c b/contrib/binutils/binutils/readelf.c index 59a20906acc5..a8c5ccc4d12d 100644 --- a/contrib/binutils/binutils/readelf.c +++ b/contrib/binutils/binutils/readelf.c @@ -9701,7 +9701,7 @@ process_archive (char *file_name, FILE *file) } if ((longnames_size & 1) != 0) - getc (file); + (void) getc (file); got = fread (&arhdr, 1, sizeof arhdr, file); if (got != sizeof arhdr) diff --git a/contrib/binutils/binutils/strings.c b/contrib/binutils/binutils/strings.c index 2238574bac04..386bac7c264f 100644 --- a/contrib/binutils/binutils/strings.c +++ b/contrib/binutils/binutils/strings.c @@ -593,7 +593,7 @@ print_strings (const char *filename, FILE *stream, file_off address, case 8: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7Lo ", (unsigned long long) start); + printf ("%7llo ", (unsigned long long) start); else #else # if !BFD_HOST_64BIT_LONG @@ -608,7 +608,7 @@ print_strings (const char *filename, FILE *stream, file_off address, case 10: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7Ld ", (unsigned long long) start); + printf ("%7lld ", (unsigned long long) start); else #else # if !BFD_HOST_64BIT_LONG @@ -623,7 +623,7 @@ print_strings (const char *filename, FILE *stream, file_off address, case 16: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7Lx ", (unsigned long long) start); + printf ("%7llx ", (unsigned long long) start); else #else # if !BFD_HOST_64BIT_LONG From eb838be1a5dcf1573a284fe828e672ec3cada77c Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Sun, 22 May 2011 22:15:42 +0000 Subject: [PATCH 159/200] Fix clang warnings. Approved by: philip (mentor) --- contrib/binutils/gas/read.h | 2 +- contrib/binutils/gas/write.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/binutils/gas/read.h b/contrib/binutils/gas/read.h index 6ac153b6d492..342a7e44a4f0 100644 --- a/contrib/binutils/gas/read.h +++ b/contrib/binutils/gas/read.h @@ -30,7 +30,7 @@ extern char *input_line_pointer; /* -> char we are parsing now. */ #ifdef PERMIT_WHITESPACE #define SKIP_WHITESPACE() \ - ((*input_line_pointer == ' ') ? ++input_line_pointer : 0) + do { if (*input_line_pointer == ' ') ++input_line_pointer; } while (0) #else #define SKIP_WHITESPACE() know(*input_line_pointer != ' ' ) #endif diff --git a/contrib/binutils/gas/write.c b/contrib/binutils/gas/write.c index 29ea2843857f..6b4af524b88e 100644 --- a/contrib/binutils/gas/write.c +++ b/contrib/binutils/gas/write.c @@ -345,7 +345,7 @@ record_alignment (/* Segment to which alignment pertains. */ return; if ((unsigned int) align > bfd_get_section_alignment (stdoutput, seg)) - bfd_set_section_alignment (stdoutput, seg, align); + (void) bfd_set_section_alignment (stdoutput, seg, align); } int @@ -2247,7 +2247,7 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass) newf = frag_alloc (ob); obstack_blank_fast (ob, fragP->fr_var); - obstack_finish (ob); + (void) obstack_finish (ob); memcpy (newf, fragP, SIZEOF_STRUCT_FRAG); memcpy (newf->fr_literal, fragP->fr_literal + fragP->fr_fix, From 4e85454a79e19e4813ce77d97827bc96538c0256 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Sun, 22 May 2011 22:16:19 +0000 Subject: [PATCH 160/200] Fix clang warnings. Approved by: philip (mentor) --- contrib/binutils/ld/ldlang.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/binutils/ld/ldlang.c b/contrib/binutils/ld/ldlang.c index 5c2697458bfc..191936f344ad 100644 --- a/contrib/binutils/ld/ldlang.c +++ b/contrib/binutils/ld/ldlang.c @@ -4274,9 +4274,10 @@ lang_size_sections_1 " section %s\n"), os->name); input = os->children.head->input_section.section; - bfd_set_section_vma (os->bfd_section->owner, - os->bfd_section, - bfd_section_vma (input->owner, input)); + (void) bfd_set_section_vma (os->bfd_section->owner, + os->bfd_section, + bfd_section_vma (input->owner, + input)); os->bfd_section->size = input->size; break; } @@ -4361,7 +4362,7 @@ lang_size_sections_1 os->name, (unsigned long) (newdot - savedot)); } - bfd_set_section_vma (0, os->bfd_section, newdot); + (void) bfd_set_section_vma (0, os->bfd_section, newdot); os->bfd_section->output_offset = 0; } From 104c8fc5273537fe46bdf199ef354deb6c0af9b9 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Sun, 22 May 2011 22:17:06 +0000 Subject: [PATCH 161/200] Fix clang warnings. Approved by: philip (mentor) --- contrib/gcc/combine.c | 2 +- contrib/gcc/emit-rtl.c | 11 ++++++----- contrib/gcc/function.c | 13 +++++-------- contrib/gcc/omp-low.c | 2 +- contrib/gcc/tree-cfg.c | 4 ++-- contrib/gcc/tree-vect-patterns.c | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/contrib/gcc/combine.c b/contrib/gcc/combine.c index c5655ea40380..f44b24685876 100644 --- a/contrib/gcc/combine.c +++ b/contrib/gcc/combine.c @@ -12442,7 +12442,7 @@ distribute_notes (rtx notes, rtx from_insn, rtx i3, rtx i2, rtx elim_i2, REG_N_DEATHS (REGNO (XEXP (note, 0)))++; REG_NOTES (place2) = gen_rtx_fmt_ee (GET_CODE (note), - REG_NOTE_KIND (note), + GET_MODE (note), XEXP (note, 0), REG_NOTES (place2)); } diff --git a/contrib/gcc/emit-rtl.c b/contrib/gcc/emit-rtl.c index 9607bf696536..73ce0b4b8ab7 100644 --- a/contrib/gcc/emit-rtl.c +++ b/contrib/gcc/emit-rtl.c @@ -3210,7 +3210,7 @@ try_split (rtx pat, rtx trial, int last) { if (CALL_P (insn)) REG_NOTES (insn) - = gen_rtx_EXPR_LIST (REG_NOTE_KIND (note), + = gen_rtx_EXPR_LIST (GET_MODE (note), XEXP (note, 0), REG_NOTES (insn)); insn = PREV_INSN (insn); @@ -3223,7 +3223,7 @@ try_split (rtx pat, rtx trial, int last) { if (JUMP_P (insn)) REG_NOTES (insn) - = gen_rtx_EXPR_LIST (REG_NOTE_KIND (note), + = gen_rtx_EXPR_LIST (GET_MODE (note), XEXP (note, 0), REG_NOTES (insn)); insn = PREV_INSN (insn); @@ -4589,7 +4589,8 @@ set_unique_reg_note (rtx insn, enum reg_note kind, rtx datum) return note; } - REG_NOTES (insn) = gen_rtx_EXPR_LIST (kind, datum, REG_NOTES (insn)); + REG_NOTES (insn) = gen_rtx_EXPR_LIST ((enum machine_mode) kind, datum, + REG_NOTES (insn)); return REG_NOTES (insn); } @@ -5344,12 +5345,12 @@ emit_copy_of_insn_after (rtx insn, rtx after) { if (GET_CODE (link) == EXPR_LIST) REG_NOTES (new) - = copy_insn_1 (gen_rtx_EXPR_LIST (REG_NOTE_KIND (link), + = copy_insn_1 (gen_rtx_EXPR_LIST (GET_MODE (link), XEXP (link, 0), REG_NOTES (new))); else REG_NOTES (new) - = copy_insn_1 (gen_rtx_INSN_LIST (REG_NOTE_KIND (link), + = copy_insn_1 (gen_rtx_INSN_LIST (GET_MODE (link), XEXP (link, 0), REG_NOTES (new))); } diff --git a/contrib/gcc/function.c b/contrib/gcc/function.c index 7549ec421f07..59970c4bafb4 100644 --- a/contrib/gcc/function.c +++ b/contrib/gcc/function.c @@ -4008,22 +4008,19 @@ stack_protect_epilogue (void) /* Allow the target to compare Y with X without leaking either into a register. */ - switch (HAVE_stack_protect_test != 0) + if (HAVE_stack_protect_test != 0) { - case 1: tmp = gen_stack_protect_test (x, y, label); if (tmp) { emit_insn (tmp); - break; + goto done; } - /* FALLTHRU */ - - default: - emit_cmp_and_jump_insns (x, y, EQ, NULL_RTX, ptr_mode, 1, label); - break; } + emit_cmp_and_jump_insns (x, y, EQ, NULL_RTX, ptr_mode, 1, label); + done: + /* The noreturn predictor has been moved to the tree level. The rtl-level predictors estimate this branch about 20%, which isn't enough to get things moved out of line. Since this is the only extant case of adding diff --git a/contrib/gcc/omp-low.c b/contrib/gcc/omp-low.c index 3008a1b3c8f2..49fb8c93fd7f 100644 --- a/contrib/gcc/omp-low.c +++ b/contrib/gcc/omp-low.c @@ -118,7 +118,7 @@ static tree maybe_lookup_decl_in_outer_ctx (tree, omp_context *); /* Find an OpenMP clause of type KIND within CLAUSES. */ static tree -find_omp_clause (tree clauses, enum tree_code kind) +find_omp_clause (tree clauses, enum omp_clause_code kind) { for (; clauses ; clauses = OMP_CLAUSE_CHAIN (clauses)) if (OMP_CLAUSE_CODE (clauses) == kind) diff --git a/contrib/gcc/tree-cfg.c b/contrib/gcc/tree-cfg.c index 1c855b793110..7573439c6541 100644 --- a/contrib/gcc/tree-cfg.c +++ b/contrib/gcc/tree-cfg.c @@ -2854,7 +2854,7 @@ bsi_insert_before (block_stmt_iterator *i, tree t, enum bsi_iterator_update m) { set_bb_for_stmt (t, i->bb); update_modified_stmts (t); - tsi_link_before (&i->tsi, t, m); + tsi_link_before (&i->tsi, t, (enum tsi_iterator_update) m); } @@ -2867,7 +2867,7 @@ bsi_insert_after (block_stmt_iterator *i, tree t, enum bsi_iterator_update m) { set_bb_for_stmt (t, i->bb); update_modified_stmts (t); - tsi_link_after (&i->tsi, t, m); + tsi_link_after (&i->tsi, t, (enum tsi_iterator_update) m); } diff --git a/contrib/gcc/tree-vect-patterns.c b/contrib/gcc/tree-vect-patterns.c index 1c57c59ebb9b..5907f88d2b32 100644 --- a/contrib/gcc/tree-vect-patterns.c +++ b/contrib/gcc/tree-vect-patterns.c @@ -487,7 +487,7 @@ vect_pattern_recog_1 ( } else { - enum tree_code vec_mode; + enum machine_mode vec_mode; enum insn_code icode; optab optab; From be07528c53cd0aa3a8b5f9338f55148cac709ea8 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 23 May 2011 09:02:44 +0000 Subject: [PATCH 162/200] Diff reduction against NetBSD. The most notable change is to zdiff(1) to handle more file formats including bzip2 and xz. MFC after: 2 weeks --- usr.bin/gzip/Makefile | 2 +- usr.bin/gzip/gzip.c | 9 +-- usr.bin/gzip/zdiff | 119 +++++++++++++++++++++++-------------- usr.bin/gzip/zdiff.1 | 59 ++++++++++++++---- usr.bin/gzip/zuncompress.c | 2 +- 5 files changed, 128 insertions(+), 63 deletions(-) diff --git a/usr.bin/gzip/Makefile b/usr.bin/gzip/Makefile index 048033738756..16a825f66133 100644 --- a/usr.bin/gzip/Makefile +++ b/usr.bin/gzip/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.10 2006/05/12 02:01:15 mrg Exp $ +# $NetBSD: Makefile,v 1.13 2009/04/14 22:15:20 lukem Exp $ # $FreeBSD$ .include diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c index d86e84b65407..474575caf9a0 100644 --- a/usr.bin/gzip/gzip.c +++ b/usr.bin/gzip/gzip.c @@ -1,4 +1,4 @@ -/* $NetBSD: gzip.c,v 1.97 2009/10/11 09:17:21 mrg Exp $ */ +/* $NetBSD: gzip.c,v 1.99 2011/03/23 12:59:44 tsutsui Exp $ */ /*- * Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green @@ -31,7 +31,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1997, 1998, 2003, 2004, 2006\ Matthew R. Green. All rights reserved."); -__RCSID("$FreeBSD$"); +__FBSDID("$FreeBSD$"); #endif /* not lint */ /* @@ -146,7 +146,7 @@ static suffixes_t suffixes[] = { #define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0]) #define SUFFIX_MAXLEN 30 -static const char gzip_version[] = "FreeBSD gzip 20100407"; +static const char gzip_version[] = "FreeBSD gzip 20110523"; #ifndef SMALL static const char gzip_copyright[] = \ @@ -314,7 +314,7 @@ main(int argc, char **argv) dflag = cflag = 1; #ifdef SMALL -#define OPT_LIST "123456789cdhltV" +#define OPT_LIST "123456789cdhlV" #else #define OPT_LIST "123456789acdfhklLNnqrS:tVv" #endif @@ -918,6 +918,7 @@ gz_uncompress(int in, int out, char *pre, size_t prelen, off_t *gsizep, case Z_BUF_ERROR: if (z.avail_out > 0 && !done_reading) continue; + case Z_STREAM_END: case Z_OK: break; diff --git a/usr.bin/gzip/zdiff b/usr.bin/gzip/zdiff index 34caf2bdfb83..9e9aca677e25 100644 --- a/usr.bin/gzip/zdiff +++ b/usr.bin/gzip/zdiff @@ -1,10 +1,12 @@ #!/bin/sh - # -# $NetBSD: zdiff,v 1.3 2004/03/29 10:01:00 wiz Exp $ +# $NetBSD: zdiff,v 1.5 2010/04/14 20:30:28 joerg Exp $ +# # $OpenBSD: zdiff,v 1.2 2003/07/29 07:42:44 otto Exp $ # #- # Copyright (c) 2003 Todd C. Miller +# Copyright (c) 2010 Joerg Sonnenberger # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -31,7 +33,57 @@ case $0 in *) prog=diff ;; esac -USAGE="usage: z$prog [options] file1 [file2]" +USAGE="usage: $0 [options] file1 [file2]" + +check_suffix() { + case "$1" in + *[._-][Zz]) + setvar $2 "${1%??}" + setvar $3 "gzip -cdqf" + ;; + *[._-]bz) + setvar $2 "${1%???}" + setvar $3 "bzip2 -cdqf" + ;; + *[._-]gz) + setvar $2 "${1%???}" + setvar $3 "gzip -cdqf" + ;; + *[._-]xz) + setvar $2 "${1%???}" + setvar $3 "xz -cdqf" + ;; + *[._-]bz2) + setvar $2 "${1%????}" + setvar $3 "bzip2 -cdqf" + ;; + *[._-]lzma) + setvar $2 "${1%?????}" + setvar $3 "xz -cdqf" + ;; + *.t[ag]z) + setvar $2 "${1%??}"ar + setvar $3 "gzip -cdqf" + ;; + *.tbz) + setvar $2 "${1%??}"ar + setvar $3 "bzip2 -cdqf" + ;; + *.tbz2) + setvar $2 "${1%???}"ar + setvar $3 "bzip2 -cdqf" + ;; + *.t[lx]z) + setvar $2 "${1%??}"ar + setvar $3 "xz -cdqf" + ;; + *) + setvar $2 "$1" + setvar $3 "" + ;; + esac +} + # Pull out any command line flags so we can pass them to diff/cmp # XXX - assumes there is no optarg @@ -42,6 +94,9 @@ while test $# -ne 0; do shift break ;; + -) + break + ;; -*) flags="$flags $1" shift @@ -55,52 +110,28 @@ done if [ $# -eq 1 ]; then # One file given, compare compressed to uncompressed files="$1" - case "$1" in - *[._-][Zz]) - files="${1%??}" - ;; - *[._-]gz) - files="${1%???}" - ;; - *.t[ag]z) - files="${1%??}"ar - ;; - *) echo "z$prog: unknown suffix" 1>&2 - exit 1 - esac - gzip -cdfq "$1" | $prog $flags - "$files" + check_suffix "$1" files filt + if [ -z "$filt" ]; then + echo "z$prog: unknown suffix" 1>&2 + exit 1 + fi + $filt -- "$1" | $prog $flags -- - "$files" status=$? elif [ $# -eq 2 ]; then # Two files given, compare the two uncompressing as needed - case "$1" in - *[._-][Zz]|*[._-]gz|*.t[ag]z) - files=- - filt="gzip -cdfq $1" - ;; - *) - files="$1" - ;; - esac - case "$2" in - *[._-][Zz]|*[._-]gz|*.t[ag]z) - if [ "$files" = "-" ]; then - tmp=`mktemp -t z$prog.XXXXXXXXXX` || exit 1 - trap "rm -f $tmp" 0 1 2 3 13 15 - gzip -cdfq "$2" > $tmp - files="$files $tmp" - else - files="$files -" - filt="gzip -cdfq $2" - fi - ;; - *) - files="$files $2" - ;; - esac - if [ -n "$filt" ]; then - $filt | $prog $flags $files + check_suffix "$1" files filt + check_suffix "$2" files2 filt2 + if [ -z "$filt" -a -z "$filt2" ]; then + $prog $flags -- "$1" "$2" + elif [ -z "$filt" -a -n "$filt2" -a "$1" != "-" ]; then + $filt2 -- "$2" | $prog $flags -- "$1" - + elif [ -n "$filt" -a -z "$filt2" -a "$2" != "-" ]; then + $filt -- "$1" | $prog $flags -- - "$2" else - $prog $flags $files + tmp=`mktemp -t z$prog.XXXXXXXXXX` || exit 1 + trap "rm -f $tmp" 0 1 2 3 13 15 + ${filt2:-cat} -- "$2" > $tmp || exit $? + ${filt:-cat} -- "$1" | $prog $flags -- - "$tmp" fi status=$? else diff --git a/usr.bin/gzip/zdiff.1 b/usr.bin/gzip/zdiff.1 index 2a6a4c8c74a8..52b5fbd100e0 100644 --- a/usr.bin/gzip/zdiff.1 +++ b/usr.bin/gzip/zdiff.1 @@ -1,7 +1,8 @@ -.\" $NetBSD: zdiff.1,v 1.3 2003/12/28 12:48:03 wiz Exp $ +.\" $NetBSD: zdiff.1,v 1.5 2010/04/14 19:52:05 wiz Exp $ .\" $OpenBSD: zdiff.1,v 1.2 2003/07/13 17:39:14 millert Exp $ .\" .\" Copyright (c) 2003 Todd C. Miller +.\" Copyright (c) 2010 Joerg Sonnenberger .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -20,7 +21,7 @@ .\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" .\" $FreeBSD$ -.Dd January 26, 2007 +.Dd May 23, 2011 .Dt ZDIFF 1 .Os .Sh NAME @@ -45,15 +46,6 @@ are filters that invoke or .Xr diff 1 respectively to compare compressed files. -Such files generally have a -.Dq Z -or -.Dq gz -extension (both the -.Xr compress 1 -and -.Xr gzip 1 -formats are supported). Any .Ar options that are specified are passed to @@ -70,6 +62,45 @@ When both or .Ar file2 are specified, either file may be compressed. +.Pp +Extensions handled by +.Xr gzip 1 : +.Bl -bullet -compact +.It +z, Z, +.It +gz, +.It +taz, +.It +tgz. +.El +.Pp +Extensions handled by +.Xr bzip2 1 : +.Bl -bullet -compact +.It +bz, +.It +bz2, +.It +tbz, +.It +tbz2. +.El +.Pp +Extensions handled by +.Xr xz 1 : +.Bl -bullet -compact +.It +lzma, +.It +xz, +.It +tlz, +.It +txz. +.El .Sh ENVIRONMENT .Bl -tag -width "TMPDIR" .It Ev TMPDIR @@ -88,9 +119,11 @@ Temporary file for .Nm zdiff . .El .Sh SEE ALSO +.Xr bzip2 1 , .Xr cmp 1 , -.Xr compress 1 , -.Xr diff 1 +.Xr diff 1 , +.Xr gzip 1 , +.Xr xz 1 .Sh CAVEATS .Nm zcmp and diff --git a/usr.bin/gzip/zuncompress.c b/usr.bin/gzip/zuncompress.c index 8e619bde1549..f68ba595680b 100644 --- a/usr.bin/gzip/zuncompress.c +++ b/usr.bin/gzip/zuncompress.c @@ -1,4 +1,4 @@ -/* $NetBSD: zuncompress.c,v 1.7 2009/04/12 10:31:14 lukem Exp $ */ +/* $NetBSD: zuncompress.c,v 1.8 2010/11/06 21:42:32 mrg Exp $ */ /*- * Copyright (c) 1985, 1986, 1992, 1993 From fc2689100470c2feae5d70c01efa073294bb8b1e Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 23 May 2011 09:40:21 +0000 Subject: [PATCH 163/200] Match symbolic link handling behavior with GNU gzip, bzip2 and xz: When we are operating on a symbolic link pointing to an existing file, bail out by default, but go ahead if -f is specified. Submitted by: arundel MFC after: 2 weeks --- usr.bin/gzip/gzip.1 | 8 ++++---- usr.bin/gzip/gzip.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.bin/gzip/gzip.1 b/usr.bin/gzip/gzip.1 index 848a4b391c94..c0dc670a2cf2 100644 --- a/usr.bin/gzip/gzip.1 +++ b/usr.bin/gzip/gzip.1 @@ -25,7 +25,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd April 27, 2010 +.Dd May 23, 2011 .Dt GZIP 1 .Os .Sh NAME @@ -127,9 +127,9 @@ stream, leaving files intact. This option selects decompression rather than compression. .It Fl f , -force This option turns on force mode. -This allows files with multiple links, overwriting of pre-existing -files, reading from or writing to a terminal, and when combined -with the +This allows files with multiple links, symbolic links to regular files, +overwriting of pre-existing files, reading from or writing to a terminal, +and when combined with the .Fl c option, allowing non-compressed data to pass through unchanged. .It Fl h , -help diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c index 474575caf9a0..927493eced7d 100644 --- a/usr.bin/gzip/gzip.c +++ b/usr.bin/gzip/gzip.c @@ -1782,7 +1782,7 @@ handle_pathname(char *path) } retry: - if (stat(path, &sb) != 0) { + if (stat(path, &sb) != 0 || (fflag == 0 && lstat(path, &sb) != 0)) { /* lets try .gz if we're decompressing */ if (dflag && s == NULL && errno == ENOENT) { len = strlen(path); From 82a5be494a04b64553b0299662402aaea2c02c2a Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 23 May 2011 13:51:57 +0000 Subject: [PATCH 164/200] A number of quite incremental refinements to struct inpcbinfo's definition: (1) Add a locking guide for inpcbinfo. (2) Annotate inpcbinfo fields with synchronisation information; not all annotations are 100% satisfactory. (3) Reorder inpcbinfo fields so that the lock is at the head of the structure, and close to fields it protects. (4) Sort fields that will eventually be hashlock/pcbgroup-related together even though they remain locked by ipi_lock for now. Reviewed by: bz Sponsored by: Juniper Networks X-MFC after: KBI analysis required --- sys/netinet/in_pcb.h | 75 ++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 813011ecbf1d..52debb063ce2 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,8 +1,12 @@ /*- * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. + * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. * + * Portions of this software were developed by Robert N. M. Watson under + * contract to Juniper Networks, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -260,53 +264,70 @@ struct inpcbport { u_short phd_port; }; -/* +/*- * Global data structure for each high-level protocol (UDP, TCP, ...) in both * IPv4 and IPv6. Holds inpcb lists and information for managing them. + * + * Each pcbinfo is protected by ipi_lock, covering mutable global fields (such + * as the global pcb list) and hashed lookup tables. The lock order is: + * + * ipi_lock (before) inpcb locks + * + * Locking key: + * + * (c) Constant or nearly constant after initialisation + * (g) Locked by ipi_lock + * (h) Read using either ipi_lock or inpcb lock; write requires both. + * (x) Synchronisation properties poorly defined */ struct inpcbinfo { + /* + * Global lock protecting global inpcb list, inpcb count, hash tables, + * etc. + */ + struct rwlock ipi_lock; + /* * Global list of inpcbs on the protocol. */ - struct inpcbhead *ipi_listhead; - u_int ipi_count; + struct inpcbhead *ipi_listhead; /* (g) */ + u_int ipi_count; /* (g) */ + + /* + * Generation count -- incremented each time a connection is allocated + * or freed. + */ + u_quad_t ipi_gencnt; /* (g) */ + + /* + * Fields associated with port lookup and allocation. + */ + u_short ipi_lastport; /* (x) */ + u_short ipi_lastlow; /* (x) */ + u_short ipi_lasthi; /* (x) */ + + /* + * UMA zone from which inpcbs are allocated for this protocol. + */ + struct uma_zone *ipi_zone; /* (c) */ /* * Global hash of inpcbs, hashed by local and foreign addresses and * port numbers. */ - struct inpcbhead *ipi_hashbase; - u_long ipi_hashmask; + struct inpcbhead *ipi_hashbase; /* (g) */ + u_long ipi_hashmask; /* (g) */ /* * Global hash of inpcbs, hashed by only local port number. */ - struct inpcbporthead *ipi_porthashbase; - u_long ipi_porthashmask; - - /* - * Fields associated with port lookup and allocation. - */ - u_short ipi_lastport; - u_short ipi_lastlow; - u_short ipi_lasthi; - - /* - * UMA zone from which inpcbs are allocated for this protocol. - */ - struct uma_zone *ipi_zone; - - /* - * Generation count--incremented each time a connection is allocated - * or freed. - */ - u_quad_t ipi_gencnt; - struct rwlock ipi_lock; + struct inpcbporthead *ipi_porthashbase; /* (g) */ + u_long ipi_porthashmask; /* (g) */ /* * Pointer to network stack instance */ - struct vnet *ipi_vnet; + struct vnet *ipi_vnet; /* (c) */ /* * general use 2 From 68e0d7e06a1876d72d1b0fdce1811c550e601fb7 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 23 May 2011 15:23:18 +0000 Subject: [PATCH 165/200] Move from passing a wildcard boolean to a general set up lookup flags into in_pcb_lport(), in_pcblookup_local(), and in_pcblookup_hash(), and similarly for IPv6 functions. In the future, we would like to support other flags relating to locking strategy. This change doesn't appear to modify the KBI in practice, as callers already passed in INPLOOKUP_WILDCARD rather than a simple boolean. MFC after: 3 weeks Reviewed by: bz Sponsored by: Juniper Networks, Inc. --- sys/netinet/in_pcb.c | 30 ++++++++++++++++++------------ sys/netinet6/in6_pcb.c | 25 ++++++++++++++++--------- sys/netinet6/in6_src.c | 6 +++--- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index b3bb8d9bb017..515bd415e150 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -329,7 +329,7 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) #if defined(INET) || defined(INET6) int in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp, - struct ucred *cred, int wild) + struct ucred *cred, int lookupflags) { struct inpcbinfo *pcbinfo; struct inpcb *tmpinp; @@ -424,14 +424,14 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp, #ifdef INET6 if ((inp->inp_vflag & INP_IPV6) != 0) tmpinp = in6_pcblookup_local(pcbinfo, - &inp->in6p_laddr, lport, wild, cred); + &inp->in6p_laddr, lport, lookupflags, cred); #endif #if defined(INET) && defined(INET6) else #endif #ifdef INET tmpinp = in_pcblookup_local(pcbinfo, laddr, - lport, wild, cred); + lport, lookupflags, cred); #endif } while (tmpinp != NULL); @@ -464,7 +464,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; struct in_addr laddr; u_short lport = 0; - int wild = 0, reuseport = (so->so_options & SO_REUSEPORT); + int lookupflags = 0, reuseport = (so->so_options & SO_REUSEPORT); int error; /* @@ -480,7 +480,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, if (nam != NULL && laddr.s_addr != INADDR_ANY) return (EINVAL); if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) - wild = INPLOOKUP_WILDCARD; + lookupflags = INPLOOKUP_WILDCARD; if (nam == NULL) { if ((error = prison_local_ip4(cred, &laddr)) != 0) return (error); @@ -561,7 +561,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, return (EADDRINUSE); } t = in_pcblookup_local(pcbinfo, sin->sin_addr, - lport, wild, cred); + lport, lookupflags, cred); if (t && (t->inp_flags & INP_TIMEWAIT)) { /* * XXXRW: If an incpb has had its timewait @@ -590,7 +590,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, if (*lportp != 0) lport = *lportp; if (lport == 0) { - error = in_pcb_lport(inp, &laddr, &lport, cred, wild); + error = in_pcb_lport(inp, &laddr, &lport, cred, lookupflags); if (error != 0) return (error); @@ -1307,7 +1307,7 @@ in_pcbpurgeif0(struct inpcbinfo *pcbinfo, struct ifnet *ifp) #define INP_LOOKUP_MAPPED_PCB_COST 3 struct inpcb * in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, - u_short lport, int wild_okay, struct ucred *cred) + u_short lport, int lookupflags, struct ucred *cred) { struct inpcb *inp; #ifdef INET6 @@ -1317,9 +1317,12 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, #endif int wildcard; + KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + INP_INFO_LOCK_ASSERT(pcbinfo); - if (!wild_okay) { + if ((lookupflags & INPLOOKUP_WILDCARD) == 0) { struct inpcbhead *head; /* * Look for an unconnected (wildcard foreign addr) PCB that @@ -1425,13 +1428,16 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, */ struct inpcb * in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, - u_int fport_arg, struct in_addr laddr, u_int lport_arg, int wildcard, + u_int fport_arg, struct in_addr laddr, u_int lport_arg, int lookupflags, struct ifnet *ifp) { struct inpcbhead *head; struct inpcb *inp, *tmpinp; u_short fport = fport_arg, lport = lport_arg; + KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + INP_INFO_LOCK_ASSERT(pcbinfo); /* @@ -1467,7 +1473,7 @@ in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, /* * Then look for a wildcard match, if requested. */ - if (wildcard == INPLOOKUP_WILDCARD) { + if ((lookupflags & INPLOOKUP_WILDCARD) != 0) { struct inpcb *local_wild = NULL, *local_exact = NULL; #ifdef INET6 struct inpcb *local_wild_mapped = NULL; @@ -1538,7 +1544,7 @@ in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, if (local_wild_mapped != NULL) return (local_wild_mapped); #endif /* defined(INET6) */ - } /* if (wildcard == INPLOOKUP_WILDCARD) */ + } /* if ((lookupflags & INPLOOKUP_WILDCARD) != 0) */ return (NULL); } diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 9e64562f9366..eacce8c5376d 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -111,7 +111,8 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)NULL; struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; u_short lport = 0; - int error, wild = 0, reuseport = (so->so_options & SO_REUSEPORT); + int error, lookupflags = 0; + int reuseport = (so->so_options & SO_REUSEPORT); INP_INFO_WLOCK_ASSERT(pcbinfo); INP_WLOCK_ASSERT(inp); @@ -121,7 +122,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, if (inp->inp_lport || !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) return (EINVAL); if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) - wild = INPLOOKUP_WILDCARD; + lookupflags = INPLOOKUP_WILDCARD; if (nam == NULL) { if ((error = prison_local_ip6(cred, &inp->in6p_laddr, ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) @@ -226,7 +227,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, #endif } t = in6_pcblookup_local(pcbinfo, &sin6->sin6_addr, - lport, wild, cred); + lport, lookupflags, cred); if (t && (reuseport & ((t->inp_flags & INP_TIMEWAIT) ? intotw(t)->tw_so_options : t->inp_socket->so_options)) == 0) @@ -238,7 +239,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, in6_sin6_2_sin(&sin, sin6); t = in_pcblookup_local(pcbinfo, sin.sin_addr, - lport, wild, cred); + lport, lookupflags, cred); if (t && t->inp_flags & INP_TIMEWAIT) { if ((reuseport & intotw(t)->tw_so_options) == 0 && @@ -652,14 +653,17 @@ in6_pcbnotify(struct inpcbinfo *pcbinfo, struct sockaddr *dst, */ struct inpcb * in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr, - u_short lport, int wild_okay, struct ucred *cred) + u_short lport, int lookupflags, struct ucred *cred) { register struct inpcb *inp; int matchwild = 3, wildcard; + KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + INP_INFO_WLOCK_ASSERT(pcbinfo); - if (!wild_okay) { + if ((lookupflags & INPLOOKUP_WILDCARD) == 0) { struct inpcbhead *head; /* * Look for an unconnected (wildcard foreign addr) PCB that @@ -815,7 +819,7 @@ in6_rtchange(struct inpcb *inp, int errno) */ struct inpcb * in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, - u_int fport_arg, struct in6_addr *laddr, u_int lport_arg, int wildcard, + u_int fport_arg, struct in6_addr *laddr, u_int lport_arg, int lookupflags, struct ifnet *ifp) { struct inpcbhead *head; @@ -823,6 +827,9 @@ in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, u_short fport = fport_arg, lport = lport_arg; int faith; + KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + INP_INFO_LOCK_ASSERT(pcbinfo); if (faithprefix_p != NULL) @@ -862,7 +869,7 @@ in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, /* * Then look for a wildcard match, if requested. */ - if (wildcard == INPLOOKUP_WILDCARD) { + if ((lookupflags & INPLOOKUP_WILDCARD) != 0) { struct inpcb *local_wild = NULL, *local_exact = NULL; struct inpcb *jail_wild = NULL; int injail; @@ -919,7 +926,7 @@ in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, return (local_exact); if (local_wild != NULL) return (local_wild); - } /* if (wildcard == INPLOOKUP_WILDCARD) */ + } /* if ((lookupflags & INPLOOKUP_WILDCARD) != 0) */ /* * Not found. diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index b491e0e7ab10..5202e091bc92 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -851,7 +851,7 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred) { struct socket *so = inp->inp_socket; u_int16_t lport = 0; - int error, wild = 0; + int error, lookupflags = 0; #ifdef INVARIANTS struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; #endif @@ -866,11 +866,11 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred) /* XXX: this is redundant when called from in6_pcbbind */ if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) - wild = INPLOOKUP_WILDCARD; + lookupflags = INPLOOKUP_WILDCARD; inp->inp_flags |= INP_ANONPORT; - error = in_pcb_lport(inp, NULL, &lport, cred, wild); + error = in_pcb_lport(inp, NULL, &lport, cred, lookupflags); if (error != 0) return (error); From f53edc909e1a03842ed21db6a851c8aa8b405953 Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Mon, 23 May 2011 16:40:44 +0000 Subject: [PATCH 166/200] In init_dynamic_kenv(), ignore environment strings exceeding the KENV_MNAMELEN + 1 + KENV_MVALLEN + 1 length limit to avoid buffer overflow in getenv(). Currenly loader(8) doesn't limit the length of environment strings. PR: kern/132104 MFC after: 1 month --- sys/kern/kern_environment.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index 41a9fa8e8310..16760ce90c54 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -225,13 +225,19 @@ static void init_dynamic_kenv(void *data __unused) { char *cp; - int len, i; + size_t len; + int i; kenvp = malloc((KENV_SIZE + 1) * sizeof(char *), M_KENV, M_WAITOK | M_ZERO); i = 0; for (cp = kern_envp; cp != NULL; cp = kernenv_next(cp)) { len = strlen(cp) + 1; + if (len > KENV_MNAMELEN + 1 + KENV_MVALLEN + 1) { + printf("WARNING: too long kenv string, ignoring %s\n", + cp); + continue; + } if (i < KENV_SIZE) { kenvp[i] = malloc(len, M_KENV, M_WAITOK); strcpy(kenvp[i++], cp); From 79bdc6e5d368f0411e7680cac68cefa046dfbc65 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 23 May 2011 19:32:02 +0000 Subject: [PATCH 167/200] Continue to refine inpcb reference counting and locking, in preparation for reworking of inpcbinfo locking: (1) Convert inpcb reference counting from manually manipulated integers to the refcount(9) KPI. This allows the refcount to be managed atomically with an inpcb read lock rather than write lock, or even with no inpcb lock at all. As a result, in_pcbref() also no longer requires an inpcb lock, so can be performed solely using the lock used to look up an inpcb. (2) Shift more inpcb freeing activity from the in_pcbrele() context (via in_pcbfree_internal) to the explicit in_pcbfree() context. This means that the inpcb refcount is increasingly used only to maintain memory stability, not actually defer the clean up of inpcb protocol parts. This is desirable as many of those protocol parts required the pcbinfo lock, which we'd like not to acquire in in_pcbrele() contexts. Document this in comments better. (3) Introduce new read-locked and write-locked in_pcbrele() variations, in_pcbrele_rlocked() and in_pcbrele_wlocked(), which allow the inpcb to be properly unlocked as needed. in_pcbrele() is a wrapper around the latter, and should probably go away at some point. This makes it easier to use this weak reference model when holding only a read lock, as will happen in the future. This may well be safe to MFC, but some more KBI analysis is required. Reviewed by: bz MFC after: 3 weeks Sponsored by: Juniper Networks, Inc. --- sys/netinet/in_pcb.c | 198 ++++++++++++++++++++++++------------------- sys/netinet/in_pcb.h | 2 + 2 files changed, 115 insertions(+), 85 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 515bd415e150..9bde3c821242 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -2,8 +2,12 @@ * Copyright (c) 1982, 1986, 1991, 1993, 1995 * The Regents of the University of California. * Copyright (c) 2007-2009 Robert N. M. Watson + * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. * + * Portions of this software were developed by Robert N. M. Watson under + * contract to Juniper Networks, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -50,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -287,7 +292,7 @@ in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo) #endif INP_WLOCK(inp); inp->inp_gencnt = ++pcbinfo->ipi_gencnt; - inp->inp_refcount = 1; /* Reference from the inpcbinfo */ + refcount_init(&inp->inp_refcount, 1); /* Reference from inpcbinfo */ #if defined(IPSEC) || defined(MAC) out: if (error != 0) { @@ -1028,26 +1033,121 @@ in_pcbdetach(struct inpcb *inp) } /* - * in_pcbfree_internal() frees an inpcb that has been detached from its - * socket, and whose reference count has reached 0. It will also remove the - * inpcb from any global lists it might remain on. + * in_pcbref() bumps the reference count on an inpcb in order to maintain + * stability of an inpcb pointer despite the inpcb lock being released. This + * is used in TCP when the inpcbinfo lock needs to be acquired or upgraded, + * but where the inpcb lock is already held. + * + * in_pcbref() should be used only to provide brief memory stability, and + * must always be followed by a call to INP_WLOCK() and in_pcbrele() to + * garbage collect the inpcb if it has been in_pcbfree()'d from another + * context. Until in_pcbrele() has returned that the inpcb is still valid, + * lock and rele are the *only* safe operations that may be performed on the + * inpcb. + * + * While the inpcb will not be freed, releasing the inpcb lock means that the + * connection's state may change, so the caller should be careful to + * revalidate any cached state on reacquiring the lock. Drop the reference + * using in_pcbrele(). */ -static void -in_pcbfree_internal(struct inpcb *inp) +void +in_pcbref(struct inpcb *inp) { - struct inpcbinfo *ipi = inp->inp_pcbinfo; - KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); - KASSERT(inp->inp_refcount == 0, ("%s: refcount !0", __func__)); - - INP_INFO_WLOCK_ASSERT(ipi); INP_WLOCK_ASSERT(inp); + KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); + + refcount_acquire(&inp->inp_refcount); +} + +/* + * Drop a refcount on an inpcb elevated using in_pcbref(); because a call to + * in_pcbfree() may have been made between in_pcbref() and in_pcbrele(), we + * return a flag indicating whether or not the inpcb remains valid. If it is + * valid, we return with the inpcb lock held. + * + * Notice that, unlike in_pcbref(), the inpcb lock must be held to drop a + * reference on an inpcb. Historically more work was done here (actually, in + * in_pcbfree_internal()) but has been moved to in_pcbfree() to avoid the + * need for the pcbinfo lock in in_pcbrele(). Deferring the free is entirely + * about memory stability (and continued use of the write lock). + */ +int +in_pcbrele_rlocked(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo; + + KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); + + INP_RLOCK_ASSERT(inp); + + if (refcount_release(&inp->inp_refcount) == 0) + return (0); + + KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + + INP_RUNLOCK(inp); + pcbinfo = inp->inp_pcbinfo; + uma_zfree(pcbinfo->ipi_zone, inp); + return (1); +} + +int +in_pcbrele_wlocked(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo; + + KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); + + INP_WLOCK_ASSERT(inp); + + if (refcount_release(&inp->inp_refcount) == 0) + return (0); + + KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + + INP_WUNLOCK(inp); + pcbinfo = inp->inp_pcbinfo; + uma_zfree(pcbinfo->ipi_zone, inp); + return (1); +} + +/* + * Temporary wrapper. + */ +int +in_pcbrele(struct inpcb *inp) +{ + + return (in_pcbrele_wlocked(inp)); +} + +/* + * Unconditionally schedule an inpcb to be freed by decrementing its + * reference count, which should occur only after the inpcb has been detached + * from its socket. If another thread holds a temporary reference (acquired + * using in_pcbref()) then the free is deferred until that reference is + * released using in_pcbrele(), but the inpcb is still unlocked. Almost all + * work, including removal from global lists, is done in this context, where + * the pcbinfo lock is held. + */ +void +in_pcbfree(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; + + KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + + INP_INFO_WLOCK_ASSERT(pcbinfo); + INP_WLOCK_ASSERT(inp); + + /* XXXRW: Do as much as possible here. */ #ifdef IPSEC if (inp->inp_sp != NULL) ipsec_delete_pcbpolicy(inp); #endif /* IPSEC */ - inp->inp_gencnt = ++ipi->ipi_gencnt; + inp->inp_gencnt = ++pcbinfo->ipi_gencnt; in_pcbremlists(inp); #ifdef INET6 if (inp->inp_vflag & INP_IPV6PROTO) { @@ -1064,82 +1164,10 @@ in_pcbfree_internal(struct inpcb *inp) #endif inp->inp_vflag = 0; crfree(inp->inp_cred); - #ifdef MAC mac_inpcb_destroy(inp); #endif - INP_WUNLOCK(inp); - uma_zfree(ipi->ipi_zone, inp); -} - -/* - * in_pcbref() bumps the reference count on an inpcb in order to maintain - * stability of an inpcb pointer despite the inpcb lock being released. This - * is used in TCP when the inpcbinfo lock needs to be acquired or upgraded, - * but where the inpcb lock is already held. - * - * While the inpcb will not be freed, releasing the inpcb lock means that the - * connection's state may change, so the caller should be careful to - * revalidate any cached state on reacquiring the lock. Drop the reference - * using in_pcbrele(). - */ -void -in_pcbref(struct inpcb *inp) -{ - - INP_WLOCK_ASSERT(inp); - - KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); - - inp->inp_refcount++; -} - -/* - * Drop a refcount on an inpcb elevated using in_pcbref(); because a call to - * in_pcbfree() may have been made between in_pcbref() and in_pcbrele(), we - * return a flag indicating whether or not the inpcb remains valid. If it is - * valid, we return with the inpcb lock held. - */ -int -in_pcbrele(struct inpcb *inp) -{ -#ifdef INVARIANTS - struct inpcbinfo *ipi = inp->inp_pcbinfo; -#endif - - KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); - - INP_INFO_WLOCK_ASSERT(ipi); - INP_WLOCK_ASSERT(inp); - - inp->inp_refcount--; - if (inp->inp_refcount > 0) - return (0); - in_pcbfree_internal(inp); - return (1); -} - -/* - * Unconditionally schedule an inpcb to be freed by decrementing its - * reference count, which should occur only after the inpcb has been detached - * from its socket. If another thread holds a temporary reference (acquired - * using in_pcbref()) then the free is deferred until that reference is - * released using in_pcbrele(), but the inpcb is still unlocked. - */ -void -in_pcbfree(struct inpcb *inp) -{ -#ifdef INVARIANTS - struct inpcbinfo *ipi = inp->inp_pcbinfo; -#endif - - KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", - __func__)); - - INP_INFO_WLOCK_ASSERT(ipi); - INP_WLOCK_ASSERT(inp); - - if (!in_pcbrele(inp)) + if (!in_pcbrele_wlocked(inp)) INP_WUNLOCK(inp); } diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 52debb063ce2..14d4ea233751 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -534,6 +534,8 @@ void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr, void in_pcbref(struct inpcb *); void in_pcbrehash(struct inpcb *); int in_pcbrele(struct inpcb *); +int in_pcbrele_rlocked(struct inpcb *); +int in_pcbrele_wlocked(struct inpcb *); void in_pcbsetsolabel(struct socket *so); int in_getpeeraddr(struct socket *so, struct sockaddr **nam); int in_getsockaddr(struct socket *so, struct sockaddr **nam); From e28b1e2d03daf1202df953902f58f001854d2518 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Mon, 23 May 2011 19:57:12 +0000 Subject: [PATCH 168/200] expr -> sh arithmetic expansion --- sys/conf/newvers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 6fe0a639a547..9681c7904d43 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -139,4 +139,4 @@ int osreldate = ${RELDATE}; char kern_ident[] = "${i}"; EOF -echo `expr ${v} + 1` > version +echo $((v + 1)) > version From 10e71e226056600fbc6bcceaeabc2d974e4c6b85 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 23 May 2011 19:58:08 +0000 Subject: [PATCH 169/200] Do not blindly clear entire GPHY control register. It seems some bits of the register is used for other purposes such that clearing these bits resulted in unexpected results such as corrupted RX frames or missing LE status updates. For old controllers like Yukon EC it had no effect but it caused all kind of troubles on Yukon Supreme. This change shall improve stability of controllers like Yukon Ultra, Ultra2, Extreme, Optima and Supreme. --- sys/dev/msk/if_msk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 3af1b205fda9..8dc2d30d8237 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -1362,8 +1362,8 @@ mskc_reset(struct msk_softc *sc) /* Reset GPHY/GMAC Control */ for (i = 0; i < sc->msk_num_port; i++) { /* GPHY Control reset. */ - CSR_WRITE_4(sc, MR_ADDR(i, GPHY_CTRL), GPC_RST_SET); - CSR_WRITE_4(sc, MR_ADDR(i, GPHY_CTRL), GPC_RST_CLR); + CSR_WRITE_1(sc, MR_ADDR(i, GPHY_CTRL), GPC_RST_SET); + CSR_WRITE_1(sc, MR_ADDR(i, GPHY_CTRL), GPC_RST_CLR); /* GMAC Control reset. */ CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_RST_SET); CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_RST_CLR); From 5e863acb636a9ccb850bc78cae90fcff2407eaa9 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Mon, 23 May 2011 19:59:01 +0000 Subject: [PATCH 170/200] BKVASIZE was bumped to 16k more than a decade ago. --- sys/kern/vfs_bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 0b5e973bc734..00681cae2f93 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -654,7 +654,7 @@ bufinit(void) * To support extreme low-memory systems, make sure hidirtybuffers cannot * eat up all available buffer space. This occurs when our minimum cannot * be met. We try to size hidirtybuffers to 3/4 our buffer space assuming - * BKVASIZE'd (8K) buffers. + * BKVASIZE'd buffers. */ while ((long)hidirtybuffers * BKVASIZE > 3 * hibufspace / 4) { hidirtybuffers >>= 1; From 7b4f47c1db3b9f1e49acf496b65cd69ba391b1f9 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 23 May 2011 20:09:32 +0000 Subject: [PATCH 171/200] Rework store and forward configuration of TX MAC FIFO. Basically it enables store and forward mode except for jumbo frame on Yukon Ultra. --- sys/dev/msk/if_msk.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 8dc2d30d8237..312e626686cf 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -3654,37 +3654,24 @@ msk_set_tx_stfwd(struct msk_if_softc *sc_if) ifp = sc_if->msk_ifp; sc = sc_if->msk_softc; - switch (sc->msk_hw_id) { - case CHIP_ID_YUKON_EX: - if (sc->msk_hw_rev == CHIP_REV_YU_EX_A0) - goto yukon_ex_workaround; - if (ifp->if_mtu > ETHERMTU) - CSR_WRITE_4(sc, - MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_JUMBO_ENA | TX_STFW_ENA); - else - CSR_WRITE_4(sc, - MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_JUMBO_DIS | TX_STFW_ENA); - break; - default: -yukon_ex_workaround: + if ((sc->msk_hw_id == CHIP_ID_YUKON_EX && + sc->msk_hw_rev != CHIP_REV_YU_EX_A0) || + sc->msk_hw_id >= CHIP_ID_YUKON_SUPR) { + CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), + TX_STFW_ENA); + } else { if (ifp->if_mtu > ETHERMTU) { /* Set Tx GMAC FIFO Almost Empty Threshold. */ CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_AE_THR), MSK_ECU_JUMBO_WM << 16 | MSK_ECU_AE_THR); /* Disable Store & Forward mode for Tx. */ - CSR_WRITE_4(sc, - MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_JUMBO_ENA | TX_STFW_DIS); + CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), + TX_STFW_DIS); } else { - /* Enable Store & Forward mode for Tx. */ - CSR_WRITE_4(sc, - MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_JUMBO_DIS | TX_STFW_ENA); + CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), + TX_STFW_ENA); } - break; } } From ca5f1efdd9403258db867e40cc32ae6c434318ea Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Mon, 23 May 2011 20:12:36 +0000 Subject: [PATCH 172/200] Decrease ACPI-fast timecounter quality to 900 and increase HPET timecounter quality to 950. HPET on modern platforms usually have better resolution and lower latency than ACPI timer. Effectively this changes default timecounter hardware from ACPI-fast to HPET by default when both are available. Discussed with: avg --- sys/dev/acpica/acpi_hpet.c | 2 +- sys/dev/acpica/acpi_timer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index 4ea5c8583b13..40e8676fceb3 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -476,7 +476,7 @@ hpet_attach(device_t dev) sc->tc.tc_get_timecount = hpet_get_timecount, sc->tc.tc_counter_mask = ~0u, sc->tc.tc_name = "HPET", - sc->tc.tc_quality = 900, + sc->tc.tc_quality = 950, sc->tc.tc_frequency = sc->freq; sc->tc.tc_priv = sc; tc_init(&sc->tc); diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c index f4562067080b..17416838e9e4 100644 --- a/sys/dev/acpica/acpi_timer.c +++ b/sys/dev/acpica/acpi_timer.c @@ -203,7 +203,7 @@ acpi_timer_probe(device_t dev) if (j == 10) { acpi_timer_timecounter.tc_name = "ACPI-fast"; acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount; - acpi_timer_timecounter.tc_quality = 1000; + acpi_timer_timecounter.tc_quality = 900; } else { acpi_timer_timecounter.tc_name = "ACPI-safe"; acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe; From d91192e329c7f80be69b13240cc363ef1156b5e8 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 23 May 2011 20:18:09 +0000 Subject: [PATCH 173/200] Do not configure RAM registers for controllers that do not have them. These registers are defined only for Yukon XL, Yukon EC and Yukon FE. --- sys/dev/msk/if_msk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 312e626686cf..e733114408e5 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -1300,7 +1300,7 @@ mskc_reset(struct msk_softc *sc) bus_addr_t addr; uint16_t status; uint32_t val; - int i; + int i, initram; CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); @@ -1396,8 +1396,14 @@ mskc_reset(struct msk_softc *sc) CSR_WRITE_1(sc, GMAC_TI_ST_CTRL, GMT_ST_STOP); CSR_WRITE_1(sc, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ); + initram = 0; + if (sc->msk_hw_id == CHIP_ID_YUKON_XL || + sc->msk_hw_id == CHIP_ID_YUKON_EC || + sc->msk_hw_id == CHIP_ID_YUKON_FE) + initram++; + /* Configure timeout values. */ - for (i = 0; i < sc->msk_num_port; i++) { + for (i = 0; initram > 0 && i < sc->msk_num_port; i++) { CSR_WRITE_2(sc, SELECT_RAM_BUFFER(i, B3_RI_CTRL), RI_RST_SET); CSR_WRITE_2(sc, SELECT_RAM_BUFFER(i, B3_RI_CTRL), RI_RST_CLR); CSR_WRITE_1(sc, SELECT_RAM_BUFFER(i, B3_RI_WTO_R1), From 1c6689d58d435ba2bbc0f336b7c13a6511f38a42 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 23 May 2011 20:59:50 +0000 Subject: [PATCH 174/200] To handle BIO_FLUSH and BIO_DELETE requests in secondary worker we need to use ioctl(2). This is why we can't use capsicum for now to sandbox secondary. Capsicum is still used to sandbox hastctl. MFC after: 1 week --- sbin/hastd/subr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sbin/hastd/subr.c b/sbin/hastd/subr.c index 29f33e7d32c4..806338b4bfc0 100644 --- a/sbin/hastd/subr.c +++ b/sbin/hastd/subr.c @@ -224,7 +224,13 @@ drop_privs(struct hast_resource *res) return (-1); } - if (res == NULL || res->hr_role != HAST_ROLE_PRIMARY) + /* + * Until capsicum doesn't allow ioctl(2) we cannot use it to sandbox + * primary and secondary worker processes, as primary uses GGATE + * ioctls and secondary uses ioctls to handle BIO_DELETE and BIO_FLUSH. + * For now capsicum is only used to sandbox hastctl. + */ + if (res == NULL) capsicum = (cap_enter() == 0); else capsicum = false; From 204a4e196a0b29990ecb3564f1bee1eed29dd423 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 23 May 2011 21:00:37 +0000 Subject: [PATCH 175/200] Recognize BIO_FLUSH requests and pass them to userland. MFC after: 1 week --- sys/geom/gate/g_gate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c index 9b4d782aa410..22338a513caa 100644 --- a/sys/geom/gate/g_gate.c +++ b/sys/geom/gate/g_gate.c @@ -180,6 +180,7 @@ g_gate_start(struct bio *bp) break; case BIO_DELETE: case BIO_WRITE: + case BIO_FLUSH: /* XXX: Hack to allow read-only mounts. */ if ((sc->sc_flags & G_GATE_FLAG_READONLY) != 0) { g_io_deliver(bp, EPERM); @@ -580,6 +581,7 @@ g_gate_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct threa switch (bp->bio_cmd) { case BIO_READ: case BIO_DELETE: + case BIO_FLUSH: break; case BIO_WRITE: error = copyout(bp->bio_data, ggio->gctl_data, @@ -643,6 +645,7 @@ g_gate_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct threa break; case BIO_DELETE: case BIO_WRITE: + case BIO_FLUSH: break; } } From c6a34f768e4e3873c69d5a9f345d01a8fabc186c Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 23 May 2011 21:00:56 +0000 Subject: [PATCH 176/200] Make sure to enable all clocks before accessing registers. Releasing PHY from power down/COMA is done after enabling all clocks. While I'm here remove unnecessary controller reset. --- sys/dev/msk/if_msk.c | 54 +++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index e733114408e5..d14a3baefda1 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -1212,37 +1212,30 @@ msk_phy_power(struct msk_softc *sc, int mode) */ CSR_WRITE_1(sc, B2_Y2_CLK_GATE, val); - val = CSR_PCI_READ_4(sc, PCI_OUR_REG_1); - val &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); + our = CSR_PCI_READ_4(sc, PCI_OUR_REG_1); + our &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); if (sc->msk_hw_id == CHIP_ID_YUKON_XL) { if (sc->msk_hw_rev > CHIP_REV_YU_XL_A1) { /* Deassert Low Power for 1st PHY. */ - val |= PCI_Y2_PHY1_COMA; + our |= PCI_Y2_PHY1_COMA; if (sc->msk_num_port > 1) - val |= PCI_Y2_PHY2_COMA; + our |= PCI_Y2_PHY2_COMA; } } - /* Release PHY from PowerDown/COMA mode. */ - CSR_PCI_WRITE_4(sc, PCI_OUR_REG_1, val); - switch (sc->msk_hw_id) { - case CHIP_ID_YUKON_EC_U: - case CHIP_ID_YUKON_EX: - case CHIP_ID_YUKON_FE_P: - case CHIP_ID_YUKON_UL_2: - case CHIP_ID_YUKON_OPT: - CSR_WRITE_2(sc, B0_CTST, Y2_HW_WOL_OFF); - - /* Enable all clocks. */ - CSR_PCI_WRITE_4(sc, PCI_OUR_REG_3, 0); - our = CSR_PCI_READ_4(sc, PCI_OUR_REG_4); - our &= (PCI_FORCE_ASPM_REQUEST|PCI_ASPM_GPHY_LINK_DOWN| - PCI_ASPM_INT_FIFO_EMPTY|PCI_ASPM_CLKRUN_REQUEST); + if (sc->msk_hw_id == CHIP_ID_YUKON_EC_U || + sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id >= CHIP_ID_YUKON_FE_P) { + val = CSR_PCI_READ_4(sc, PCI_OUR_REG_4); + val &= (PCI_FORCE_ASPM_REQUEST | + PCI_ASPM_GPHY_LINK_DOWN | PCI_ASPM_INT_FIFO_EMPTY | + PCI_ASPM_CLKRUN_REQUEST); /* Set all bits to 0 except bits 15..12. */ - CSR_PCI_WRITE_4(sc, PCI_OUR_REG_4, our); - our = CSR_PCI_READ_4(sc, PCI_OUR_REG_5); - our &= PCI_CTL_TIM_VMAIN_AV_MSK; - CSR_PCI_WRITE_4(sc, PCI_OUR_REG_5, our); + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_4, val); + val = CSR_PCI_READ_4(sc, PCI_OUR_REG_5); + val &= PCI_CTL_TIM_VMAIN_AV_MSK; + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_5, val); CSR_PCI_WRITE_4(sc, PCI_CFG_REG_1, 0); + CSR_WRITE_2(sc, B0_CTST, Y2_HW_WOL_ON); /* * Disable status race, workaround for * Yukon EC Ultra & Yukon EX. @@ -1251,10 +1244,10 @@ msk_phy_power(struct msk_softc *sc, int mode) val |= GLB_GPIO_STAT_RACE_DIS; CSR_WRITE_4(sc, B2_GP_IO, val); CSR_READ_4(sc, B2_GP_IO); - break; - default: - break; } + /* Release PHY from PowerDown/COMA mode. */ + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_1, our); + for (i = 0; i < sc->msk_num_port; i++) { CSR_WRITE_2(sc, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_SET); @@ -1302,8 +1295,6 @@ mskc_reset(struct msk_softc *sc) uint32_t val; int i, initram; - CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); - /* Disable ASF. */ if (sc->msk_hw_id == CHIP_ID_YUKON_EX) { status = CSR_READ_2(sc, B28_Y2_ASF_HCU_CCSR); @@ -1712,6 +1703,9 @@ mskc_attach(device_t dev) } } + /* Enable all clocks before accessing any registers. */ + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_3, 0); + CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); sc->msk_hw_id = CSR_READ_1(sc, B2_CHIP_ID); sc->msk_hw_rev = (CSR_READ_1(sc, B2_MAC_CFG) >> 4) & 0x0f; @@ -1752,9 +1746,6 @@ mskc_attach(device_t dev) resource_int_value(device_get_name(dev), device_get_unit(dev), "int_holdoff", &sc->msk_int_holdoff); - /* Soft reset. */ - CSR_WRITE_2(sc, B0_CTST, CS_RST_SET); - CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); sc->msk_pmd = CSR_READ_1(sc, B2_PMD_TYP); /* Check number of MACs. */ sc->msk_num_port = 1; @@ -2969,6 +2960,7 @@ mskc_resume(device_t dev) MSK_LOCK(sc); + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_3, 0); mskc_reset(sc); for (i = 0; i < sc->msk_num_port; i++) { if (sc->msk_if[i] != NULL && sc->msk_if[i]->msk_ifp != NULL && From fe0b141e733e1cc79fa76daf2f4f49a285a06020 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 23 May 2011 21:11:46 +0000 Subject: [PATCH 177/200] Do not touch ASF related register for controllers that do not have these registers. Also disable Watchdog of ASF microcontroller. --- sys/dev/msk/if_msk.c | 41 ++++++++++++++++++++++++----------------- sys/dev/msk/if_mskreg.h | 1 + 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index d14a3baefda1..868a9facf368 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -1296,23 +1296,30 @@ mskc_reset(struct msk_softc *sc) int i, initram; /* Disable ASF. */ - if (sc->msk_hw_id == CHIP_ID_YUKON_EX) { - status = CSR_READ_2(sc, B28_Y2_ASF_HCU_CCSR); - /* Clear AHB bridge & microcontroller reset. */ - status &= ~(Y2_ASF_HCU_CCSR_AHB_RST | - Y2_ASF_HCU_CCSR_CPU_RST_MODE); - /* Clear ASF microcontroller state. */ - status &= ~ Y2_ASF_HCU_CCSR_UC_STATE_MSK; - CSR_WRITE_2(sc, B28_Y2_ASF_HCU_CCSR, status); - } else - CSR_WRITE_1(sc, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); - CSR_WRITE_2(sc, B0_CTST, Y2_ASF_DISABLE); - - /* - * Since we disabled ASF, S/W reset is required for Power Management. - */ - CSR_WRITE_2(sc, B0_CTST, CS_RST_SET); - CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); + if (sc->msk_hw_id >= CHIP_ID_YUKON_XL && + sc->msk_hw_id <= CHIP_ID_YUKON_SUPR) { + if (sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id == CHIP_ID_YUKON_SUPR) { + CSR_WRITE_4(sc, B28_Y2_CPU_WDOG, 0); + status = CSR_READ_2(sc, B28_Y2_ASF_HCU_CCSR); + /* Clear AHB bridge & microcontroller reset. */ + status &= ~(Y2_ASF_HCU_CCSR_AHB_RST | + Y2_ASF_HCU_CCSR_CPU_RST_MODE); + /* Clear ASF microcontroller state. */ + status &= ~Y2_ASF_HCU_CCSR_UC_STATE_MSK; + status &= ~Y2_ASF_HCU_CCSR_CPU_CLK_DIVIDE_MSK; + CSR_WRITE_2(sc, B28_Y2_ASF_HCU_CCSR, status); + CSR_WRITE_4(sc, B28_Y2_CPU_WDOG, 0); + } else + CSR_WRITE_1(sc, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); + CSR_WRITE_2(sc, B0_CTST, Y2_ASF_DISABLE); + /* + * Since we disabled ASF, S/W reset is required for + * Power Management. + */ + CSR_WRITE_2(sc, B0_CTST, CS_RST_SET); + CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); + } /* Clear all error bits in the PCI status register. */ status = pci_read_config(sc->msk_dev, PCIR_STATUS, 2); diff --git a/sys/dev/msk/if_mskreg.h b/sys/dev/msk/if_mskreg.h index 3b05b9ba8587..0179608d4cb4 100644 --- a/sys/dev/msk/if_mskreg.h +++ b/sys/dev/msk/if_mskreg.h @@ -677,6 +677,7 @@ /* ASF Subsystem Registers (Yukon-2 only) */ #define B28_Y2_SMB_CONFIG 0x0e40 /* 32 bit ASF SMBus Config Register */ #define B28_Y2_SMB_CSD_REG 0x0e44 /* 32 bit ASF SMB Control/Status/Data */ +#define B28_Y2_CPU_WDOG 0x0e48 /* 32 bit Watchdog Register */ #define B28_Y2_ASF_IRQ_V_BASE 0x0e60 /* 32 bit ASF IRQ Vector Base */ #define B28_Y2_ASF_STAT_CMD 0x0e68 /* 32 bit ASF Status and Command Reg */ #define B28_Y2_ASF_HCU_CCSR 0x0e68 /* 32 bit ASF HCU CCSR (Yukon EX) */ From 3db86c39aed2f276a65d71b8362cf30baed64beb Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Mon, 23 May 2011 21:15:19 +0000 Subject: [PATCH 178/200] Keep statistics on number of BIO_READ, BIO_WRITE, BIO_DELETE and BIO_FLUSH requests as well as number of activemap updates. Number of BIO_WRITEs and activemap updates are especially interesting, because if those two are too close to each other, it means that your workload needs bigger number of dirty extents. Activemap should be updated as rarely as possible. MFC after: 1 week --- sbin/hastctl/hastctl.c | 11 +++++++++++ sbin/hastd/control.c | 17 +++++++++++++++++ sbin/hastd/hast.h | 11 +++++++++++ sbin/hastd/primary.c | 11 +++++++++++ sbin/hastd/secondary.c | 14 ++++++++++++++ 5 files changed, 64 insertions(+) diff --git a/sbin/hastctl/hastctl.c b/sbin/hastctl/hastctl.c index c4cd6a4b91c1..2f8a6eb8dff7 100644 --- a/sbin/hastctl/hastctl.c +++ b/sbin/hastctl/hastctl.c @@ -341,6 +341,17 @@ control_status(struct nv *nv) printf(" dirty: %ju (%NB)\n", (uintmax_t)nv_get_uint64(nv, "dirty%u", ii), (intmax_t)nv_get_uint64(nv, "dirty%u", ii)); + printf(" statistics:\n"); + printf(" reads: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_read%u", ii)); + printf(" writes: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_write%u", ii)); + printf(" deletes: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_delete%u", ii)); + printf(" flushes: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_flush%u", ii)); + printf(" activemap updates: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_activemap_update%u", ii)); } return (ret); } diff --git a/sbin/hastd/control.c b/sbin/hastd/control.c index dce2d53bcc3a..4d00403924d3 100644 --- a/sbin/hastd/control.c +++ b/sbin/hastd/control.c @@ -199,6 +199,16 @@ control_status_worker(struct hast_resource *res, struct nv *nvout, "extentsize%u", no); nv_add_uint32(nvout, nv_get_uint32(cnvin, "keepdirty"), "keepdirty%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_read"), + "stat_read%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_write"), + "stat_write%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_delete"), + "stat_delete%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_flush"), + "stat_flush%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_activemap_update"), + "stat_activemap_update%u", no); end: if (cnvin != NULL) nv_free(cnvin); @@ -446,6 +456,13 @@ ctrl_thread(void *arg) nv_add_uint32(nvout, (uint32_t)0, "keepdirty"); nv_add_uint64(nvout, (uint64_t)0, "dirty"); } + nv_add_uint64(nvout, res->hr_stat_read, "stat_read"); + nv_add_uint64(nvout, res->hr_stat_write, "stat_write"); + nv_add_uint64(nvout, res->hr_stat_delete, + "stat_delete"); + nv_add_uint64(nvout, res->hr_stat_flush, "stat_flush"); + nv_add_uint64(nvout, res->hr_stat_activemap_update, + "stat_activemap_update"); nv_add_int16(nvout, 0, "error"); break; case CONTROL_RELOAD: diff --git a/sbin/hastd/hast.h b/sbin/hastd/hast.h index 3f2616228352..a62b63a263f6 100644 --- a/sbin/hastd/hast.h +++ b/sbin/hastd/hast.h @@ -218,6 +218,17 @@ struct hast_resource { /* Locked used to synchronize access to hr_amp. */ pthread_mutex_t hr_amp_lock; + /* Number of BIO_READ requests. */ + uint64_t hr_stat_read; + /* Number of BIO_WRITE requests. */ + uint64_t hr_stat_write; + /* Number of BIO_DELETE requests. */ + uint64_t hr_stat_delete; + /* Number of BIO_FLUSH requests. */ + uint64_t hr_stat_flush; + /* Number of activemap updates. */ + uint64_t hr_stat_activemap_update; + /* Next resource. */ TAILQ_ENTRY(hast_resource) hr_next; }; diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c index d8eb664740cb..1f6585c87a1a 100644 --- a/sbin/hastd/primary.c +++ b/sbin/hastd/primary.c @@ -1117,6 +1117,7 @@ ggate_recv_thread(void *arg) */ switch (ggio->gctl_cmd) { case BIO_READ: + res->hr_stat_read++; pjdlog_debug(2, "ggate_recv: (%p) Moving request to the send queue.", hio); @@ -1145,6 +1146,7 @@ ggate_recv_thread(void *arg) QUEUE_INSERT1(hio, send, ncomp); break; case BIO_WRITE: + res->hr_stat_write++; if (res->hr_resuid == 0) { /* * This is first write, initialize localcnt and @@ -1183,12 +1185,21 @@ ggate_recv_thread(void *arg) mtx_lock(&res->hr_amp_lock); if (activemap_write_start(res->hr_amp, ggio->gctl_offset, ggio->gctl_length)) { + res->hr_stat_activemap_update++; (void)hast_activemap_flush(res); } mtx_unlock(&res->hr_amp_lock); /* FALLTHROUGH */ case BIO_DELETE: case BIO_FLUSH: + switch (ggio->gctl_cmd) { + case BIO_DELETE: + res->hr_stat_delete++; + break; + case BIO_FLUSH: + res->hr_stat_flush++; + break; + } pjdlog_debug(2, "ggate_recv: (%p) Moving request to the send queues.", hio); diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c index 176d0470eedb..1597af83a85d 100644 --- a/sbin/hastd/secondary.c +++ b/sbin/hastd/secondary.c @@ -612,6 +612,20 @@ recv_thread(void *arg) QUEUE_INSERT(send, hio); continue; } + switch (hio->hio_cmd) { + case HIO_READ: + res->hr_stat_read++; + break; + case HIO_WRITE: + res->hr_stat_write++; + break; + case HIO_DELETE: + res->hr_stat_delete++; + break; + case HIO_FLUSH: + res->hr_stat_flush++; + break; + } reqlog(LOG_DEBUG, 2, -1, hio, "recv: (%p) Got request header: ", hio); if (hio->hio_cmd == HIO_KEEPALIVE) { From ff239280c643985c0fc14f6e11d8884427b0447c Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 23 May 2011 21:32:45 +0000 Subject: [PATCH 179/200] Test against "no" rather than "yes" for MK_KERNEL_SYMBOLS Also, change DEBUG back to DEBUG_FLAGS in kmod.mk. The latter accidentally snuck in with my backwards compat fix. Submitted by: ru,gcooper --- sys/conf/kern.post.mk | 4 ++-- sys/conf/kmod.mk | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 21d9572d8d50..8cb36f9f0fdf 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -228,7 +228,7 @@ kernel-install: mkdir -p ${DESTDIR}${KODIR} ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR} .if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ - (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} != "no") ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR} .endif .if defined(KERNEL_EXTRA_INSTALL) @@ -241,7 +241,7 @@ kernel-reinstall: @-chflags -R noschg ${DESTDIR}${KODIR} ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR} .if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ - (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} != "no") ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR} .endif diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index b50fc6833fbb..36e0b9d51bfc 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -286,8 +286,8 @@ realinstall: _kmodinstall _kmodinstall: ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR} -.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ - (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") +.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) && \ + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} != "no") ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ ${_INSTALLFLAGS} ${PROG}.symbols ${DESTDIR}${KMODDIR} .endif From e0029a7260da2ca2acaf4481d779d05e2fd4fb80 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 23 May 2011 21:51:47 +0000 Subject: [PATCH 180/200] Add initial support for Marvell 88E8055/88E8075 Yukon Supreme. --- sys/dev/msk/if_msk.c | 23 +++++++++++++++++++---- sys/dev/msk/if_mskreg.h | 9 +++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 868a9facf368..74264daa69ee 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -221,6 +221,10 @@ static struct msk_product { "Marvell Yukon 88E8071 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_436C, "Marvell Yukon 88E8072 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_436D, + "Marvell Yukon 88E8055 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4370, + "Marvell Yukon 88E8075 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4380, "Marvell Yukon 88E8057 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4381, @@ -1366,11 +1370,16 @@ mskc_reset(struct msk_softc *sc) CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_RST_SET); CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_RST_CLR); CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_F_LOOPB_OFF); - if (sc->msk_hw_id == CHIP_ID_YUKON_EX) + if (sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id == CHIP_ID_YUKON_SUPR) CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_BYP_MACSECRX_ON | GMC_BYP_MACSECTX_ON | GMC_BYP_RETR_ON); } + + if (sc->msk_hw_id == CHIP_ID_YUKON_SUPR && + sc->msk_hw_rev > CHIP_REV_YU_SU_B0) + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_3, PCI_CLK_MACSEC_DIS); if (sc->msk_hw_id == CHIP_ID_YUKON_OPT && sc->msk_hw_rev == 0) { /* Disable PCIe PHY powerdown(reg 0x80, bit7). */ CSR_WRITE_4(sc, Y2_PEX_PHY_DATA, (0x0080 << 16) | 0x0080); @@ -1719,7 +1728,6 @@ mskc_attach(device_t dev) /* Bail out if chip is not recognized. */ if (sc->msk_hw_id < CHIP_ID_YUKON_XL || sc->msk_hw_id > CHIP_ID_YUKON_OPT || - sc->msk_hw_id == CHIP_ID_YUKON_SUPR || sc->msk_hw_id == CHIP_ID_YUKON_UNKNOWN) { device_printf(dev, "unknown device: id=0x%02x, rev=0x%02x\n", sc->msk_hw_id, sc->msk_hw_rev); @@ -1826,6 +1834,11 @@ mskc_attach(device_t dev) sc->msk_clock = 156; /* 156 MHz */ sc->msk_pflags |= MSK_FLAG_JUMBO; break; + case CHIP_ID_YUKON_SUPR: + sc->msk_clock = 125; /* 125 MHz */ + sc->msk_pflags |= MSK_FLAG_JUMBO | MSK_FLAG_DESCV2 | + MSK_FLAG_AUTOTX_CSUM; + break; case CHIP_ID_YUKON_UL_2: sc->msk_clock = 125; /* 125 MHz */ sc->msk_pflags |= MSK_FLAG_JUMBO; @@ -3729,7 +3742,8 @@ msk_init_locked(struct msk_if_softc *sc_if) CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_RST_SET); CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_RST_CLR); CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_F_LOOPB_OFF); - if (sc->msk_hw_id == CHIP_ID_YUKON_EX) + if (sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id == CHIP_ID_YUKON_SUPR) CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_BYP_MACSECRX_ON | GMC_BYP_MACSECTX_ON | GMC_BYP_RETR_ON); @@ -3924,7 +3938,8 @@ msk_init_locked(struct msk_if_softc *sc_if) msk_stop(sc_if); return; } - if (sc->msk_hw_id == CHIP_ID_YUKON_EX) { + if (sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id == CHIP_ID_YUKON_SUPR) { /* Disable flushing of non-ASF packets. */ CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), GMF_RX_MACSEC_FLUSH_OFF); diff --git a/sys/dev/msk/if_mskreg.h b/sys/dev/msk/if_mskreg.h index 0179608d4cb4..583f5e88ef80 100644 --- a/sys/dev/msk/if_mskreg.h +++ b/sys/dev/msk/if_mskreg.h @@ -144,6 +144,8 @@ #define DEVICEID_MRVL_436A 0x436A #define DEVICEID_MRVL_436B 0x436B #define DEVICEID_MRVL_436C 0x436C +#define DEVICEID_MRVL_436D 0x436D +#define DEVICEID_MRVL_4370 0x4370 #define DEVICEID_MRVL_4380 0x4380 #define DEVICEID_MRVL_4381 0x4381 @@ -321,6 +323,9 @@ #define PCI_OS_SPD_X100 2 /* PCI-X 100MHz Bus */ #define PCI_OS_SPD_X133 3 /* PCI-X 133MHz Bus */ +/* PCI_OUR_REG_3 32 bit Our Register 3 (Yukon-ECU only) */ +#define PCI_CLK_MACSEC_DIS BIT_17 /* Disable Clock MACSec. */ + /* PCI_OUR_REG_4 32 bit Our Register 4 (Yukon-ECU only) */ #define PCI_TIMER_VALUE_MSK (0xff<<16) /* Bit 23..16: Timer Value Mask */ #define PCI_FORCE_ASPM_REQUEST BIT_15 /* Force ASPM Request (A1 only) */ @@ -919,6 +924,10 @@ #define CHIP_REV_YU_EX_A0 1 /* Chip Rev. for Yukon-2 EX A0 */ #define CHIP_REV_YU_EX_B0 2 /* Chip Rev. for Yukon-2 EX B0 */ +#define CHIP_REV_YU_SU_A0 0 /* Chip Rev. for Yukon-2 SUPR A0 */ +#define CHIP_REV_YU_SU_B0 1 /* Chip Rev. for Yukon-2 SUPR B0 */ +#define CHIP_REV_YU_SU_B1 3 /* Chip Rev. for Yukon-2 SUPR B1 */ + /* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ #define Y2_STATUS_LNK2_INAC BIT_7 /* Status Link 2 inactiv (0 = activ) */ #define Y2_CLK_GAT_LNK2_DIS BIT_6 /* Disable clock gating Link 2 */ From 8be664b8b7de21140755e3cf3cbdba94a7246494 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 23 May 2011 21:56:04 +0000 Subject: [PATCH 181/200] When MTU is changed, check whether driver should be reinitialized or not. If reinitialized is required, clear driver running flag. --- sys/dev/msk/if_msk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 74264daa69ee..2adbf1cb2c7a 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -1034,7 +1034,10 @@ msk_ioctl(struct ifnet *ifp, u_long command, caddr_t data) } } ifp->if_mtu = ifr->ifr_mtu; - msk_init_locked(sc_if); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + msk_init_locked(sc_if); + } } MSK_IF_UNLOCK(sc_if); break; From e7b49f6068bb73e55f7c57c59be93bde52c32e20 Mon Sep 17 00:00:00 2001 From: Pyun YongHyeon Date: Mon, 23 May 2011 22:02:15 +0000 Subject: [PATCH 182/200] Add 88E8075 Yukon Supreme to the list of supported hardware list. --- share/man/man4/msk.4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/man/man4/msk.4 b/share/man/man4/msk.4 index fe32a68a4226..200c6f7f3e52 100644 --- a/share/man/man4/msk.4 +++ b/share/man/man4/msk.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 23, 2010 +.Dd May 23, 2011 .Dt MSK 4 .Os .Sh NAME @@ -195,6 +195,8 @@ Marvell Yukon 88E8071 Gigabit Ethernet .It Marvell Yukon 88E8072 Gigabit Ethernet .It +Marvell Yukon 88E8075 Gigabit Ethernet +.It SysKonnect SK-9Sxx Gigabit Ethernet .It SysKonnect SK-9Exx Gigabit Ethernet From 484c842d57529159f014f94f2a544cebc7d6e123 Mon Sep 17 00:00:00 2001 From: Rick Macklem Date: Mon, 23 May 2011 22:31:42 +0000 Subject: [PATCH 183/200] Set the MNT_NFS4ACLS flag for an NFSv4 client mount if the NFSv4 server supports it. Requested by trasz. MFC after: 2 weeks --- sys/fs/nfsclient/nfs_clvfsops.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 8dc5b0b4b0f2..84725dde0e16 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -79,6 +79,7 @@ FEATURE(nfscl, "NFSv4 client"); extern int nfscl_ticks; extern struct timeval nfsboottime; extern struct nfsstats newnfsstats; +extern int nfsrv_useacl; MALLOC_DEFINE(M_NEWNFSREQ, "newnfsclient_req", "New NFS request header"); MALLOC_DEFINE(M_NEWNFSMNT, "newnfsmnt", "New NFS mount struct"); @@ -1331,6 +1332,15 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, if (argp->flags & NFSMNT_NFSV3) ncl_fsinfo(nmp, *vpp, cred, td); + /* Mark if the mount point supports NFSv4 ACLs. */ + if ((argp->flags & NFSMNT_NFSV4) != 0 && nfsrv_useacl != 0 && + ret == 0 && + NFSISSET_ATTRBIT(&nfsva.na_suppattr, NFSATTRBIT_ACL)) { + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_NFS4ACLS; + MNT_IUNLOCK(mp); + } + /* * Lose the lock but keep the ref. */ From f7a10dcfe0f98f117b8bbbf2923db660259e3ffa Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Mon, 23 May 2011 23:35:50 +0000 Subject: [PATCH 184/200] Merge r221846 from largeSMP project branch: Fix arguments passing to _long() version of atomic function for mips. The native implementation is bogus in that regard and offers the same problem solved for powerpc as r222198, but mips' guys just wanted a small and self-contained patch for mips rather than rewriting the whole support. Reviewed by: art, imp Tested by: gonzo MFC after: 2 weeks --- sys/mips/include/atomic.h | 61 ++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/sys/mips/include/atomic.h b/sys/mips/include/atomic.h index 7b4a82cb06a9..9a0c557ee08c 100644 --- a/sys/mips/include/atomic.h +++ b/sys/mips/include/atomic.h @@ -581,32 +581,47 @@ atomic_fetchadd_64(__volatile uint64_t *p, uint64_t v) #else /* !__mips_n64 */ /* Operations on longs. */ -#define atomic_set_long atomic_set_32 -#define atomic_set_acq_long atomic_set_acq_32 -#define atomic_set_rel_long atomic_set_rel_32 -#define atomic_clear_long atomic_clear_32 -#define atomic_clear_acq_long atomic_clear_acq_32 -#define atomic_clear_rel_long atomic_clear_rel_32 -#define atomic_add_long(p, v) \ +#define atomic_set_long(p, v) \ + atomic_set_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_acq_long(p, v) \ + atomic_set_acq_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_rel_long(p, v) \ + atomic_set_rel_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_long(p, v) \ + atomic_clear_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_acq_long(p, v) \ + atomic_clear_acq_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_rel_long(p, v) \ + atomic_clear_rel_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_long(p, v) \ atomic_add_32((volatile u_int *)(p), (u_int)(v)) -#define atomic_add_acq_long atomic_add_acq_32 -#define atomic_add_rel_long atomic_add_rel_32 -#define atomic_subtract_long(p, v) \ +#define atomic_add_acq_long(p, v) \ + atomic_add_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_rel_long(p, v) \ + atomic_add_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_long(p, v) \ atomic_subtract_32((volatile u_int *)(p), (u_int)(v)) -#define atomic_subtract_acq_long atomic_subtract_acq_32 -#define atomic_subtract_rel_long atomic_subtract_rel_32 -#define atomic_cmpset_long atomic_cmpset_32 -#define atomic_cmpset_acq_long(p, cmpval, newval) \ - atomic_cmpset_acq_32((volatile u_int *)(p), \ - (u_int)(cmpval), (u_int)(newval)) -#define atomic_cmpset_rel_long(p, cmpval, newval) \ - atomic_cmpset_rel_32((volatile u_int *)(p), \ - (u_int)(cmpval), (u_int)(newval)) -#define atomic_load_acq_long atomic_load_acq_32 -#define atomic_store_rel_long atomic_store_rel_32 -#define atomic_fetchadd_long(p, v) \ +#define atomic_subtract_acq_long(p, v) \ + atomic_subtract_acq_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_rel_long(p, v) \ + atomic_subtract_rel_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_cmpset_long(p, cmpval, newval) \ + atomic_cmpset_32((volatile u_int *)(p), (u_int)(cmpval), \ + (u_int)(newval)) +#define atomic_cmpset_acq_long(p, cmpval, newval) \ + atomic_cmpset_acq_32((volatile u_int *)(p), (u_int)(cmpval), \ + (u_int)(newval)) +#define atomic_cmpset_rel_long(p, cmpval, newval) \ + atomic_cmpset_rel_32((volatile u_int *)(p), (u_int)(cmpval), \ + (u_int)(newval)) +#define atomic_load_acq_long(p) \ + (u_long)atomic_load_acq_32((volatile u_int *)(p)) +#define atomic_store_rel_long(p, v) \ + atomic_store_rel_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_fetchadd_long(p, v) \ atomic_fetchadd_32((volatile u_int *)(p), (u_int)(v)) -#define atomic_readandclear_long atomic_readandclear_32 +#define atomic_readandclear_long(p) \ + atomic_readandclear_32((volatile u_int *)(p)) #endif /* __mips_n64 */ From 5c59afe04ba636c536071fdab3a388b21158415c Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Tue, 24 May 2011 02:19:45 +0000 Subject: [PATCH 185/200] Add RTC support for the LV1 clock on the PS3. The hypervisor won't let us set it, but it's better than nothing. --- sys/powerpc/ps3/ps3bus.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/sys/powerpc/ps3/ps3bus.c b/sys/powerpc/ps3/ps3bus.c index 11dbba5a67d8..6a5120a5743c 100644 --- a/sys/powerpc/ps3/ps3bus.c +++ b/sys/powerpc/ps3/ps3bus.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #include "ps3bus.h" #include "ps3-hvcall.h" #include "iommu_if.h" +#include "clock_if.h" static void ps3bus_identify(driver_t *, device_t); static int ps3bus_probe(device_t); @@ -63,6 +65,8 @@ static int ps3_iommu_map(device_t dev, bus_dma_segment_t *segs, int *nsegs, bus_size_t boundary, void *cookie); static int ps3_iommu_unmap(device_t dev, bus_dma_segment_t *segs, int nsegs, void *cookie); +static int ps3_gettime(device_t dev, struct timespec *ts); +static int ps3_settime(device_t dev, struct timespec *ts); struct ps3bus_devinfo { int bus; @@ -106,6 +110,10 @@ static device_method_t ps3bus_methods[] = { DEVMETHOD(iommu_map, ps3_iommu_map), DEVMETHOD(iommu_unmap, ps3_iommu_unmap), + /* Clock interface */ + DEVMETHOD(clock_gettime, ps3_gettime), + DEVMETHOD(clock_settime, ps3_settime), + { 0, 0 } }; @@ -312,6 +320,8 @@ ps3bus_attach(device_t self) device_set_ivars(cdev, dinfo); } } + + clock_register(self, 1000); return (bus_generic_attach(self)); } @@ -551,7 +561,6 @@ ps3_iommu_map(device_t dev, bus_dma_segment_t *segs, int *nsegs, return (0); } - static int ps3_iommu_unmap(device_t dev, bus_dma_segment_t *segs, int nsegs, void *cookie) { @@ -559,3 +568,26 @@ ps3_iommu_unmap(device_t dev, bus_dma_segment_t *segs, int nsegs, void *cookie) return (0); } +#define Y2K 946684800 + +static int +ps3_gettime(device_t dev, struct timespec *ts) +{ + uint64_t rtc, tb; + int result; + + result = lv1_get_rtc(&rtc, &tb); + if (result) + return (result); + + ts->tv_sec = rtc + Y2K; + ts->tv_nsec = 0; + return (0); +} + +static int +ps3_settime(device_t dev, struct timespec *ts) +{ + return (-1); +} + From e808ca44541f072491ea74ae1cd19a683f4213c6 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 24 May 2011 05:34:45 +0000 Subject: [PATCH 186/200] Add in descriptions for TX descriptor fields ctl8-11 - these fields control the antenna control bits for the four TX series and the TPC settings for TX series 1, 2, 3. The specifics: * The TPC setting for TX series 0 is handled in ctl0. * TPC is currently disabled, so the per-packet TX power is set via the global per-rate TX power register, not per packet. * The antenna control bits don't matter for AR5416 and later so they should stay 0 (which they currently do); they may be set for Kite but as there's no TX diversity supported at the moment (it requires the NIC to be built with an external antenna switch, matching how antenna diversity is done on legacy NICs), so again keep them 0. This is in preparation for supporting per-rate TPC on the AR5416 and later. The Kite (and soon to come Kiwi) code sets ctl8-11 to 0x0, which doesn't have any effect at the moment. When TPC is enabled it would result in the second, third and fourth TX series attmpts to be done with a TX power of 0. This commit doesn't change that; it'll be followed up with some commits to properly set the TPC registers appropriately. --- sys/dev/ath/ath_hal/ar5416/ar5416desc.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416desc.h b/sys/dev/ath/ath_hal/ar5416/ar5416desc.h index 76f508025e6b..105c5d6080dc 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416desc.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416desc.h @@ -205,6 +205,29 @@ struct ar5416_desc { #define AR_STBC2 0x40000000 #define AR_STBC3 0x80000000 +/* ds_ctl8 */ +#define AR_AntCtl0 0x00ffffff +#define AR_AntCtl0_S 0 +/* Xmit 0 TPC is AR_XmitPower in ctl0 */ + +/* ds_ctl9 */ +#define AR_AntCtl1 0x00ffffff +#define AR_AntCtl1_S 0 +#define AR_XmitPower1 0xff000000 +#define AR_XmitPower1_S 24 + +/* ds_ctl10 */ +#define AR_AntCtl2 0x00ffffff +#define AR_AntCtl2_S 0 +#define AR_XmitPower2 0xff000000 +#define AR_XmitPower2_S 24 + +/* ds_ctl11 */ +#define AR_AntCtl3 0x00ffffff +#define AR_AntCtl3_S 0 +#define AR_XmitPower3 0xff000000 +#define AR_XmitPower3_S 24 + /************* * TX Status * *************/ From 634be0a971b5e3ed97db34edb7142ec5cda380fd Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 24 May 2011 05:49:02 +0000 Subject: [PATCH 187/200] Use the new per-series antenna and TPC definitions when setting ctl8->11. This should hopefully make it clearer to developers what is going on and when TPC is being hacked on, make it obvious why it isn't working for series 1, 2, 3. I won't flip on setting TX power for TX series 1, 2, 3 until I've done some further testing with Kite to ensure it doesn't break anything. (Before people ask - yes, TPC is only needed for 5ghz regdomains and yes, Kite is a 2.4ghz only chip, but there are potential use cases for 2ghz TPC. I just need to sit down and ensure it's supported and functional.) --- sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c | 43 +++++++++++++++--------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c b/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c index 3cf7da929381..48956c51cb84 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c @@ -208,10 +208,11 @@ ar5416SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds, | SM(ahp->ah_tx_chainmask, AR_ChainSel2) | SM(ahp->ah_tx_chainmask, AR_ChainSel3) ; - ads->ds_ctl8 = 0; - ads->ds_ctl9 = (txPower << 24); /* XXX? */ - ads->ds_ctl10 = (txPower << 24); /* XXX? */ - ads->ds_ctl11 = (txPower << 24); /* XXX? */ + ads->ds_ctl8 = SM(0, AR_AntCtl0); + ads->ds_ctl9 = SM(0, AR_AntCtl1) | SM(txPower, AR_XmitPower1); + ads->ds_ctl10 = SM(0, AR_AntCtl2) | SM(txPower, AR_XmitPower2); + ads->ds_ctl11 = SM(0, AR_AntCtl3) | SM(txPower, AR_XmitPower3); + if (keyIx != HAL_TXKEYIX_INVALID) { /* XXX validate key index */ ads->ds_ctl1 |= SM(keyIx, AR_DestIdx); @@ -232,11 +233,16 @@ ar5416SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds, ads->ds_ctl7 |= (rtsctsRate << AR_RTSCTSRate_S); } + /* + * Set the TX antenna to 0 for Kite + * To preserve existing behaviour, also set the TPC bits to 0; + * when TPC is enabled these should be filled in appropriately. + */ if (AR_SREV_KITE(ah)) { - ads->ds_ctl8 = 0; - ads->ds_ctl9 = 0; - ads->ds_ctl10 = 0; - ads->ds_ctl11 = 0; + ads->ds_ctl8 = SM(0, AR_AntCtl0); + ads->ds_ctl9 = SM(0, AR_AntCtl1) | SM(0, AR_XmitPower1); + ads->ds_ctl10 = SM(0, AR_AntCtl2) | SM(0, AR_XmitPower2); + ads->ds_ctl11 = SM(0, AR_AntCtl3) | SM(0, AR_XmitPower3); } return AH_TRUE; #undef RTSCTS @@ -410,10 +416,10 @@ ar5416SetupFirstTxDesc(struct ath_hal *ah, struct ath_desc *ds, | SM(AH5416(ah)->ah_tx_chainmask, AR_ChainSel3); /* NB: no V1 WAR */ - ads->ds_ctl8 = 0; - ads->ds_ctl9 = (txPower << 24); - ads->ds_ctl10 = (txPower << 24); - ads->ds_ctl11 = (txPower << 24); + ads->ds_ctl8 = SM(0, AR_AntCtl0); + ads->ds_ctl9 = SM(0, AR_AntCtl1) | SM(txPower, AR_XmitPower1); + ads->ds_ctl10 = SM(0, AR_AntCtl2) | SM(txPower, AR_XmitPower2); + ads->ds_ctl11 = SM(0, AR_AntCtl3) | SM(txPower, AR_XmitPower3); ads->ds_ctl6 &= ~(0xffff); ads->ds_ctl6 |= SM(aggrLen, AR_AggrLen); @@ -424,11 +430,16 @@ ar5416SetupFirstTxDesc(struct ath_hal *ah, struct ath_desc *ds, | (flags & HAL_TXDESC_RTSENA ? AR_RTSEnable : 0); } + /* + * Set the TX antenna to 0 for Kite + * To preserve existing behaviour, also set the TPC bits to 0; + * when TPC is enabled these should be filled in appropriately. + */ if (AR_SREV_KITE(ah)) { - ads->ds_ctl8 = 0; - ads->ds_ctl9 = 0; - ads->ds_ctl10 = 0; - ads->ds_ctl11 = 0; + ads->ds_ctl8 = SM(0, AR_AntCtl0); + ads->ds_ctl9 = SM(0, AR_AntCtl1) | SM(0, AR_XmitPower1); + ads->ds_ctl10 = SM(0, AR_AntCtl2) | SM(0, AR_XmitPower2); + ads->ds_ctl11 = SM(0, AR_AntCtl3) | SM(0, AR_XmitPower3); } return AH_TRUE; From e47136127949e311ee53472b7d1620c09bc5170a Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Tue, 24 May 2011 06:44:16 +0000 Subject: [PATCH 188/200] Remove unused variable. MFC after: 1 week --- sys/geom/part/g_part_mbr.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sys/geom/part/g_part_mbr.c b/sys/geom/part/g_part_mbr.c index 4fa829a3c91e..63dcac4c3a9c 100644 --- a/sys/geom/part/g_part_mbr.c +++ b/sys/geom/part/g_part_mbr.c @@ -251,14 +251,11 @@ g_part_mbr_bootcode(struct g_part_table *basetable, struct g_part_parms *gpp) static int g_part_mbr_create(struct g_part_table *basetable, struct g_part_parms *gpp) { - struct g_consumer *cp; struct g_provider *pp; struct g_part_mbr_table *table; uint32_t msize; pp = gpp->gpp_provider; - cp = LIST_FIRST(&pp->consumers); - if (pp->sectorsize < MBRSIZE) return (ENOSPC); From 49d12fd5be6154208a780e9a916ec6bed37c02e0 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Tue, 24 May 2011 06:46:07 +0000 Subject: [PATCH 189/200] Remove unused variable. MFC after: 1 week --- sys/geom/part/g_part_pc98.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sys/geom/part/g_part_pc98.c b/sys/geom/part/g_part_pc98.c index 693fad881c30..0bdc0a6042c0 100644 --- a/sys/geom/part/g_part_pc98.c +++ b/sys/geom/part/g_part_pc98.c @@ -246,14 +246,11 @@ g_part_pc98_bootcode(struct g_part_table *basetable, struct g_part_parms *gpp) static int g_part_pc98_create(struct g_part_table *basetable, struct g_part_parms *gpp) { - struct g_consumer *cp; struct g_provider *pp; struct g_part_pc98_table *table; uint32_t cyl, msize; pp = gpp->gpp_provider; - cp = LIST_FIRST(&pp->consumers); - if (pp->sectorsize < SECSIZE || pp->mediasize < BOOTSIZE) return (ENOSPC); if (pp->sectorsize > SECSIZE) From 71737f5a06afd4967cf7549ddb1dcf0a5695ac12 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 24 May 2011 06:56:40 +0000 Subject: [PATCH 190/200] Ensure there is a whitespace after a mount point. PR: 157286 Submitted by: Marcus Reid MFC after: 3 days --- usr.bin/showmount/showmount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/showmount/showmount.c b/usr.bin/showmount/showmount.c index f4372b52bd1f..263525066800 100644 --- a/usr.bin/showmount/showmount.c +++ b/usr.bin/showmount/showmount.c @@ -185,7 +185,7 @@ main(int argc, char **argv) printf("Exports list on %s:\n", host); exp = exportslist; while (exp) { - printf("%-35s", exp->ex_dirp); + printf("%-34s ", exp->ex_dirp); grp = exp->ex_groups; if (grp == NULL) { printf("Everyone\n"); From 2dccdd45623bd043d930790a02e33da5b6305d28 Mon Sep 17 00:00:00 2001 From: Marko Zec Date: Tue, 24 May 2011 07:57:28 +0000 Subject: [PATCH 191/200] Let epair(4) virtual interfaces report fake link / media status, by borrowing the skeleton of if_media manipulation and reporting code from if_lagg(4). The main motivation behind this change is to allow for epair(4) interfaces to participate in STP if_bridge(4) configurations. Reviewed by: bz MFC after: 3 days --- sys/net/if_epair.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index 8775e6f7337c..a8d47113e52c 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -92,6 +93,8 @@ static struct mbuf *epair_nh_m2cpuid(struct mbuf *, uintptr_t, u_int *); static void epair_nh_drainedcpu(u_int); static void epair_start_locked(struct ifnet *); +static int epair_media_change(struct ifnet *); +static void epair_media_status(struct ifnet *, struct ifmediareq *); static int epair_clone_match(struct if_clone *, const char *); static int epair_clone_create(struct if_clone *, char *, size_t, caddr_t); @@ -127,6 +130,7 @@ SYSCTL_PROC(_net_link_epair, OID_AUTO, netisr_maxqlen, CTLTYPE_INT|CTLFLAG_RW, struct epair_softc { struct ifnet *ifp; /* This ifp. */ struct ifnet *oifp; /* other ifp of pair. */ + struct ifmedia media; /* Media config (fake). */ u_int refcount; /* # of mbufs in flight. */ u_int cpuid; /* CPU ID assigned upon creation. */ void (*if_qflush)(struct ifnet *); @@ -610,9 +614,26 @@ epair_qflush(struct ifnet *ifp) sc->if_qflush(ifp); } +static int +epair_media_change(struct ifnet *ifp __unused) +{ + + /* Do nothing. */ + return (0); +} + +static void +epair_media_status(struct ifnet *ifp __unused, struct ifmediareq *imr) +{ + + imr->ifm_status = IFM_AVALID | IFM_ACTIVE; + imr->ifm_active = IFM_ETHER | IFM_10G_T | IFM_FDX; +} + static int epair_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { + struct epair_softc *sc; struct ifreq *ifr; int error; @@ -624,6 +645,12 @@ epair_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) error = 0; break; + case SIOCSIFMEDIA: + case SIOCGIFMEDIA: + sc = ifp->if_softc; + error = ifmedia_ioctl(ifp, ifr, &sc->media, cmd); + break; + case SIOCSIFMTU: /* We basically allow all kinds of MTUs. */ ifp->if_mtu = ifr->ifr_mtu; @@ -829,6 +856,14 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) strlcpy(name, sca->ifp->if_xname, len); DPRINTF("name='%s/%db' created sca=%p scb=%p\n", name, unit, sca, scb); + /* Initialise pseudo media types. */ + ifmedia_init(&sca->media, 0, epair_media_change, epair_media_status); + ifmedia_add(&sca->media, IFM_ETHER | IFM_10G_T, 0, NULL); + ifmedia_set(&sca->media, IFM_ETHER | IFM_10G_T); + ifmedia_init(&scb->media, 0, epair_media_change, epair_media_status); + ifmedia_add(&scb->media, IFM_ETHER | IFM_10G_T, 0, NULL); + ifmedia_set(&scb->media, IFM_ETHER | IFM_10G_T); + /* Tell the world, that we are ready to rock. */ sca->ifp->if_drv_flags |= IFF_DRV_RUNNING; scb->ifp->if_drv_flags |= IFF_DRV_RUNNING; @@ -895,6 +930,8 @@ epair_clone_destroy(struct if_clone *ifc, struct ifnet *ifp) if_free(oifp); CURVNET_RESTORE(); if_free(ifp); + ifmedia_removeall(&sca->media); + ifmedia_removeall(&scb->media); free(scb, M_EPAIR); free(sca, M_EPAIR); ifc_free_unit(ifc, unit); From 9f8cab7fc21d921c4ac0dccc2b4401a9813ef0a4 Mon Sep 17 00:00:00 2001 From: Marko Zec Date: Tue, 24 May 2011 08:02:55 +0000 Subject: [PATCH 192/200] Allow for vlan(4) interfaces with MTU of 1500 bytes to be configured on top of epair(4) virtual interfaces, since there's no physical hardware associated with epair interfaces which would imply any constraints on MTU sizes. MFC after: 3 days --- sys/net/if_epair.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index a8d47113e52c..dff9efcf86f3 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -810,6 +810,8 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) ifp->if_dname = ifc->ifc_name; ifp->if_dunit = unit; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_capabilities = IFCAP_VLAN_MTU; + ifp->if_capenable = IFCAP_VLAN_MTU; ifp->if_start = epair_start; ifp->if_ioctl = epair_ioctl; ifp->if_init = epair_init; @@ -834,6 +836,8 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) ifp->if_dname = ifc->ifc_name; ifp->if_dunit = unit; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_capabilities = IFCAP_VLAN_MTU; + ifp->if_capenable = IFCAP_VLAN_MTU; ifp->if_start = epair_start; ifp->if_ioctl = epair_ioctl; ifp->if_init = epair_init; From 12dd58a3198ece862d1c341218ca2814fbf94b34 Mon Sep 17 00:00:00 2001 From: Rebecca Cran Date: Tue, 24 May 2011 09:01:56 +0000 Subject: [PATCH 193/200] Remove an outdated comment as requested by Bruce Evans in a private email to Alexander Best (arundel@). For clang, -fdiagnostics-show-option is enabled by default, but for gcc it isn't. This option will report which -W* flag was responsible for triggering a certain warning. This will bring gcc warnings closer to the ones clang emits and might also help developers track down tinderbox failures a bit quicker. Submitted by: arundel --- sys/conf/kern.mk | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 58ab6eebf010..a0a595f50645 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -1,15 +1,12 @@ # $FreeBSD$ # -# Warning flags for compiling the kernel and components of the kernel. +# Warning flags for compiling the kernel and components of the kernel: # -# Note that the newly added -Wcast-qual is responsible for generating -# most of the remaining warnings. Warnings introduced with -Wall will -# also pop up, but are easier to fix. CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \ -Wundef -Wno-pointer-sign -fformat-extensions \ - -Wmissing-include-dirs + -Wmissing-include-dirs -fdiagnostics-show-option # # The following flags are next up for working on: # -Wextra From f2d2d69438edd673aa8917cdbb782267551fbedc Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Tue, 24 May 2011 12:34:19 +0000 Subject: [PATCH 194/200] Rework netisr policy mechanism so that per-protocol dispatch policies can be represented: - A single policy namespace is defined, consisting of four possible policies: "default" to use the global default, "deferred" to force deferred dispatch, "direct" to employ direct dispatch where possible, and "hybrid" which makes a dynamic decision based on CPU affinity, ordering, etc. Routines are implemented to convert between strings and an integer namespace. - A new global variable, netisr_dispatch_policy, subsumes existing global variables for direct dispatch, forced direct dispatch, etc, and is used for explicit policy interpretation and composition. Old variables remain so that they can be exported by legacy sysctls for use by old netstat(1) binaries. A new sysctl and tunable, netisr.dispatch.policy, accepts the above strings for specifying a global policy default. - The protocol registration structure, netisr_handler, grows an nh_dispatch field, which accepts a per-policy policy override. The default value is '0', which corresponds to "default", meaning that protocols will accept the global default policy unless otherwise specified. - Policies are now interpreted and composed explicitly at various points in packet dispatch; protocol policies override global policies. - Protocols grow the ability to express a non-opinion about affinity even when implenting m2cpuid by returning NETISR_CPUID_NONE. In that case, the framework falls back on source ordering, rather than simply using the current CPU. These changes are in support of allowing link layer re-dispatch based on RSS or similar hashes provided by NICs, especially in the case where the number of hardware receive queues matches hardware core count, rather than hardware thread count, requiring further software redistributeon. (i.e., on RMI XLR). MFC after: 3 weeks Reviewed by: bz Sponsored by: Juniper Networks, Inc. --- sys/net/netisr.c | 282 +++++++++++++++++++++++++++++++------- sys/net/netisr.h | 19 ++- sys/net/netisr_internal.h | 3 +- 3 files changed, 247 insertions(+), 57 deletions(-) diff --git a/sys/net/netisr.c b/sys/net/netisr.c index 952b463e115f..67ec16014c32 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2007-2009 Robert N. M. Watson - * Copyright (c) 2010 Juniper Networks, Inc. + * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. * * This software was developed by Robert N. M. Watson under contract @@ -127,32 +127,44 @@ static struct rmlock netisr_rmlock; SYSCTL_NODE(_net, OID_AUTO, isr, CTLFLAG_RW, 0, "netisr"); /*- - * Three direct dispatch policies are supported: + * Three global direct dispatch policies are supported: * - * - Always defer: all work is scheduled for a netisr, regardless of context. - * (!direct) + * NETISR_DISPATCH_QUEUED: All work is deferred for a netisr, regardless of + * context (may be overriden by protocols). * - * - Hybrid: if the executing context allows direct dispatch, and we're - * running on the CPU the work would be done on, then direct dispatch if it - * wouldn't violate ordering constraints on the workstream. - * (direct && !direct_force) + * NETISR_DISPATCH_HYBRID: If the executing context allows direct dispatch, + * and we're running on the CPU the work would be performed on, then direct + * dispatch it if it wouldn't violate ordering constraints on the workstream. * - * - Always direct: if the executing context allows direct dispatch, always - * direct dispatch. (direct && direct_force) + * NETISR_DISPATCH_DIRECT: If the executing context allows direct dispatch, + * always direct dispatch. (The default.) * * Notice that changing the global policy could lead to short periods of * misordered processing, but this is considered acceptable as compared to - * the complexity of enforcing ordering during policy changes. + * the complexity of enforcing ordering during policy changes. Protocols can + * override the global policy (when they're not doing that, they select + * NETISR_DISPATCH_DEFAULT). */ -static int netisr_direct_force = 1; /* Always direct dispatch. */ -TUNABLE_INT("net.isr.direct_force", &netisr_direct_force); -SYSCTL_INT(_net_isr, OID_AUTO, direct_force, CTLFLAG_RW, - &netisr_direct_force, 0, "Force direct dispatch"); +#define NETISR_DISPATCH_POLICY_DEFAULT NETISR_DISPATCH_DIRECT +#define NETISR_DISPATCH_POLICY_MAXSTR 20 /* Used for temporary buffers. */ +static u_int netisr_dispatch_policy = NETISR_DISPATCH_POLICY_DEFAULT; +static int sysctl_netisr_dispatch_policy(SYSCTL_HANDLER_ARGS); +SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RW | + CTLFLAG_TUN, 0, 0, sysctl_netisr_dispatch_policy, "A", + "netisr dispatch policy"); -static int netisr_direct = 1; /* Enable direct dispatch. */ -TUNABLE_INT("net.isr.direct", &netisr_direct); -SYSCTL_INT(_net_isr, OID_AUTO, direct, CTLFLAG_RW, - &netisr_direct, 0, "Enable direct dispatch"); +/* + * These sysctls were used in previous versions to control and export + * dispatch policy state. Now, we provide read-only export via them so that + * older netstat binaries work. At some point they can be garbage collected. + */ +static int netisr_direct_force; +SYSCTL_INT(_net_isr, OID_AUTO, direct_force, CTLFLAG_RD, + &netisr_direct_force, 0, "compat: force direct dispatch"); + +static int netisr_direct; +SYSCTL_INT(_net_isr, OID_AUTO, direct, CTLFLAG_RD, &netisr_direct, 0, + "compat: enable direct dispatch"); /* * Allow the administrator to limit the number of threads (CPUs) to use for @@ -275,6 +287,106 @@ netisr_default_flow2cpu(u_int flowid) return (nws_array[flowid % nws_count]); } +/* + * Dispatch tunable and sysctl configuration. + */ +struct netisr_dispatch_table_entry { + u_int ndte_policy; + const char *ndte_policy_str; +}; +static const struct netisr_dispatch_table_entry netisr_dispatch_table[] = { + { NETISR_DISPATCH_DEFAULT, "default" }, + { NETISR_DISPATCH_DEFERRED, "deferred" }, + { NETISR_DISPATCH_HYBRID, "hybrid" }, + { NETISR_DISPATCH_DIRECT, "direct" }, +}; +static const u_int netisr_dispatch_table_len = + (sizeof(netisr_dispatch_table) / sizeof(netisr_dispatch_table[0])); + +static void +netisr_dispatch_policy_to_str(u_int dispatch_policy, char *buffer, + u_int buflen) +{ + const struct netisr_dispatch_table_entry *ndtep; + const char *str; + u_int i; + + str = "unknown"; + for (i = 0; i < netisr_dispatch_table_len; i++) { + ndtep = &netisr_dispatch_table[i]; + if (ndtep->ndte_policy == dispatch_policy) { + str = ndtep->ndte_policy_str; + break; + } + } + snprintf(buffer, buflen, "%s", str); +} + +static int +netisr_dispatch_policy_from_str(const char *str, u_int *dispatch_policyp) +{ + const struct netisr_dispatch_table_entry *ndtep; + u_int i; + + for (i = 0; i < netisr_dispatch_table_len; i++) { + ndtep = &netisr_dispatch_table[i]; + if (strcmp(ndtep->ndte_policy_str, str) == 0) { + *dispatch_policyp = ndtep->ndte_policy; + return (0); + } + } + return (EINVAL); +} + +static void +netisr_dispatch_policy_compat(void) +{ + + switch (netisr_dispatch_policy) { + case NETISR_DISPATCH_DEFERRED: + netisr_direct_force = 0; + netisr_direct = 0; + break; + + case NETISR_DISPATCH_HYBRID: + netisr_direct_force = 0; + netisr_direct = 1; + break; + + case NETISR_DISPATCH_DIRECT: + netisr_direct_force = 1; + netisr_direct = 1; + break; + + default: + panic("%s: unknown policy %u", __func__, + netisr_dispatch_policy); + } +} + +static int +sysctl_netisr_dispatch_policy(SYSCTL_HANDLER_ARGS) +{ + char tmp[NETISR_DISPATCH_POLICY_MAXSTR]; + u_int dispatch_policy; + int error; + + netisr_dispatch_policy_to_str(netisr_dispatch_policy, tmp, + sizeof(tmp)); + error = sysctl_handle_string(oidp, tmp, sizeof(tmp), req); + if (error == 0 && req->newptr != NULL) { + error = netisr_dispatch_policy_from_str(tmp, + &dispatch_policy); + if (error == 0 && dispatch_policy == NETISR_DISPATCH_DEFAULT) + error = EINVAL; + if (error == 0) { + netisr_dispatch_policy = dispatch_policy; + netisr_dispatch_policy_compat(); + } + } + return (error); +} + /* * Register a new netisr handler, which requires initializing per-protocol * fields for each workstream. All netisr work is briefly suspended while @@ -312,6 +424,12 @@ netisr_register(const struct netisr_handler *nhp) KASSERT(nhp->nh_policy != NETISR_POLICY_CPU || nhp->nh_m2cpuid != NULL, ("%s: nh_policy == CPU but m2cpuid not defined for %s", __func__, name)); + KASSERT(nhp->nh_dispatch == NETISR_DISPATCH_DEFAULT || + nhp->nh_dispatch == NETISR_DISPATCH_DEFERRED || + nhp->nh_dispatch == NETISR_DISPATCH_HYBRID || + nhp->nh_dispatch == NETISR_DISPATCH_DIRECT, + ("%s: invalid nh_dispatch (%u)", __func__, nhp->nh_dispatch)); + KASSERT(proto < NETISR_MAXPROT, ("%s(%u, %s): protocol too big", __func__, proto, name)); @@ -339,6 +457,7 @@ netisr_register(const struct netisr_handler *nhp) } else netisr_proto[proto].np_qlimit = nhp->nh_qlimit; netisr_proto[proto].np_policy = nhp->nh_policy; + netisr_proto[proto].np_dispatch = nhp->nh_dispatch; CPU_FOREACH(i) { npwp = &(DPCPU_ID_PTR(i, nws))->nws_work[proto]; bzero(npwp, sizeof(*npwp)); @@ -540,16 +659,33 @@ netisr_unregister(const struct netisr_handler *nhp) NETISR_WUNLOCK(); } +/* + * Compose the global and per-protocol policies on dispatch, and return the + * dispatch policy to use. + */ +static u_int +netisr_get_dispatch(struct netisr_proto *npp) +{ + + /* + * Protocol-specific configuration overrides the global default. + */ + if (npp->np_dispatch != NETISR_DISPATCH_DEFAULT) + return (npp->np_dispatch); + return (netisr_dispatch_policy); +} + /* * Look up the workstream given a packet and source identifier. Do this by * checking the protocol's policy, and optionally call out to the protocol * for assistance if required. */ static struct mbuf * -netisr_select_cpuid(struct netisr_proto *npp, uintptr_t source, - struct mbuf *m, u_int *cpuidp) +netisr_select_cpuid(struct netisr_proto *npp, u_int dispatch_policy, + uintptr_t source, struct mbuf *m, u_int *cpuidp) { struct ifnet *ifp; + u_int policy; NETISR_LOCK_ASSERT(); @@ -567,11 +703,30 @@ netisr_select_cpuid(struct netisr_proto *npp, uintptr_t source, * If we want to support per-interface policies, we should do that * here first. */ - switch (npp->np_policy) { - case NETISR_POLICY_CPU: - return (npp->np_m2cpuid(m, source, cpuidp)); + policy = npp->np_policy; + if (policy == NETISR_POLICY_CPU) { + m = npp->np_m2cpuid(m, source, cpuidp); + if (m == NULL) + return (NULL); - case NETISR_POLICY_FLOW: + /* + * It's possible for a protocol not to have a good idea about + * where to process a packet, in which case we fall back on + * the netisr code to decide. In the hybrid case, return the + * current CPU ID, which will force an immediate direct + * dispatch. In the queued case, fall back on the SOURCE + * policy. + */ + if (*cpuidp != NETISR_CPUID_NONE) + return (m); + if (dispatch_policy == NETISR_DISPATCH_HYBRID) { + *cpuidp = curcpu; + return (m); + } + policy = NETISR_POLICY_SOURCE; + } + + if (policy == NETISR_POLICY_FLOW) { if (!(m->m_flags & M_FLOWID) && npp->np_m2flow != NULL) { m = npp->np_m2flow(m, source); if (m == NULL) @@ -582,21 +737,19 @@ netisr_select_cpuid(struct netisr_proto *npp, uintptr_t source, netisr_default_flow2cpu(m->m_pkthdr.flowid); return (m); } - /* FALLTHROUGH */ - - case NETISR_POLICY_SOURCE: - ifp = m->m_pkthdr.rcvif; - if (ifp != NULL) - *cpuidp = nws_array[(ifp->if_index + source) % - nws_count]; - else - *cpuidp = nws_array[source % nws_count]; - return (m); - - default: - panic("%s: invalid policy %u for %s", __func__, - npp->np_policy, npp->np_name); + policy = NETISR_POLICY_SOURCE; } + + KASSERT(policy == NETISR_POLICY_SOURCE, + ("%s: invalid policy %u for %s", __func__, npp->np_policy, + npp->np_name)); + + ifp = m->m_pkthdr.rcvif; + if (ifp != NULL) + *cpuidp = nws_array[(ifp->if_index + source) % nws_count]; + else + *cpuidp = nws_array[source % nws_count]; + return (m); } /* @@ -795,7 +948,8 @@ netisr_queue_src(u_int proto, uintptr_t source, struct mbuf *m) KASSERT(netisr_proto[proto].np_handler != NULL, ("%s: invalid proto %u", __func__, proto)); - m = netisr_select_cpuid(&netisr_proto[proto], source, m, &cpuid); + m = netisr_select_cpuid(&netisr_proto[proto], NETISR_DISPATCH_DEFERRED, + source, m, &cpuid); if (m != NULL) { KASSERT(!CPU_ABSENT(cpuid), ("%s: CPU %u absent", __func__, cpuid)); @@ -826,23 +980,23 @@ netisr_dispatch_src(u_int proto, uintptr_t source, struct mbuf *m) struct rm_priotracker tracker; #endif struct netisr_workstream *nwsp; + struct netisr_proto *npp; struct netisr_work *npwp; int dosignal, error; - u_int cpuid; - - /* - * If direct dispatch is entirely disabled, fall back on queueing. - */ - if (!netisr_direct) - return (netisr_queue_src(proto, source, m)); + u_int cpuid, dispatch_policy; KASSERT(proto < NETISR_MAXPROT, ("%s: invalid proto %u", __func__, proto)); #ifdef NETISR_LOCKING NETISR_RLOCK(&tracker); #endif - KASSERT(netisr_proto[proto].np_handler != NULL, - ("%s: invalid proto %u", __func__, proto)); + npp = &netisr_proto[proto]; + KASSERT(npp->np_handler != NULL, ("%s: invalid proto %u", __func__, + proto)); + + dispatch_policy = netisr_get_dispatch(npp); + if (dispatch_policy == NETISR_DISPATCH_DEFERRED) + return (netisr_queue_src(proto, source, m)); /* * If direct dispatch is forced, then unconditionally dispatch @@ -851,7 +1005,7 @@ netisr_dispatch_src(u_int proto, uintptr_t source, struct mbuf *m) * nws_flags because all netisr processing will be source ordered due * to always being forced to directly dispatch. */ - if (netisr_direct_force) { + if (dispatch_policy == NETISR_DISPATCH_DIRECT) { nwsp = DPCPU_PTR(nws); npwp = &nwsp->nws_work[proto]; npwp->nw_dispatched++; @@ -861,18 +1015,22 @@ netisr_dispatch_src(u_int proto, uintptr_t source, struct mbuf *m) goto out_unlock; } + KASSERT(dispatch_policy == NETISR_DISPATCH_HYBRID, + ("%s: unknown dispatch policy (%u)", __func__, dispatch_policy)); + /* * Otherwise, we execute in a hybrid mode where we will try to direct * dispatch if we're on the right CPU and the netisr worker isn't * already running. */ - m = netisr_select_cpuid(&netisr_proto[proto], source, m, &cpuid); + sched_pin(); + m = netisr_select_cpuid(&netisr_proto[proto], NETISR_DISPATCH_HYBRID, + source, m, &cpuid); if (m == NULL) { error = ENOBUFS; - goto out_unlock; + goto out_unpin; } KASSERT(!CPU_ABSENT(cpuid), ("%s: CPU %u absent", __func__, cpuid)); - sched_pin(); if (cpuid != curcpu) goto queue_fallback; nwsp = DPCPU_PTR(nws); @@ -1003,6 +1161,9 @@ netisr_start_swi(u_int cpuid, struct pcpu *pc) static void netisr_init(void *arg) { + char tmp[NETISR_DISPATCH_POLICY_MAXSTR]; + u_int dispatch_policy; + int error; KASSERT(curcpu == 0, ("%s: not on CPU 0", __func__)); @@ -1033,6 +1194,20 @@ netisr_init(void *arg) } #endif + if (TUNABLE_STR_FETCH("net.isr.dispatch", tmp, sizeof(tmp))) { + error = netisr_dispatch_policy_from_str(tmp, + &dispatch_policy); + if (error == 0 && dispatch_policy == NETISR_DISPATCH_DEFAULT) + error = EINVAL; + if (error == 0) { + netisr_dispatch_policy = dispatch_policy; + netisr_dispatch_policy_compat(); + } else + printf( + "%s: invalid dispatch policy %s, using default\n", + __func__, tmp); + } + netisr_start_swi(curcpu, pcpu_find(curcpu)); } SYSINIT(netisr_init, SI_SUB_SOFTINTR, SI_ORDER_FIRST, netisr_init, NULL); @@ -1088,6 +1263,7 @@ sysctl_netisr_proto(SYSCTL_HANDLER_ARGS) snpp->snp_proto = proto; snpp->snp_qlimit = npp->np_qlimit; snpp->snp_policy = npp->np_policy; + snpp->snp_dispatch = npp->np_dispatch; if (npp->np_m2flow != NULL) snpp->snp_flags |= NETISR_SNP_FLAGS_M2FLOW; if (npp->np_m2cpuid != NULL) diff --git a/sys/net/netisr.h b/sys/net/netisr.h index cd692f6d601d..83bf9ce5d4d1 100644 --- a/sys/net/netisr.h +++ b/sys/net/netisr.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2007-2009 Robert N. M. Watson - * Copyright (c) 2010 Juniper Networks, Inc. + * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. * * This software was developed by Robert N. M. Watson under contract @@ -70,6 +70,15 @@ #define NETISR_POLICY_FLOW 2 /* Maintain flow ordering. */ #define NETISR_POLICY_CPU 3 /* Protocol determines CPU placement. */ +/* + * Protocol dispatch policy constants; selects whether and when direct + * dispatch is permitted. + */ +#define NETISR_DISPATCH_DEFAULT 0 /* Use global default. */ +#define NETISR_DISPATCH_DEFERRED 1 /* Always defer dispatch. */ +#define NETISR_DISPATCH_HYBRID 2 /* Allow hybrid dispatch. */ +#define NETISR_DISPATCH_DIRECT 3 /* Always direct dispatch. */ + /* * Monitoring data structures, exported by sysctl(2). * @@ -84,7 +93,8 @@ struct sysctl_netisr_proto { u_int snp_qlimit; /* nh_qlimit */ u_int snp_policy; /* nh_policy */ u_int snp_flags; /* Various flags. */ - u_int _snp_ispare[7]; + u_int snp_dispatch; /* Dispatch policy. */ + u_int _snp_ispare[6]; }; /* @@ -173,6 +183,8 @@ typedef struct mbuf *netisr_m2cpuid_t(struct mbuf *m, uintptr_t source, typedef struct mbuf *netisr_m2flow_t(struct mbuf *m, uintptr_t source); typedef void netisr_drainedcpu_t(u_int cpuid); +#define NETISR_CPUID_NONE ((u_int)-1) /* No affinity returned. */ + /* * Data structure describing a protocol handler. */ @@ -185,7 +197,8 @@ struct netisr_handler { u_int nh_proto; /* Integer protocol ID. */ u_int nh_qlimit; /* Maximum per-CPU queue depth. */ u_int nh_policy; /* Work placement policy. */ - u_int nh_ispare[5]; /* For future use. */ + u_int nh_dispatch; /* Dispatch policy. */ + u_int nh_ispare[4]; /* For future use. */ void *nh_pspare[4]; /* For future use. */ }; diff --git a/sys/net/netisr_internal.h b/sys/net/netisr_internal.h index 40afaf16d839..ac3ed0f292fe 100644 --- a/sys/net/netisr_internal.h +++ b/sys/net/netisr_internal.h @@ -1,6 +1,6 @@ /*- * Copyright (c) 2007-2009 Robert N. M. Watson - * Copyright (c) 2010 Juniper Networks, Inc. + * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. * * This software was developed by Robert N. M. Watson under contract @@ -64,6 +64,7 @@ struct netisr_proto { netisr_drainedcpu_t *np_drainedcpu; /* Callback when drained a queue. */ u_int np_qlimit; /* Maximum per-CPU queue depth. */ u_int np_policy; /* Work placement policy. */ + u_int np_dispatch; /* Work dispatch policy. */ }; #define NETISR_MAXPROT 16 /* Compile-time limit. */ From 8f092df025ce5a08d98085c4390ab0224170273d Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Tue, 24 May 2011 12:38:00 +0000 Subject: [PATCH 195/200] Teach netstat(1) about the new global netisr policy sysctl, net.isr.dispatch, and about per-protocol dispatch policies. MFC after: 3 weeks Reviewed by: bz Sponsored by: Juniper Networks, Inc. --- usr.bin/netstat/netisr.c | 65 ++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/usr.bin/netstat/netisr.c b/usr.bin/netstat/netisr.c index 25f341cc5ddc..cc05c38b76e4 100644 --- a/usr.bin/netstat/netisr.c +++ b/usr.bin/netstat/netisr.c @@ -60,8 +60,7 @@ static u_int numthreads; static u_int defaultqlimit; static u_int maxqlimit; -static u_int direct; -static u_int direct_force; +static char dispatch_policy[20]; static struct sysctl_netisr_proto *proto_array; static u_int proto_array_len; @@ -76,6 +75,32 @@ static u_int *nws_array; static u_int maxprot; +static void +netisr_dispatch_policy_to_string(u_int dispatch_policy, char *buf, + size_t buflen) +{ + const char *str; + + switch (dispatch_policy) { + case NETISR_DISPATCH_DEFAULT: + str = "default"; + break; + case NETISR_DISPATCH_DEFERRED: + str = "deferred"; + break; + case NETISR_DISPATCH_HYBRID: + str = "hybrid"; + break; + case NETISR_DISPATCH_DIRECT: + str = "direct"; + break; + default: + str = "unknown"; + break; + } + snprintf(buf, buflen, "%s", str); +} + static void netisr_load_kvm_uint(kvm_t *kd, char *name, u_int *p) { @@ -144,6 +169,7 @@ netisr_protoispresent(u_int proto) static void netisr_load_kvm_config(kvm_t *kd) { + u_int tmp; netisr_load_kvm_uint(kd, "_netisr_bindthreads", &bindthreads); netisr_load_kvm_uint(kd, "_netisr_maxthreads", &maxthreads); @@ -152,8 +178,9 @@ netisr_load_kvm_config(kvm_t *kd) netisr_load_kvm_uint(kd, "_netisr_defaultqlimit", &defaultqlimit); netisr_load_kvm_uint(kd, "_netisr_maxqlimit", &maxqlimit); - netisr_load_kvm_uint(kd, "_netisr_direct", &direct); - netisr_load_kvm_uint(kd, "_netisr_direct_force", &direct_force); + netisr_load_kvm_uint(kd, "_netisr_dispatch_policy", &tmp); + netisr_dispatch_policy_to_string(tmp, dispatch_policy, + sizeof(dispatch_policy)); } static void @@ -168,6 +195,17 @@ netisr_load_sysctl_uint(const char *name, u_int *p) errx(-1, "%s: invalid len %ju", name, (uintmax_t)retlen); } +static void +netisr_load_sysctl_string(const char *name, char *p, size_t len) +{ + size_t retlen; + + retlen = len; + if (sysctlbyname(name, p, &retlen, NULL, 0) < 0) + err(-1, "%s", name); + p[len - 1] = '\0'; +} + static void netisr_load_sysctl_config(void) { @@ -179,8 +217,8 @@ netisr_load_sysctl_config(void) netisr_load_sysctl_uint("net.isr.defaultqlimit", &defaultqlimit); netisr_load_sysctl_uint("net.isr.maxqlimit", &maxqlimit); - netisr_load_sysctl_uint("net.isr.direct", &direct); - netisr_load_sysctl_uint("net.isr.direct_force", &direct_force); + netisr_load_sysctl_string("net.isr.dispatch", dispatch_policy, + sizeof(dispatch_policy)); } static void @@ -244,6 +282,7 @@ netisr_load_kvm_proto(kvm_t *kd) snpp->snp_proto = i; snpp->snp_qlimit = npp->np_qlimit; snpp->snp_policy = npp->np_policy; + snpp->snp_dispatch = npp->np_dispatch; if (npp->np_m2flow != NULL) snpp->snp_flags |= NETISR_SNP_FLAGS_M2FLOW; if (npp->np_m2cpuid != NULL) @@ -418,6 +457,7 @@ netisr_load_sysctl_work(void) static void netisr_print_proto(struct sysctl_netisr_proto *snpp) { + char tmp[20]; printf("%-6s", snpp->snp_name); printf(" %5u", snpp->snp_proto); @@ -426,6 +466,9 @@ netisr_print_proto(struct sysctl_netisr_proto *snpp) (snpp->snp_policy == NETISR_POLICY_SOURCE) ? "source" : (snpp->snp_policy == NETISR_POLICY_FLOW) ? "flow" : (snpp->snp_policy == NETISR_POLICY_CPU) ? "cpu" : "-"); + netisr_dispatch_policy_to_string(snpp->snp_dispatch, tmp, + sizeof(tmp)); + printf(" %8s", tmp); printf(" %s%s%s\n", (snpp->snp_flags & NETISR_SNP_FLAGS_M2CPUID) ? "C" : "-", (snpp->snp_flags & NETISR_SNP_FLAGS_DRAINEDCPU) ? "D" : "-", @@ -483,17 +526,15 @@ netisr_stats(void *kvmd) printf("%-25s %12u %12u\n", "Thread count", numthreads, maxthreads); printf("%-25s %12u %12u\n", "Default queue limit", defaultqlimit, maxqlimit); - printf("%-25s %12s %12s\n", "Direct dispatch", - direct ? "enabled" : "disabled", "n/a"); - printf("%-25s %12s %12s\n", "Forced direct dispatch", - direct_force ? "enabled" : "disabled", "n/a"); + printf("%-25s %12s %12s\n", "Dispatch policy", dispatch_policy, + "n/a"); printf("%-25s %12s %12s\n", "Threads bound to CPUs", bindthreads ? "enabled" : "disabled", "n/a"); printf("\n"); printf("Protocols:\n"); - printf("%-6s %5s %6s %-6s %-5s\n", "Name", "Proto", "QLimit", - "Policy", "Flags"); + printf("%-6s %5s %6s %-6s %-8s %-5s\n", "Name", "Proto", "QLimit", + "Policy", "Dispatch", "Flags"); for (i = 0; i < proto_array_len; i++) { snpp = &proto_array[i]; netisr_print_proto(snpp); From 61401ec2dee8eeb5480f6becfc82658cf52ee447 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Tue, 24 May 2011 13:08:59 +0000 Subject: [PATCH 196/200] An inpcb lock is no longer required in in_pcbref() since the move to refcount(9). MFC after: 3 weeks Sponsored by: Juniper Networks, Inc. --- sys/netinet/in_pcb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 9bde3c821242..85e31dc0ca10 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1054,8 +1054,6 @@ void in_pcbref(struct inpcb *inp) { - INP_WLOCK_ASSERT(inp); - KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); refcount_acquire(&inp->inp_refcount); From 211d4a2c42f4a070f0339d4cc641c456c6607e21 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 24 May 2011 13:17:08 +0000 Subject: [PATCH 197/200] Simplify a stale assertion. We have not called mi_switch() from a nested critical section during a preemption for several years. MFC after: 1 week --- sys/kern/kern_synch.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index d3aef7648d55..05fb4a119a3f 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -400,9 +400,7 @@ mi_switch(int flags, struct thread *newtd) if (!TD_ON_LOCK(td) && !TD_IS_RUNNING(td)) mtx_assert(&Giant, MA_NOTOWNED); #endif - KASSERT(td->td_critnest == 1 || (td->td_critnest == 2 && - (td->td_owepreempt) && (flags & SW_INVOL) != 0 && - newtd == NULL) || panicstr, + KASSERT(td->td_critnest == 1 || panicstr, ("mi_switch: switch in a critical section")); KASSERT((flags & (SW_INVOL | SW_VOL)) != 0, ("mi_switch: switch must be voluntary or involuntary")); From af21235ac46d08fb107b79f18b0d48cbcaa34407 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 24 May 2011 13:22:40 +0000 Subject: [PATCH 198/200] Update comments for DEVICE_PROBE() to reflect that BUS_PROBE_DEFAULT is now the preferred typical return value from a probe routine. Discourage the use of 0 (BUS_PROBE_SPECIFIC) as it should be used very rarely. Point the reader to the DEVICE_PROBE(9) manpage for more detailed notes on possible probe return values. Submitted by: Philip Soeberg philip-dev of soeberg net --- sys/kern/device_if.m | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/kern/device_if.m b/sys/kern/device_if.m index 2931c0a5cd2f..eb720eb69dca 100644 --- a/sys/kern/device_if.m +++ b/sys/kern/device_if.m @@ -89,28 +89,29 @@ CODE { * the probe before returning. The return value of DEVICE_PROBE() * is used to elect which driver is used - the driver which returns * the largest non-error value wins the election and attaches to - * the device. + * the device. Common non-error values are described in the + * DEVICE_PROBE(9) manual page. * * If a driver matches the hardware, it should set the device * description string using device_set_desc() or - * device_set_desc_copy(). This string is - * used to generate an informative message when DEVICE_ATTACH() - * is called. + * device_set_desc_copy(). This string is used to generate an + * informative message when DEVICE_ATTACH() is called. * * As a special case, if a driver returns zero, the driver election * is cut short and that driver will attach to the device - * immediately. + * immediately. This should rarely be used. * - * For example, a probe method for a pci device driver might look + * For example, a probe method for a PCI device driver might look * like this: * * @code - * int foo_probe(device_t dev) + * int + * foo_probe(device_t dev) * { * if (pci_get_vendor(dev) == FOOVENDOR && * pci_get_device(dev) == FOODEVICE) { * device_set_desc(dev, "Foo device"); - * return (0); + * return (BUS_PROBE_DEFAULT); * } * return (ENXIO); * } @@ -125,7 +126,8 @@ CODE { * * @param dev the device to probe * - * @retval 0 if the driver strongly matches this device + * @retval 0 if this is the only possible driver for this + * device * @retval negative if the driver can match this device - the * least negative value is used to select the * driver From 47ad691f8763115eda126f6c2c021d88bfc22ea3 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 24 May 2011 13:36:41 +0000 Subject: [PATCH 199/200] Fix an issue with critical sections and SMP rendezvous handlers. Specifically, a critical_exit() call that drops the nesting level to zero has a brief window where the pending preemption flag is set and the nesting level is set to zero. This is done purposefully to avoid races where a preemption scheduled by an interrupt could be lost otherwise (see revision 144777). However, this does mean that if an interrupt fires during this window and enters and exits a critical section, it may preempt from the interrupt context. This is generally fine as the interrupt code is careful to arrange critical sections so that they are not exited until it is safe to preempt (e.g. interrupts EOI'd and masked if necessary). However, the SMP rendezvous IPI handler does not quite follow this rule, and in general a rendezvous can never be preempted. Rendezvous handlers are also not permitted to schedule threads to execute, so they will not typically trigger preemptions. SMP rendezvous handlers may use spinlocks (carefully) such as the rm_cleanIPI() handler used in rmlocks, but using a spinlock also enters and exits a critical section. If the interrupted top-half code is in the brief window of critical_exit() where the nesting level is zero but a preemption is pending, then releasing the spinlock can trigger a preemption. Because we know that SMP rendezvous handlers can never schedule a thread, we know that a critical_exit() in an SMP rendezvous handler will only preempt in this edge case. We also know that the top-half thread will happily handle the deferred preemption once the SMP rendezvous has completed, so the preemption will not be lost. This makes it safe to employ a workaround where we use a nested critical section in the SMP rendezvous code itself around rendezvous action routines to prevent any preemptions during an SMP rendezvous. The workaround intentionally avoids checking for a deferred preemption when leaving the critical section on the assumption that if there is a pending preemption it will be handled by the interrupted top-half code. Submitted by: mlaier (variation specific to rm_cleanIPI()) Obtained from: Isilon MFC after: 1 week --- sys/kern/subr_smp.c | 50 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 0c2c286f1d03..67774d812c77 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -311,11 +311,15 @@ restart_cpus(cpumask_t map) void smp_rendezvous_action(void) { + struct thread *td; void *local_func_arg; void (*local_setup_func)(void*); void (*local_action_func)(void*); void (*local_teardown_func)(void*); int generation; +#ifdef INVARIANTS + int owepreempt; +#endif /* Ensure we have up-to-date values. */ atomic_add_acq_int(&smp_rv_waiters[0], 1); @@ -329,6 +333,34 @@ smp_rendezvous_action(void) local_teardown_func = smp_rv_teardown_func; generation = smp_rv_generation; + /* + * Use a nested critical section to prevent any preemptions + * from occurring during a rendezvous action routine. + * Specifically, if a rendezvous handler is invoked via an IPI + * and the interrupted thread was in the critical_exit() + * function after setting td_critnest to 0 but before + * performing a deferred preemption, this routine can be + * invoked with td_critnest set to 0 and td_owepreempt true. + * In that case, a critical_exit() during the rendezvous + * action would trigger a preemption which is not permitted in + * a rendezvous action. To fix this, wrap all of the + * rendezvous action handlers in a critical section. We + * cannot use a regular critical section however as having + * critical_exit() preempt from this routine would also be + * problematic (the preemption must not occur before the IPI + * has been acknowleged via an EOI). Instead, we + * intentionally ignore td_owepreempt when leaving the + * critical setion. This should be harmless because we do not + * permit rendezvous action routines to schedule threads, and + * thus td_owepreempt should never transition from 0 to 1 + * during this routine. + */ + td = curthread; + td->td_critnest++; +#ifdef INVARIANTS + owepreempt = td->td_owepreempt; +#endif + /* * If requested, run a setup function before the main action * function. Ensure all CPUs have completed the setup @@ -362,14 +394,18 @@ smp_rendezvous_action(void) */ MPASS(generation == smp_rv_generation); atomic_add_int(&smp_rv_waiters[2], 1); - if (local_teardown_func == smp_no_rendevous_barrier) - return; - while (smp_rv_waiters[2] < smp_rv_ncpus && - generation == smp_rv_generation) - cpu_spinwait(); + if (local_teardown_func != smp_no_rendevous_barrier) { + while (smp_rv_waiters[2] < smp_rv_ncpus && + generation == smp_rv_generation) + cpu_spinwait(); - if (local_teardown_func != NULL) - local_teardown_func(local_func_arg); + if (local_teardown_func != NULL) + local_teardown_func(local_func_arg); + } + + td->td_critnest--; + KASSERT(owepreempt == td->td_owepreempt, + ("rendezvous action changed td_owepreempt")); } void From 7d5ddd30cd6c46f5202ba541653aef5263d77f4c Mon Sep 17 00:00:00 2001 From: Marko Zec Date: Tue, 24 May 2011 14:10:33 +0000 Subject: [PATCH 200/200] Provide fake link status information in an attempt to let ng_eiface(4) virtual ifnets more realistically mimic physical ethernet interfaces. The main motivation behind this change is to allow for ng_eiface(4) interfaces to participate in STP if_bridge(4) configurations. When announcing link status changes, switch to the vnet to which the ifnet belongs, since it is possible for ng_eiface ifnets to be assigned to a vnet different from the one in which its netgraph node resides. MFC after: 3 days --- sys/netgraph/ng_eiface.c | 71 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c index cbae38fafd14..d761a6cbac75 100644 --- a/sys/netgraph/ng_eiface.c +++ b/sys/netgraph/ng_eiface.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -76,6 +77,8 @@ static const struct ng_cmdlist ng_eiface_cmdlist[] = { /* Node private data */ struct ng_eiface_private { struct ifnet *ifp; /* per-interface network data */ + struct ifmedia media; /* (fake) media information */ + int link_status; /* fake */ int unit; /* Interface unit number */ node_p node; /* Our netgraph node */ hook_p ether; /* Hook for ethernet stream */ @@ -127,6 +130,7 @@ static VNET_DEFINE(struct unrhdr *, ng_eiface_unit); static int ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { + const priv_p priv = (priv_p)ifp->if_softc; struct ifreq *const ifr = (struct ifreq *)data; int s, error = 0; @@ -170,6 +174,12 @@ ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data) ifp->if_mtu = ifr->ifr_mtu; break; + /* (Fake) media type manipulation */ + case SIOCSIFMEDIA: + case SIOCGIFMEDIA: + error = ifmedia_ioctl(ifp, ifr, &priv->media, command); + break; + /* Stuff that's not supported */ case SIOCADDMULTI: case SIOCDELMULTI: @@ -280,7 +290,6 @@ ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2) static void ng_eiface_start(struct ifnet *ifp) { - const priv_p priv = (priv_p)ifp->if_softc; /* Don't do anything if output is active */ @@ -328,6 +337,41 @@ ng_eiface_print_ioctl(struct ifnet *ifp, int command, caddr_t data) } #endif /* DEBUG */ +/* + * ifmedia stuff + */ +static int +ng_eiface_mediachange(struct ifnet *ifp) +{ + const priv_p priv = (priv_p)ifp->if_softc; + struct ifmedia *ifm = &priv->media; + + if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) + return (EINVAL); + if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO) + ifp->if_baudrate = ifmedia_baudrate(IFM_ETHER | IFM_1000_T); + else + ifp->if_baudrate = ifmedia_baudrate(ifm->ifm_media); + + return (0); +} + +static void +ng_eiface_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) +{ + const priv_p priv = (priv_p)ifp->if_softc; + struct ifmedia *ifm = &priv->media; + + if (ifm->ifm_cur->ifm_media == (IFM_ETHER | IFM_AUTO) && + (priv->link_status & IFM_ACTIVE)) + ifmr->ifm_active = IFM_ETHER | IFM_1000_T | IFM_FDX; + else + ifmr->ifm_active = ifm->ifm_cur->ifm_media; + ifmr->ifm_status = priv->link_status; + + return; +} + /************************************************************************ NETGRAPH NODE STUFF ************************************************************************/ @@ -371,6 +415,18 @@ ng_eiface_constructor(node_p node) ifp->if_flags = (IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST); ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU; ifp->if_capenable = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU; + ifmedia_init(&priv->media, 0, ng_eiface_mediachange, + ng_eiface_mediastatus); + ifmedia_add(&priv->media, IFM_ETHER | IFM_10_T, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_100_TX, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_1000_T, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL); + ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO); + priv->link_status = IFM_AVALID; /* Give this node the same name as the interface (if possible) */ if (ng_name_node(node, ifp->if_xname) != 0) @@ -379,6 +435,7 @@ ng_eiface_constructor(node_p node) /* Attach the interface */ ether_ifattach(ifp, eaddr); + ifp->if_baudrate = ifmedia_baudrate(IFM_ETHER | IFM_1000_T); /* Done */ return (0); @@ -401,7 +458,10 @@ ng_eiface_newhook(node_p node, hook_p hook, const char *name) NG_HOOK_SET_PRIVATE(hook, &priv->ether); NG_HOOK_SET_TO_INBOUND(hook); + priv->link_status |= IFM_ACTIVE; + CURVNET_SET_QUIET(ifp->if_vnet); if_link_state_change(ifp, LINK_STATE_UP); + CURVNET_RESTORE(); return (0); } @@ -486,16 +546,20 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook) } /* end of inner switch() */ break; case NGM_FLOW_COOKIE: + CURVNET_SET_QUIET(ifp->if_vnet); switch (msg->header.cmd) { case NGM_LINK_IS_UP: + priv->link_status |= IFM_ACTIVE; if_link_state_change(ifp, LINK_STATE_UP); break; case NGM_LINK_IS_DOWN: + priv->link_status &= ~IFM_ACTIVE; if_link_state_change(ifp, LINK_STATE_DOWN); break; default: break; } + CURVNET_RESTORE(); break; default: error = EINVAL; @@ -557,6 +621,7 @@ ng_eiface_rmnode(node_p node) * hence we have to change the current vnet context here. */ CURVNET_SET_QUIET(ifp->if_vnet); + ifmedia_removeall(&priv->media); ether_ifdetach(ifp); if_free(ifp); CURVNET_RESTORE(); @@ -576,6 +641,10 @@ ng_eiface_disconnect(hook_p hook) const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); priv->ether = NULL; + priv->link_status &= ~IFM_ACTIVE; + CURVNET_SET_QUIET(priv->ifp->if_vnet); + if_link_state_change(priv->ifp, LINK_STATE_DOWN); + CURVNET_RESTORE(); return (0); }