wccp2.cc
Go to the documentation of this file.
185 char buckets[32]; /* Draft indicates 8x 32-bit buckets but it's just a mask so doesn't matter how we define. */
512 wccp2_service_list_ptr = (wccp2_service_list_t *) xcalloc(1, sizeof(struct wccp2_service_list_t));
589 static_assert(sizeof(pwd) - 1 == 8, "WCCP2 password has exactly 8 (padded) octets, excluding storage-terminating NUL");
619 debugs(80, DBG_IMPORTANT, "wccp2_check_security: received packet has the wrong security option");
645 static_assert(sizeof(pwd) - 1 == 8, "WCCP2 password has exactly 8 (padded) octets, excluding storage-terminating NUL");
760 memset(&wccp2_identity_info.cache_identity.hash_revision, '\0', sizeof(wccp2_identity_info.cache_identity.hash_revision));
761 memset(&wccp2_identity_info.cache_identity.bits, '\0', sizeof(wccp2_identity_info.cache_identity.bits));
762 memset(&wccp2_identity_info.cache_identity.buckets, '\0', sizeof(wccp2_identity_info.cache_identity.buckets));
764 memset(&wccp2_identity_info.cache_identity.status, '\0', sizeof(wccp2_identity_info.cache_identity.status));
777 wccp2_mask_identity_info.cache_identity_length = htons(sizeof(wccp2_mask_identity_info.cache_identity));
785 if ((service_flags & WCCP2_SERVICE_SRC_IP_HASH) || (service_flags & WCCP2_SERVICE_SRC_IP_ALT_HASH)) {
787 } else if ((service_list_ptr->info.service == WCCP2_SERVICE_STANDARD) || (service_flags & WCCP2_SERVICE_DST_IP_HASH) || (service_flags & WCCP2_SERVICE_DST_IP_ALT_HASH)) {
789 } else if ((service_flags & WCCP2_SERVICE_SRC_PORT_HASH) || (service_flags & WCCP2_SERVICE_SRC_PORT_ALT_HASH)) {
791 } else if ((service_flags & WCCP2_SERVICE_DST_PORT_HASH) || (service_flags & WCCP2_SERVICE_DST_PORT_ALT_HASH)) {
837 /* Add each router. Keep this functionality here to make sure the received_id can be updated in the packet */
884 wccp2_capability_info_header.capability_info_length = htons(3 * sizeof(wccp2_capability_element));
897 wccp2_capability_element.capability_length = htons(sizeof(wccp2_capability_element.capability_value));
912 wccp2_capability_element.capability_length = htons(sizeof(wccp2_capability_element.capability_value));
927 wccp2_capability_element.capability_length = htons(sizeof(wccp2_capability_element.capability_value));
938 memcpy(&service_list_ptr->wccp_packet, &wccp2_here_i_am_header, sizeof(wccp2_here_i_am_header));
940 service_list_ptr->wccp_packet_size = ntohs(wccp2_here_i_am_header.length) + sizeof(wccp2_here_i_am_header);
976 debugs(80, DBG_CRITICAL, "WCCPv2 Disabled. Local address " << Config.Wccp2.address << " is not an IPv4 address.");
995 debugs(80, 2, "WARNING: Path MTU discovery could not be disabled on FD " << theWccp2Connection << ": " << xstrerr(xerrno));
1002 debugs(80, DBG_IMPORTANT, "Accepting WCCPv2 messages on port " << WCCP_PORT << ", FD " << theWccp2Connection << ".");
1013 for (router_list_ptr = &service_list_ptr->router_list_head; router_list_ptr->next != nullptr; router_list_ptr = router_list_ptr->next) {
1083 for (router_list_ptr = &service_list_ptr->router_list_head; router_list_ptr != nullptr; router_list_ptr = router_list_next) {
1084 for (cache_list_ptr = &router_list_ptr->cache_list_head; cache_list_ptr; cache_list_ptr = cache_list_ptr_next) {
1134 CheckSectionLength(const void *sectionStart, const size_t sectionLength, const void *wholeStart, const size_t wholeSize, const char *error)
1141 assert(sectionStart <= wholeEnd && "we never go beyond our whole (but zero-sized fields are OK)");
1142 static_assert(sizeof(wccp2_i_see_you_t) <= PTRDIFF_MAX, "paranoid: no UB when subtracting in-whole pointers");
1161 CheckFieldDataLength(const FieldHeader *header, const size_t dataLength, const void *areaStart, const size_t areaSize, const char *error)
1178 SetField(Field *&field, const void *fieldStart, const void *areaStart, const size_t areaSize, const char *error)
1234 const auto lenOrError = comm_udp_recvfrom(sock, &wccp2_i_see_you, WCCP_RESPONSE_SIZE, 0, from_tmp);
1301 CheckFieldDataLength(router_capability_header, ntohs(router_capability_header->capability_info_length),
1315 debugs(80, DBG_IMPORTANT, "ERROR: Unknown record type in WCCPv2 Packet (" << ntohs(itemHeader->type) << ").");
1341 debugs(80, DBG_IMPORTANT, "ERROR: WCCPv2 Unknown service received from router (" << service_info->service_id << ")");
1345 if (ntohl(security_info->security_option) != ntohl(service_list_ptr->security_info->security_option)) {
1346 debugs(80, DBG_IMPORTANT, "ERROR: Invalid security option in WCCPv2 Packet (" << ntohl(security_info->security_option) << " vs " << ntohl(service_list_ptr->security_info->security_option) << ").");
1350 if (!wccp2_check_security(service_list_ptr, (char *) security_info, (char *) &wccp2_i_see_you, len)) {
1356 for (router_list_ptr = &service_list_ptr->router_list_head; router_list_ptr->next != nullptr; router_list_ptr = router_list_ptr->next) {
1364 router_list_ptr->info->router_address = router_identity_info->router_id_element.router_address;
1367 if (ntohl(router_list_ptr->info->received_id) != ntohl(router_identity_info->router_id_element.received_id)) {
1368 debugs(80, 3, "Incoming WCCP2_I_SEE_YOU Received ID old=" << ntohl(router_list_ptr->info->received_id) << " new=" << ntohl(router_identity_info->router_id_element.received_id) << ".");
1374 if ((Config.Wccp2.return_method != WCCP2_PACKET_RETURN_METHOD_GRE) || (Config.Wccp2.forwarding_method != WCCP2_FORWARDING_METHOD_GRE)) {
1375 debugs(80, DBG_IMPORTANT, "ERROR: wccp2HandleUdp: fatal error - A WCCP router does not support the forwarding method specified, only GRE supported");
1381 const auto router_capability_data_length = ntohs(router_capability_header->capability_info_length);
1401 debugs(80, DBG_IMPORTANT, "ERROR: wccp2HandleUdp: fatal error - A WCCP router has specified a different forwarding method " << ntohl(router_capability_element->capability_value) << ", expected " << Config.Wccp2.forwarding_method);
1411 debugs(80, DBG_IMPORTANT, "ERROR: wccp2HandleUdp: fatal error - A WCCP router has specified a different assignment method " << ntohl(router_capability_element->capability_value) << ", expected "<< Config.Wccp2.assignment_method);
1421 debugs(80, DBG_IMPORTANT, "ERROR: wccp2HandleUdp: fatal error - A WCCP router has specified a different return method " << ntohl(router_capability_element->capability_value) << ", expected " << Config.Wccp2.return_method);
1433 debugs(80, DBG_IMPORTANT, "ERROR: Unknown capability type in WCCPv2 Packet (" << ntohs(router_capability_element->capability_type) << ").");
1443 for (cache_list_ptr = &router_list_ptr->cache_list_head; cache_list_ptr; cache_list_ptr = cache_list_ptr_next) {
1475 CheckSectionLength(ptr, ipsSize, router_view_header, router_view_size, "invalid IP address count");
1544 debugs (80, 5, "checking cache list: (" << std::hex << cache_address.s_addr << ":" << router_list_ptr->local_ip.s_addr << ")");
1579 debugs(80, 5, "Change not detected (" << ntohl(router_view_header->change_number) << " = " << router_list_ptr->member_change << ")");
1625 for (router_list_ptr = &service_list_ptr->router_list_head; router_list_ptr->next != nullptr; router_list_ptr = router_list_ptr->next) {
1634 wccp2_identity_info_ptr = (struct wccp2_identity_info_t *) service_list_ptr->wccp2_identity_info_ptr;
1640 wccp2_mask_identity_info_ptr = (struct wccp2_mask_identity_info_t *) service_list_ptr->wccp2_identity_info_ptr;
1651 wccp2_update_md5_security(service_list_ptr->wccp_password, (char *) service_list_ptr->security_info, service_list_ptr->wccp_packet, service_list_ptr->wccp_packet_size);
1663 if (send(theWccp2Connection, &service_list_ptr->wccp_packet, service_list_ptr->wccp_packet_size, 0) < static_cast<int>(service_list_ptr->wccp_packet_size)) {
1665 debugs(80, 2, "ERROR: failed to send WCCPv2 HERE_I_AM packet to " << router << " : " << xstrerr(xerrno));
1776 memcpy(&wccp_packet[offset], service_list_ptr->service_info, sizeof(struct wccp2_service_info_t));
1823 memcpy(&wccp_packet[offset], &service_list_ptr->num_routers, sizeof(service_list_ptr->num_routers));
1827 for (router_list_ptr = &service_list_ptr->router_list_head; router_list_ptr->next != nullptr; router_list_ptr = router_list_ptr->next) {
1841 for (router_list_ptr = &service_list_ptr->router_list_head; router_list_ptr->next != nullptr; router_list_ptr = router_list_ptr->next) {
1842 unsigned long *weight = (unsigned long *)xcalloc(sizeof(*weight), ntohl(router_list_ptr->num_caches));
1852 memcpy(&wccp_packet[offset], &router_list_ptr->num_caches, sizeof(router_list_ptr->num_caches));
1858 for (cache = 0, cache_list_ptr = &router_list_ptr->cache_list_head; cache_list_ptr->next; cache_list_ptr = cache_list_ptr->next, ++cache) {
1928 if ((service_flags & WCCP2_SERVICE_SRC_IP_HASH) || (service_flags & WCCP2_SERVICE_SRC_IP_ALT_HASH)) {
1933 } else if ((service_list_ptr->info.service == WCCP2_SERVICE_STANDARD) || (service_flags & WCCP2_SERVICE_DST_IP_HASH) || (service_flags & WCCP2_SERVICE_DST_IP_ALT_HASH)) {
1938 } else if ((service_flags & WCCP2_SERVICE_SRC_PORT_HASH) || (service_flags & WCCP2_SERVICE_SRC_PORT_ALT_HASH)) {
1943 } else if ((service_flags & WCCP2_SERVICE_DST_PORT_HASH) || (service_flags & WCCP2_SERVICE_DST_PORT_ALT_HASH)) {
1969 if ((service_flags & WCCP2_SERVICE_SRC_IP_HASH) || (service_flags & WCCP2_SERVICE_SRC_IP_ALT_HASH)) {
1974 } else if ((service_list_ptr->info.service == WCCP2_SERVICE_STANDARD) || (service_flags & WCCP2_SERVICE_DST_IP_HASH) || (service_flags & WCCP2_SERVICE_DST_IP_ALT_HASH)) {
1979 } else if ((service_flags & WCCP2_SERVICE_SRC_PORT_HASH) || (service_flags & WCCP2_SERVICE_SRC_PORT_ALT_HASH)) {
1984 } else if ((service_flags & WCCP2_SERVICE_DST_PORT_HASH) || (service_flags & WCCP2_SERVICE_DST_PORT_ALT_HASH)) {
2032 wccp2_update_md5_security(service_list_ptr->wccp_password, (char *) security, wccp_packet, offset);
2049 debugs(80, 2, "ERROR: failed to send WCCPv2 HERE_I_AM packet to " << tmp_rtr << " : " << xstrerr(xerrno));
2151 debugs(80, DBG_CRITICAL, "FATAL: WCCPv2 configured " << label << " (" << v << ") is not valid.");
2175 debugs(80, DBG_IMPORTANT, "WCCPv2: Somehow reparsing the configuration without having shut down WCCP! Try reloading squid again.");
2181 debugs(80, DBG_CRITICAL, "ERROR: wccp2ParseServiceInfo: missing service info type (standard|dynamic)");
2191 debugs(80, DBG_CRITICAL, "ERROR: wccp2ParseServiceInfo: bad service info type (expected standard|dynamic, got " << t << ")");
2200 debugs(80, DBG_CRITICAL, "ERROR: invalid WCCP service id " << service_id << " (must be between 0 .. 255)");
2216 wccp2_add_service_list(service, service_id, 0, 0, 0, empty_portlist, security_type, wccp_password);
2226 debugs(80, 3, "dump_wccp2_service: id " << srv->info.service_id << ", type " << srv->info.service);
2358 debugs(80, DBG_IMPORTANT, "WCCPv2: Somehow reparsing the configuration without having shut down WCCP! Try reloading squid again.");
2368 debugs(80, DBG_CRITICAL, "ERROR: invalid WCCP service id " << service_id << " (must be between 0 .. 255)");
2377 fatalf("parse_wccp2_service_info: unknown dynamic service id %d: you need to define it using wccp2_service (and make sure you wish to configure it as a dynamic service.)\n", service_id);
2393 fatalf("parse_wccp2_service_info: id %d: unknown protocol (%s) - must be tcp or udp!\n", service_id, t);
2407 fatalf("parse_wccp2_service_info: service %d: no priority defined (valid: 0..255)!\n", service_id);
2411 fatalf("parse_wccp2_service_info: service %d: no protocol defined (valid: tcp or udp)!\n", service_id);
2433 debugs(80, 3, "dump_wccp2_service_info: id " << srv->info.service_id << " (type " << srv->info.service << ")");
2438 debugs(80, 3, "dump_wccp2_service_info: id " << srv->info.service_id << ": standard service, not dumping info");
2552 storeAppendPrintf(e, " protocol=%s", (srv->info.service_protocol == IPPROTO_TCP) ? "tcp" : "udp");
void dump_wccp2_method(StoreEntry *e, const char *label, int v)
Definition: wccp2.cc:2093
static void CheckSectionLength(const void *sectionStart, const size_t sectionLength, const void *wholeStart, const size_t wholeSize, const char *error)
Definition: wccp2.cc:1134
DefineRunnerRegistrator(Wccp2Rr)
static char wccp2_check_security(struct wccp2_service_list_t *srv, char *security, char *packet, int len)
Definition: wccp2.cc:608
void dump_wccp2_amethod(StoreEntry *e, const char *label, int v)
Definition: wccp2.cc:2141
Definition: wccp2.cc:298
Definition: wccp2.cc:193
struct wccp2_service_info_t * service_info
Definition: wccp2.cc:451
Definition: wccp2.cc:266
int comm_udp_sendto(int fd, const Ip::Address &to_addr, const void *buf, int len)
Definition: comm.cc:908
void error(char *format,...)
Definition: wccp2.cc:241
static struct wccp2_service_list_t * wccp2_service_list_head
Definition: wccp2.cc:460
static void parse_wccp2_service_ports(char *options, int portlist[])
Definition: wccp2.cc:2311
Definition: wccp2.cc:410
Definition: wccp2.cc:392
struct wccp2_router_id_element_t router_id_element
Definition: wccp2.cc:369
static struct wccp2_mask_identity_info_t wccp2_mask_identity_info
Definition: wccp2.cc:248
static struct wccp2_cache_view_header_t wccp2_cache_view_header
Definition: wccp2.cc:262
#define WCCP2_CAPABILITY_ASSIGNMENT_METHOD
Definition: wccp2.cc:307
SQUIDCEXTERN void SquidMD5Final(uint8_t digest[16], struct SquidMD5Context *context)
Definition: wccp2.cc:256
uint16_t capability_info_length
Definition: wccp2.cc:289
struct in_addr router_sendto_address
Definition: wccp2.cc:426
static struct wccp2_service_list_t * wccp2_get_service_by_id(int service, int service_id)
Definition: wccp2.cc:532
Definition: wccp2.cc:104
struct wccp2_router_list_t router_list_head
Definition: wccp2.cc:443
Definition: wccp2.cc:216
void comm_open_listener(int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note)
Definition: comm.cc:257
Definition: wccp2.cc:438
Definition: wccp2.cc:62
uint32_t mask_element_count
Definition: wccp2.cc:227
struct wccp2_cache_mask_identity_info_t cache_identity
Definition: wccp2.cc:245
Definition: wccp2.cc:178
Definition: md5.h:55
static struct wccp2_capability_element_t wccp2_capability_element
Definition: wccp2.cc:303
Definition: wccp2.cc:328
Definition: RunnersRegistry.h:37
Definition: wccp2.cc:287
static void wccp2_add_service_list(int service, int service_id, int service_priority, int service_proto, int service_flags, int ports[], int security_type, char *password)
Definition: wccp2.cc:505
Definition: wccp2.cc:205
Definition: wccp2.cc:382
Definition: wccp2.cc:342
Definition: wccp2.cc:400
std::ostream & CurrentException(std::ostream &os)
prints active (i.e., thrown but not yet handled) exception
Definition: TextException.cc:88
void dump_wccp2_service(StoreEntry *e, const char *label, void *)
Definition: wccp2.cc:2220
Definition: wccp2.cc:365
Definition: wccp2.cc:132
static struct wccp2_message_header_t wccp2_here_i_am_header
Definition: wccp2.cc:91
static int store_dirs_rebuilding
the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
Definition: Controller.h:133
struct wccp2_cache_list_t cache_list_head
Definition: wccp2.cc:430
uint16_t cache_identity_length
Definition: wccp2.cc:243
struct wccp2_cache_identity_info_t cache_identity
Definition: wccp2.cc:197
Definition: wccp2.cc:84
struct SquidConfig::@88 Wccp2
Definition: wccp2.cc:276
void dump_wccp2_service_info(StoreEntry *e, const char *label, void *)
Definition: wccp2.cc:2426
Definition: Store.h:37
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
Definition: ModDevPoll.cc:220
static void wccp2_update_service(struct wccp2_service_list_t *srv, int service, int service_id, int service_priority, int service_proto, int service_flags, int ports[])
Definition: wccp2.cc:484
static void SetField(Field *&field, const void *fieldStart, const void *areaStart, const size_t areaSize, const char *error)
Definition: wccp2.cc:1178
struct wccp2_security_md5_t * security_info
Definition: wccp2.cc:449
static char wccp2_update_md5_security(char *password, char *ptr, char *packet, int len)
Definition: wccp2.cc:555
static struct wccp2_capability_info_header_t wccp2_capability_info_header
Definition: wccp2.cc:293
static struct wccp2_cache_view_info_t wccp2_cache_view_info
Definition: wccp2.cc:271
SQUIDCEXTERN void SquidMD5Update(struct SquidMD5Context *context, const void *buf, unsigned len)
Definition: md5.c:89
Definition: wccp2.cc:1117
Definition: wccp2.cc:420
int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from)
Definition: comm.cc:126
#define WCCP2_CAPABILITY_FORWARDING_METHOD
Definition: wccp2.cc:306
uint8_t security_implementation[WCCP2_MD5_SECURITY_LEN]
Definition: wccp2.cc:124
void getSockAddr(struct sockaddr_storage &addr, const int family) const
Definition: Address.cc:944
Definition: Address.h:42
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
Definition: event.cc:107
Definition: wccp2.cc:120
Definition: wccp2.cc:354
uint16_t capability_info_type
Definition: wccp2.cc:288
static size_t CheckFieldDataLength(const FieldHeader *header, const size_t dataLength, const void *areaStart, const size_t areaSize, const char *error)
Definition: wccp2.cc:1161
static void wccp2SortCacheList(struct wccp2_cache_list_t *head)
Definition: wccp2.cc:2562
Definition: Address.h:382
Introduction
- About Squid
- Why Squid?
- Squid Developers
- How to Donate
- How to Help Out
- Getting Squid
- Squid Source Packages
- Squid Deployment Case-Studies
- Squid Software Foundation
Documentation
- Quick Setup
- Configuration:
- FAQ and Wiki
- Guide Books:
- Non-English
- More...
Support
- Security Advisories
- Bugzilla Database
- Mailing lists
- Contacting us
- Commercial services
- Project Sponsors
- Squid-based products