[gPXE-devel] [PATCH 12/31] [ipv6] call icmp6_rx from ipv6.c directly

matthew at theiselins.net matthew at theiselins.net
Fri Jul 8 10:28:21 EDT 2011


From: Matthew Iselin <matthew at theiselins.net>

Signed-off-by: Matthew Iselin <matthew at theiselins.net>
---
 src/include/gpxe/icmp6.h |    4 ++++
 src/include/gpxe/ip6.h   |    2 +-
 src/net/icmpv6.c         |   10 ++++++----
 src/net/ipv6.c           |    7 ++++---
 4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/include/gpxe/icmp6.h b/src/include/gpxe/icmp6.h
index e8fd1eb..ae309d6 100644
--- a/src/include/gpxe/icmp6.h
+++ b/src/include/gpxe/icmp6.h
@@ -54,6 +54,10 @@ struct neighbour_advert {
 #define ICMP6_FLAGS_SOLICITED 0x40
 #define ICMP6_FLAGS_OVERRIDE 0x20
 
+int icmp6_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
+	       struct sockaddr_tcpip *st_dest, struct net_device *netdev,
+	       uint16_t pshdr_csum );
+
 int icmp6_send_solicit ( struct net_device *netdev, struct in6_addr *src, struct in6_addr *dest );
 
 #endif /* _GPXE_ICMP6_H */
diff --git a/src/include/gpxe/ip6.h b/src/include/gpxe/ip6.h
index 3983e52..53811ca 100644
--- a/src/include/gpxe/ip6.h
+++ b/src/include/gpxe/ip6.h
@@ -55,12 +55,12 @@ struct ipv6_pseudo_header {
 
 /* Next header numbers */
 #define IP6_HOPBYHOP 		0x00
+#define IP6_ICMP6		0x3A
 #define IP6_ROUTING 		0x43
 #define IP6_FRAGMENT		0x44
 #define IP6_AUTHENTICATION	0x51
 #define IP6_DEST_OPTS		0x60
 #define IP6_ESP			0x50
-#define IP6_ICMP6		0x58
 #define IP6_NO_HEADER		0x59
 
 struct io_buffer;
diff --git a/src/net/icmpv6.c b/src/net/icmpv6.c
index aee4ca0..50a548b 100644
--- a/src/net/icmpv6.c
+++ b/src/net/icmpv6.c
@@ -67,8 +67,9 @@ int icmp6_send_solicit ( struct net_device *netdev, struct in6_addr *src __unuse
  * @v st_src	Source address
  * @v st_dest	Destination address
  */
-static int icmp6_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
-		      struct sockaddr_tcpip *st_dest, __unused uint16_t pshdr_csum ) {
+int icmp6_rx ( struct io_buffer *iobuf, struct sockaddr_tcpip *st_src,
+	       struct sockaddr_tcpip *st_dest, struct net_device *netdev __unused,
+	       uint16_t pshdr_csum __unused ) {
 	struct icmp6_header *icmp6hdr = iobuf->data;
 
 	/* Sanity check */
@@ -116,9 +117,10 @@ void icmp6_test_nadvert (struct net_device *netdev, struct sockaddr_in6 *server_
 }
 #endif
 
-/** ICMP6 protocol */
+/** ICMP6 protocol (needed for ipv6_tx) */
 struct tcpip_protocol icmp6_protocol __tcpip_protocol = {
 	.name = "ICMP6",
-	.rx = icmp6_rx,
+	.rx = NULL, /* icmp6_rx if tcpip passes netdev in future */
 	.tcpip_proto = IP_ICMP6, // 58
 };
+
diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index 5c6b942..85f896b 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -329,13 +329,14 @@ static int ipv6_tx ( struct io_buffer *iobuf,
  * @v nxt_hdr	Next header number
  * @v src	Source socket address
  * @v dest	Destination socket address
+ * @v netdev	Net device the packet arrived on
  * @v phcsm Partial checksum over the IPv6 psuedo-header.
  *
  * Refer http://www.iana.org/assignments/ipv6-parameters for the numbers
  */
 static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
 		struct sockaddr_tcpip *src, struct sockaddr_tcpip *dest,
-		uint16_t phcsm ) {
+		struct net_device *netdev, uint16_t phcsm ) {
 	switch ( nxt_hdr ) {
 	case IP6_HOPBYHOP:
 	case IP6_ROUTING:
@@ -346,7 +347,7 @@ static int ipv6_process_nxt_hdr ( struct io_buffer *iobuf, uint8_t nxt_hdr,
 		DBG ( "Function not implemented for header %d\n", nxt_hdr );
 		return -ENOSYS;
 	case IP6_ICMP6:
-		break;
+		return icmp6_rx ( iobuf, src, dest, netdev, phcsm );
 	case IP6_NO_HEADER:
 		DBG ( "No next header\n" );
 		return 0;
@@ -418,7 +419,7 @@ static int ipv6_rx ( struct io_buffer *iobuf,
 
 	/* Send it to the transport layer */
 	return ipv6_process_nxt_hdr ( iobuf, ip6hdr->nxt_hdr, &src.st, &dest.st,
-				      phcsm );
+				      netdev, phcsm );
 
   drop:
 	DBG ( "IP6 packet dropped\n" );
-- 
1.7.2.5



More information about the gPXE-devel mailing list