Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Sep 1998 00:48:16 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        luigi@labinfo.iet.unipi.it (Luigi Rizzo)
Cc:        hackers@FreeBSD.ORG
Subject:   Re: bcmp abuse in networking code ?
Message-ID:  <199809030048.RAA01032@usr07.primenet.com>
In-Reply-To: <199809021506.RAA10910@labinfo.iet.unipi.it> from "Luigi Rizzo" at Sep 2, 98 05:06:30 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> poking around in /sys/net and /sys/netinet, i frequently see bcmp() being
> used to compare ethernet addresses (but not only those). In some cases,
> even against the ethernet broadcast address.
> 
> In my revised bridge code i have the following macros
> 
> #define ETH_MATCH(a,b) ( \
>     ((unsigned short *)(a))[2] == ((unsigned short *)(b))[2] && \
>     *((unsigned int *)(a)) == *((unsigned int *)(b)) )
> #define IS_ETHER_BROADCAST(a) ( \
>         *((unsigned int *)(a)) == 0xffffffff && \
>         ((unsigned short *)(a))[2] == 0xffff )
> 
> which seem to do a decent job in terms of performance. On a Pentium90,
> they save about 40-50 ticks per call, which is not bad considering how
> frequently they are used on a bridge or on a multicast router.

As you noted, alignment is one issue.

Another issue is the use of arbitrary length addresses in the ARP code.

See www.daemonnews.org, in the "under the hood" column, where they
talk about implementing precisely this for FDDI and AX.25 support
in the NetBSD kernel.

Assumptions about the entry length are bad (IMO), in that they break
future compatability.

Consider the IPv6 code from WIDE and INRIA, and make sure this change
does not damage the ability to use IPv6 on FreeBSD (for one concrete
case of current, working code, for all you X.25-haters...).


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



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