<div dir="ltr">Hi Andrei,<div><br></div><div>this patch is for <a href="https://github.com/xemul/criu/issues/73">https://github.com/xemul/criu/issues/73</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-27 22:08 GMT+03:00 Andrei Vagin <span dir="ltr">&lt;<a href="mailto:avagin@virtuozzo.com" target="_blank">avagin@virtuozzo.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Dec 20, 2016 at 05:17:34PM +0300, <a href="mailto:the7winds@yandex.ru">the7winds@yandex.ru</a> wrote:<br>
&gt; From: Gleb Valin &lt;<a href="mailto:the7winds@yandex.ru">the7winds@yandex.ru</a>&gt;<br>
&gt;<br>
&gt; If socket type is SOCK_PACKET it restores binding with proper address structure.<br>
<br>
</span>Hi Gleb,<br>
<br>
Could you give more details about this patch? I remember that Pavel did<br>
something with packet sockets.<br>
<br>
commit fc7071d05e1b7140bcc39f0a45a86c<wbr>46bdbcb716<br>
Author: Pavel Emelyanov &lt;<a href="mailto:xemul@parallels.com">xemul@parallels.com</a>&gt;<br>
Date:   Thu Aug 9 16:17:41 2012 +0400<br>
<br>
    net: Packet sockets basic support<br>
<br>
    Support only basic packet socket functionality -- create and bind.<br>
    This should be enough to start testing dhclient inside container.<br>
    Other stuff (filter, mmaps, fanouts, etc.) will come later.<br>
<br>
    Signed-off-by: Pavel Emelyanov &lt;<a href="mailto:xemul@parallels.com">xemul@parallels.com</a>&gt;<br>
<div><div class="h5"><br>
&gt;<br>
&gt; Signed-off-by: Gleb Valin &lt;<a href="mailto:the7winds@yandex.ru">the7winds@yandex.ru</a>&gt;<br>
&gt; Signed-off-by: Eugene Batalov &lt;<a href="mailto:eabatalov89@gmail.com">eabatalov89@gmail.com</a>&gt;<br>
&gt; ---<br>
&gt;  criu/sk-packet.c | 54 ++++++++++++++++++++++++++++++<wbr>++++++++++++++++++++++++<br>
&gt;  1 file changed, 54 insertions(+)<br>
&gt;<br>
&gt; diff --git a/criu/sk-packet.c b/criu/sk-packet.c<br>
&gt; index bcd4ff33..a7657bfc 100644<br>
&gt; --- a/criu/sk-packet.c<br>
&gt; +++ b/criu/sk-packet.c<br>
&gt; @@ -1,5 +1,7 @@<br>
&gt;  #include &lt;linux/if_packet.h&gt;<br>
&gt;  #include &lt;sys/socket.h&gt;<br>
&gt; +#include &lt;net/if.h&gt;<br>
&gt; +#include &lt;sys/ioctl.h&gt;<br>
&gt;  #include &lt;linux/netlink.h&gt;<br>
&gt;  #include &lt;linux/rtnetlink.h&gt;<br>
&gt;  #include &lt;libnl3/netlink/msg.h&gt;<br>
&gt; @@ -403,6 +405,55 @@ static int restore_rings(int sk, PacketSockEntry *psk)<br>
&gt;       return 0;<br>
&gt;  }<br>
&gt;<br>
&gt; +static int open_packet_sk_spkt(<wbr>PacketSockEntry *pse)<br>
&gt; +{<br>
&gt; +     struct sockaddr addr_spkt;<br>
&gt; +     int sk;<br>
&gt; +<br>
&gt; +     sk = socket(PF_PACKET, pse-&gt;type, pse-&gt;protocol);<br>
&gt; +     if (sk &lt; 0) {<br>
&gt; +             pr_perror(&quot;Can&#39;t create packet socket&quot;);<br>
&gt; +             return -1;<br>
&gt; +     }<br>
&gt; +<br>
&gt; +     memset(&amp;addr_spkt, 0, sizeof(addr_spkt));<br>
&gt; +     addr_spkt.sa_family = AF_PACKET;<br>
&gt; +<br>
&gt; +     // if the socket was bound to any device<br>
&gt; +     if (pse-&gt;ifindex &gt; 0) {<br>
&gt; +             const size_t sa_data_size = sizeof(addr_spkt.sa_data);<br>
&gt; +             struct ifreq req;<br>
&gt; +<br>
&gt; +             memset(&amp;req, 0, sizeof(req));<br>
&gt; +             req.ifr_ifindex = pse-&gt;ifindex;<br>
&gt; +<br>
&gt; +             if (ioctl(sk, SIOCGIFNAME, &amp;req) &lt; 0) {<br>
&gt; +                     pr_perror(&quot;Can&#39;t get interface name (ifindex %d)&quot;, pse-&gt;ifindex);<br>
&gt; +                     goto err;<br>
&gt; +             }<br>
&gt; +<br>
&gt; +             strncpy(addr_spkt.sa_data, req.ifr_name, sa_data_size);<br>
&gt; +             addr_spkt.sa_data[sa_data_size - 1] = 0;<br>
&gt; +<br>
&gt; +             if (bind(sk, &amp;addr_spkt, sizeof(addr_spkt)) &lt; 0) {<br>
&gt; +                     pr_perror(&quot;Can&#39;t bind packet socket to %s&quot;, req.ifr_name);<br>
&gt; +                     goto err;<br>
&gt; +             }<br>
&gt; +     }<br>
&gt; +<br>
&gt; +     if (rst_file_params(sk, pse-&gt;fown, pse-&gt;flags))<br>
&gt; +             goto err;<br>
&gt; +<br>
&gt; +     if (restore_socket_opts(sk, pse-&gt;opts))<br>
&gt; +             goto err;<br>
&gt; +<br>
&gt; +     return sk;<br>
&gt; +<br>
&gt; +err:<br>
&gt; +     close(sk);<br>
&gt; +     return -1;<br>
&gt; +}<br>
&gt; +<br>
&gt;  static int open_packet_sk(struct file_desc *d)<br>
&gt;  {<br>
&gt;       struct packet_sock_info *psi;<br>
&gt; @@ -415,6 +466,9 @@ static int open_packet_sk(struct file_desc *d)<br>
&gt;<br>
&gt;       pr_info(&quot;Opening packet socket id %#x\n&quot;, pse-&gt;id);<br>
&gt;<br>
&gt; +     if (pse-&gt;type == SOCK_PACKET)<br>
&gt; +             return open_packet_sk_spkt(pse);<br>
&gt; +<br>
&gt;       sk = socket(PF_PACKET, pse-&gt;type, pse-&gt;protocol);<br>
&gt;       if (sk &lt; 0) {<br>
&gt;               pr_perror(&quot;Can&#39;t create packet sock&quot;);<br>
&gt; --<br>
&gt; 2.11.0<br>
&gt;<br>
</div></div>&gt; ______________________________<wbr>_________________<br>
&gt; CRIU mailing list<br>
&gt; <a href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br>
&gt; <a href="https://lists.openvz.org/mailman/listinfo/criu" rel="noreferrer" target="_blank">https://lists.openvz.org/<wbr>mailman/listinfo/criu</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Best regards,<br>Eugene Batalov.</div>
</div>