--------------------- PatchSet 8793 Date: 2006/12/04 05:39:03 Author: adri Branch: s26_wccp2 Tag: (none) Log: Fix crash with the mask assignment generation code; its still generating badly formed packets but i can at least generate them. Members: src/wccp2.c:1.26.2.7->1.26.2.8 Index: squid/src/wccp2.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/wccp2.c,v retrieving revision 1.26.2.7 retrieving revision 1.26.2.8 diff -u -r1.26.2.7 -r1.26.2.8 --- squid/src/wccp2.c 3 Dec 2006 12:54:17 -0000 1.26.2.7 +++ squid/src/wccp2.c 4 Dec 2006 05:39:03 -0000 1.26.2.8 @@ -1,6 +1,6 @@ /* - * $Id: wccp2.c,v 1.26.2.7 2006/12/03 12:54:17 adri Exp $ + * $Id: wccp2.c,v 1.26.2.8 2006/12/04 05:39:03 adri Exp $ * * DEBUG: section 80 WCCP Support * AUTHOR: Steven WIlton @@ -1153,12 +1153,12 @@ } wccp2_out_add_service_info(&op, &service_list_ptr->info); if (Config.Wccp2.assignment_method == WCCP2_ASSIGNMENT_METHOD_HASH) { - wccp2_out_add_hash_assignment_info(&op, service_list_ptr, router_list_ptr); + wccp2_out_add_hash_assignment_info(&op, service_list_ptr, router_list_ptr); } else if (Config.Wccp2.assignment_method == WCCP2_ASSIGNMENT_METHOD_MASK) { wccp2_out_add_mask_assignment_info(&op, service_list_ptr, router_list_ptr); } else { fatalf("WCCP2 unknown assignment_method!\n"); - } + } /* Finish packet */ wccp2_out_packet_finish(&op); @@ -1969,6 +1969,15 @@ cache_list_ptr = &rl->cache_list_head; value = 0; for (valuecounter = 0; valuecounter < 64; valuecounter++) { + /* Update the value according the the "correct" formula */ + /* + * XXX what this should do is calculate the maxium number of hash values available rather than + * XXX just using 64 fixed ones. + */ + for (; (value & 0x1741) != value; value++) { + assert(value <= 0x1741); + } + debug(80, 5) (" Mask Assignment: Cache: %s; value %x\n", inet_ntoa(cache_list_ptr->cache_ip), value); if ((service_flags & WCCP2_SERVICE_SRC_IP_HASH) || (service_flags & WCCP2_SERVICE_SRC_IP_ALT_HASH)) { ve.source_ip_value = htonl(value); ve.dest_ip_value = 0; @@ -1994,11 +2003,7 @@ } ve.cache_ip = cache_list_ptr->cache_ip; wccp2_out_packet_append(p, &ve, sizeof(&ve)); - - /* Update the value according the the "correct" formula */ - for (value++; (value & 0x1741) != value; value++) { - assert(value <= 0x1741); - } + value++; /* Assign the next value to the next cache */ if ((cache_list_ptr->next) && (cache_list_ptr->next->next))