From owner-freebsd-net Fri Mar 26 16:57:35 1999 Delivered-To: freebsd-net@freebsd.org Received: from maxwell.syr.edu (maxwell.syr.edu [128.230.129.5]) by hub.freebsd.org (Postfix) with ESMTP id 84BE714E3E for ; Fri, 26 Mar 1999 16:57:31 -0800 (PST) (envelope-from cmsedore@maxwell.syr.edu) Received: from exchange.maxwell.syr.edu (exchange.maxwell.syr.edu [128.230.129.241]) by maxwell.syr.edu (8.9.1a/8.9.1) with ESMTP id TAA10200 for ; Fri, 26 Mar 1999 19:44:07 GMT Received: by exchange.maxwell.syr.edu with Internet Mail Service (5.5.1960.3) id ; Fri, 26 Mar 1999 19:57:02 -0500 Message-ID: <262C3DA9BE0CD211971700A0C9B413A1CBF1@exchange.maxwell.syr.edu> From: Christopher Sedore To: "'freebsd-net@freebsd.org'" Subject: bpf output bug fix Date: Fri, 26 Mar 1999 19:56:53 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.1960.3) Content-Type: text/plain Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Since it appears that 2 people (3 if you count me :) agree that having the kernel overwrite the source ethernet mac address on sends through bpf is a bug, I fixed it (patch on the end). Basically, rather than setting the dst->sa_family to AF_UNSPEC in the bpfwrite call, I set it to AF_LINK instead. I added glue to if_ethersubr.c to handle AF_LINK, implying that this usage would not conflict with anything else since it wasn't handled previously. It works as expected in my testing. -Chris diff -c -r sys/net/bpf.c /usr/src/sys/net/bpf.c *** sys/net/bpf.c Mon Dec 7 21:58:36 1998 --- /usr/src/sys/net/bpf.c Fri Mar 26 19:52:37 1999 *************** *** 177,185 **** break; case DLT_EN10MB: ! sockp->sa_family = AF_UNSPEC; ! /* XXX Would MAXLINKHDR be better? */ ! hlen = sizeof(struct ether_header); break; case DLT_FDDI: --- 177,184 ---- break; case DLT_EN10MB: ! sockp->sa_family = AF_LINK; ! hlen = 0; break; case DLT_FDDI: diff -c -r sys/net/if_ethersubr.c /usr/src/sys/net/if_ethersubr.c *** sys/net/if_ethersubr.c Tue Jan 12 12:07:00 1999 --- /usr/src/sys/net/if_ethersubr.c Fri Mar 26 18:58:58 1999 *************** *** 336,360 **** type = eh->ether_type; break; default: printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit, dst->sa_family); senderr(EAFNOSUPPORT); } ! /* ! * Add local net header. If no space in first mbuf, ! * allocate another. ! */ ! M_PREPEND(m, sizeof (struct ether_header), M_DONTWAIT); ! if (m == 0) ! senderr(ENOBUFS); ! eh = mtod(m, struct ether_header *); ! (void)memcpy(&eh->ether_type, &type, ! sizeof(eh->ether_type)); ! (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); ! (void)memcpy(eh->ether_shost, ac->ac_enaddr, ! sizeof(eh->ether_shost)); /* * If a simplex interface, and the packet is being sent to our --- 336,369 ---- type = eh->ether_type; break; + case AF_LINK: + loop_copy = -1; + break; + default: printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit, dst->sa_family); senderr(EAFNOSUPPORT); } ! if (dst->sa_family!=AF_LINK) { ! ! /* ! * Add local net header. If no space in first mbuf, ! * allocate another. ! */ ! M_PREPEND(m, sizeof (struct ether_header), M_DONTWAIT); ! if (m == 0) ! senderr(ENOBUFS); ! eh = mtod(m, struct ether_header *); ! (void)memcpy(&eh->ether_type, &type, ! sizeof(eh->ether_type)); ! (void)memcpy(eh->ether_dhost, edst, sizeof (edst)); ! (void)memcpy(eh->ether_shost, ac->ac_enaddr, ! sizeof(eh->ether_shost)); ! } else { ! eh = mtod(m, struct ether_header *); ! } /* * If a simplex interface, and the packet is being sent to our To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message