Bug 215008 - [patch] jls(8) separate lists for IPv4 and IPv6 in verbose libxo output
Summary: [patch] jls(8) separate lists for IPv4 and IPv6 in verbose libxo output
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-jail (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-12-02 16:25 UTC by Christian Schwarz
Modified: 2016-12-25 00:41 UTC (History)
1 user (show)

See Also:


Attachments
[Patch 1/2] Separate libxo lists for IPv4 and IPv6 addresses in verbose mode. (4.04 KB, patch)
2016-12-02 16:25 UTC, Christian Schwarz
no flags Details | Diff
[Patch 2/2] Emit IP addresses as lists in -n and encoding-format mode. (5.34 KB, patch)
2016-12-03 21:14 UTC, Christian Schwarz
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Schwarz 2016-12-02 16:25:23 UTC
Created attachment 177607 [details]
[Patch 1/2] Separate libxo lists for IPv4 and IPv6 addresses in verbose mode.

jls(8) prints IPv6 addresses in the 'ipv4_addr' field
when running 'jls -v --libxo json'

This patch starts separate libxo lists for IPv4 and IPv6 addresses.
Comment 1 Christian Schwarz 2016-12-03 21:14:44 UTC
Created attachment 177639 [details]
[Patch 2/2] Emit IP addresses as lists in -n and encoding-format mode.
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-12-24 23:52:21 UTC
A commit references this bug:

Author: jamie
Date: Sat Dec 24 23:51:27 UTC 2016
New revision: 310530
URL: https://svnweb.freebsd.org/changeset/base/310530

Log:
  Improve IP address list representation in libxo output.

  Extract decision-making about special-case printing of certain
  jail parameters into a function.

  Refactor emitting of IPv4 and IPv6 address lists into a function.

  Resulting user-facing changes:

  XO_VERSION is bumped to 2.

  In verbose mode (-v), IPv4 and IPv6-Addresses are now properly emitted
  as separate lists.
  This only affects the output in encoding styles, i.e. xml and json.

  {                                    {
    "__version": "1",                    "__version": "2",
    "jail-information": {                "jail-information": {
      "jail": [                            "jail": [
        {                                    {
          "jid": 166,                          "jid": 166,
          "hostname": "foo.com",               "hostname": "foo.com",
          "path": "/var/jail/foo",             "path": "/var/jail/foo",
          "name": "foo",                       "name": "foo",
          "state": "ACTIVE",                   "state": "ACTIVE",
          "cpusetid": 2,                       "cpusetid": 2,
          "ipv4_addrs": [                      "ipv4_addrs": [
            "10.1.1.1",                          "10.1.1.1",
            "10.1.1.2",                          "10.1.1.2",
            "10.1.1.3",              |           "10.1.1.3"
                                     >         ],
                                     >         "ipv6_addrs": [
            "fe80::1000:1",                      "fe80::1000:1",
            "fe80::1000:2"                       "fe80::1000:2"
          ]                                    ]
        }                                    }
      ]                                    ]
    }                                    }
  }                                    }

  In -n mode, ip4.addr and ip6.addr are formatted in the encoding styles'
  native list types, e.g. instead of comma-separated lists, JSON arrays
  are printed.

  jls -n all --libxo json
   ...
   "ip4.addr": [
      "10.1.1.1",
      "10.1.1.2",
      "10.1.1.3"
    ],
    "ip4.saddrsel": true,
    "ip6.addr": [
      "fe80::1000:1",
      "fe80::1000:2"
    ],
    ...

  jls -n all --libxo xml
    ...
    <ip4.addr>10.1.1.1</ip4.addr>
    <ip4.addr>10.1.1.2</ip4.addr>
    <ip4.addr>10.1.1.3</ip4.addr>
    <ip4.saddrsel>true</ip4.saddrsel>
    <ip6.addr>fe80::1000:1</ip6.addr>
    <ip6.addr>fe80::1000:2</ip6.addr>
    ...

  PR:		215008
  Submitted by:	Christian Schwarz <me@cschwarz.com>
  Differential Revision:	https://reviews.freebsd.org/D8766

Changes:
  head/usr.sbin/jls/jls.c