]> git.proxmox.com Git - mirror_iproute2.git/commit
tc: flower: fix json output with mpls lse
authorGuillaume Nault <gnault@redhat.com>
Tue, 12 Jan 2021 10:30:53 +0000 (11:30 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Sat, 16 Jan 2021 17:13:36 +0000 (09:13 -0800)
commit676a1a708f8e99d6a4faa3de8a093f8f8c14b9da
tree46b8efa3e43ae403fef5c0a8bcb77c19c22fb864
parent934919b991a6c727f2fec65697c5b599e33bb507
tc: flower: fix json output with mpls lse

The json output of the TCA_FLOWER_KEY_MPLS_OPTS attribute was invalid.

Example:

  $ tc filter add dev eth0 ingress protocol mpls_uc flower mpls \
      lse depth 1 label 100                                     \
      lse depth 2 label 200

  $ tc -json filter show dev eth0 ingress
    ...{"eth_type":"8847",
        "  mpls":["    lse":["depth":1,"label":100],
                  "    lse":["depth":2,"label":200]]}...

This is invalid as the arrays, introduced by "[", can't contain raw
string:value pairs. Those must be enclosed into "{}" to form valid json
ojects. Also, there are spurious whitespaces before the mpls and lse
strings because of the indentation used for normal output.

Fix this by putting all LSE parameters (depth, label, tc, bos and ttl)
into the same json object. The "mpls" key now directly contains a list
of such objects.

Also, handle strings differently for normal and json output, so that
json strings don't get spurious indentation whitespaces.

Normal output isn't modified.
The json output now looks like:

  $ tc -json filter show dev eth0 ingress
    ...{"eth_type":"8847",
        "mpls":[{"depth":1,"label":100},
                {"depth":2,"label":200}]}...

Fixes: eb09a15c12fb ("tc: flower: support multiple MPLS LSE match")
Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
tc/f_flower.c