From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30081.outbound.protection.outlook.com [40.107.3.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id 93E543CB48 for ; Sat, 10 Mar 2018 10:56:18 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=darbyshire-bryant.me.uk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=yYKJF0tGmeZ5ANxlkVUOtTFLBEFLU3zZSXcTnOixzp4=; b=roKHozAc2bpLb4P1u3lw/oe3Tc7eVkHnQXWlb4JEgnh1A+6UtaBbXZwkBsCrfWgzdiiFABLPrr3iUQrepJY4fTA3XWTHXx72XPL9rGJEZb6GNX4tPX/j8S5MrLwE+ZXJxsZqSJ28IpWpcMqRSE7DHFP3gZpvVWCj5jUq7BvEHbs= Received: from AM0PR0702MB3730.eurprd07.prod.outlook.com (52.133.51.23) by AM0PR0702MB3636.eurprd07.prod.outlook.com (52.133.50.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.7; Sat, 10 Mar 2018 15:56:16 +0000 Received: from AM0PR0702MB3730.eurprd07.prod.outlook.com ([fe80::a95a:1cfd:7299:5172]) by AM0PR0702MB3730.eurprd07.prod.outlook.com ([fe80::a95a:1cfd:7299:5172%3]) with mapi id 15.20.0588.001; Sat, 10 Mar 2018 15:56:16 +0000 From: Kevin Darbyshire-Bryant To: =?utf-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= CC: Stephen Hemminger , "cake@lists.bufferbloat.net" Thread-Topic: [Cake] [PATCH] q_cake: Update xstats format to use per-tin structure Thread-Index: AQHTtf92ZAagU2vDn02WdO/2XvDtbKPElDwAgAAI7YCAAAWrAIAACK4AgAAQ4oCAAFtzAIAANGmAgAA2UYCAAHgrgIAAFtAAgAAT6ICAAAGnAIAABVyAgAADTgCAAAGeAIAAAcEAgANxgIA= Date: Sat, 10 Mar 2018 15:56:16 +0000 Message-ID: References: <20180127130542.25817-1-toke@toke.dk> <876068nccm.fsf@toke.dk> <0A156FD3-4816-462C-952B-7938EF8C0EA3@gmail.com> <87sh9cl15n.fsf@toke.dk> <879005B6-2334-4F46-9922-4BC2CACBF107@darbyshire-bryant.me.uk> <87vae8yy68.fsf@toke.dk> <87sh9cyxy9.fsf@toke.dk> <340269AF-2325-4657-8939-5E3195D1C0DC@darbyshire-bryant.me.uk> <87muzkyvj7.fsf@toke.dk> <11DDD9A0-BBD7-4DAA-ACE1-EB88CDC26E7C@darbyshire-bryant.me.uk> <87h8psyraq.fsf@toke.dk> <6F0B516E-3244-4A93-8762-3EAF3BD71BF2@darbyshire-bryant.me.uk> <87k1unlgck.fsf@toke.dk> <4654DB0C-74E6-46FB-9F62-119076D0A20B@darbyshire-bryant.me.uk> <87371a3ljk.fsf@toke.dk> <87sh9a25ta.fsf@toke.dk> <8B3F5A39-852D-41CE-B623-C65FCBA037FF@darbyshire-bryant.me.uk> <04044BF0-504A-41DC-8F1B-A9528B4E887A@darbyshire-bryant.me.uk> <87po4e24ph.fsf@toke.dk> In-Reply-To: <87po4e24ph.fsf@toke.dk> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [193.240.142.133] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR0702MB3636; 7:odQDQUH0os5iCwFi4xQkts7Pdj+Jf/OG3iFZpFtB2e0R/5QzPP6os6ncsNDXys5OqLg/SkNwEqv1gfqiswyfvNRpII7/dnS/lp9YoWx2b30Stppqm0ahD+I/U5pTMjG8S8tdiMc7FLU9rsMnadk3HYCsbqxGDpwnmoP4hVVS9fbHWvmfdPDmQjmE1/Qql9fHrPJ7CajjqXDFv/Z9tbBC1C2KvEyoyuQ4zk8yiP8eb9PN1UNQ7mfA5hCskgJxzPQU x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 69abb5f2-e62a-45aa-6739-08d5869f7525 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(5600026)(4604075)(3008032)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(49563074)(7193020); SRVR:AM0PR0702MB3636; x-ms-traffictypediagnostic: AM0PR0702MB3636: authentication-results: spf=none (sender IP is ) smtp.mailfrom=kevin@darbyshire-bryant.me.uk; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415395)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231220)(944501244)(52105095)(10201501046)(93006095)(93001095)(6041310)(20161123562045)(20161123558120)(2016111802025)(20161123564045)(20161123560045)(6072148)(6043046)(201708071742011); SRVR:AM0PR0702MB3636; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0702MB3636; x-forefront-prvs: 06070568C5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39830400003)(376002)(396003)(346002)(39380400002)(189003)(199004)(54906003)(25786009)(68736007)(6506007)(81156014)(6116002)(6436002)(3846002)(3660700001)(102836004)(8676002)(74482002)(3280700002)(33656002)(6512007)(7736002)(305945005)(316002)(82746002)(4326008)(5660300001)(8936002)(76176011)(53546011)(6486002)(99936001)(105586002)(83716003)(86362001)(81166006)(99286004)(229853002)(478600001)(2906002)(97736004)(66066001)(106356001)(186003)(26005)(2900100001)(53936002)(36756003)(6246003)(2950100002)(5250100002)(14454004)(6916009)(93886005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0702MB3636; H:AM0PR0702MB3730.eurprd07.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: darbyshire-bryant.me.uk does not designate permitted sender hosts) x-microsoft-antispam-message-info: 8eF6d95/+iX43Zdjkmon0Sp/8be1KwPuPtsvxSe897pONI4s/RTeqkRvvkw5AviCy0WQ9sGwlx0j/VePtBxG1DVdsxTo8SAqGEUfNP8XAWVOrUxCMxkc9s5rpebNem1eaxEXwzMsuHEQUQhsYegoVZVWRhKNWe7OplkCck6WWlsGp0h4sMWrZyyg7PLc18up0PD286tEy4Zh5e3NwcUSrgm+qY4moA32tT9K+/8qgRooX59XnQZp2A1/BxmmsZphq322QVMmvWH5ohgKklUpc7JKKamOyzk3LhRRZbOsn5SjmC75tEWUxWYjgWsGJqlk4DKGRXrgki3ep2Xtl+KNrQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/signed; boundary="Apple-Mail=_01A9F511-9254-4421-9B97-D1E2D77D5148"; protocol="application/pgp-signature"; micalg=pgp-sha256 MIME-Version: 1.0 X-OriginatorOrg: darbyshire-bryant.me.uk X-MS-Exchange-CrossTenant-Network-Message-Id: 69abb5f2-e62a-45aa-6739-08d5869f7525 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Mar 2018 15:56:16.5007 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9151708b-c553-406f-8e56-694f435154a4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0702MB3636 Subject: Re: [Cake] [PATCH] q_cake: Update xstats format to use per-tin structure X-BeenThere: cake@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Cake - FQ_codel the next generation List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Mar 2018 15:56:18 -0000 --Apple-Mail=_01A9F511-9254-4421-9B97-D1E2D77D5148 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 8 Mar 2018, at 11:21, Toke H=C3=B8iland-J=C3=B8rgensen = wrote: >=20 >>=20 >> Oh and curiously the bad values go away if you ask for json output >> it=E2=80=99s much better. Which rather points at a =E2=80=98feature=E2= =80=99 of the >> =E2=80=98print_string=E2=80=99 behaviour. >=20 > Right. Well, the print_* functions are behind several levels of > pre-processor indirection, so not quite obvious what's going on here. > Don't really see why they should spit out garbage values, though. >=20 >=20 > Stephen, do you have any ideas? >=20 > -Toke Right, cracked it and it=E2=80=99s horrible! print_uint is expanded thus: Note the type of value uint64_t void print_color_uint(enum output_type t, enum color_attr = color, const char *key, const char *fmt, uint64_t value); static inline void print_uint (enum output_type t, = const char *key, const char *fmt, uint64_t value) { print_color_uint( t, COLOR_NONE, = key, fmt, value); }; So far so good. print_color_uint expands to: void print_color_uint(enum output_type t, enum color_attr = color, const char *key, const char *fmt, uint64_t value) { if (((t & PRINT_JSON || t & PRINT_ANY) && _jw)) { if (!key) jsonw_uint(_jw, value); else jsonw_uint_field(_jw, key, value); } else if ((!_jw && (t & PRINT_FP || t & PRINT_ANY))) { color_fprintf( (stdout) , color, fmt, value); } }; Again, no issue and we eventually call color_fprintf int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...) { int ret =3D 0; va_list args; va_start(args, fmt); if (!color_is_enabled || attr =3D=3D COLOR_NONE) { ret =3D vfprintf(fp, fmt, args); goto end; } Now, color_printf is a variable argument list function and as such is = dependent upon being told the correct size of argument variables in the = fmt variable. And that=E2=80=99s our problem, we=E2=80=99re passing a = 64bit integer but telling the format string that it=E2=80=99s = =E2=80=98int=E2=80=99=E2=80=A6which I=E2=80=99m guessing can be variable = sizes depending on architecture, as can the endianness. If we instead do (in q_cake.c) #include print_uint(PRINT_ANY, "min_transport_size", " min/max transport layer = size: %10" PRIu64, stnc->min_trnlen); it works. This needs sanity checking by a clever person. Cheers, Kevin D-B 012C ACB2 28C6 C53E 9775 9123 B3A2 389B 9DE2 334A --Apple-Mail=_01A9F511-9254-4421-9B97-D1E2D77D5148 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEASyssijGxT6XdZEjs6I4m53iM0oFAlqkAB8ACgkQs6I4m53i M0rC2RAAsHPMtHCEwYJhP/7jBCfpT+YxB33o7l1KmVQd2f1kN+VuQZTYVqKrm4YO TXIiy/qcJFVxv03004nYHarIVQrkPsR0Opx2SkInj5ngHFprvKAN5KVlIle6RTsO +G7+MusjFhxZRn57ZeQFbWarZbLMQhnQ9mJpfTz6C86m1Y/YX1U81YQI9NFjmdiO zkqGrjiMmzaGGCJfpoe91dZYpfoF/RY3F4eiqLXKxbw6aGJym9zr35Cb4qzRq8I0 axZuRV49xwVD0XHBnBgyRWvtb6T/lGDHpj/pTWMZS4ILxGLn36s+NnGkeiK6XdXK IHgF7Vmcc+lnhuUAEydNkoQmsK+vDaB2FRT83TSpkA1LgOxg4WVyjUmX3oeW0LoU gt7XWEtx4dQgkwf/uaurUys8YmwT7UhY+wFZAnoNYXDeDDKkuiWdvtTzRjqw60iI +Fu4AoCJ0CZp/18PWGmJD4QtynHUtPcXxt6rr5IL5Lf6gOHf+1LCKfNDHvhYOuks nN+prLC42wE5nAXbbz++SIYQogu4BUwPruwrLDgwh2jXG/uKpLpfJ6/awTfAejxL q6mxBA3q1in9QLQQbdJLF/pucnemUx6esc/buhA88R4wkdlkNoweBMf06fbFKPMx SszFvR3Z5tDCUJCmqCN5J+zT3OnnaxRek8oFbrSCcLtAPc7mmSA= =FPi8 -----END PGP SIGNATURE----- --Apple-Mail=_01A9F511-9254-4421-9B97-D1E2D77D5148--