From owner-freebsd-net@FreeBSD.ORG Tue May 18 03:09:57 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8AB6A16A4CE for ; Tue, 18 May 2004 03:09:57 -0700 (PDT) Received: from mailtoaster1.pipeline.ch (mailtoaster1.pipeline.ch [62.48.0.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4A64E43D53 for ; Tue, 18 May 2004 03:09:49 -0700 (PDT) (envelope-from andre@freebsd.org) Received: (qmail 90717 invoked from network); 18 May 2004 10:09:47 -0000 Received: from unknown (HELO freebsd.org) ([62.48.0.53]) (envelope-sender ) by mailtoaster1.pipeline.ch (qmail-ldap-1.03) with SMTP for ; 18 May 2004 10:09:47 -0000 Message-ID: <40A9E0ED.4FD479BD@freebsd.org> Date: Tue, 18 May 2004 12:09:49 +0200 From: Andre Oppermann X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Pawel Jakub Dawidek References: <20040518092439.GF845@darkness.comp.waw.pl> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: freebsd-net@freebsd.org Subject: Re: ia_netbroadcast X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 May 2004 10:09:57 -0000 Pawel Jakub Dawidek wrote: > > Hi. > > Do we still need ia_netboradcast field? It is calculated depending on > old-fashion classes (A, B, C). Is it used still? > I wonder if ia_broadaddr isn't sufficient today. Yes, it should be sufficient and the ia_netbroadcast field doesn't serve any special purpose anymore since it wrong most of the time anyway. The only problem you could run into is Windoze stuff. They still use it extensively and will broadcast their NetBIOS stuff always on the classful netmask. I don't know how much Samba and such depend on this. You'll have to check. > IP netmask ia_broadaddr ia_netbroadcast > 10.0.0.101 255.0.0.0 10.255.255.255 10.255.255.255 > 1.0.0.2 255.255.255.252 1.0.0.3 1.255.255.255 > 2.0.0.1 255.255.0.0 2.0.255.255 2.255.255.255 > > I'm planing to work on removing O(n) from interface aliases search. > Now every incoming packet have to be compared with every single > broadcast from every single alias. When I tested something and > there were ~10000 aliases on interface it worked really slow. There are two ways I see to optimize this. One is to use a hash for the broadcast addresses too as with the IP address. The second is to go only into this loop if the packet was actually received on an link level broadcast address (M_BCAST flag in mbuf packet header). However this might work only for ieee802-type interfaces. > This slowdown probably exists in more places. It exists in NetBSD and > OpenBSD as well. -- Andre [patch to netinet/ip_fastfwd.c but same to ip_input.c] /* * Or is it for a local IP broadcast address on this host? */ if ((m->m_flags & M_BCAST) && (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST)) { TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET) continue; ia = ifatoia(ifa); if (ia->ia_netbroadcast.s_addr == ip->ip_dst.s_addr) return 0; if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr == ip->ip_dst.s_addr) return 0; } }