tasklwIP - A Lightweight TCP/IP stack - Tasks: task #7269, Call netif_set_default during...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

task #7269: Call netif_set_default during netif_add if not yet defined

Submitter:  Frédéric Bernon <fbernon>
Submitted:  Mon 03 Sep 2007 10:06:21 AM UTC
   
 
Category:  None Should Start On:  Sun 02 Sep 2007 10:00:00 PM UTC
Should be Finished on:  Sun 02 Sep 2007 10:00:00 PM UTC Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  fbernon Percent Complete:  100%
Open/Closed:  Closed Planned Release:  1.3.0
Effort:  0.00

Mon 03 Sep 2007 12:22:03 PM UTC, comment #4: 

Ok, so, I will just fix the netif_remove, and let the netif_add like this.

>What if you have an initialization where you set the loopback up first and the ETH later? Then, the loopback would be default and you'd have to set ETH as default explicitly.


If you have several netif, you should do an explicit netif_set_default (but, since we don't check in this part of the patch, it's just a remark).

I'm surprise to never have see any questions about a potential routing table. But it doesn't seems to be an usual need for embedded products...

Ok, I fix the netif_remove, and close this task...

Frédéric Bernon <fbernon>
Group Member
Mon 03 Sep 2007 10:52:21 AM UTC, comment #3: 

I agree with jonathan. Except for windows, in most OSes I know you have to set the default route explicitly.

If you want more documentation, I'd rather point out that this has to be done than set the first as the default. What if you have an initialization where you set the loopback up first and the ETH later? Then, the loopback would be default and you'd have to set ETH as default explicitly. In my opinion, this would even be more confusing to new users...

Simon Goldschmidt <goldsimon>
Group administrator
Mon 03 Sep 2007 10:38:30 AM UTC, comment #2: 


>I think it is valid to only provide some defined routes


Except if I do a mistake, there is no real route table handling in lwIP (just the default, and one for each netif&mask) ?

I'm agree this is a valid scenario, but if a NULL netif_default is the exception (what I suppose to be the case), perhaps it's better to let these users do a explicit netif_set_default(NULL) call just after their netif_add ? I think the most usual case should be more supported, than the exception. Of course, it's not replace any documentation (even if rawapi.txt is a little bit obsolete)...


Frédéric Bernon <fbernon>
Group Member
Mon 03 Sep 2007 10:17:38 AM UTC, comment #1: 

Unfortunately I think this netif_add change would be wrong. I think it is valid to only provide some defined routes, and no default route.

In fact there is code in lwIP that exists specifically to handle that scenario.

Jonathan Larmour <jifl>
Group Member
Mon 03 Sep 2007 10:06:21 AM UTC, original submission:  

Is there any objections to patch netif_add like this ?

Index: netif.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/netif.c,v
retrieving revision 1.59
diff -u -0 -p -r1.59 netif.c
--- netif.c 29 Aug 2007 21:12:33 -0000 1.59
+++ netif.c 3 Sep 2007 10:04:22 -0000
@@ -138,0 +139,6 @@ netif_add(struct netif *netif, struct ip
+  /* if netif_default if not yet defined */
+  if (netif_default == NULL) {
+    /* set this one as netif_default */
+    netif_set_default(netif);
+  }
+
@@ -205 +211 @@ void netif_remove(struct netif * netif)
-    netif_default = NULL;
+    netif_set_default(NULL);

I'm looking rawapi.txt to update the "--- System initalization" part, and I think it can help new users.

Note that the patch in netif_remove is mandatory (some processing are done in netif_set_default with NULL parameter).

Frédéric Bernon <fbernon>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by jifl (Posted a comment)
  • -email is unavailable- added by fbernon (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-09-03 fbernon StatusNone Done
        Percent Complete0% 100%
        Assigned toNone fbernon
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.3.0

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code