ref: 57bc073cfb6910075b6548610f2a472494164d76
parent: 268251a9b32e5df02d2cbee95589ed3ad3a149d2
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Jun 9 06:04:04 EDT 2015
ip: fix wrong radix for iphash() (thanks yoann padioleau)
yoann padioleaus report on 9fans:
> I think I’ve found a bug in the network stack.
> in 9/ip/ip.h there is
> struct Ipht
> {
> Lock;
> Iphash *tab[Nipht];
> };
>
> where Night is 521,
>
> but then in 9/ip/ipaux.c there is
>
> ulong
> iphash(uchar *sa, ushort sp, uchar *da, ushort dp)
> {
> return ((sa[IPaddrlen-1]<<24) ^ (sp << 16) ^ (da[IPaddrlen-1]<<8) ^ dp ) % Nhash;
> }
>
> where Nhash is just 64,
--- a/sys/src/9/ip/ip.h
+++ b/sys/src/9/ip/ip.h
@@ -37,7 +37,6 @@
{Addrlen= 64,
Maxproto= 20,
- Nhash= 64,
Maxincall= 10,
Nchans= 1024,
MAClen= 16, /* longest mac address */
--- a/sys/src/9/ip/ipaux.c
+++ b/sys/src/9/ip/ipaux.c
@@ -238,7 +238,7 @@
ulong
iphash(uchar *sa, ushort sp, uchar *da, ushort dp)
{- return ((sa[IPaddrlen-1]<<24) ^ (sp << 16) ^ (da[IPaddrlen-1]<<8) ^ dp ) % Nhash;
+ return ((sa[IPaddrlen-1]<<24) ^ (sp << 16) ^ (da[IPaddrlen-1]<<8) ^ dp ) % Nipht;
}
void
--
⑨