[ofw] [Patch][IPoIB_NDIS6_CM] Fixes at DHCPv4 and IPv6 flows

Alex Naslednikov xalex at mellanox.co.il
Wed Dec 22 02:58:50 PST 2010


Additional fixes for IPv6 and DHCPv4, caused by initial IPv6 commit
Signed-off by: Galina Tcharny (galina at mellanox.co.il)

Index: ipoib_port.cpp
===================================================================
--- ipoib_port.cpp	(revision 3033)
+++ ipoib_port.cpp	(working copy)
@@ -351,7 +351,7 @@
 	IN		const	void* const					p_ip_hdr,
 	IN				MDL*						p_mdl,
 	IN				size_t						buf_len,
-	IN				uint8_t					prot,
+	IN				net16_t 					ethertype,
 	IN	OUT			ipoib_send_NB_SG* const		s_buf);
 
 static NDIS_STATUS
@@ -359,6 +359,7 @@
 	IN		const	udp_hdr_t* const			p_udp_hdr,
 	IN				MDL*						p_mdl,
 	IN				size_t						buf_len,
+	IN				net16_t 					ethertype,
 	IN	OUT			ipoib_send_NB_SG* const		s_buf );
 
 static NDIS_STATUS
@@ -616,7 +617,8 @@
 
 static inline void* GetIpv6PayloadPtr(const	ipv6_hdr_t* const	p_ipv6_hdr)
 {
-	return (void*)((uint8_t*)p_ipv6_hdr + p_ipv6_hdr->payload_length);
+	// BUGBUG: need to add support for extension headers
+	return (void*)((uint8_t*)p_ipv6_hdr + sizeof(ipv6_hdr_t));
 }
 
 
@@ -1425,6 +1427,8 @@
 	NdisInitializeNPagedLookasideList( &p_port->buf_mgr.send_buf_list,
 		NULL, NULL, 0, MAX_LSO_PAYLOAD_MTU, 'bipi', 0 );
 
+	p_port->buf_mgr.send_buf_len = MAX_LSO_PAYLOAD_MTU;
+
 	p_port->buf_mgr.h_send_pkt_pool = NULL;
 }
 
@@ -4425,6 +4429,7 @@
 	
 	if ( p_eth_hdr->type == ETH_PROT_TYPE_IPV6 ) 
 	{
+		// BUGBUG: need to add support for extension headers
 		prot = ((ipv6_hdr_t *) p_ip_hdr)->next_header;
 		hdr_size = sizeof(ipv6_hdr_t);
 	}
@@ -4446,7 +4451,7 @@
 	case IP_PROT_UDP:
 		cl_perf_start( FilterUdp );
 		status = __send_mgr_filter_udp( p_ip_hdr, p_mdl,
-										(buf_len - hdr_size), prot, s_buf );
+										(buf_len - hdr_size), p_eth_hdr->type, s_buf );
 		cl_perf_stop( &p_port->p_adapter->perf, FilterUdp );
 		if( status == NDIS_STATUS_PENDING )
 		{  /* not DHCP packet, keep going */
@@ -4671,7 +4676,7 @@
 	IN		const	void* const				p_ip_hdr,
 	IN				MDL*					p_mdl,
 	IN				size_t					buf_len,
-	IN				uint8_t					prot,
+	IN				net16_t					ethertype,
 	IN	OUT			ipoib_send_NB_SG*		s_buf )
 {
 	NDIS_STATUS			status;
@@ -4702,7 +4707,7 @@
 	}
 	else
 	{
-		if ( prot == ETH_PROT_TYPE_IPV6 ) 
+		if ( ethertype == ETH_PROT_TYPE_IPV6 ) 
 		{
 			p_udp_hdr = (udp_hdr_t*)GetIpv6PayloadPtr((ipv6_hdr_t*)p_ip_hdr);
 		}
@@ -4729,7 +4734,7 @@
 		return NDIS_STATUS_BUFFER_TOO_SHORT;
 	}
 
