Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-3088

Add nftables support to netavark

    • netavark-1.10.3
    • High
    • 1
    • rhel-sst-container-tools
    • 3
    • False
    • Hide

      None

      Show
      None
    • None
    • RUN 252
    • If docs needed, set a value
    • None

      Description of problem:

      Podman CNI is unable to use full nftables (not any iptables compatibility) to work cleanly.

      Version-Release number of selected component (if applicable):

      • latest podman on RHEL 8

      How reproducible:

      • 100% Reproducible

      Steps to Reproduce:

      1. Remove the existing firewalld and iptables packages and freshly install podman, nftables

      1. yum remove -y firewalld iptables
      2. yum install -y podman nftables
      3. rpm -q podman nftables

      2. Migrate existing containers to a new podman version.

      1. podman system migrate

      3. Create rules and inject to nft.

      1. cat rulesets.txt
        add table ip filter
        add chain ip filter INPUT { type filter hook input priority 0; policy drop; }

        add chain ip filter FORWARD

        { type filter hook forward priority 0; policy drop; }

        add rule ip filter INPUT ct state invalid tcp sport 5010 counter reject with tcp reset
        add rule ip filter INPUT tcp flags & (fin|syn|rst|psh|ack|urg) == fin|syn|rst|psh|ack|urg counter drop
        add rule ip filter INPUT tcp flags & (fin|syn) == fin|syn counter drop
        add rule ip filter INPUT tcp flags & (fin|rst) == fin|rst counter drop
        add rule ip filter INPUT tcp flags & (fin|syn|rst|psh|ack|urg) == fin|psh|urg counter drop
        add rule ip filter INPUT tcp flags & (fin|syn|rst|psh|ack|urg) == 0x0 counter drop
        add rule ip filter INPUT ct state related, established counter accept
        add rule ip filter INPUT iifname "lo" counter accept
        add rule ip filter INPUT ct state invalid counter drop
        add rule ip filter INPUT ct state new tcp flags & (syn|rst|ack) != syn counter drop
        add rule ip filter INPUT meta l4proto icmp icmp type timestamp-request counter drop
        add rule ip filter INPUT meta l4proto icmp icmp type address-mask-request counter drop
        add rule ip filter INPUT ip saddr 127.1.1.0/24 counter accept
        add rule ip filter INPUT ip saddr 127.0.0.0/8 counter drop
        add rule ip filter INPUT ip saddr 169.254.0.0/16 counter drop
        add rule ip filter INPUT ip saddr 192.0.2.0/24 counter drop
        add rule ip filter INPUT ip saddr 224.0.0.0/4 counter drop
        add rule ip filter INPUT ip saddr 240.0.0.0/5 counter drop
        add rule ip filter INPUT ip saddr 248.0.0.0/5 counter drop
        add rule ip filter INPUT meta l4proto icmp ip daddr 255.255.255.255 counter drop
        add rule ip filter INPUT meta l4proto icmp icmp type echo-request limit rate 100/second burst 5 packets counter accept
        add rule ip filter INPUT meta l4proto icmp counter drop
        add rule ip filter INPUT meta l4proto ipv6-icmp limit rate 100/second burst 5 packets counter accept
        add rule ip filter INPUT meta l4proto ipv6-icmp counter drop
        add rule ip filter INPUT tcp dport 22 tcp flags & (fin|syn|rst|psh|ack|urg) == syn counter accept
        add rule ip filter INPUT tcp dport 2222 tcp flags & (fin|syn|rst|psh|ack|urg) == syn counter accept
        add rule ip filter INPUT tcp dport 5022 tcp flags & (fin|syn|rst|psh|ack|urg) == syn counter accept
        add rule ip filter INPUT tcp dport 23 tcp flags & (fin|syn|rst|psh|ack|urg) == syn counter accept
        add rule ip filter INPUT tcp dport 5023 tcp flags & (fin|syn|rst|psh|ack|urg) == syn counter accept
        add rule ip filter INPUT tcp dport 80 tcp flags & (fin|syn|rst|psh|ack|urg) == syn counter accept
        add rule ip filter INPUT tcp dport 443 tcp flags & (fin|syn|rst|psh|ack|urg) == syn counter accept
        add rule ip filter INPUT ip daddr 0.0.0.0 udp sport 161 ip frag-off & 0x1fff != 0 counter accept
        add rule ip filter INPUT tcp dport

        { 22,2222,5022,23,5023,80,443}

        tcp flags & (fin|syn|rst|ack) == syn counter drop
        add rule ip filter INPUT ip protocol udp udp sport

        { 161,162} counter drop
        add rule ip filter INPUT ip protocol udp udp dport { 161,162}

        counter drop
        add rule ip filter INPUT ct state

        {new, related, established} tcp flags & (fin|syn|rst|psh|ack|urg) == syn counter accept
        add rule ip filter INPUT ct state {new, related, established}

        meta l4proto udp counter accept
        add chain ip filter OUTPUT

        { type filter hook output priority 0; policy drop; }

        add rule ip filter OUTPUT oifname "lo" counter accept
        add rule ip filter OUTPUT counter accept
        add rule ip filter OUTPUT udp sport 161 ip frag-off & 0x1fff != 0 counter accept

      1. nft -f rulesets.txt

      4. Try to create a test container and observe the error.

      1. podman run -d --name nginx -p 80:80 docker.io/nginx

      Actual results:

      1. podman run -d --name nginx-1 -p 80:80 docker.io/nginx
        ERRO[0000] error loading cached network config: network "podman" not found in CNI cache
        WARN[0000] falling back to loading from existing plugins on disk
        Error: error configuring network namespace for container 4376cfc0a24ca5f51676dd66462180aaf0bcc58e4c9df9301e379a2b6a30b270: error adding pod nginx-1_nginx-1 to CNI network "podman": failed to list iptables chains: running [/usr/sbin/iptables -t filter -S --wait]: exit status 1: iptables v1.8.2 (nf_tables): table `filter' is incompatible, use 'nft' tool.

      Expected results:

      Container should run properly using nftables rules

      Additional info:

      • We are aware of the bug (1984040) which was closed as WONTFIX, but this needs to be address this as CNI is unable to recognize nft as a default one.

              rhn-support-jnovy Jindrich Novy
              rhn-support-snangare Sameer Nangare
              Matt Heon Matt Heon
              Yuhui Jiang Yuhui Jiang
              Votes:
              0 Vote for this issue
              Watchers:
              19 Start watching this issue

                Created:
                Updated:
                Resolved: