From owner-svn-src-head@freebsd.org Tue Aug 13 16:54:05 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FB6BB5CC2 for ; Tue, 13 Aug 2019 16:54:05 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 467JhX38pyz46Yq for ; Tue, 13 Aug 2019 16:54:04 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qk1-x72c.google.com with SMTP id r6so80243877qkc.0 for ; Tue, 13 Aug 2019 09:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9NXwsKLajKr99S/pxr1BSITxGFaKNUfYXMupH6pzEZ8=; b=rUVDkLTM07yH6V0ZjVKHmMWoAeOyGkQW8NH06miPEnUVnZv2bQ7Z7onUKkQVnfzg+9 AQ8ljy54Hq0AqYD0OxvHiHPzwVcQF+rXRi0oe8bwBalo1yKKWgDyp/A1GEVuYvxaS7Da asKGrKOBlJIvIBsIibREDfRbb7R6QYiY09Hw+yCwdRyQ3HrfL5kLtd6kufHvHcX2aM+7 M91PM4VTkq2JzcUdzTNAP9vFGH03vnAoo9ro5qDJmuyjGfuTtxX3xP3VPhXtgalbygM2 PlWLKiCYIV8buIqgB+J4iZJP590qjqcwGHJAd2AvQ6AGCVxN4g7hbidtlvIllcjcun/3 7w7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9NXwsKLajKr99S/pxr1BSITxGFaKNUfYXMupH6pzEZ8=; b=oPiFu8sRzgzP1V9T/YLYSuWYBKZHYwkImepGs01wjeWGlXkZZjoukvuJv2e8DKBba2 PMUl1xREfkp0NQNTMiitEBiiTvBfF7kFje4fVUIuYCcYjPYQtaihpV88NxJL2e2Rlbp/ eqGj0anzagJwxbZVvaQN0z9joREtqxzG5/uwAmHTcV8B4wElrzytlX8dG4717oPp7d6G Cd6m8HLY/oZZ/mLDjHJI7yWh45IHY4FBONK/WS+JZkAcV4qezPWshb5cySMguQ36RgD4 ZJ+8+Jdp8GQriFpYCB1XBTHzdJSiStG4A7LsGiRZ87UrAaK9dFQ7NRzAFfgaU/eB/PjH HFLg== X-Gm-Message-State: APjAAAVVRYDzSURJlP5spv3O4O+/C9842yiSgRqQXrNnnQbehx1xQKyH 6ODuoeTzyw1tb3REmT8XzwPvTeBtHxeMPqmeLCiM9g== X-Google-Smtp-Source: APXvYqwT1Kv3+et2AGmFh2g/jV5CoYlzf2n/D4lv4tgdrhOvOgTv/Rop66yysc+GDb4bXC1r7/IRPRCTaP3+n1eT+8M= X-Received: by 2002:a37:c87:: with SMTP id 129mr31806674qkm.240.1565715243232; Tue, 13 Aug 2019 09:54:03 -0700 (PDT) MIME-Version: 1.0 References: <201908131622.x7DGMhUL047226@repo.freebsd.org> In-Reply-To: From: Warner Losh Date: Tue, 13 Aug 2019 10:53:52 -0600 Message-ID: Subject: Re: svn commit: r350993 - head/sbin/ping6 To: "Enji Cooper (yaneurabeya)" Cc: Alan Somers , src-committers , svn-src-all , svn-src-head X-Rspamd-Queue-Id: 467JhX38pyz46Yq X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=rUVDkLTM; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::72c) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-4.94 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-head@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; URI_COUNT_ODD(1.00)[3]; RCPT_COUNT_FIVE(0.00)[5]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; NEURAL_HAM_SHORT(-0.99)[-0.991,0]; RCVD_IN_DNSWL_NONE(0.00)[c.2.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; FREEMAIL_TO(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-2.95)[ip: (-9.35), ipnet: 2607:f8b0::/32(-2.97), asn: 15169(-2.39), country: US(-0.05)]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Aug 2019 16:54:05 -0000 On Tue, Aug 13, 2019 at 10:50 AM Enji Cooper (yaneurabeya) < yaneurabeya@gmail.com> wrote: > > > On Aug 13, 2019, at 09:22, Alan Somers wrote: > > > > Author: asomers > > Date: Tue Aug 13 16:22:43 2019 > > New Revision: 350993 > > URL: https://svnweb.freebsd.org/changeset/base/350993 > > > > Log: > > Consistently use the byteorder functions in the correct direction > > > > Though ntohs and htons are functionally identical, they have different > meanings.Using the correct one helps to document the code. > > This statement is only true for BE platforms. For LE platforms like > i386/x64, ntohs and htons actually does a endianness conversion: > > sys/powerpc/include/endian.h:#define __ntohs(x) > (__bswap16((__uint16_t)(x))) > sys/powerpc/include/endian.h:#define __ntohs(x) ((__uint16_t)(x)) > sys/sparc64/include/endian.h:#define __ntohs(x) ((__uint16_t)(x)) > sys/x86/include/endian.h:#define __ntohs(x) __bswap16(x) > sys/mips/include/endian.h:#define __ntohs(x) ((__uint16_t)(x)) > sys/mips/include/endian.h:#define __ntohs(x) (__bswap16((x))) > sys/arm/include/endian.h:#define __ntohs(x) ((__uint16_t)(x)) > sys/arm/include/endian.h:#define __ntohs(x) (__bswap16(x)) > sys/arm64/include/endian.h:#define __ntohs(x) (__bswap16(x)) > sys/riscv/include/endian.h:#define __ntohs(x) (__bswap16(x)) > sys/sys/param.h:#define ntohs(x) __ntohs(x) > sys/netinet/in.h:#define ntohs(x) __ntohs(x) > The statement was that htons and ntohs are the same actual code, but document different things. And that's correct. htons and ntohs can be used indiscriminately and the code will still work. But using htons when putting data into network byte order and ntohs when putting it into host order documents the operations better. This is independent of endian: either both do nothing, or both do bswap16. Warner