Subject: Re: WFQ_HASH_SRCADDR added to ALTQ (with patch)
To: None <tech-kern@NetBSD.org>
From: Petter Lindquist <pollen@astrakan.hig.se>
List: tech-kern
Date: 10/25/2004 11:03:45
Petter Lindquist wrote:

> I just implemented above mentioned hash algorithm for WFQ.
> Anyone interested in patches?
> (Perhaps this has alreadey been done in -current? I made this on 2.0_RC4)
> (Or should this have been posted to tech-net? Or some other?)

Ok, this adds support for source address hashing of WFQ in ALTQ.

Patches included, they are ok to commit into the tree if you want. And 
please let me know what I've done wrong, so I can do it the right way 
next time. :)

diff altq/altq_wfq.c /usr/src/sys/altq/altq_wfq.c
77a78
 > static __inline u_long  wfq_hashbysrcaddr(struct flowinfo *, int);
388a390,415
 > static __inline u_long wfq_hashbysrcaddr(flow, n)
 >         struct flowinfo *flow;
 >       int n;
 > {              
 >       u_long val = 0;
 >                      
 >       if (flow != NULL) {
 >               if (flow->fi_family == AF_INET) {
 >                       struct flowinfo_in *fp = (struct flowinfo_in 
*)flow;
 >                                                                               

 >                       val = fp->fi_src.s_addr;
 >                       val = val ^ (val >> 8) ^ (val >> 16) ^ (val >> 24);
 >               }
 > #ifdef INET6
 >               else if (flow->fi_family == AF_INET6) {
 >                       struct flowinfo_in6 *fp6 = (struct flowinfo_in6 
*)flow;
 >                       val = ntohl(fp6->fi6_flowlabel);
 >               }
 > #endif         
 >       }      
 >                                                                                                                                       

 >       return (val % n);
 > }
 >
 >
 >
613a641,644
 >       case WFQ_HASH_SRCADDR:
 >               wfqp->hash_func = wfq_hashbysrcaddr;
 >               wfqp->fbmask = FIMB4_SADDR;
 >               break;
diff altq/altq_wfq.h /usr/src/sys/altq/altq_wfq.h
80a81
 > #define WFQ_HASH_SRCADDR      3       /* hash by src address */
diff usr.sbin/altq/libaltq/qop_wfq.c 
/usr/src/usr.sbin/altq/libaltq/qop_wfq.c
120a121,122
 >                               else if (EQUAL(*argv, "srcaddr"))
 >                                       hash_policy = WFQ_HASH_SRCADDR;