]> git.proxmox.com Git - mirror_iproute2.git/commit
tc: pedit: Support JSON dumping
authorPetr Machata <petrm@mellanox.com>
Tue, 28 Apr 2020 11:44:33 +0000 (14:44 +0300)
committerDavid Ahern <dsahern@gmail.com>
Thu, 30 Apr 2020 02:43:23 +0000 (02:43 +0000)
commit081d6c310d3a6e0412431a9652f641dff3f72aee
tree76ae697312d68242181a24f2c807b20b37e9a989
parent846b6b2da8358d34aa4be8b310f90195e134b5b0
tc: pedit: Support JSON dumping

The action pedit does not currently support dumping to JSON. Convert
print_pedit() to the print_* family of functions so that dumping is correct
both in plain and JSON mode. In plain mode, the output is character for
character the same as it was before. In JSON mode, this is an example dump:

$ tc filter add dev dummy0 ingress prio 125 flower \
         action pedit ex munge udp dport set 12345 \
                 munge ip ttl add 1        \
 munge offset 10 u8 clear
$ tc -j filter show dev dummy0 ingress | jq
[
  {
    "protocol": "all",
    "pref": 125,
    "kind": "flower",
    "chain": 0
  },
  {
    "protocol": "all",
    "pref": 125,
    "kind": "flower",
    "chain": 0,
    "options": {
      "handle": 1,
      "keys": {},
      "not_in_hw": true,
      "actions": [
        {
          "order": 1,
          "kind": "pedit",
          "control_action": {
            "type": "pass"
          },
          "nkeys": 3,
          "index": 1,
          "ref": 1,
          "bind": 1,
          "keys": [
            {
              "htype": "udp",
              "offset": 0,
              "cmd": "set",
              "val": "3039",
              "mask": "ffff0000"
            },
            {
              "htype": "ipv4",
              "offset": 8,
              "cmd": "add",
              "val": "1000000",
              "mask": "ffffff"
            },
            {
              "htype": "network",
              "offset": 8,
              "cmd": "set",
              "val": "0",
              "mask": "ffff00ff"
            }
          ]
        }
      ]
    }
  }
]

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
tc/m_pedit.c