-	if ( prot == ETH_PROT_TYPE_IPV6 ) {
+	if ( ethertype == ETH_PROT_TYPE_IP ) {
 		if( (p_udp_hdr->src_port != DHCP_PORT_CLIENT ||
 			p_udp_hdr->dst_port != DHCP_PORT_SERVER) &&
 			(p_udp_hdr->src_port != DHCP_PORT_SERVER ||
@@ -4739,7 +4744,7 @@
 			return NDIS_STATUS_PENDING;
 		}
 	}
-	else //IPv4
+	else //IPv6
 	{
 		if( (p_udp_hdr->src_port != DHCP_IPV6_PORT_CLIENT||
 			p_udp_hdr->dst_port != DHCP_IPV6_PORT_SERVER_OR_AGENT) &&
@@ -4762,9 +4767,11 @@
 			("Failed to query DHCP packet buffer.\n") );
 		return NDIS_STATUS_RESOURCES;
 	}
+	NdisZeroMemory(s_buf->p_send_buf, s_buf->p_port->buf_mgr.send_buf_len);
+		
 	/* Copy the IP and UDP headers. */
 	//TODO: in this case we limited IP size to 20, but it can be bigger, according to GetIpPayloadPtr
-	if ( prot == ETH_PROT_TYPE_IPV6 ) 
+	if ( ethertype == ETH_PROT_TYPE_IPV6 ) 
 	{
 		cl_memcpy( &s_buf->p_send_buf->ip.hdr_ipv6, p_ip_hdr , sizeof(ipv6_hdr_t) );
 	}
@@ -4777,7 +4784,7 @@
 		&s_buf->p_send_buf->ip.prot.udp.hdr, p_udp_hdr, sizeof(udp_hdr_t) );
 
 	cl_perf_start( FilterDhcp );
-	status = __send_mgr_filter_dhcp( p_udp_hdr, p_mdl, buf_len, s_buf );
+	status = __send_mgr_filter_dhcp( p_udp_hdr, p_mdl, buf_len, ethertype, s_buf );
 	cl_perf_stop( &p_port->p_adapter->perf, FilterDhcp );
 
 	IPOIB_EXIT( IPOIB_DBG_SEND );
@@ -4802,6 +4809,7 @@
 	IN		const	udp_hdr_t* const			p_udp_hdr,
 	IN				NDIS_BUFFER*				p_mdl,
 	IN				size_t						buf_len,
+	IN				net16_t						ethertype,
 	IN	OUT			ipoib_send_NB_SG*			s_buf )
 {
 	dhcp_pkt_t			*p_dhcp;
@@ -4836,6 +4844,13 @@
 		p_dhcp = (dhcp_pkt_t*)(p_udp_hdr + 1);
 	}
 
+	if(ethertype == ETH_PROT_TYPE_IPV6)
+	{
+			IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
+				("DHCPv6 packet - not supported.\n") );
+			return NDIS_STATUS_FAILURE;
+	}
+	
 	if( buf_len < DHCP_MIN_SIZE )
 	{
 		IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,
@@ -8866,4 +8881,4 @@
 	}
 	return;
 }
-#endif
+#endif
\ No newline at end of file
Index: ipoib_port.h
===================================================================
--- ipoib_port.h	(revision 3031)
+++ ipoib_port.h	(working copy)
@@ -320,6 +320,8 @@
 	NDIS_HANDLE			h_packet_pool;
 
 	NPAGED_LOOKASIDE_LIST	send_buf_list;
+	uint32_t				send_buf_len;
+	
 	NDIS_HANDLE			h_send_pkt_pool;
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DHCP_ipv6_ofw_2_galina.patch
Type: application/octet-stream
Size: 4659 bytes
Desc: DHCP_ipv6_ofw_2_galina.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20101222/8a944a3b/attachment.obj>


More information about the ofw mailing list