Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
symbolic variables are available in scripts but cannot be used if lines are executed sequentially in interactive mode. documentation is not
Version-Release number of selected component (if applicable):
nftables-0.9.0-14.el8.x86_64
How reproducible:
always
Steps to Reproduce:
cat > variable.nft <<EOF
#!/usr/sbin/nft -f
add table inet test_table
add chain inet test_table test_chain
define DNS_SERVERS = { 192.0.2.1, 192.0.2.2 }
add rule inet test_table test_chain ip daddr $DNS_SERVERS accept
EOF
this script can be successfully executed and loads DNS_SERVERS variable.
when executed line-by-line in interactive mode `nft -i`:
nft> add rule inet test_table test_chain ip daddr $DNS_SERVERS accept
Error: unknown identifier 'DNS_SERVERS'
add rule inet test_table test_chain ip daddr $DNS_SERVERS accept
^^^^^^^^^^^
nft>
Actual results:
reference to a defined variable (without a failure) leads to dereference error "Error: unknown identifier"
Expected results:
variables should be supported also in interactive mode for script debugging
Additional info:
include statement works in interactive mode
command:
>define DNS_SERVERS = { 192.0.2.1, 192.0.2.2 }; add rule inet example_table example_chain ip daddr $DNS_SERVERS accept
apparently works because the context of variable is apparently ended by EOF
ref 'nft --debug all --interactive' after sole define command
Stack now 0
Entering state 1
Reading a token: --(end of buffer or a NUL)
--EOF (start condition 0)
Now at end of input.
Shifting token "end of file" (: )
Entering state 2
Stack now 0 1 2
Cleanup: popping token "end of file" (: )
Cleanup: popping nterm input (: )
Is there a way to preserve context so that the variable could be used later on during interactive execution?
Upstream commit to backport:
commit 332325e3c3fab4c25bb5f387f9663205f63748dc
Author: Phil Sutter <phil>
Date: Wed Oct 30 21:45:39 2019 +0100
libnftables: Store top_scope in struct nft_ctx
Allow for interactive sessions to make use of defines. Since parser is
initialized for each line, top scope defines didn't persist although
they are actually useful for stuff like:
| # nft -i
| define goodports = { 22, 23, 80, 443 }
| add rule inet t c tcp dport $goodports accept
| add rule inet t c tcp sport $goodports accept
While being at it, introduce scope_alloc() and scope_free().
Signed-off-by: Phil Sutter <phil>
Acked-by: Pablo Neira Ayuso <pablo>
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHEA-2020:1774
Description of problem: symbolic variables are available in scripts but cannot be used if lines are executed sequentially in interactive mode. documentation is not Version-Release number of selected component (if applicable): nftables-0.9.0-14.el8.x86_64 How reproducible: always Steps to Reproduce: cat > variable.nft <<EOF #!/usr/sbin/nft -f add table inet test_table add chain inet test_table test_chain define DNS_SERVERS = { 192.0.2.1, 192.0.2.2 } add rule inet test_table test_chain ip daddr $DNS_SERVERS accept EOF this script can be successfully executed and loads DNS_SERVERS variable. when executed line-by-line in interactive mode `nft -i`: nft> add rule inet test_table test_chain ip daddr $DNS_SERVERS accept Error: unknown identifier 'DNS_SERVERS' add rule inet test_table test_chain ip daddr $DNS_SERVERS accept ^^^^^^^^^^^ nft> Actual results: reference to a defined variable (without a failure) leads to dereference error "Error: unknown identifier" Expected results: variables should be supported also in interactive mode for script debugging Additional info: include statement works in interactive mode