patchlwIP - A Lightweight TCP/IP stack - Patches: patch #7913, Enable Support for IPv6 Loopback

 
 

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

patch #7913: Enable Support for IPv6 Loopback

Submitter:  Grant Erickson <marathon96>
Submitted:  Fri 04 Jan 2013 12:51:59 AM UTC
   
 
Category:  IPv6 Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  goldsimon Open/Closed:  Closed
Planned Release:  None

Fri 17 Jan 2014 08:56:17 PM UTC, comment #3: 

Done, thanks for the patch.

Simon Goldschmidt <goldsimon>
Group administrator
Tue 05 Feb 2013 11:20:38 PM UTC, comment #2: 

Attached is an updated version of this patch that I believe is more correct.  In particular, the updated version directs all packets addressed to a valid local IPv6 address through the loopback path, not just those addressed to the link-local address.

Thanks,
Jay


(file #27396)

Jay Logue <jdl>
Wed 09 Jan 2013 08:54:32 PM UTC, comment #1: 

Thanks for submitting, will review and consider for inclusion soon.

Cheers
Ivan

Ivan Delamer <idelamer>
Group Member
Fri 04 Jan 2013 12:51:59 AM UTC, original submission:  

diff --git a/src/core/ipv6/ip6.c b/src/core/ipv6/ip6.c
index 94e423a..e3957b1 100644
--- a/src/core/ipv6/ip6.c
+++ b/src/core/ipv6/ip6.c
@@ -802,10 +802,11 @@ ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest,
   ip6_debug_print(p);
 
 #if ENABLE_LOOPBACK
-  /* TODO implement loopback for v6
-  if (ip6_addr_cmp(dest, netif_ip6_addr(0))) {
+  if (ip6_addr_cmp(dest, netif_ip6_addr(netif, 0))) {
+    /* Packet to self, enqueue it for loopback */
+    LWIP_DEBUGF(IP6_DEBUG, ("netif_loop_output()\n"));
     return netif_loop_output(netif, p, dest);
-  }*/
+  }
 #endif /* ENABLE_LOOPBACK */
 #if LWIP_IPV6_FRAG
   /* don't fragment if interface has mtu set to 0 [loopif] */
diff --git a/src/core/netif.c b/src/core/netif.c
index f8133f7..7b5ab17 100644
--- a/src/core/netif.c
+++ b/src/core/netif.c
@@ -88,6 +88,12 @@ static u8_t netif_num;
 static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr);
 #endif /* LWIP_IPV6 */
 
+#if LWIP_IPV6
+#define ipX_input(in, netif) (IP6H_V((const struct ip6_hdr *)in->payload) == 6) ? ip6_input(in, netif) : ip_input(in, netif)
+#else
+#define ipX_input(in, netif) ip_input(in, netif)
+#endif
+
 #if LWIP_HAVE_LOOPIF
 static struct netif loop_netif;
 
@@ -127,6 +133,10 @@ netif_init(void)
 #else  /* NO_SYS */
   netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input);
 #endif /* NO_SYS */
+#if LWIP_IPV6
+  ip6_addr_set_loopback(&loop_netif.ip6_addr[0]);
+  netif_ip6_addr_set_state(&loop_netif, 0, IP6_ADDR_VALID);
+#endif /* LWIP_IPV6 */
   netif_set_up(&loop_netif);
 
 #endif /* LWIP_HAVE_LOOPIF */
@@ -798,7 +808,7 @@ netif_poll(struct netif *netif)
       snmp_add_ifinoctets(stats_if, in->tot_len);
       snmp_inc_ifinucastpkts(stats_if);
       /* loopback packets are always IP packets! */
-      if (ip_input(in, netif) != ERR_OK) {
+      if (ipX_input(in, netif) != ERR_OK) {
         pbuf_free(in);
       }
       /* Don't reference the packet any more! */

Grant Erickson <marathon96>

 

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

Attached Files
file #27396:  ip6-loopback-UPDATED.patch added by jdl (2KiB - application/octet-stream - Updated patch to add support for IPv6 loopback.)
file #27196:  ip6-loopback-0001.0.patch added by marathon96 (822B - application/octet-stream - These patches add support for IPv6 loopback.)
file #27197:  ip6-loopback-0002.0.patch added by marathon96 (2KiB - application/octet-stream - These patches add support for IPv6 loopback.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jdl (Updated the item)
  • -email is unavailable- added by goldsimon (Updated the item)
  • -email is unavailable- added by idelamer (Posted a comment)
  • -email is unavailable- added by marathon96 (Submitted the item)
  • -email is unavailable- added by marathon96 (IPv6 loopback support works!)
  •  

    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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-17 goldsimon StatusNone Done
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2013-02-05 jdl Attached File- Added ip6-loopback-UPDATED.patch, #27396
    2013-01-15 goldsimon CategoryNone IPv6
    2013-01-04 marathon96 Attached File- Added ip6-loopback-0001.0.patch, #27196
        Attached File- Added ip6-loopback-0002.0.patch, #27197
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code