Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues when parsing output from NFTables #49

Closed
mheon opened this issue Jul 24, 2018 · 5 comments
Closed

Issues when parsing output from NFTables #49

mheon opened this issue Jul 24, 2018 · 5 comments
Assignees

Comments

@mheon
Copy link

mheon commented Jul 24, 2018

Running on a system using nftables for firewalling (IPTables version iptables v1.8.0 (nf_tables)), go-iptables causes a slice out of bounds panic while trying to adjust some firewall rules.

Relevant error message (generated by CNI portmap plugin): https://paste.fedoraproject.org/paste/Lt73H2OSbAzJJoc5eNJqRQ

This is seemingly caused by https://github.com/containernetworking/plugins/blob/master/plugins/meta/portmap/chain.go#L80 returning a slice with fewer than 2 entries.

I'm told this is likely a result of an error parsing the output of nftables-backed IPTables which seems to have slightly different field arrangement.

@squeed
Copy link
Collaborator

squeed commented Jul 31, 2018

Taking a look at this.

@squeed
Copy link
Collaborator

squeed commented Aug 1, 2018

Ideally we switch List to use the output of iptables-save, which has a more stable output. Let's see if that breaks anything.

@squeed
Copy link
Collaborator

squeed commented Aug 1, 2018

Really, we should move the whole library over to using iptables-save...

@squeed
Copy link
Collaborator

squeed commented Aug 1, 2018

More immediately, when using iptables in standard (legacy) mode, iptables -S returns the exact output that would result in a chain, e.g.

$ iptables -t filter  -S foo1
-N foo1
-A foo1 -p tcp -m tcp --dport 1337 -j ACCEPT

However, when it is in nftables mode, the output includes the counters in iptables-save format:

$ iptables -t filter -S foo1
-N foo1
[0:0] -A foo1 -p tcp -m tcp --dport 1337 -j ACCEPT

So we just have to detect that and work around.

@erig0
Copy link

erig0 commented Aug 1, 2018

FWIW, I just posted a fix for the counters upstream.

edit: Applied upstream, ed30b9311d2b ("nft: don't print rule counters unless verbose")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants