Re: broken network connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

On Fri, Nov 7, 2014 at 2:37 AM, Grzegorz Dwornicki <gd1100@xxxxxxxxx> wrote:
>
> Hi
>
> I have a big interest in how kernel handles this situaction.
>
> Lets assume that we have two hosts: host 1 and host 2 and on host 1 I
> have started this command:
> nc -l -p 4444
> on host 2 I have started this command (2 means IP addres of second host here!):
> nc 2 4444
>
> Now i can send msgs betweem them. In time I have decided to end
> connection. To do this I'm using ctrl+c on host 2. What functions are
> called to clean broken socket on host 1? What functions are called to
> clean up socket on host 2?
>

I'm not expert on this but from what your steps suggests at the kernel
level both machines know there's no communication
between them.

When you hit ctl+c or send your process signal which is not handled
then by default that process is killed.
When you open a socket, it's actually linked to a file via sockfs,
this is socket is on your opened file lists so assuming you didn't
forked and the refcount was still 1 for this sockfs inode the do_exit
would perform cleanup when it calls fput on these opened files.

That would terminate the socket by calling sock_release, see
net/socket.c. So the application at the other end doesn't yet know
about it but it'll when it attempts to go and read since the kernel at
the other end already knows that this connection has been terminated.

For specific functions you'll need to see net/ipv4[6]/. something like
sock_close/ sock_disconnect?

What would be interesting if you took the ether cable out or just
turned off power? It won't be a clean shutdown then :-p.


> Grzegorz.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@xxxxxxxxxxxxxxxxx
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




-- 
        ---P.K.S

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux