Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/sys/net Pull up revision 1.96-1.97 (requested by thorpe...



details:   https://anonhg.NetBSD.org/src/rev/8e9082bf437c
branches:  netbsd-1-6
changeset: 529412:8e9082bf437c
user:      tron <tron%NetBSD.org@localhost>
date:      Tue Nov 19 21:08:12 2002 +0000

description:
Pull up revision 1.96-1.97 (requested by thorpej in ticket #702):
In ether_output(), don't bother calling memcpy() to plop the ethertype
into the packet: On system with no strict alignment constraints, just
assign the value, and on others, do an inline 2 byte copy.

diffstat:

 sys/net/if_ethersubr.c |  21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r 61ccdc8a2f5e -r 8e9082bf437c sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Mon Nov 18 03:02:02 2002 +0000
+++ b/sys/net/if_ethersubr.c    Tue Nov 19 21:08:12 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.95 2002/05/18 22:52:44 itojun Exp $ */
+/*     $NetBSD: if_ethersubr.c,v 1.95.2.1 2002/11/19 21:08:12 tron Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.95 2002/05/18 22:52:44 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.95.2.1 2002/11/19 21:08:12 tron Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -479,8 +479,21 @@
        if (m == 0)
                senderr(ENOBUFS);
        eh = mtod(m, struct ether_header *);
-       bcopy((caddr_t)&etype,(caddr_t)&eh->ether_type,
-               sizeof(eh->ether_type));
+       /* Note: etype is already in network byte order. */
+#ifdef __NO_STRICT_ALIGNMENT
+       eh->ether_type = etype;
+#else
+       {
+               uint8_t *dstp = (uint8_t *) &eh->ether_type;
+#if BYTE_ORDER == BIG_ENDIAN
+               dstp[0] = etype >> 8;
+               dstp[1] = etype; 
+#else
+               dstp[0] = etype;
+               dstp[1] = etype >> 8;
+#endif /* BYTE_ORDER == BIG_ENDIAN */
+       }
+#endif /* __NO_STRICT_ALIGNMENT */
        bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
        if (hdrcmplt)
                bcopy((caddr_t)esrc, (caddr_t)eh->ether_shost,



Home | Main Index | Thread Index | Old Index