Subject: Re: Ethersubr fix for netiso
To: None <tech-net@netbsd.org>
From: Ignatios Souvatzis <is@netbsd.org>
List: tech-net
Date: 12/04/2006 22:48:25
--VS++wcV0S1rZb1Fb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Here's part two of the patches, for FDDI (again, netiso/clnp_input.c and
netinet/fddi_subr.c). 

I did test that it compiles, but not run-time - no FDDI here. Testers
can use the package at 

ftp://ftp.netbsd.org/pub/NetBSD/misc/is/isotest/

It comes with a README file that explains how to setup two machines and
send an ISO CLTP packet from one to the other.

Regards,
	-is

--VS++wcV0S1rZb1Fb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=netiso-fddi-diff

Index: sys/netiso/clnp_input.c
===================================================================
RCS file: /cvsroot/src/sys/netiso/clnp_input.c,v
retrieving revision 1.31
diff -u -r1.31 clnp_input.c
--- sys/netiso/clnp_input.c	1 Dec 2006 18:43:40 -0000	1.31
+++ sys/netiso/clnp_input.c	4 Dec 2006 21:20:11 -0000
@@ -204,9 +204,8 @@
 	case IFT_FDDI:
 		bcopy((caddr_t) (mtod(m, struct fddi_header *)->fddi_dhost),
 		  (caddr_t) sh.snh_dhost, 2 * sizeof(sh.snh_dhost));
-		m->m_data += sizeof(struct fddi_header);
-		m->m_len -= sizeof(struct fddi_header);
-		m->m_pkthdr.len -= sizeof(struct fddi_header);
+
+		m_adj(m, sizeof(struct fddi_header) + 3);
 		break;
 	case IFT_PTPSERIAL:
 	case IFT_GIF:
Index: sys/net/if_fddisubr.c
===================================================================
RCS file: /cvsroot/src/sys/net/if_fddisubr.c,v
retrieving revision 1.63
diff -u -r1.63 if_fddisubr.c
--- sys/net/if_fddisubr.c	7 Sep 2006 02:40:33 -0000	1.63
+++ sys/net/if_fddisubr.c	4 Dec 2006 21:20:12 -0000
@@ -580,10 +580,7 @@
 		m->m_flags |= M_LINK0;
 #endif
 
-	/* Strip off the FDDI header. */
-	m_adj(m, sizeof(struct fddi_header));
-
-	l = mtod(m, struct llc *);
+	l = (struct llc *)(fh+1);
 	switch (l->llc_dsap) {
 #if defined(INET) || defined(INET6) || defined(NS) || defined(DECNET) || defined(IPX) || defined(NETATALK)
 	case LLC_SNAP_LSAP:
@@ -591,6 +588,10 @@
 		u_int16_t etype;
 		if (l->llc_control != LLC_UI || l->llc_ssap != LLC_SNAP_LSAP)
 			goto dropanyway;
+
+		/* Strip off the FDDI header. */
+		m_adj(m, sizeof(struct fddi_header));
+
 #ifdef NETATALK
 		if (Bcmp(&(l->llc_snap_org_code)[0], at_org_code,
 			 sizeof(at_org_code)) == 0 &&
@@ -684,14 +685,7 @@
 			/* LLC_UI_P forbidden in class 1 service */
 			if ((l->llc_dsap == LLC_ISO_LSAP) &&
 			    (l->llc_ssap == LLC_ISO_LSAP)) {
-				/* LSAP for ISO */
-				m->m_data += 3;		/* XXX */
-				m->m_len -= 3;		/* XXX */
-				m->m_pkthdr.len -= 3;	/* XXX */
-				M_PREPEND(m, sizeof *fh, M_DONTWAIT);
-				if (m == 0)
-					return;
-				*mtod(m, struct fddi_header *) = *fh;
+
 				schednetisr(NETISR_ISO);
 				inq = &clnlintrq;
 				break;
@@ -700,7 +694,7 @@
 
 		case LLC_XID:
 		case LLC_XID_P:
-			if(m->m_len < 6)
+			if(m->m_len < 6 + sizeof(struct fddi_header))
 				goto dropanyway;
 			l->llc_window = 0;
 			l->llc_fid = 9;
@@ -727,6 +721,7 @@
 				eh->ether_dhost[i] = fh->fddi_shost[i];
 			}
 			eh->ether_type = 0;
+			m_adj(m, sizeof(struct fddi_header));
 			ifp->if_output(ifp, m, &sa, NULL);
 			return;
 		}

--VS++wcV0S1rZb1Fb--