Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jun 1996 00:38:32 -0700
From:      Ted Lemon <mellon@fugue.com>
To:        davidg@root.com
Cc:        Jason Thorpe <thorpej@nas.nasa.gov>, freebsd-hackers@freebsd.org
Subject:   Re: Swapped ethertype in BPF output? 
Message-ID:  <199606110738.AAA29287@toccata.fugue.com>
In-Reply-To: Your message of "Mon, 10 Jun 1996 18:16:41 PDT." <199606110116.SAA18815@Root.COM> 

next in thread | previous in thread | raw e-mail | index | archive | help

>   ehh, uhh, well, send me a context diff for however people want it in the
> kernel. :-)

Be careful what you ask for - you may get it!   :')

I believe that the patch below is the right way to solve the problem,
although I'm by no means positive, since I don't have a FreeBSD
machine to check it on.   The patch is on the latest FreeBSD kernel
snapshot (960606).

It's not clear to me how this worked in 4.4BSD.   The code just after
the 4.4BSD merge in the NetBSD tree does the right thing, albeit in a
slightly less efficient way.   But this may be based on the previous
NetBSD code, which is also correct.

The changes below actually only do a runtime swap for AF_ISO and
AF_CCITT (as if anybody cared) - otherwise the swap is done on a
constant (ETHERTYPE_XXX) at compile time.  So in addition to being
(IMHO) correct, these changes make the code slightly faster.  Not that
I can claim credit for this - the changes are analogous to changes
made by mycroft in the NetBSD tree.

			       _MelloN_


*** sys/net/if_ethersubr.c~   Wed Jun  5 12:49:24 1996
--- sys/net/if_ethersubr.c      Tue Jun 11 00:19:52 1996
***************
*** 145,154 ****
                        mcopy = m_copy(m, 0, (int)M_COPYALL);
                off = m->m_pkthdr.len - m->m_len;
!               type = ETHERTYPE_IP;
                break;
  #endif
  #ifdef NS
        case AF_NS:
!               type = ETHERTYPE_NS;
                bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
                    (caddr_t)edst, sizeof (edst));
--- 145,154 ----
                        mcopy = m_copy(m, 0, (int)M_COPYALL);
                off = m->m_pkthdr.len - m->m_len;
!               type = htons (ETHERTYPE_IP);
                break;
  #endif
  #ifdef NS
        case AF_NS:
!               type = htons (ETHERTYPE_NS);
                bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host),
                    (caddr_t)edst, sizeof (edst));
***************
*** 190,194 ****
                if (m == NULL)
                        return (0);
!               type = m->m_pkthdr.len;
                l = mtod(m, struct llc *);
                l->llc_dsap = l->llc_ssap = LLC_ISO_LSAP;
--- 190,194 ----
                if (m == NULL)
                        return (0);
!               type = htons (m->m_pkthdr.len);
                l = mtod(m, struct llc *);
                l->llc_dsap = l->llc_ssap = LLC_ISO_LSAP;
***************
*** 226,230 ****
                        }
                }
!               type = m->m_pkthdr.len;
  #ifdef LLC_DEBUG
                {
--- 226,230 ----
                        }
                }
!               type = htons (m->m_pkthdr.len);
  #ifdef LLC_DEBUG
                {
***************
*** 267,271 ****
                senderr(ENOBUFS);
        eh = mtod(m, struct ether_header *);
-       type = htons((u_short)type);
        (void)memcpy(&eh->ether_type, &type,
                sizeof(eh->ether_type));
--- 267,270 ----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606110738.AAA29287>