2007-03-28 15:27:57

by Aarti Kumar

[permalink] [raw]
Subject: [Bluez-devel] L2CAP: ECONNRESET is set for every l2cap disconnect.

I am sure if this issue has been discussed before or
not.

Is it necessary to the set the struct sock->err value
to ECONNRESET when l2cap disconnect request is
received from remote device ?

l2cap_disconnect_req function sets the error value in
sock structure by calling l2cap_chan_del(sk,
ECONNRESET) every time l2cap connection is
disconnected.

This might lead to some loss of data at receiver side
in case of fast sender and slow receiver.

The sender will send l2cap packets and disconnects.

The receiver side will read the packets, but once
l2cap disconnect is received, even though there is
data in sk_buff, the bt_sock_recvmsg will return 0 as
skb_recv_datagram will return NULL.

Can we set the value to ECONNRESET only in case of
error condition and for the normal disconnect set it
to 0 by calling l2cap_chan_del(sk,0) from
l2cap_disconnect_req ?

So if error field is not set in sock structure,
bt_sock_recvmsg will return data bytes till sk_buff is
empty and which case 0 will be returned. This will
prevent any data loss.

Also if the user wants to know when socket
disconnected, POLLHUP will be set for sock fd so after
disconnect happens and there is data to be read both
POLLHUP and POLLIN will set.
If we set sock err field then user will not be able to
retrieve data from sk_buff, even if POLLLIN is set.

I am using 2.6 kernel.

Thanks,
Aarti.







____________________________________________________________________________________
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2007-03-31 13:55:29

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] L2CAP: ECONNRESET is set for every l2cap disconnect.

Hi Aarti,

> I am sure if this issue has been discussed before or
> not.

it hasn't been discussed. I would remember it.

> Is it necessary to the set the struct sock->err value
> to ECONNRESET when l2cap disconnect request is
> received from remote device ?
>
> l2cap_disconnect_req function sets the error value in
> sock structure by calling l2cap_chan_del(sk,
> ECONNRESET) every time l2cap connection is
> disconnected.

This is actually the correct behavior since the remote side is about to
terminate the connection. There is no more data pending. All data after
this command is invalid anyway.

> This might lead to some loss of data at receiver side
> in case of fast sender and slow receiver.

This has been always a problem of L2CAP since flow control is missing.

> The sender will send l2cap packets and disconnects.
>
> The receiver side will read the packets, but once
> l2cap disconnect is received, even though there is
> data in sk_buff, the bt_sock_recvmsg will return 0 as
> skb_recv_datagram will return NULL.
>
> Can we set the value to ECONNRESET only in case of
> error condition and for the normal disconnect set it
> to 0 by calling l2cap_chan_del(sk,0) from
> l2cap_disconnect_req ?
>
> So if error field is not set in sock structure,
> bt_sock_recvmsg will return data bytes till sk_buff is
> empty and which case 0 will be returned. This will
> prevent any data loss.
>
> Also if the user wants to know when socket
> disconnected, POLLHUP will be set for sock fd so after
> disconnect happens and there is data to be read both
> POLLHUP and POLLIN will set.
> If we set sock err field then user will not be able to
> retrieve data from sk_buff, even if POLLLIN is set.

Provide a patch and a test program and I will have a look at it.

Regards

Marcel



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel