From 382cccd87dd1565ec09b889cb8934592a3d60f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20C=C5=82api=C5=84ski?= Date: Wed, 13 Dec 2017 17:58:20 +0100 Subject: [PATCH] General changes for Windows Mixed changes related to net,vnsw/agent/{cfg,controller,diag,filter,pkt}: 1. boost::array to IpYAddress::bytes_type where applicable. IpYAddress::bytes_type is std::array if c++11 and boost::array otherwise and on Windows we compile with c++11. 2. addr.to_bytes().c_array() to addr.to_bytes().data() Difference between boost::array and std::array 3. variable length arrays to dynamic allocation with smart pointers 4. s_addr to s_address, DELETE to DEL, EVENT_MAX to EVENT_MAXIMUM s_addr, DELETE, EVENT_MAX are reserved on Windows 5. bind to ::bind To avoid confusion with std::bind 6. and more various bugs Initial changes: https://github.com/sagarkchitnis/windows/commits/master/controller/src Further work and cleanup: https://github.com/codilime/contrail-controller/commits/windows3.1/src Change-Id: I7b963703d6d0aefb6591bc40ab6048351bb30593 Partial-Bug: #1737177 --- src/SConscript | 11 ++++++-- src/net/address.cc | 2 +- src/net/address_util.cc | 4 +-- src/net/mac_address.cc | 2 +- src/vnsw/agent/cfg/cfg_mirror.h | 2 +- src/vnsw/agent/controller/controller_peer.cc | 28 +++++++++----------- src/vnsw/agent/diag/diag.cc | 4 +-- src/vnsw/agent/diag/diag.h | 2 +- src/vnsw/agent/diag/diag_pkt_handler.cc | 12 ++++----- src/vnsw/agent/diag/traceroute.cc | 1 + src/vnsw/agent/filter/acl.cc | 9 ------- src/vnsw/agent/filter/acl.h | 1 + src/vnsw/agent/filter/acl_entry.cc | 16 +++++------ src/vnsw/agent/pkt/flow_entry.cc | 13 ++++++--- src/vnsw/agent/pkt/flow_entry.h | 2 +- src/vnsw/agent/pkt/flow_mgmt.h | 4 +-- src/vnsw/agent/pkt/flow_mgmt_dbclient.cc | 1 + src/vnsw/agent/pkt/flow_mgmt_dbclient.h | 2 +- src/vnsw/agent/pkt/flow_table.cc | 2 +- src/vnsw/agent/pkt/flow_table.h | 4 ++- src/vnsw/agent/pkt/flow_trace_filter.cc | 14 +++++----- src/vnsw/agent/pkt/pkt_handler.cc | 4 +-- src/vnsw/agent/pkt/pkt_sandesh_flow.cc | 8 +++--- src/vnsw/agent/pkt/proto_handler.cc | 2 +- 24 files changed, 76 insertions(+), 74 deletions(-) diff --git a/src/SConscript b/src/SConscript index 560b279f963..3f7e95aaf03 100644 --- a/src/SConscript +++ b/src/SConscript @@ -44,7 +44,11 @@ include = ['#/controller/src', '#/build/include', '#src/contrail-common', '#cont libpath = ['#/build/lib'] -libs = ['boost_system', 'log4cplus', 'pthread'] +libs = ['boost_system', 'log4cplus'] +if sys.platform.startswith('win'): + libs.append('windowsstubs') +else: + libs.append('pthread') common = DefaultEnvironment().Clone() @@ -55,7 +59,10 @@ else: common.Append(LIBPATH = libpath) common.Prepend(LIBS = libs) -common.Append(CCFLAGS = '-Wall -Werror -Wsign-compare') + +if not sys.platform.startswith('win'): + common.Append(CCFLAGS = '-Wall -Werror -Wsign-compare') + if not sys.platform.startswith('darwin'): if platform.system().startswith('Linux'): if not platform.linux_distribution()[0].startswith('XenServer'): diff --git a/src/net/address.cc b/src/net/address.cc index 91864d5e1cc..5e25374dff4 100644 --- a/src/net/address.cc +++ b/src/net/address.cc @@ -299,7 +299,7 @@ Ip6Address Address::GetIp6SubnetAddress(const Ip6Address &prefix, uint16_t plen) ip6[i] = htons(in_ip6[i]); } memcpy(bytes, ip6, sizeof(ip6)); - boost::array to_bytes; + Ip6Address::bytes_type to_bytes; for (int i = 0; i < 16; ++i) { to_bytes.at(i) = bytes[i]; } diff --git a/src/net/address_util.cc b/src/net/address_util.cc index 7a4409617a4..6e9c036c439 100644 --- a/src/net/address_util.cc +++ b/src/net/address_util.cc @@ -91,7 +91,7 @@ IpAddress PrefixToIp6Netmask(uint32_t plen) { return IpAddress(all_fs); } - boost::array bytes; + Ip6Address::bytes_type bytes; int index = (int) (plen / 8); int remain_mask = plen % 8; @@ -269,7 +269,7 @@ void Ip6AddressToU64Array(const Ip6Address &addr, uint64_t *arr, int size) { if (size != 2) return; - memcpy(b, addr.to_bytes().c_array(), sizeof(b)); + memcpy(b, addr.to_bytes().data(), sizeof(b)); for (i = 0, j = 0, k = 0; i < 4; i++, j = j+4) { ip = 0; diff --git a/src/net/mac_address.cc b/src/net/mac_address.cc index dd03342f32e..042f2f5d0e5 100644 --- a/src/net/mac_address.cc +++ b/src/net/mac_address.cc @@ -42,7 +42,7 @@ MacAddress::MacAddress(unsigned int a, unsigned int b, unsigned int c, MacAddress::MacAddress(const std::string &s, boost::system::error_code *errorp) { - this->addr_ = FromString(s, errorp); + *this = FromString(s, errorp); } string MacAddress::ToString() const { diff --git a/src/vnsw/agent/cfg/cfg_mirror.h b/src/vnsw/agent/cfg/cfg_mirror.h index de02c44a5ac..3c54c51c3c6 100644 --- a/src/vnsw/agent/cfg/cfg_mirror.h +++ b/src/vnsw/agent/cfg/cfg_mirror.h @@ -69,7 +69,7 @@ struct MirrorCfgEntry { }; struct MirrorCfgKeyCmp { - bool operator()(const MirrorCfgKey &lhs, const MirrorCfgKey &rhs) { + bool operator()(const MirrorCfgKey &lhs, const MirrorCfgKey &rhs) const { return lhs.handle < rhs.handle; } }; diff --git a/src/vnsw/agent/controller/controller_peer.cc b/src/vnsw/agent/controller/controller_peer.cc index 08f511839d8..381f0800a81 100644 --- a/src/vnsw/agent/controller/controller_peer.cc +++ b/src/vnsw/agent/controller/controller_peer.cc @@ -181,8 +181,8 @@ void AgentXmppChannel::ReceiveEvpnUpdate(XmlPugi *pugi) { CONTROLLER_INFO_TRACE(Trace, GetBgpPeerName(), vrf_name, "EVPN Delete Node id:" + id); - char buff[id.length() + 1]; - strcpy(buff, id.c_str()); + boost::scoped_array buff(new char[id.length() + 1]); + strcpy(buff.get(), id.c_str()); // retract does not have nlri. Need to decode key fields from // retract id. Format of retract-id expected are: @@ -200,14 +200,14 @@ void AgentXmppChannel::ReceiveEvpnUpdate(XmlPugi *pugi) { // If id has "-", the value before "-" is treated as // ethernet-tag - char *token = strtok_r(buff + offset, "-", &saveptr); + char *token = strtok_r(buff.get() + offset, "-", &saveptr); if ((strlen(saveptr) != 0) && token) { ethernet_tag = atoi(token); offset += strlen(token) + 1; } // Get MAC address. Its delimited by "," - token = strtok_r(buff + offset, ",", &saveptr); + token = strtok_r(buff.get() + offset, ",", &saveptr); if ((strlen(saveptr) == 0) || (token == NULL)) { CONTROLLER_TRACE(Trace, GetBgpPeerName(), vrf_name, "Error parsing MAC from retract-id: " +id); @@ -224,7 +224,7 @@ void AgentXmppChannel::ReceiveEvpnUpdate(XmlPugi *pugi) { offset += strlen(token) + 1; IpAddress ip_addr; - if (ParseAddress(buff + offset, &ip_addr) < 0) { + if (ParseAddress(buff.get() + offset, &ip_addr) < 0) { CONTROLLER_TRACE(Trace, GetBgpPeerName(), vrf_name, "Error decoding IP address from " "retract-id: "+id); @@ -341,16 +341,14 @@ void AgentXmppChannel::ReceiveMulticastUpdate(XmlPugi *pugi) { } boost::system::error_code ec; - IpAddress g_addr = - IpAddress::from_string(group, ec); + IpAddress g_address = IpAddress::from_string(group, ec); if (ec.value() != 0) { CONTROLLER_TRACE(Trace, GetBgpPeerName(), vrf_name, "Error parsing multicast group address"); return; } - IpAddress s_addr = - IpAddress::from_string(source, ec); + IpAddress s_address = IpAddress::from_string(source, ec); if (ec.value() != 0) { CONTROLLER_TRACE(Trace, GetBgpPeerName(), vrf_name, "Error parsing multicast source address"); @@ -360,8 +358,8 @@ void AgentXmppChannel::ReceiveMulticastUpdate(XmlPugi *pugi) { //Retract with invalid identifier agent_->oper_db()->multicast()-> ModifyFabricMembers(agent_->multicast_tree_builder_peer(), - vrf, g_addr.to_v4(), - s_addr.to_v4(), 0, olist, + vrf, g_address.to_v4(), + s_address.to_v4(), 0, olist, ControllerPeerPath::kInvalidPeerIdentifier); } } @@ -400,16 +398,14 @@ void AgentXmppChannel::ReceiveMulticastUpdate(XmlPugi *pugi) { item = &*items_iter; - IpAddress g_addr = - IpAddress::from_string(item->entry.nlri.group, ec); + IpAddress g_address = IpAddress::from_string(item->entry.nlri.group, ec); if (ec.value() != 0) { CONTROLLER_TRACE(Trace, GetBgpPeerName(), vrf_name, "Error parsing multicast group address"); return; } - IpAddress s_addr = - IpAddress::from_string(item->entry.nlri.source, ec); + IpAddress s_address = IpAddress::from_string(item->entry.nlri.source, ec); if (ec.value() != 0) { CONTROLLER_TRACE(Trace, GetBgpPeerName(), vrf_name, "Error parsing multicast source address"); @@ -439,7 +435,7 @@ void AgentXmppChannel::ReceiveMulticastUpdate(XmlPugi *pugi) { agent_->oper_db()->multicast()->ModifyFabricMembers( agent_->multicast_tree_builder_peer(), - vrf, g_addr.to_v4(), s_addr.to_v4(), + vrf, g_address.to_v4(), s_address.to_v4(), item->entry.nlri.source_label, olist, agent_->controller()->multicast_sequence_number()); } diff --git a/src/vnsw/agent/diag/diag.cc b/src/vnsw/agent/diag/diag.cc index 28f2f824ecc..e162a1ea693 100644 --- a/src/vnsw/agent/diag/diag.cc +++ b/src/vnsw/agent/diag/diag.cc @@ -67,7 +67,7 @@ bool DiagEntry::TimerExpiry( uint32_t seq_no) { DiagEntryOp *op; RequestTimedOut(seq_no); if (IsDone()) { - op = new DiagEntryOp(DiagEntryOp::DELETE, this); + op = new DiagEntryOp(DiagEntryOp::DEL, this); diag_table_->Enqueue(op); return false; } @@ -91,7 +91,7 @@ bool DiagTable::Process(DiagEntryOp *op) { Add(op->de_); break; - case DiagEntryOp::DELETE: + case DiagEntryOp::DEL: if (op->de_->TimerCancel() == true) { op->de_->SendSummary(); delete op->de_; diff --git a/src/vnsw/agent/diag/diag.h b/src/vnsw/agent/diag/diag.h index 0b5aef01969..bbcbe6384ae 100644 --- a/src/vnsw/agent/diag/diag.h +++ b/src/vnsw/agent/diag/diag.h @@ -85,7 +85,7 @@ struct AgentDiagPktData { struct DiagEntryOp { enum Op { ADD = 1, - DELETE, + DEL, RETRY, FORCE_DELETE }; diff --git a/src/vnsw/agent/diag/diag_pkt_handler.cc b/src/vnsw/agent/diag/diag_pkt_handler.cc index 7ed45e504c7..1a715134ef1 100644 --- a/src/vnsw/agent/diag/diag_pkt_handler.cc +++ b/src/vnsw/agent/diag/diag_pkt_handler.cc @@ -130,10 +130,10 @@ void DiagPktHandler::SendTimeExceededPacket() { uint16_t icmp_len = pkt_info_->ip->ip_hl * 4 + 128; if (ntohs(pkt_info_->ip->ip_len) < icmp_len) icmp_len = ntohs(pkt_info_->ip->ip_len); - uint8_t icmp_payload[icmp_len]; - memcpy(icmp_payload, pkt_info_->ip, icmp_len); + boost::scoped_array icmp_payload(new uint8_t[icmp_len]); + memcpy(icmp_payload.get(), pkt_info_->ip, icmp_len); DiagEntry::DiagKey key = -1; - if (!ParseIcmpData(icmp_payload, icmp_len, (uint16_t *)&key, true)) + if (!ParseIcmpData(icmp_payload.get(), icmp_len, (uint16_t *)&key, true)) return; char *ptr = (char *)pkt_info_->pkt; @@ -173,7 +173,7 @@ void DiagPktHandler::SendTimeExceededPacket() { memset((uint8_t *)hdr, 0, 8); hdr->icmp_type = ICMP_TIME_EXCEEDED; hdr->icmp_code = ICMP_EXC_TTL; - memcpy(ptr + len + 8, icmp_payload, icmp_len); + memcpy(ptr + len + 8, icmp_payload.get(), icmp_len); IcmpChecksum((char *)hdr, 8 + icmp_len); len += 8 + icmp_len; @@ -271,7 +271,7 @@ bool DiagPktHandler::HandleTraceRouteResponse() { DiagEntryOp *op; if (IsDone()) { - op = new DiagEntryOp(DiagEntryOp::DELETE, entry); + op = new DiagEntryOp(DiagEntryOp::DEL, entry); } else { op = new DiagEntryOp(DiagEntryOp::RETRY, entry); } @@ -427,7 +427,7 @@ bool DiagPktHandler::Run() { if (entry->GetSeqNo() == entry->GetMaxAttempts()) { DiagEntryOp *op; - op = new DiagEntryOp(DiagEntryOp::DELETE, entry); + op = new DiagEntryOp(DiagEntryOp::DEL, entry); entry->diag_table()->Enqueue(op); } else { entry->Retry(); diff --git a/src/vnsw/agent/diag/traceroute.cc b/src/vnsw/agent/diag/traceroute.cc index 9899200a85d..394983eb080 100644 --- a/src/vnsw/agent/diag/traceroute.cc +++ b/src/vnsw/agent/diag/traceroute.cc @@ -4,6 +4,7 @@ #include #include +#include #include #include "vr_defs.h" #include "cmn/agent_cmn.h" diff --git a/src/vnsw/agent/filter/acl.cc b/src/vnsw/agent/filter/acl.cc index c95aa139fb2..cee83df98f9 100644 --- a/src/vnsw/agent/filter/acl.cc +++ b/src/vnsw/agent/filter/acl.cc @@ -396,15 +396,6 @@ static void AclObjectTrace(AgentLogEvent::type event, AclSpec &acl_spec) } else if (event == AgentLogEvent::DELETE) { ACL_TRACE(AclTrace, "Delete", UuidToString(acl_spec.acl_id), acl); } - switch (event) { - case AgentLogEvent::ADD: - case AgentLogEvent::CHANGE: - break; - case AgentLogEvent::DELETE: - break; - default: - break; - } } bool AclTable::IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u) { diff --git a/src/vnsw/agent/filter/acl.h b/src/vnsw/agent/filter/acl.h index 3ec0ae2fde9..46d5657c589 100644 --- a/src/vnsw/agent/filter/acl.h +++ b/src/vnsw/agent/filter/acl.h @@ -15,6 +15,7 @@ #include #include #include +#include struct FlowKey; diff --git a/src/vnsw/agent/filter/acl_entry.cc b/src/vnsw/agent/filter/acl_entry.cc index cfc11dd0004..28cd33fef02 100644 --- a/src/vnsw/agent/filter/acl_entry.cc +++ b/src/vnsw/agent/filter/acl_entry.cc @@ -30,10 +30,10 @@ AclEntry::ActionList AclEntry::kEmptyActionList; AclEntry::~AclEntry() { // Clean up Matches std::vector::iterator it; - for (it = matches_.begin(); it != matches_.end();) { + for (it = matches_.begin(); it != matches_.end(); it++) { delete(*it); - matches_.erase(it); } + matches_.clear(); // Clean up Actions ActionList::iterator ial; @@ -448,12 +448,12 @@ static bool SubnetMatch(const std::vector &list, const Ip6Address &ip6 = ip.to_v6(); const Ip6Address &data6 = data.to_v6(); const Ip6Address &mask6 = mask.to_v6(); - boost::array ip6_bytes = ip6.to_bytes(); - boost::array data6_bytes = data6.to_bytes(); - boost::array mask6_bytes = mask6.to_bytes(); - const uint32_t *ip6_words = (uint32_t *)ip6_bytes.c_array(); - const uint32_t *data6_words = (uint32_t *)data6_bytes.c_array(); - const uint32_t *mask6_words = (uint32_t *)mask6_bytes.c_array(); + Ip6Address::bytes_type ip6_bytes = ip6.to_bytes(); + Ip6Address::bytes_type data6_bytes = data6.to_bytes(); + Ip6Address::bytes_type mask6_bytes = mask6.to_bytes(); + const uint32_t *ip6_words = (const uint32_t *)ip6_bytes.data(); + const uint32_t *data6_words = (const uint32_t *)data6_bytes.data(); + const uint32_t *mask6_words = (const uint32_t *)mask6_bytes.data(); bool matched = true; for (int i = 0; i < 4; i++) { if ((data6_words[i] & mask6_words[i]) != ip6_words[i]) { diff --git a/src/vnsw/agent/pkt/flow_entry.cc b/src/vnsw/agent/pkt/flow_entry.cc index fa26a1ce3d2..67f6b663818 100644 --- a/src/vnsw/agent/pkt/flow_entry.cc +++ b/src/vnsw/agent/pkt/flow_entry.cc @@ -177,7 +177,12 @@ void VmFlowRef::FreeFd() { FlowProto *proto = flow_->flow_table()->agent()->pkt()->get_flow_proto(); proto->update_linklocal_flow_count(-1); flow_->flow_table()->DelLinkLocalFlowInfo(fd_); +#ifdef _WIN32 + closesocket(fd_); +#else close(fd_); +#endif + fd_ = kInvalidFd; port_ = 0; } @@ -226,12 +231,12 @@ bool VmFlowRef::AllocateFd(Agent *agent, uint8_t l3_proto) { // allow the socket to be reused upon close int optval = 1; - setsockopt(fd_, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); + setsockopt(fd_, SOL_SOCKET, SO_REUSEADDR, (const char*)&optval, sizeof(optval)); struct sockaddr_in address; memset(&address, 0, sizeof(address)); address.sin_family = AF_INET; - if (bind(fd_, (struct sockaddr*) &address, sizeof(address)) < 0) { + if (::bind(fd_, (struct sockaddr*) &address, sizeof(address)) < 0) { FreeFd(); return false; } @@ -398,7 +403,7 @@ void SessionPolicy::ResetPolicy() { ///////////////////////////////////////////////////////////////////////////// // FlowEventLog constructor/destructor ///////////////////////////////////////////////////////////////////////////// -FlowEventLog::FlowEventLog() : time_(0), event_(EVENT_MAX), +FlowEventLog::FlowEventLog() : time_(0), event_(EVENT_MAXIMUM), flow_handle_(FlowEntry::kInvalidFlowHandle), flow_gen_id_(0), ksync_entry_(NULL), hash_id_(FlowEntry::kInvalidFlowHandle), gen_id_(0), vrouter_flow_handle_(FlowEntry::kInvalidFlowHandle), vrouter_gen_id_(0) { @@ -2694,7 +2699,7 @@ bool FlowPendingAction::CanRevaluate() { void SetActionStr(const FlowAction &action_info, std::vector &action_str_l) { std::bitset<32> bs(action_info.action); - for (unsigned int i = 0; i <= bs.size(); i++) { + for (unsigned int i = 0; i < bs.size(); i++) { if (bs[i]) { ActionStr astr; astr.action = diff --git a/src/vnsw/agent/pkt/flow_entry.h b/src/vnsw/agent/pkt/flow_entry.h index 88adcfc514b..db4c04675b5 100644 --- a/src/vnsw/agent/pkt/flow_entry.h +++ b/src/vnsw/agent/pkt/flow_entry.h @@ -359,7 +359,7 @@ struct FlowEventLog { FLOW_EVICT, FLOW_HANDLE_ASSIGN, FLOW_MSG_SKIP_EVICTED, - EVENT_MAX + EVENT_MAXIMUM }; FlowEventLog(); diff --git a/src/vnsw/agent/pkt/flow_mgmt.h b/src/vnsw/agent/pkt/flow_mgmt.h index 0c936a00126..aaeaf626fe7 100644 --- a/src/vnsw/agent/pkt/flow_mgmt.h +++ b/src/vnsw/agent/pkt/flow_mgmt.h @@ -7,6 +7,7 @@ #include #include "pkt/flow_table.h" #include "pkt/flow_mgmt_request.h" +#include "pkt/flow_mgmt_dbclient.h" #include "pkt/flow_event.h" //////////////////////////////////////////////////////////////////////////// @@ -194,7 +195,6 @@ // Forward declaration class FlowMgmtManager; class VrfFlowMgmtTree; -class FlowMgmtDbClient; class HealthCheckInstanceBase; //////////////////////////////////////////////////////////////////////////// @@ -314,7 +314,7 @@ class FlowMgmtKey { }; struct FlowMgmtKeyCmp { - bool operator()(const FlowMgmtKey *l, const FlowMgmtKey *r) { + bool operator()(const FlowMgmtKey *l, const FlowMgmtKey *r) const { return l->IsLess(r); } }; diff --git a/src/vnsw/agent/pkt/flow_mgmt_dbclient.cc b/src/vnsw/agent/pkt/flow_mgmt_dbclient.cc index 71d6e6ad5a2..2306e43a41b 100644 --- a/src/vnsw/agent/pkt/flow_mgmt_dbclient.cc +++ b/src/vnsw/agent/pkt/flow_mgmt_dbclient.cc @@ -1,4 +1,5 @@ #include "pkt/flow_mgmt_dbclient.h" +#include "pkt/flow_mgmt.h" #include "oper/ecmp_load_balance.h" #include "oper/ecmp.h" diff --git a/src/vnsw/agent/pkt/flow_mgmt_dbclient.h b/src/vnsw/agent/pkt/flow_mgmt_dbclient.h index 225cf0c7278..b5c68464326 100644 --- a/src/vnsw/agent/pkt/flow_mgmt_dbclient.h +++ b/src/vnsw/agent/pkt/flow_mgmt_dbclient.h @@ -4,7 +4,7 @@ #ifndef __AGENT_FLOW_MGMT_DBCLIENT_H__ #define __AGENT_FLOW_MGMT_DBCLIENT_H__ -#include "pkt/flow_mgmt.h" +#include "pkt/flow_event.h" class EcmpLoadBalance; //////////////////////////////////////////////////////////////////////////// diff --git a/src/vnsw/agent/pkt/flow_table.cc b/src/vnsw/agent/pkt/flow_table.cc index e4e8bf3eb6d..8b258d36a2c 100644 --- a/src/vnsw/agent/pkt/flow_table.cc +++ b/src/vnsw/agent/pkt/flow_table.cc @@ -845,7 +845,7 @@ bool FlowTable::ProcessFlowEvent(const FlowEvent *req, FlowEntry *flow, void FlowTable::GetFlowSandeshActionParams(const FlowAction &action_info, std::string &action_str) { std::bitset<32> bs(action_info.action); - for (unsigned int i = 0; i <= bs.size(); i++) { + for (unsigned int i = 0; i < bs.size(); i++) { if (bs[i]) { if (!action_str.empty()) { action_str += "|"; diff --git a/src/vnsw/agent/pkt/flow_table.h b/src/vnsw/agent/pkt/flow_table.h index 9c036f9a0d8..8679170e87b 100644 --- a/src/vnsw/agent/pkt/flow_table.h +++ b/src/vnsw/agent/pkt/flow_table.h @@ -14,9 +14,11 @@ #endif #endif #include -#if defined(__GNUC__) && __GNUC_PREREQ(4, 6) +#if defined(__GNUC__) +#if __GNUC_PREREQ(4, 6) #pragma GCC diagnostic pop #endif +#endif #include #include diff --git a/src/vnsw/agent/pkt/flow_trace_filter.cc b/src/vnsw/agent/pkt/flow_trace_filter.cc index 4fc4394b1b2..67f7eb1daa3 100644 --- a/src/vnsw/agent/pkt/flow_trace_filter.cc +++ b/src/vnsw/agent/pkt/flow_trace_filter.cc @@ -58,8 +58,8 @@ void FlowTraceFilter::SetFilter(bool enable, Address::Family family, src_addr_ = Ip4Address(addr); } else { src_mask_ = PrefixToIp6Netmask(src_plen); - boost::array addr_bytes = src_addr_.to_v6().to_bytes(); - boost::array mask_bytes = src_mask_.to_v6().to_bytes(); + Ip6Address::bytes_type addr_bytes = src_addr_.to_v6().to_bytes(); + Ip6Address::bytes_type mask_bytes = src_mask_.to_v6().to_bytes(); for (int i = 0; i < 16; i++) { addr_bytes[i] = addr_bytes[i] & mask_bytes[i]; } @@ -74,8 +74,8 @@ void FlowTraceFilter::SetFilter(bool enable, Address::Family family, dst_addr_ = Ip4Address(addr); } else { dst_mask_ = PrefixToIp6Netmask(dst_plen); - boost::array addr_bytes = dst_addr_.to_v6().to_bytes(); - boost::array mask_bytes = dst_mask_.to_v6().to_bytes(); + Ip6Address::bytes_type addr_bytes = dst_addr_.to_v6().to_bytes(); + Ip6Address::bytes_type mask_bytes = dst_mask_.to_v6().to_bytes(); for (int i = 0; i < 16; i++) { addr_bytes[i] = addr_bytes[i] & mask_bytes[i]; } @@ -97,9 +97,9 @@ static bool Ip4Match(const Ip4Address &ip1, const Ip4Address &ip2, static bool Ip6Match(const Ip6Address &ip1, const Ip6Address &ip2, const Ip6Address &mask) { - boost::array ip1_bytes = ip1.to_bytes(); - boost::array ip2_bytes = ip2.to_bytes(); - boost::array mask_bytes = mask.to_bytes(); + Ip6Address::bytes_type ip1_bytes = ip1.to_bytes(); + Ip6Address::bytes_type ip2_bytes = ip2.to_bytes(); + Ip6Address::bytes_type mask_bytes = mask.to_bytes(); for (int i = 0; i < 16; i++) { if ((ip1_bytes[i] & mask_bytes[i]) != ip2_bytes[i]) diff --git a/src/vnsw/agent/pkt/pkt_handler.cc b/src/vnsw/agent/pkt/pkt_handler.cc index a622f8d8e05..bdefc2b1fa4 100644 --- a/src/vnsw/agent/pkt/pkt_handler.cc +++ b/src/vnsw/agent/pkt/pkt_handler.cc @@ -1173,7 +1173,7 @@ std::size_t PktInfo::hash(const Agent *agent, } else if (family == Address::INET6) { if (ecmp_load_balance.is_source_ip_set()) { uint32_t words[4]; - memcpy(words, ip_saddr.to_v6().to_bytes().c_array(), sizeof(words)); + memcpy(words, ip_saddr.to_v6().to_bytes().data(), sizeof(words)); boost::hash_combine(seed, words[0]); boost::hash_combine(seed, words[1]); boost::hash_combine(seed, words[2]); @@ -1182,7 +1182,7 @@ std::size_t PktInfo::hash(const Agent *agent, if (ecmp_load_balance.is_destination_ip_set()) { uint32_t words[4]; - memcpy(words, ip_daddr.to_v6().to_bytes().c_array(), sizeof(words)); + memcpy(words, ip_daddr.to_v6().to_bytes().data(), sizeof(words)); boost::hash_combine(seed, words[0]); boost::hash_combine(seed, words[1]); boost::hash_combine(seed, words[2]); diff --git a/src/vnsw/agent/pkt/pkt_sandesh_flow.cc b/src/vnsw/agent/pkt/pkt_sandesh_flow.cc index 2e5f08c6a71..d9e6223eb50 100644 --- a/src/vnsw/agent/pkt/pkt_sandesh_flow.cc +++ b/src/vnsw/agent/pkt/pkt_sandesh_flow.cc @@ -15,8 +15,6 @@ #include #include -using boost::system::error_code; - static string InetRouteFlowMgmtKeyToString(uint16_t id, InetRouteFlowMgmtKey *key) { stringstream ss; @@ -313,7 +311,7 @@ bool PktSandeshFlow::SetFlowKey(string key) { if (getline(ss, item, ch)) { dip = item; } - error_code ec; + boost::system::error_code ec; flow_iteration_key_.src_addr = IpAddress::from_string(sip.c_str(), ec); flow_iteration_key_.dst_addr = IpAddress::from_string(dip.c_str(), ec); if (flow_iteration_key_.src_addr.is_v4()) { @@ -444,7 +442,7 @@ void FetchFlowRecord::HandleRequest() const { FlowTable *flow_obj = NULL; key.nh = get_nh(); - error_code ec; + boost::system::error_code ec; key.src_addr = IpAddress::from_string(get_sip(), ec); key.dst_addr = IpAddress::from_string(get_dip(), ec); if (key.src_addr.is_v4()) { @@ -735,7 +733,7 @@ static InetRouteFlowMgmtKey* StringToInetRouteFlowMgmtKey(const string &key, if (getline(ss, item, ch)) { istringstream(item) >> plen; } - error_code ec; + boost::system::error_code ec; IpAddress ip = IpAddress::from_string(ip_str.c_str(), ec); if (ec) { return NULL; diff --git a/src/vnsw/agent/pkt/proto_handler.cc b/src/vnsw/agent/pkt/proto_handler.cc index 006ee386ada..1089671b523 100644 --- a/src/vnsw/agent/pkt/proto_handler.cc +++ b/src/vnsw/agent/pkt/proto_handler.cc @@ -176,7 +176,7 @@ uint16_t ProtoHandler::IcmpHdr(char *buff, uint16_t buf_len, uint8_t type, if (buf_len < sizeof(hdr)) return 0; - bzero(hdr, sizeof(struct icmp)); + memset(hdr, 0, sizeof(struct icmp)); hdr->icmp_type = type; hdr->icmp_code = code;