Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4378298pxv; Tue, 20 Jul 2021 02:19:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwIqcuPEscN8IvBom7aig4+AoRFwyqnN0cDaROxV7KBOVu3ntQO/02d9u/IzHuidWiPV15 X-Received: by 2002:a05:6402:1a3c:: with SMTP id be28mr39247954edb.15.1626772748836; Tue, 20 Jul 2021 02:19:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626772748; cv=none; d=google.com; s=arc-20160816; b=Nw94qJ1YHhyVFicN5fuSJfBZB0zmMdXS9Gn/pfzDRVl9jzDB3fCb+iyZG6KpmiS3Ci xLuwVht4FdmrjI5Ppo8ssRdHe2HtQusA+1U8yoKFkb7CBYPIRv1/y/u++vgpMiddgwWF sVN+s03fREwaRwSXQEcb000AcCQT2zdIsPCMxETd6Ssk7zzzJDku6Th3YvHGjGvSQFpQ DEs0ML4Q6gQ72lIqIjoLC+hICvhRKNe5193ecE+IFU5k+TN7huZFpX7GOe/gSNoupzGR VEu9cFRA1FPWVnwTCQqdxuib5P0l0wlCC1Mn5kp5lh0P8VfPzt9kaaFxC7Olej/Qy/sb m1Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:reply-to:subject:to :from:dkim-signature; bh=+GcYhvCkG0nF6Zw2BBvM+1MyP49pbxXL8NMXyfEzDF8=; b=CKdktVlIdUBBm93KcW5pK6vcdztjEOjqlhswADWdwskYgAv53X06mooTdv7Inguyra PAPyMXbJfr89QU8IHzg/+TqalRCVnHsTLRoq3CweKG9UDy5qtDRvJaaxftCKdgNYeDAj zo4YdlGqgIEOLe916s8KbxNaeG3YxcGbcHQviMm8WqsqPj7ZHbxdcQpOqY2TdJ6bQuyZ /vMW9aIq5u05oYHvdVgMhzo74HJueXb4xLoco74q+mlhkkrU8tqylEkqemspHoJ//8qJ d32B6GU4wDwcCTNayFl4SqlXPvuRveatbJhTyBGWpw4HwNC5GcJ8NCfPmI5+uJpS5YiB 6IwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qUWG1SFl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si22688091ejb.555.2021.07.20.02.18.44; Tue, 20 Jul 2021 02:19:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qUWG1SFl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235181AbhGTIgM (ORCPT + 99 others); Tue, 20 Jul 2021 04:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234988AbhGTIeR (ORCPT ); Tue, 20 Jul 2021 04:34:17 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 361CFC061574; Tue, 20 Jul 2021 02:14:17 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id f8-20020a1c1f080000b029022d4c6cfc37so1045912wmf.5; Tue, 20 Jul 2021 02:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:reply-to:date:message-id:mime-version; bh=+GcYhvCkG0nF6Zw2BBvM+1MyP49pbxXL8NMXyfEzDF8=; b=qUWG1SFlvLeh8MPoN8Vp58/XI+cMJKauP4oMdnYhtD0L2S9O92Lpb0Z8H/C8bYlTyT T7ABO/rMuurHowXDUValpwG6/rbKD1ld/9Z3T7rOoTMIyhOOhJysC6kZZGfhRGTVWj/h D59UOdTJz1CcL88C4AtZCC5iOjzxDVX9CclNGGHw/KafZRNiI8UQlIz0VkC+wj8dUOIS o6dJRUKTsOX2Dkyh6hmKdp6yjIuIa8x4lflK6/zCkj+kK6RF42EK06S75eQFJ4OzED2m 9L0euQKmqLo6mKN8MZX6CmuU53g7HhonGKj1Il7m6eYHh64HzvJwLuCtwZmlazLc3e8U v48Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:reply-to:date:message-id :mime-version; bh=+GcYhvCkG0nF6Zw2BBvM+1MyP49pbxXL8NMXyfEzDF8=; b=bG7dnX+hRIclST8uRuUd7bCPD9esgWEdAfX2EdEWW3pDRSOVvlz4gzvMrBMqAIFLvY V7I3HiLVBOJSYpCcvNDGwTlb1zNbBiTbdZRmusr3obDitWVQ34UpovcPtSCOWg6aiebT CZOdV5OQ/8XD64b5bZIXycjLT/ZNTucgTeRsTUf8huk5C0mMX0kCkC/U9nj0Oy2AQwGB sAzTf6OQQGh4i8ew2kzfhMGlFNtwP2WLK0+wh7CIvcyM4/nOpbXMG3tAi6Qmj8+3KJ2Z 0qFio/x8u+rPIUDDEqZbwnAs0QUoc1Ccm9ohT5b1NZXSK6eLSccKvJvPNt9xPRMh01Bt 8dhA== X-Gm-Message-State: AOAM533pT6MPveOREoA02EBnQCx/czx1f+Uo4vt08lc6tzRzTSD2fvF/ ZDThLSdIzJrRshPHeRqQeWBUMVkT/OI= X-Received: by 2002:a05:600c:430c:: with SMTP id p12mr37231933wme.16.1626772455773; Tue, 20 Jul 2021 02:14:15 -0700 (PDT) Received: from jvdspc.jvds.net ([212.129.81.137]) by smtp.gmail.com with ESMTPSA id n23sm19362537wmc.38.2021.07.20.02.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 02:14:14 -0700 (PDT) Received: from jvdspc.jvds.net (localhost [127.0.0.1]) by jvdspc.jvds.net (8.16.1/8.15.2) with ESMTPS id 16K9EESl295025 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 20 Jul 2021 10:14:14 +0100 Received: (from jvd@localhost) by jvdspc.jvds.net (8.16.1/8.16.1/Submit) id 16K9ED1N295023; Tue, 20 Jul 2021 10:14:13 +0100 X-Authentication-Warning: jvdspc.jvds.net: jvd set sender to jason.vas.dias@gmail.com using -f From: "Jason Vas Dias" To: linux-kernel@vger.kernel.org, linux-8086@vger.kernel.org Subject: /proc/net/{udp,tcp}{,6} : ip address format : RFC : need for /proc/net/{udp,tcp}{,6}{{n,h},{le,be}} ? Reply-To: "Jason Vas Dias" Date: Tue, 20 Jul 2021 10:14:13 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Good day - I noticed that /proc/net/{udp,tcp} files (bash expansion) - the IPv4 socket tables - contain IPv4 addresses in hex format like: 0100007F:0035 (Little-Endian IPv4 address 127.0.0.1 , Big Endian port 53) I would have printed / expected the IPv4 address to be printed EITHER like: 7F000001:0035 (Both Big-Endian) OR 0100007F:3500 (Both Little-Endian) . It is rather idiosyncratic that Linux chooses to print Little-Endian IPv4 addresses, but not Little-Endian Ports , and where the other numbers eg. (rx:tx) , (tr:tm/when) in those files are all Big-Endian. Perhaps a later version of Linux could either A) Print ALL IP addresses and Ports and numbers in network (Big Endian) byte order, or as IP dotted-quad+port strings ; OR: B) Provide /proc/net/{udp,tcp}{,6}{n,be,h,le,ip} files ( use shell : $ echo which print IPv4 addresses & Ports in formats: n: network: always Big Endian h: host: native either Little-Endian (LE) or Big Endian (BE) be: BE - alias for 'n' le: LE - alias for 'h' on LE platforms, else LE ip: as dotted-decimal-quad+':'decimal-port strings, with numbers in BE. ; OR: C) Provide /proc/net/{udp,tcp}{,6}bin memory mappable binary socket table files . ? Should I raise a bug on this ? Rather than currently letting users discover this fact by mis-converting IP addresses / ports initially as I did at first. Just a thought / request for comments. One would definitely want to inform the netstat + lsof + glibc developers before choosing option A . Option B allows users to choose which endianess to use (for ALL numbers) by only adding new files, not changing existing ones. Option C would obviate the need to choose an endianess file by just providing one new memory-mappable binary representation of the sockets table, of size an even multiple of the page-size, but whose reported size would be (sizeof(some_linux_ip_socket_table_struct_t) * n_sockets_in_table). It could be provided alongside option B. I think options B and / or C would be nice to have - I might implement an extension to the procfs code that prints these socket tables to do this, maybe enabled by a new experimental '+rational-ip-socket-tables' boot option - then at least it would be clear how the numbers in those files are meant to be read / converted. All the best, Jason