lwip-users
[Top][All Lists]
Advanced

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

RE : RE : [lwip-users] Receiving RSTs


From: Frédéric BERNON
Subject: RE : RE : [lwip-users] Receiving RSTs
Date: Wed, 12 Dec 2007 09:34:48 +0100

I have checked with a router which reply with a RST packet when we try to connect to a port which is not up.
 
Starting lwIP, loopback interface IP is 127.0.0.1
Starting lwIP, local interface IP is 192.168.1.249
 0: \Device\NPF_GenericDialupAdapter
 1: \Device\NPF_{E0F42C25-0F0D-43B3-94DF-74D3B575B0A8}
MAC: 00:15:F2:4C:D0:59
err=-5, conn->pcb.tcp!=NULL
connected error==-1 [0]
close now
 
In this case, err_tcp will receive a -5 (ERR_RST), but only once. So, the tcp state machine is good (there is no retry inside core code).
 
BTW: I just fix a small error in err_strerr[] table. I suggest we could use a xmacro like for memp_std.h to avoid this kind of errors in the future.
 
 
====================================
Frédéric BERNON
HYMATOM SA
Chef de projet informatique
Microsoft Certified Professional
Tél. : +33 (0)4-67-87-61-10
Fax. : +33 (0)4-67-70-85-44
Email : address@hiddenr
Web Site : http://www.hymatom.fr
====================================
P Avant d'imprimer, penser à l'environnement
 
-----Message d'origine-----
De : address@hidden [mailto:address@hidden De la part de Frédéric BERNON
Envoyé : mercredi 12 décembre 2007 08:29
À : Mailing list for lwIP users
Objet : Re: RE : [lwip-users] Receiving RSTs

I did this test with last CVS HEAD (with a Vista workstation):
 
static void
tcp_connect_thread(void *arg)
{
int sock;
struct sockaddr_in local;
struct sockaddr_in to;
int iResult;
u32_t server_address;
 
/* initialize server address */
server_address = inet_addr("192.168.0.1");/*my pc*/
/* if we got a valid server address... */
if (server_address!=0) {
/* create new socket */
sock = socket( AF_INET, SOCK_STREAM, 0);
if (sock>=0) {
/* prepare local address */
memset(&local, 0, sizeof(local));
local.sin_family = AF_INET;
local.sin_port = htons(INADDR_ANY);
local.sin_addr.s_addr = htonl(INADDR_ANY);
/* bind to local address */
if (bind( sock, (struct sockaddr *)&local, sizeof(local))==0) {
/* prepare server address */
memset(&to, 0, sizeof(to));
to.sin_family = AF_INET;
to.sin_port = htons(62345);/* a port which is not opened*/
to.sin_addr.s_addr = server_address;
 
/* connect to server */
if ((iResult=connect( sock, (struct sockaddr *)&to, sizeof(to)))>=0) {
printf("connected success==%i [%i]\n", iResult, errno);
} else {
printf("connected error==%i [%i]\n", iResult, errno);
}
/* sleep */
sys_msleep(60000);/*let the time to see if any other packet is received*/
printf("close now\n");
 
}
/* close the socket */
closesocket(sock);
}
}
}
 
I got :
 
Starting lwIP, loopback interface IP is 127.0.0.1
Starting lwIP, local interface IP is 192.168.0.2
 0: \Device\NPF_{A6293F5E-B3DF-4E8D-8D01-C65870EEDD1E}
 1: \Device\NPF_{2DA42D7E-7436-40CD-901E-5D73107798B0}
MAC: 00:18:F3:E3:8D:8D
err_tcp==-4
connected error==-1 [0]
close now
-4 = ERR_ABRT
 
What I can said is the PC never send any RST packet (checked with wireshark). Of course, perhaps it's different with another pc OS.
 
But in all cases, in err_tcp, we set to NULL conn->pcb.tcp. So, we can't reuse the pcb. The only solution seems to close the socket and reopen it. If on RST, we receive any error, perhaps we could add a line like:

static void

err_tcp(void *arg, err_t err)

{

struct netconn *conn;

conn = arg;

LWIP_ASSERT("conn != NULL", (conn != NULL));

if (conn->pcb.tcp == NULL) return; /*<<<<<<<<<<<<<<<<<<<<<<<<<<*/

conn->pcb.tcp = NULL;

conn->err = err;

 
----- Original Message -----
From: "Jonathan Larmour" <address@hidden>
To: "Mailing list for lwIP users" <address@hidden>
Sent: Tuesday, December 11, 2007 11:45 PM
Subject: Re: RE : [lwip-users] Receiving RSTs

> address@hidden wrote:
>> Jonathan Larmour wrote:
>>
>>> I wonder from what Aparna says:
>>>
>>> 
>>>
>>>>>         When the Windows server is not up, the PC responds with a RST
>>>>>         for a received SYN. The connect() API returns an error, and the
>>>>>         client retries connect() after every few seconds.
>>>>>      
>>>
>>>
>>> whether he/she is not closing the socket before calling connect again?
>>>
>>> Maybe the netconn API needs to explicitly disallow connects if
>>> conn->err is
>>> set?
>>>
>>> Either way, if the socket isn't being closed, Aparna needs to fix
>>> his/her code.
>>>  
>>
>> Normally, the socket API allows calling connect for a second time (when
>> the first call fails and the socket is not already connected).
>
> Oh yes, of course you are right. Aparna's code should be valid for a BSD
> sockets API, sorry.
>
>> LwIP
>> might not allow this, in which case we can argue if there is
>> documentation missing or an assert (or a code change)...
>
> I think in the short term, disallowing based on non-zero conn->err would
> be best. This could be solved, but probably only when we have the richer
> set of synchronisation primitives we've been thinking about elsewhere.
>
> Jifl
> --
> eCosCentric Limited     
http://www.eCosCentric.com/     The eCos experts
> Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
> Registered in England and Wales: Reg No 4422071.
> ------["The best things in life aren't things."]------      Opinions==mine
>
>
> _______________________________________________
> lwip-users mailing list
>
address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>

Attachment: Frédéric BERNON.vcf
Description: Frédéric BERNON.vcf


reply via email to

[Prev in Thread] Current Thread [Next in Thread]