Date: Tue, 18 May 2004 12:09:49 +0200 From: Andre Oppermann <andre@freebsd.org> To: Pawel Jakub Dawidek <pjd@FreeBSD.org> Cc: freebsd-net@freebsd.org Subject: Re: ia_netbroadcast Message-ID: <40A9E0ED.4FD479BD@freebsd.org> References: <20040518092439.GF845@darkness.comp.waw.pl>
next in thread | previous in thread | raw e-mail | index | archive | help
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; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40A9E0ED.4FD479BD>