From owner-freebsd-jail@freebsd.org Mon Nov 28 22:47:33 2016 Return-Path: Delivered-To: freebsd-jail@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 386D5C5A95B for ; Mon, 28 Nov 2016 22:47:33 +0000 (UTC) (envelope-from jamie@freebsd.org) Received: from gritton.org (gritton.org [199.192.165.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gritton.org", Issuer "Let's Encrypt Authority X3" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id DE48415C9 for ; Mon, 28 Nov 2016 22:47:32 +0000 (UTC) (envelope-from jamie@freebsd.org) Received: from gritton.org (gritton.org [199.192.165.131] (may be forged)) by gritton.org (8.15.2/8.15.2) with ESMTPS id uASMcukb055036 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 28 Nov 2016 15:38:56 -0700 (MST) (envelope-from jamie@freebsd.org) Received: (from www@localhost) by gritton.org (8.15.2/8.15.2/Submit) id uASMctwP055035; Mon, 28 Nov 2016 15:38:55 -0700 (MST) (envelope-from jamie@freebsd.org) X-Authentication-Warning: gritton.org: www set sender to jamie@freebsd.org using -f To: freebsd-jail@freebsd.org Subject: Re: jls(8) inconsistent output X-PHP-Originating-Script: 0:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 28 Nov 2016 15:38:55 -0700 From: James Gritton In-Reply-To: <20161127200022.GA14008@csarch> References: <20161127200022.GA14008@csarch> Message-ID: <4e514e3bff16be825c7b52de3b441ed3@freebsd.org> X-Sender: jamie@freebsd.org User-Agent: Roundcube Webmail/1.2.2 X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2016 22:47:33 -0000 On 2016-11-27 13:00, Christian Schwarz wrote: > Hi all, > > jls(8) is generating inconsistent output regarding IPv4 & IPv6 > addresses. > > Below are some examples documenting the behavior. > > - For readability, I use `--libxo json` and pipe the output through > jq. > However, the information is the same as without `--libxo` > - These are all jails spawned by ezjail(8), hence spawned using the > old rc.conf syntax. > > Can anyone reproduce these inconsistencies on their system? > Possibly with the native jail.conf / other jail managers. > > Furthermore: I would be willing to try fixing the behavior. > However, do you think changing/correcting the output at this point > will > break existing software? Most of the output doesn't need fixing, just understanding why it is the way it is. The no-option jls is the original format used when jails had much less information in them, and has been kept in that format for just the reason you mentioned (not breaking existing software). Later on, jails got a little more complex, and the "-v" was added to show the (then) complete jail information. I consider both of these options (well, the one option and the one lack of options) to be back-compatible behavior at this point. For the modern jails with the more dynamic parameters you should either specify the parameters you want on the command line, or use "all". The "-n" doesn't matter if you're using libxo which needs to print names anyway. This explains the difference in your examples, except the weirdness of the -v output having both IPv4 and IPv6 addresses listed as "ipv4_addrs". I guess that follows the non-libxo -v convention of printing both kinds of addresses together, though the label "ipv4_addrs" is incorrect and probably should be "ip_addrs" or the like. That may be worth fixing, or may have the existing software problem at this point; I don't know what software uses the libxo output, but I imagine something does. I can only give a similar "maybe" for your comment of the multiple addresses being better presented as JSON arrays. That does seem cleaner, as long as it doesn't break much. On the point ip ip4 and ip6 being inconsistent: yes they are. I'm going to have to look in to why they're showing as "disabled" when then should be "new". This is a problem independent of whether the output is from libxo. - Jamie > jls --libxo json > IPv6 addresses are not printed at all > ... > { > ... > "ipv4": "10.123.234.6", > ... > } > ... > > jls --libxo json -n all > Both address types are printed, but not particularly nicely (should > use JSON arrays) > Additionally, the ip(4|6) variables seem inconsistent. > ... > { > "ip4": "disable", > "ip6": "disable", > ... > "ip4.addr": "10.123.234.6", > "ip4.saddrsel": true, > "ip6.addr": "2001:ffff:ffff::b,2001:ffff:ffff::d", > "ip6.saddrsel": true > } > ... > > jls --libxo json -v > Attention: no -n specified > Prints IPv6-Addresses as IPv4 addresses. > ... > { > ... > "ipv4_addrs": [ > "10.123.234.6", > "2001:ffff:ffff::b", > "2001:ffff:ffff::d" > ] > } > ...