Repository navigation
Closed
Description
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind feature
Description
I use nftables; when starting a container I get:
ERRO[0000] Error adding network: failed to list chains: running [/usr/sbin/iptables -t nat -S --wait]: exit status 1: iptables v1.8.2 (nf_tables): table `nat' is incompatible, use 'nft' tool.
ERRO[0000] Error while adding pod to CNI network "podman": failed to list chains: running [/usr/sbin/iptables -t nat -S --wait]: exit status 1: iptables v1.8.2 (nf_tables): table `nat' is incompatible, use 'nft' tool.
Error: error configuring network namespace for container 51f6adbaed7d674fb4b48d501eb7ce0605d09e003ac09f6588b98dea7230ca9f: failed to list chains: running [/usr/sbin/iptables -t nat -S --wait]: exit status 1: iptables v1.8.2 (nf_tables): table `nat' is incompatible, use 'nft' tool.
Steps to reproduce the issue:
- Create network configuration:
cat >/etc/cni/net.d/podman.conflist <<EOF
{
"cniVersion": "0.4.0",
"name": "podman",
"plugins": [
{
"type": "bridge",
"bridge": "cni-podman0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"routes": [
{
"dst": "0.0.0.0/0"
}
],
"ranges": [
[
{
"subnet": "192.168.124.0/24",
"gateway": "192.168.124.1"
}
]
]
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
},
{
"type": "firewall",
"backend": "nftables"
}
]
}
EOF
- Pull fedora image and start a container:
podman pull fedora:latest
podman run -it fedora bash
Describe the results you received:
ERRO[0000] Error adding network: failed to list chains: running [/usr/sbin/iptables -t nat -S --wait]: exit status 1: iptables v1.8.2 (nf_tables): table `nat' is incompatible, use 'nft' tool.
ERRO[0000] Error while adding pod to CNI network "podman": failed to list chains: running [/usr/sbin/iptables -t nat -S --wait]: exit status 1: iptables v1.8.2 (nf_tables): table `nat' is incompatible, use 'nft' tool.
Error: error configuring network namespace for container 51f6adbaed7d674fb4b48d501eb7ce0605d09e003ac09f6588b98dea7230ca9f: failed to list chains: running [/usr/sbin/iptables -t nat -S --wait]: exit status 1: iptables v1.8.2 (nf_tables): table `nat' is incompatible, use 'nft' tool.
Describe the results you expected:
No errors.
Additional information you deem important (e.g. issue happens only occasionally):
Output of podman version:
podman version 1.6.4
Output of podman info --debug:
debug:
compiler: gc
git commit: ""
go version: go1.12.12
podman version: 1.6.4
host:
BuildahVersion: 1.12.0-dev
CgroupVersion: v1
Conmon:
package: conmon-2.0.6-1.module+el8.1.1+5259+bcdd613a.x86_64
path: /usr/bin/conmon
version: 'conmon version 2.0.6, commit: 6ffbb2ec70dbe5ba56e4bfde946fb04f19dd8bbf'
Distribution:
distribution: '"rhel"'
version: "8.1"
MemFree: 483997450240
MemTotal: 540217061376
OCIRuntime:
name: runc
package: runc-1.0.0-64.rc9.module+el8.1.1+5259+bcdd613a.x86_64
path: /usr/bin/runc
version: 'runc version spec: 1.0.1-dev'
SwapFree: 10737414144
SwapTotal: 10737414144
arch: amd64
cpus: 64
eventlogger: journald
kernel: 4.18.0-147.5.1.el8_1.x86_64
os: linux
rootless: false
uptime: 662h 43m 16.45s (Approximately 27.58 days)
registries:
blocked: null
insecure: null
search:
- registry.redhat.io
- registry.access.redhat.com
- quay.io
- docker.io
store:
ConfigFile: /etc/containers/storage.conf
ContainerStore:
number: 4
GraphDriverName: overlay
GraphOptions: {}
GraphRoot: /var/lib/containers/storage
GraphStatus:
Backing Filesystem: xfs
Native Overlay Diff: "true"
Supports d_type: "true"
Using metacopy: "false"
ImageStore:
number: 2
RunRoot: /var/run/containers/storage
VolumePath: /var/lib/containers/storage/volumes
Package info (e.g. output of rpm -q podman or apt list podman):
podman-1.6.4-2.module+el8.1.1+5363+bf8ff1af.x86_64
Additional environment details (AWS, VirtualBox, physical, etc.):
Physical.
Reference: podman-container-tools/podman#5446
Reacted by Philip Schmid, Brandon Bennett and Thomas Peißl
Metadata
Metadata
Assignees
Labels
No labels
Activity
mars1024 commentedon Mar 11, 2020
It seems that
ipMasq==truerequires some iptables actions, but from the outputiptables v1.8.2 (nf_tables), the iptables of your kernel is working with mode nf_tables, as far as I know, the iptables utility package go-iptables which is used by cni-plugins does not support this mode.ping to go-iptables owner @squeed
greenpau commentedon Mar 11, 2020
Research notes
The
addToNetworkis in../../../github.com/containernetworking/cni/libcni/api.go:Here, the
AddNetworkListis the method of*libcni.CNIConfig.It takes in
network.config(*libcni.NetworkConfigList) andrt(*libcni.RuntimeConf).The
*libcni.RuntimeConf:The
*libcni.NetworkConfigList:greenpau commentedon Mar 13, 2020
@mars1024, I tracked it down. As you said,
go-iptablesdoes not supportnftables. This is indeed related to IPMasq. I will attempt a PR usinggoogle/nftables. In sum, I would need to implementSetupandTeardownfunctions. It looks pretty straightforward.greenpau commentedon Mar 14, 2020
Research Notes
The error comes from
EnsureChain(). It is invoked fromsetupChains(). Theib(*main.iptablesBackend)contains the following structure.The key to distinguish between
iptablesandnftis by usingmodekey. If it isnf_tables, then usenft.This structure gets created by
newIptablesBackend()function.The
newIptablesBackend()is being invoked by./plugins/meta/firewall/firewall.go.Luckily, here is another clue:
There is either
firewalldoriptables.On one hand we could add
case "nftables":. On the other hand, perhaps it is possible to make things happen with firewalld.The next step is
newFirewalldBackend()... to be continued ..greenpau commentedon Mar 14, 2020
As my first step, I implemented "donothing" firewall backend: https://github.com/greenpau/origin_containernetworking_plugins/blob/1dde487bf69f688e932ca04fc47fa55b502a45e6/plugins/meta/firewall/nftables.go
The next step is going through iptables/firewalld backends and figuring out what is necessary.
greenpau commentedon Mar 14, 2020
Research Notes
Invoked the following command to start a container:
The newly added
nftBackend.Add()receives the following result:The IP addressing (removed references to IPv6) inside the container looks like this:
The main network namespace looks like this:
Inside the container, I issue
nslookup www.google.com. In the logs I see the following denies:My NFT config (
/etc/nftables/config.nft) logs the drop. There are some existingvirbr0rules, but nothing relates to CNI bridge.The next step is figuring out which rules to we need. The FORWARD chain is a good start ... to be continued ..
greenpau commentedon Mar 14, 2020
Research Notes
The following commands would be sufficient to make the containers talk to the outside world:
This is what the FORWARD chain looks like after the change:
A container on
192.168.124.0/24network is able to reachgoogle.comsuccessfully.The thing necessary to complete
cmdAdd()are in here ....The first interface in the list of the
Interfacesiscni-podman0. The IP address and subnet mask is inIP.The logic should be:
Interfaceshas less than 3 interfaces, through an erroriifnameandoifnameIP.Addressisip daddrandip saddrgreenpau commentedon Mar 14, 2020
Research Notes
To implement the above logic, let's start working on the
Add()method ofnftBackend:The tables look like this.
The
TableFamilyis being described here https://godoc.org/github.com/google/nftables#TableFamily.2: IPv4 (NFPROTO_IPV4 = 0x2)10: IPv6 (NFPROTO_IPV6 = 0xa)7: IPv6 (NFPROTO_BRIDGE = 0x7)First, step is our validation that IPv4 "filter" table exists.
greenpau commentedon Mar 15, 2020
Research Notes
The each individual rule in the
FORWARDchain is in the structure references in google/nftables#102.What I hoped for was that there is an easy way to convert that struct to a string for comparison, but there isn't.
Working on the comparison right now.
add nftables firewall backend
add nftables firewall backend
greenpau commentedon Mar 15, 2020
google/nftablesdoes not have a good interface to work with rules. I am switching to callingnfttool, i.e.os/exec.greenpau commentedon Mar 15, 2020
Research Notes
Just for my records. I am leaving some nftables functions here:
greenpau commentedon Mar 16, 2020
Research Notes
Noticed a lot of
CNI-xxxchains intable ip natwhen listing chains.Upon review the
nattable, noticed the following:This basically means that if a packet came from IP
192.168.124.8and the packet's destination is local subnet, i.e.192.168.124.0/24, then pass the packet and do not masquerade. Any other packets, except multicast, are being NATed (masqueraded).greenpau commentedon Mar 16, 2020
Chain priorities explained: https://wiki.nftables.org/wiki-nftables/index.php/Configuring_chains#Base_chain_priority
17 remaining items
firewall: add nftables backend
firewall: add nftables backend
firewall: add nftables backend
firewall: add nftables backend
firewall: add nftables backend
firewall: add nftables backend
firewall: add nftables backend
firewall: add nftables backend
firewall: add nftables backend
firewall: add nftables backend
nemith commentedon Jan 26, 2022
Any plans on picking this back up. I am kinda surprised to find out nftables isn't supported on centos 9 with podman.
greenpau commentedon Jan 26, 2022
@nemith , i did. See https://github.com/greenpau/cni-plugins
egberts commentedon Jul 18, 2022
To get rid of that libvirt error, my permanent workaround in Debian 11 (as a host) with libvirtd daemon is to block the loading of iptables-related modules:
Create a file in
/etc/modprobe.d/nft-only.conf:libvirtddaemon now starts without any error.Post-analysis: Apparently, I had
iptablesmodule loaded alongside with many nft-related modules; onceiptableswas gone, the pesky error message went away.AkihiroSuda commentedon Dec 24, 2024
Any chance to reopen this issue?
The upstream plugins still do not support
nft.@greenpau Do you plan to submit a PR to merge https://github.com/greenpau/cni-plugins to the upstream plugins?