------------------------------------------------------------ revno: 13121 revision-id: squid3@treenet.co.nz-20140418184412-nvv2jvb1xqkcylzd parent: squid3@treenet.co.nz-20140418184335-jh773qjx245u1b8a fixes bug(s): http://bugs.squid-cache.org/show_bug.cgi?id=3982 committer: Amos Jeffries branch nick: 3.4 timestamp: Fri 2014-04-18 12:44:12 -0600 message: Bug 3982: EUI logging and helpers show blank MAC address Also, * improved debugging of EUI processing. * fixed code correctness in EUI class definitions ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140418184412-nvv2jvb1xqkcylzd # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.4 # testament_sha1: e39fac3b7a610311ba9de44a2dd9fd64f93ff1ee # timestamp: 2014-04-18 18:45:37 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.4 # base_revision_id: squid3@treenet.co.nz-20140418184335-\ # jh773qjx245u1b8a # # Begin patch === modified file 'src/comm/TcpAcceptor.cc' --- src/comm/TcpAcceptor.cc 2013-06-18 23:26:17 +0000 +++ src/comm/TcpAcceptor.cc 2014-04-18 18:44:12 +0000 @@ -388,10 +388,10 @@ #if USE_SQUID_EUI if (Eui::TheConfig.euiLookup) { - if (conn->remote.isIPv4()) { - conn->remoteEui48.lookup(conn->remote); - } else if (conn->remote.isIPv6()) { - conn->remoteEui64.lookup(conn->remote); + if (details->remote.isIPv4()) { + details->remoteEui48.lookup(details->remote); + } else if (details->remote.isIPv6()) { + details->remoteEui64.lookup(details->remote); } } #endif === modified file 'src/eui/Eui48.cc' --- src/eui/Eui48.cc 2013-07-06 15:11:43 +0000 +++ src/eui/Eui48.cc 2014-04-18 18:44:12 +0000 @@ -135,18 +135,23 @@ eui[3] = (u_char) a4; eui[4] = (u_char) a5; eui[5] = (u_char) a6; + + debugs(28, 4, "id=" << (void*)this << " decoded " << asc); return true; } bool Eui::Eui48::encode(char *buf, const int len) { - if (len < SZ_EUI48_BUF) return false; + if (len < SZ_EUI48_BUF) + return false; snprintf(buf, len, "%02x:%02x:%02x:%02x:%02x:%02x", eui[0] & 0xff, eui[1] & 0xff, eui[2] & 0xff, eui[3] & 0xff, eui[4] & 0xff, eui[5] & 0xff); + + debugs(28, 4, "id=" << (void*)this << " encoded " << buf); return true; } @@ -154,9 +159,6 @@ bool Eui::Eui48::lookup(const Ip::Address &c) { -#if !_SQUID_WINDOWS_ -#endif /* !_SQUID_WINDOWS_ */ - Ip::Address ipAddr = c; ipAddr.port(0); @@ -198,6 +200,7 @@ ipAddr.getSockAddr(*sa); /* Query ARP table */ + debugs(28, 4, "id=" << (void*)this << " query ARP table"); if (ioctl(tmpSocket, SIOCGARP, &arpReq) != -1) { /* Skip non-ethernet interfaces */ close(tmpSocket); @@ -207,7 +210,7 @@ return false; } - debugs(28, 4, "Got address "<< std::setfill('0') << std::hex << + debugs(28, 4, "id=" << (void*)this << " got address "<< std::setfill('0') << std::hex << std::setw(2) << (arpReq.arp_ha.sa_data[0] & 0xff) << ":" << std::setw(2) << (arpReq.arp_ha.sa_data[1] & 0xff) << ":" << std::setw(2) << (arpReq.arp_ha.sa_data[2] & 0xff) << ":" << @@ -240,20 +243,22 @@ /* Attempt ARP lookup on each interface */ offset = 0; - + debugs(28, 4, "id=" << (void*)this << " query ARP on each interface (" << ifc.ifc_len << " found)"); while (offset < ifc.ifc_len) { ifr = (struct ifreq *) (ifbuffer + offset); offset += sizeof(*ifr); + + debugs(28, 4, "id=" << (void*)this << " found interface " << ifr->ifr_name); + /* Skip loopback and aliased interfaces */ - - if (0 == strncmp(ifr->ifr_name, "lo", 2)) - continue; - - if (NULL != strchr(ifr->ifr_name, ':')) - continue; - - debugs(28, 4, "Looking up ARP address for " << ipAddr << " on " << ifr->ifr_name); + if (!strncmp(ifr->ifr_name, "lo", 2)) + continue; + + if (strchr(ifr->ifr_name, ':')) + continue; + + debugs(28, 4, "id=" << (void*)this << " looking up ARP address for " << ipAddr << " on " << ifr->ifr_name); /* Set up structures for ARP lookup */ @@ -284,10 +289,12 @@ } /* Skip non-ethernet interfaces */ - if (arpReq.arp_ha.sa_family != ARPHRD_ETHER) + if (arpReq.arp_ha.sa_family != ARPHRD_ETHER) { + debugs(28, 4, "id=" << (void*)this << "... not an Ethernet interface"); continue; + } - debugs(28, 4, "Got address "<< std::setfill('0') << std::hex << + debugs(28, 4, "id=" << (void*)this << " got address "<< std::setfill('0') << std::hex << std::setw(2) << (arpReq.arp_ha.sa_data[0] & 0xff) << ":" << std::setw(2) << (arpReq.arp_ha.sa_data[1] & 0xff) << ":" << std::setw(2) << (arpReq.arp_ha.sa_data[2] & 0xff) << ":" << @@ -528,7 +535,7 @@ /* * Address was not found on any interface */ - debugs(28, 3, HERE << ipAddr << " NOT found"); + debugs(28, 3, "id=" << (void*)this << ' ' << ipAddr << " NOT found"); clear(); return false; === modified file 'src/eui/Eui48.h' --- src/eui/Eui48.h 2010-11-27 14:02:42 +0000 +++ src/eui/Eui48.h 2014-04-18 18:44:12 +0000 @@ -27,9 +27,9 @@ { public: - Eui48() { clear(); }; - Eui48(const Eui48 &t) { memcpy(this, &t, sizeof(Eui48)); }; - ~Eui48() {}; + Eui48() { clear(); } + Eui48(const Eui48 &t) { memcpy(this, &t, sizeof(Eui48)); } + ~Eui48() {} const unsigned char *get(void); @@ -38,9 +38,9 @@ if (len < SZ_EUI48_BUF) clear(); memcpy(eui, src, len); return true; - }; + } - void clear() { memset(eui, 0, SZ_EUI48_BUF); }; + void clear() { memset(eui, 0, SZ_EUI48_BUF); } /** * Decode an ascii representation of an EUI-48 ethernet address. === modified file 'src/eui/Eui64.cc' --- src/eui/Eui64.cc 2013-06-03 14:05:16 +0000 +++ src/eui/Eui64.cc 2014-04-18 18:44:12 +0000 @@ -18,8 +18,12 @@ bool Eui::Eui64::decode(const char *asc) { - if (eui64_aton(asc, (struct eui64 *)eui) != 0) return false; + if (eui64_aton(asc, (struct eui64 *)eui) != 0) { + debugs(28, 4, "id=" << (void*)this << " decode fail on " << asc); + return false; + } + debugs(28, 4, "id=" << (void*)this << " ATON decoded " << asc); return true; } @@ -31,6 +35,7 @@ snprintf(buf, len, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x", eui[0], eui[1], eui[2], eui[3], eui[4], eui[5], eui[6], eui[7]); + debugs(28, 4, "id=" << (void*)this << " encoded " << buf); return true; } @@ -39,7 +44,8 @@ Eui::Eui64::lookup(const Ip::Address &c) { /* try to short-circuit slow OS lookups by using SLAAC data */ - if (lookupSlaac(c)) return true; + if (lookupSlaac(c)) + return true; // find EUI-64 some other way. NDP table lookup? return lookupNdp(c); @@ -49,15 +55,18 @@ Eui::Eui64::lookupSlaac(const Ip::Address &c) { /* RFC 4291 Link-Local unicast addresses which contain SLAAC - usually trustable. */ - if (c.isSiteLocal6() && c.isSiteLocalAuto() ) { + if (c.isSiteLocal6() && c.isSiteLocalAuto()) { // strip the final 64 bits of the address... struct in6_addr tmp; c.getInAddr(tmp); memcpy(eui, &(tmp.s6_addr[8]), SZ_EUI64_BUF); - + debugs(28, 4, "id=" << (void*)this << " SLAAC decoded " << c); return true; } + + debugs(28, 4, "id=" << (void*)this << " SLAAC fail on " << c << " SL-6=" + << (c.isSiteLocal6()?'T':'F') << " AAC-6=" << (c.isSiteLocalAuto()?'T':'F')); return false; } @@ -73,7 +82,7 @@ /* * Address was not found on any interface */ - debugs(28, 3, HERE << c << " NOT found"); + debugs(28, 3, "id=" << (void*)this << ' ' << c << " NOT found"); #endif /* 0 */ clear(); === modified file 'src/eui/Eui64.h' --- src/eui/Eui64.h 2010-11-27 14:02:42 +0000 +++ src/eui/Eui64.h 2014-04-18 18:44:12 +0000 @@ -34,9 +34,9 @@ { public: - Eui64() { clear(); }; - Eui64(const Eui64 &t) { memcpy(this, &t, sizeof(Eui64)); }; - ~Eui64() {}; + Eui64() { clear(); } + Eui64(const Eui64 &t) { memcpy(this, &t, sizeof(Eui64)); } + ~Eui64() {} const unsigned char *get(void); @@ -45,9 +45,9 @@ if (len < SZ_EUI64_BUF) clear(); memcpy(eui, src, len); return true; - }; + } - void clear() { memset(eui, 0, SZ_EUI64_BUF); }; + void clear() { memset(eui, 0, SZ_EUI64_BUF); } /** * Decode an ascii representation of an EUI-64 address.