<div dir="ltr">I think the root cause of the problem here is that we are losing segregation between tenants at the conntrack level. The compute side plugs everything into the same namespace and we have no guarantees about uniqueness of any other fields kept by conntrack. <div><br></div><div>Because of this loss of uniqueness, I think there may be another lurking bug here as well. One tenant establishing connections between IPs that overlap with another tenant will create the possibility that a connection the other tenant attempts will match the conntrack entry from the original connection. Then whichever closes the connection first will result in the conntrack entry being removed and the return traffic from the remaining connection being dropped.<br></div><div><div><br></div><div>I think the correct way forward here is to isolate each tenant (or even compute interface) into its own conntrack zone.[1] This will provide isolation against that imaginary unlikely scenario I just presented. :-)</div><div>More importantly, it will allow us to clear connections for a specific tenant (or compute interface) without interfering with others because conntrack can delete by zone.[2]<br></div></div><div><br></div><div><br></div><div>1. <a href="https://github.com/torvalds/linux/commit/5d0aa2ccd4699a01cfdf14886191c249d7b45a01">https://github.com/torvalds/linux/commit/5d0aa2ccd4699a01cfdf14886191c249d7b45a01</a></div><div>2. see the -w option. <a href="http://manpages.ubuntu.com/manpages/raring/man8/conntrack.8.html">http://manpages.ubuntu.com/manpages/raring/man8/conntrack.8.html</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 23, 2014 at 3:22 AM, Elena Ezhova <span dir="ltr"><<a href="mailto:eezhova@mirantis.com" target="_blank">eezhova@mirantis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">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><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" target="_blank">0.0.0.0/0</a>            <a href="http://0.0.0.0/0" target="_blank">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" target="_blank">0.0.0.0/0</a>            <a href="http://0.0.0.0/0" target="_blank">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" target="_blank">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" target="_blank">0.0.0.0/0</a>            <a href="http://0.0.0.0/0" target="_blank">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" target="_blank">0.0.0.0/0</a>            <a href="http://0.0.0.0/0" target="_blank">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" target="_blank">0.0.0.0/0</a>            <a href="http://0.0.0.0/0" target="_blank">0.0.0.0/0</a>           </div><div>    0     0 neutron-openvswi-sg-fallback  all  --  *      *       <a href="http://0.0.0.0/0" target="_blank">0.0.0.0/0</a>            <a href="http://0.0.0.0/0" target="_blank">0.0.0.0/0</a>            /* Send unmatched traffic to the fallback chain. */</div><div><br></div></div></div><h1 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" target="_blank">0.0.0.0/0</a>            <a href="http://0.0.0.0/0" target="_blank">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>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Kevin Benton</div>
</div>