<div dir="ltr"><font face="arial, helvetica, sans-serif">Hi!</font><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I am working on a bug "</font><span style="font-family:arial,helvetica,sans-serif;color:rgb(51,51,51);line-height:34px">ping still working once connected even after related security group rule is deleted" </span><span style="font-family:arial,helvetica,sans-serif">(</span><span style="font-family:arial,helvetica,sans-serif"><a href="https://bugs.launchpad.net/neutron/+bug/1335375">https://bugs.launchpad.net/neutron/+bug/1335375</a></span><span style="font-family:arial,helvetica,sans-serif">). The gist of the problem is the following: when we delete a security group rule the corresponding rule in iptables is also deleted, but the connection, that was allowed by that rule, is not being destroyed.</span></div><div><span style="font-family:arial,helvetica,sans-serif">The reason for such behavior is that in iptables we have the following structure of a chain that filters input packets for an interface of an istance:</span></div><div><span style="font-family:arial,helvetica,sans-serif"><br></span></div><div><div style><div>Chain neutron-openvswi-i830fa99f-3 (1 references)</div><div> pkts bytes target     prot opt in     out     source               destination         </div><div>    0     0 DROP       all  --  *      *       <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>            state INVALID /* Drop packets that are not associated with a state. */</div><div>    0     0 RETURN     all  --  *      *       <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>            state RELATED,ESTABLISHED /* Direct packets associated with a known session to the RETURN chain. */</div><div>    0     0 RETURN     udp  --  *      *       10.0.0.3             <a href="http://0.0.0.0/0">0.0.0.0/0</a>            udp spt:67 dpt:68</div><div>    0     0 RETURN     all  --  *      *       <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>            match-set IPv43a0d3610-8b38-43f2-8 src</div><div>    0     0 RETURN     tcp  --  *      *       <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>            tcp dpt:22      <---- rule that allows ssh on port 22                    </div><div>    1    84 RETURN     icmp --  *      *       <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>           </div><div>    0     0 neutron-openvswi-sg-fallback  all  --  *      *       <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>            /* Send unmatched traffic to the fallback chain. */</div><div><br></div></div></div><h1 id="edit-title" class="" style="margin:0px;padding:0px;font-weight:normal;clear:none;line-height:34px;color:rgb(51,51,51);background-image:none;background-repeat:initial"><font>So, if we delete rule </font><span style="font-size:small;line-height:normal;color:rgb(34,34,34)">that allows tcp on port 22, then all connections that are already established won't be closed, because all packets would satisfy the rule: </span></h1><div>0     0 RETURN     all  --  *      *       <a href="http://0.0.0.0/0">0.0.0.0/0</a>            <a href="http://0.0.0.0/0">0.0.0.0/0</a>            state RELATED,ESTABLISHED /* Direct packets associated with a known session to the RETURN chain. */<span style="font-size:small;line-height:normal;color:rgb(34,34,34)"><br></span></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I seek advice on the way how to deal with the problem. There are a couple of ideas how to do it (more or less realistic):</font></div><div><ul><li><font face="arial, helvetica, sans-serif">Kill the connection using conntrack</font></li></ul><font face="arial, helvetica, sans-serif">          The problem here is that it is sometimes impossible to tell which connection should be killed. For example there may be two instances running in different namespaces that have the same ip addresses. As a compute doesn't know anything about namespaces, it cannot distinguish between the two seemingly identical connections: </font></div><div><font face="arial, helvetica, sans-serif"><div>         $ sudo conntrack -L  | grep "10.0.0.5"</div><div>         tcp      6 431954 ESTABLISHED src=10.0.0.3 dst=10.0.0.5 sport=60723 dport=22 src=10.0.0.5 dst=10.0.0.3 sport=22 dport=60723 [ASSURED] mark=0 use=1</div><div>         tcp      6 431976 ESTABLISHED src=10.0.0.3 dst=10.0.0.5 sport=60729 dport=22 src=10.0.0.5 dst=10.0.0.3 sport=22 dport=60729 [ASSURED] mark=0 use=1</div><div><br></div></font></div><div><font face="arial, helvetica, sans-serif">I wonder whether there is any way to search for a connection by destination MAC?</font></div><div><ul><li><font face="arial, helvetica, sans-serif">Delete iptables rule that directs </font>packets associated with a known session to the RETURN chain</li></ul>           It will force all packets to go through the full chain each time and this will definitely make the connection close. But this will strongly affect the performance. Probably there may be created a timeout after which this rule will be restored, but it is uncertain how long should it be.</div><div><br></div><div>Please share your thoughts on how it would be better to handle it.</div><div><br></div><div>Thanks in advance,</div><div>Elena</div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><br></div></div>