From owner-freebsd-atm Wed Mar 12 5:45:23 2003 Delivered-To: freebsd-atm@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3C84237B401 for ; Wed, 12 Mar 2003 05:45:20 -0800 (PST) Received: from mailhub.fokus.fraunhofer.de (mailhub.fokus.fraunhofer.de [193.174.154.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 046C643F75 for ; Wed, 12 Mar 2003 05:45:19 -0800 (PST) (envelope-from brandt@fokus.fraunhofer.de) Received: from beagle (beagle [193.175.132.100]) by mailhub.fokus.fraunhofer.de (8.11.6/8.11.6) with ESMTP id h2CDjHk20975 for ; Wed, 12 Mar 2003 14:45:17 +0100 (MET) Date: Wed, 12 Mar 2003 14:45:17 +0100 (CET) From: Harti Brandt To: freebsd-atm@freebsd.org Subject: endian patch to NATM Message-ID: <20030312144011.N641@beagle.fokus.fraunhofer.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-atm@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Hi all, there seems to be an endian related bug in NATM. The problem is, that in contrast to the comments in if_atm.h, the ATM_LLC_SETTYPE macros expects its V argument (the ethertype) in swapped host order (the ATM_LLC_TYPE macros on the other hand returns host order). The code feeds the htons'ed ethernet type into the macro, so that for i386 it happens to work. On the sparc the ethernet type in the LLC/SNAP header is wrong. The attached patch changes the macro to actually require host byte order and the calling code to feed the ethertype in host byte order. The patch has been verified by using IP between an i386 and a sparc64. Comments? Ok to commit? Regards, harti Index: if_atm.h =================================================================== RCS file: /home/ncvs/src/sys/net/if_atm.h,v retrieving revision 1.5 diff -u -r1.5 if_atm.h --- if_atm.h 19 Mar 2002 21:54:16 -0000 1.5 +++ if_atm.h 12 Mar 2003 13:39:51 -0000 @@ -93,8 +93,8 @@ /* ATM_LLC macros: note type code in host byte order */ #define ATM_LLC_TYPE(X) (((X)->type[0] << 8) | ((X)->type[1])) #define ATM_LLC_SETTYPE(X,V) { \ - (X)->type[1] = ((V) >> 8) & 0xff; \ - (X)->type[0] = ((V) & 0xff); \ + (X)->type[0] = ((V) >> 8) & 0xff; \ + (X)->type[1] = ((V) & 0xff); \ } #ifdef _KERNEL Index: if_atmsubr.c =================================================================== RCS file: /home/ncvs/src/sys/net/if_atmsubr.c,v retrieving revision 1.23 diff -u -r1.23 if_atmsubr.c --- if_atmsubr.c 4 Mar 2003 23:19:51 -0000 1.23 +++ if_atmsubr.c 12 Mar 2003 13:39:51 -0000 @@ -130,9 +130,9 @@ case AF_INET: case AF_INET6: if (dst->sa_family == AF_INET6) - etype = htons(ETHERTYPE_IPV6); + etype = ETHERTYPE_IPV6; else - etype = htons(ETHERTYPE_IP); + etype = ETHERTYPE_IP; if (!atmresolve(rt, m, dst, &atmdst)) { m = NULL; /* XXX: atmresolve already free'd it */ @@ -180,7 +180,7 @@ bcopy(ATMLLC_HDR, atmllc->llchdr, sizeof(atmllc->llchdr)); ATM_LLC_SETTYPE(atmllc, etype); - /* note: already in network order */ + /* note: in host order */ } else bcopy(llc_hdr, atmllc, sizeof(struct atmllc)); -- harti brandt, http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.fraunhofer.de, harti@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-atm" in the body of the message From owner-freebsd-atm Wed Mar 12 6:41:11 2003 Delivered-To: freebsd-atm@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5E7C437B401 for ; Wed, 12 Mar 2003 06:41:10 -0800 (PST) Received: from linus.csl.sony.co.jp (linus.csl.sony.co.jp [133.138.1.176]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1DA3C43FBF for ; Wed, 12 Mar 2003 06:41:09 -0800 (PST) (envelope-from kjc@csl.sony.co.jp) Received: from localhost (localhost [127.0.0.1]) by linus.csl.sony.co.jp (8.12.8/8.12.6) with ESMTP id h2CEexuN021526; Wed, 12 Mar 2003 23:41:00 +0900 (JST) (envelope-from kjc@csl.sony.co.jp) Date: Wed, 12 Mar 2003 23:40:59 +0900 (JST) Message-Id: <20030312.234059.74730339.kjc@csl.sony.co.jp> To: brandt@fokus.fraunhofer.de Cc: freebsd-atm@FreeBSD.ORG Subject: Re: endian patch to NATM From: Kenjiro Cho In-Reply-To: <20030312144011.N641@beagle.fokus.fraunhofer.de> References: <20030312144011.N641@beagle.fokus.fraunhofer.de> X-Mailer: Mew version 2.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-atm@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Harti Brandt wrote: > there seems to be an endian related bug in NATM. The problem is, that > in contrast to the comments in if_atm.h, the ATM_LLC_SETTYPE macros > expects its V argument (the ethertype) in swapped host order (the > ATM_LLC_TYPE macros on the other hand returns host order). The code feeds > the htons'ed ethernet type into the macro, so that for i386 it happens to > work. On the sparc the ethernet type in the LLC/SNAP header is wrong. > > The attached patch changes the macro to actually require host byte order > and the calling code to feed the ethertype in host byte order. > > The patch has been verified by using IP between an i386 and a sparc64. > > Comments? Ok to commit? > > Regards, > harti I've just noticed that NetBSD fixed this long time ago. Please commit. -Kenjiro To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-atm" in the body of the message