Bug 1807601 - libnftables: JSON: IPv6 addresses can not contain square brackets
Summary: libnftables: JSON: IPv6 addresses can not contain square brackets
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: nftables
Version: 8.2
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: 8.0
Assignee: Phil Sutter
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-26 17:24 UTC by Eric Garver
Modified: 2020-06-22 13:57 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-06-22 13:57:46 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)

Description Eric Garver 2020-02-26 17:24:47 UTC
If an IPv6 address has square brackets it will be rejected by libnftables JSON parsing. The CLI (bison) parser happily accepts the square bracket syntax. Square brackets are also accepted by ipset and iptables.

Found when working on bug 1779835. Also see RFC 2732 [1].

[1] https://tools.ietf.org/rfc/rfc2732.txt

-->8--

# nft delete table ip foobar; cat /tmp/json | nft -j -f -
internal:0:0-0: Error: Could not resolve hostname: Name or service not known

# nft delete table ip foobar; sed -e 's/[[]1234::[]]/1234::/' /tmp/json | nft -j -f -
** no error **

# nft add element ip foobar myset '{ [4321::]/64 }'
** no error **

# cat /tmp/json  | python3 -m json.tool
{
    "nftables": [
        {
            "metainfo": {
                "version": "0.9.3",
                "release_name": "Topsy",
                "json_schema_version": 1
            }
        },
        {
            "table": {
                "family": "ip",
                "name": "foobar"
            }
        },
        {
            "set": {
                "family": "ip",
                "name": "myset",
                "table": "foobar",
                "type": "ipv6_addr",
                "flags": [
                    "interval"
                ],
                "elem": [
                    {
                        "prefix": {
                            "addr": "[1234::]",
                            "len": 64
                        }
                    }
                ]
            }
        }
    ]
}

Comment 2 Eric Garver 2020-02-26 18:07:11 UTC
Correction: ip6tables-nft also appears to reject the square bracket syntax.

Comment 3 Phil Sutter 2020-06-22 13:57:46 UTC
Bracket syntax is accepted by bison due to flex detecting patterns that look
like IPv6 addresses and if surrounded by brackets skipping the latter. For the
CLI interface I think that's feasible to provide some flexibility to users, but
for JSON I don't. Filtering any undefined string through IPv6 address detection
is pretty tedious and I would rather consider introducing an object defining an
IPv6 address if ambiguity is a concern.

Given that firewalld is fine without a change on nft side, I'm closing this as WONTFIX.


Note You need to log in before you can comment on or make changes to this bug.