<html>
    <head>
      <base href="https://bugzilla.netfilter.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - noflush actually flushes in case of custom chain"
   href="https://bugzilla.netfilter.org/show_bug.cgi?id=1242">1242</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>noflush actually flushes in case of custom chain
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>iptables
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P5
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>iptables-restore
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>netfilter-buglog@lists.netfilter.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>assafcw@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Caught while trying to restore iptables with docker chains using:

iptables-restore -n -c MYFILE

The file might look like
*nat
:DOCKER
COMMIT

where the DOCKER chain already has rules in it, when restored - will be
flushed.

while in case of builtin chains - will not flush and duplicate the entry.
For instance:
*nat
-I PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
COMMIT

I believe the bug is in
iptables-restore.c
line 369

                if (noflush && ops->is_chain(chain, handle)) {
                    DEBUGP("Flushing existing user defined chain '%s'\n",
chain);
                    if (!ops->flush_entries(chain, handle))
                        xtables_error(PARAMETER_PROBLEM,
                               "error flushing chain "
                               "'%s':%s\n", chain,
                               strerror(errno));

where it should be if(!noflush %% ops->...</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are watching all bug changes.</li>
      </ul>
    </body>
</html>