Commit 924a4f46 authored by Thomas Markwalder's avatar Thomas Markwalder

[#260,!120] Addressed most of review comments

    Addressed all comments except parsing regen and
    refactor of watch sockets in IfaceMgr.  Doing those
    separately.
parent 1f31a082
......@@ -9,13 +9,38 @@
<!-- Converted by db4-upgrade version 1.1 -->
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="congestion-handling">
<title>Congestion Handling in DHCPv4 and DHCPv6</title>
<para>Congestion occurs when servers are subjected to client queries
faster than they can be fulfilled. Subsequently, the servers begin
accumulating a backlog of pending queries. The longer the high rate of
traffic continues the farther behind the servers fall. Depending on the
client implementations, those that fail to get leases either give or simply
continue to retry forever. In the former case, the server may eventually
recover. The latter case is vicious cycle from which the server is unable
escape.
</para>
<para>
In a well-planned deployment, the number and capacity of servers is matched
to the maximum client loads expected. As long as capacity is matched to
load, congestion does not occur. If the load is routinely too heavy, then
the deployment needs to be re-evaluated. Congestion typically occurs when
there is a network event that causes overly large numbers of clients to
simultaneously need leases such as recovery after a network outage.
</para>
<para>
The goal of Congestion handling is to help the servers mitigate the peak
in traffic by fulfilling as many of the most relevant requests as possible
until it subsides.
</para>
<para>Prior to Kea 1.5, kea-dhcp4 and kea-dhcp4 read inbound packets directly
from the interface sockets in the main application thread. This meant that
packets waiting to be processed were held in socket buffers themselves. Once
these buffers fill any new packets are discarded. Under swamped conditions
the servers can end up processing client packets that may no longer be
relevant, or worse are redundant. In other words, the packets waiting in
the FIFO socket buffers become more and more stale.
the FIFO socket buffers become increasingly stale.
</para>
<para>Kea 1.5 introduces a new feature referred to as Congestion Handling.
......@@ -34,13 +59,13 @@
always discarding the newest packets, we now always discard the oldest
packets. The capacity of the buffer, (i.e the maximum number of packets the
buffer can contain) is configurable. A reasonable starting point would be to
match the queue size to the number of leases per second your installation of
Kea can handle (Please note this figure varies widely depending on your
configuration). We anticipate adding more knobs as we learn from experience,
testing, and user feedback.
match the capacity to the number of leases per second your installation of
Kea can handle. Please note this figure varies widely depending on the
specifics of your deployment. We anticipate adding more knobs as we learn
from experience, testing, and user feedback.
</para>
<para>As there is no one algorithm that will best handle the dynamncis of
<para>As there is no one algorithm that will best handle the dynamics of
all sites, and because over time new approaches will evolve, the packet
queue is implemented as plug-in, which can replaced by a custom queue
implementation via hook library. This should make it straight forward
......@@ -53,7 +78,6 @@
servers through an optional, top level configuration element,
'dhcp-queue-control' (Omitting this element disables packet queueing):
<screen>
...
"dhcp-queue-control": {
"enable-queue": true|false,
"queue-type": "queue type",
......@@ -74,9 +98,9 @@
<listitem>
<simpara><command>queue-type</command> name of the queue implementation
to use. This value exists such that custom implementations can be
registered (via hook lib) and then selected. As mentioned earlier,
there is a default implementation registered: "kea-ring4" for kea-dhcp4
and "kea-ring6" for kea-dhcp6.
registered (via hook lib) and then selected. There is a default
packet queue implementation that is pre-registered during server
start up: "kea-ring4" for kea-dhcp4 and "kea-ring6" for kea-dhcp6.
</simpara>
</listitem>
<listitem>
......@@ -89,7 +113,7 @@
</itemizedlist>
</para>
<para>The following example enables the default packet queue for kea-dhcp4,
with a queue capactiy fo 250 packets:
with a queue capacity of 250 packets:
<screen>
"Dhcp4":
{
......@@ -104,7 +128,7 @@
</screen>
</para>
<para> The following example enables the default packet queue for kea-dhcp6,
with a queue capactiy fo 300 packets:
with a queue capacity of 300 packets:
<screen>
"Dhcp6":
{
......
This diff is collapsed.
......@@ -1849,34 +1849,27 @@ dhcp_queue_control: DHCP_QUEUE_CONTROL {
if (!qc->contains("enable-queue")) {
std::stringstream msg;
msg << "'enable-queue' is required: ";
msg << qc->getPosition().str() << ")";
msg << "(" << qc->getPosition().str() << ")";
error(@1, msg.str());
}
ConstElementPtr enable_queue = qc->get("enable-queue");
if (enable_queue->getType() != Element::boolean) {
ConstElementPtr enable_queue = qc->get("enable-queue");
if (enable_queue->getType() != Element::boolean) {
std::stringstream msg;
msg << "'enable-queue' must be boolean: ";
msg << qc->getPosition().str() << ")";
msg << "(" << qc->getPosition().str() << ")";
error(@1, msg.str());
}
if (enable_queue->boolValue()) {
if (!qc->contains("queue-type")) {
std::stringstream msg;
msg << "'queue-type' is required, when 'enable-queue' is true: ";
msg << qc->getPosition().str() << ")";
error(@1, msg.str());
}
}
if (qc->contains("queue-type")) {
ConstElementPtr queue_type = qc->get("queue-type");
if (queue_type->getType() != Element::string) {
std::stringstream msg;
msg << "'queue-type' must be a string: ";
msg << qc->getPosition().str() << ")";
msg << "(" << qc->getPosition().str() << ")";
error(@1, msg.str());
}
}
}
ctx.leave();
};
......
......@@ -6591,21 +6591,14 @@ TEST_F(Dhcp4ParserTest, dhcpQueueControlInvalid) {
"{ \n"
" \"enable-type\": \"some-type\" \n"
"} \n",
"<string>:2.2-21: 'enable-queue' is required: <string>:2:24)"
"<string>:2.2-21: 'enable-queue' is required: (<string>:2:24)"
},
{
"enable-queue not boolean",
"{ \n"
" \"enable-queue\": \"always\" \n"
"} \n",
"<string>:2.2-21: 'enable-queue' must be boolean: <string>:2:24)"
},
{
"queue enabled, type missing",
"{ \n"
" \"enable-queue\": true \n"
"} \n",
"<string>:2.2-21: 'queue-type' is required, when 'enable-queue' is true: <string>:2:24)"
"<string>:2.2-21: 'enable-queue' must be boolean: (<string>:2:24)"
},
{
"queue enabled, type not a string",
......@@ -6613,7 +6606,7 @@ TEST_F(Dhcp4ParserTest, dhcpQueueControlInvalid) {
" \"enable-queue\": true, \n"
" \"queue-type\": 7777 \n"
"} \n",
"<string>:2.2-21: 'queue-type' must be a string: <string>:2:24)"
"<string>:2.2-21: 'queue-type' must be a string: (<string>:2:24)"
}
};
......
This diff is collapsed.
......@@ -1938,35 +1938,29 @@ dhcp_queue_control: DHCP_QUEUE_CONTROL {
if (!qc->contains("enable-queue")) {
std::stringstream msg;
msg << "'enable-queue' is required: ";
msg << qc->getPosition().str() << ")";
msg << "(" << qc->getPosition().str() << ")";
error(@1, msg.str());
}
ConstElementPtr enable_queue = qc->get("enable-queue");
if (enable_queue->getType() != Element::boolean) {
// queue-enable is mandatory
ConstElementPtr enable_queue = qc->get("enable-queue");
if (enable_queue->getType() != Element::boolean) {
std::stringstream msg;
msg << "'enable-queue' must be boolean: ";
msg << qc->getPosition().str() << ")";
msg << "(" << qc->getPosition().str() << ")";
error(@1, msg.str());
}
if (enable_queue->boolValue()) {
if (!qc->contains("queue-type")) {
std::stringstream msg;
msg << "'queue-type' is required, when 'enable-queue' is true: ";
msg << qc->getPosition().str() << ")";
error(@1, msg.str());
}
// if queue-type is supplied make sure it's a string
if (qc->contains("queue-type")) {
ConstElementPtr queue_type = qc->get("queue-type");
if (queue_type->getType() != Element::string) {
std::stringstream msg;
msg << "'queue-type' must be a string: ";
msg << qc->getPosition().str() << ")";
msg << "(" << qc->getPosition().str() << ")";
error(@1, msg.str());
}
}
}
ctx.leave();
};
......
......@@ -7096,29 +7096,22 @@ TEST_F(Dhcp6ParserTest, dhcpQueueControlInvalid) {
"{ \n"
" \"enable-type\": \"some-type\" \n"
"} \n",
"<string>:2.2-21: 'enable-queue' is required: <string>:2:24)"
"<string>:2.2-21: 'enable-queue' is required: (<string>:2:24)"
},
{
"enable-queue not boolean",
"{ \n"
" \"enable-queue\": \"always\" \n"
"} \n",
"<string>:2.2-21: 'enable-queue' must be boolean: <string>:2:24)"
"<string>:2.2-21: 'enable-queue' must be boolean: (<string>:2:24)"
},
{
"queue enabled, type missing",
"{ \n"
" \"enable-queue\": true \n"
"} \n",
"<string>:2.2-21: 'queue-type' is required, when 'enable-queue' is true: <string>:2:24)"
},
{
"queue enabled, type not a string",
"queue type not a string",
"{ \n"
" \"enable-queue\": true, \n"
" \"queue-type\": 7777 \n"
"} \n",
"<string>:2.2-21: 'queue-type' must be a string: <string>:2:24)"
"<string>:2.2-21: 'queue-type' must be a string: (<string>:2:24)"
}
};
......
......@@ -78,7 +78,8 @@ const char* EXTRACTED_CONFIGS[] = {
" \"preferred-lifetime\": 3000,\n"
" \"rebind-timer\": 2000,\n"
" \"renew-timer\": 1000,\n"
" \"subnet6\": [ ],\n" " \"valid-lifetime\": 4000\n"
" \"subnet6\": [ ],\n"
" \"valid-lifetime\": 4000\n"
" }\n",
// CONFIGURATION 1
"{\n"
......
......@@ -1485,8 +1485,12 @@ TestControl::run() {
isc_throw(InvalidOperation,
"command options must be parsed before running a test");
} else if (options.getIpVersion() == 4) {
// Turn off packet queueing.
IfaceMgr::instance().configureDHCPPacketQueue(AF_INET, data::ElementPtr());
setTransidGenerator(NumberGeneratorPtr(new SequentialGenerator()));
} else {
// Turn off packet queueing.
IfaceMgr::instance().configureDHCPPacketQueue(AF_INET6, data::ElementPtr());
setTransidGenerator(NumberGeneratorPtr(new SequentialGenerator(0x00FFFFFF)));
}
......
......@@ -314,7 +314,6 @@ IfaceMgr::~IfaceMgr() {
// control_buf_ is deleted automatically (scoped_ptr)
control_buf_len_ = 0;
stopDHCPReceiver();
closeSockets();
// Explicitly delete PQM singletons.
......@@ -595,8 +594,9 @@ IfaceMgr::openSockets4(const uint16_t port, const bool use_bcast,
}
}
// If we have open sockets, start the receiver.
if (count > 0) {
// starts the receiver thread (if queueing is enabled);
// starts the receiver thread (if queueing is enabled).
startDHCPReceiver(AF_INET);
}
......@@ -679,8 +679,9 @@ IfaceMgr::openSockets6(const uint16_t port,
}
}
// If we have open sockets, start the receiver.
if (count > 0) {
// starts the receiver thread (if queueing is enabled);
// starts the receiver thread (if queueing is enabled).
startDHCPReceiver(AF_INET6);
}
return (count > 0);
......@@ -694,6 +695,7 @@ IfaceMgr::startDHCPReceiver(const uint16_t family) {
switch (family) {
case AF_INET:
// If there's no queue, then has been disabled, simply return.
if(!getPacketQueue4()) {
return;
}
......@@ -701,6 +703,7 @@ IfaceMgr::startDHCPReceiver(const uint16_t family) {
receiver_thread_.reset(new Thread(boost::bind(&IfaceMgr::receiveDHCP4Packets, this)));
break;
case AF_INET6:
// If there's no queue, then has been disabled, simply return.
if(!getPacketQueue6()) {
return;
}
......@@ -964,7 +967,7 @@ IfaceMgr::send(const Pkt4Ptr& pkt) {
}
Pkt4Ptr IfaceMgr::receive4(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) {
if (receiver_thread_) {
if (isReceiverRunning()) {
return (receive4Indirect(timeout_sec, timeout_usec));
}
......@@ -1189,7 +1192,7 @@ Pkt4Ptr IfaceMgr::receive4Direct(uint32_t timeout_sec, uint32_t timeout_usec /*
}
Pkt6Ptr IfaceMgr::receive6(uint32_t timeout_sec, uint32_t timeout_usec /* = 0 */) {
if (receiver_thread_) {
if (isReceiverRunning()) {
return (receive6Indirect(timeout_sec, timeout_usec));
}
......
......@@ -677,56 +677,32 @@ public:
/// @return true if sending was successful
bool send(const Pkt4Ptr& pkt);
/// @brief Tries to receive DHCPv6 message over open IPv6 sockets.
/// @brief Receive IPv4 packets or data from external sockets
///
/// Attempts to receive a single DHCPv6 message over any of the open IPv6
/// sockets. If reception is successful and all information about its
/// sender is obtained, Pkt6 object is created and returned.
///
/// This method also checks if data arrived over registered external socket.
/// This data may be of a different protocol family than AF_INET6.
/// Wrapper around calls to either @c receive4Direct or @c
/// receive4Indirect. The former is called when packet queuing is
/// disabled, the latter when it is enabled.
///
/// @param timeout_sec specifies integral part of the timeout (in seconds)
/// @param timeout_usec specifies fractional part of the timeout
/// (in microseconds)
///
/// @throw isc::BadValue if timeout_usec is greater than one million
/// @throw isc::dhcp::SocketReadError if error occurred when receiving a
/// packet.
/// @throw isc::dhcp::SignalInterruptOnSelect when a call to select() is
/// interrupted by a signal.
///
/// @return Pkt6 object representing received packet (or NULL)
/// @return Pkt4 object representing received packet (or NULL)
Pkt6Ptr receive6(uint32_t timeout_sec, uint32_t timeout_usec = 0);
Pkt6Ptr receive6Direct(uint32_t timeout_sec, uint32_t timeout_usec = 0);
Pkt6Ptr receive6Indirect(uint32_t timeout_sec, uint32_t timeout_usec = 0);
/// @brief Tries to receive IPv4 packet over open IPv4 sockets.
/// @brief Receive IPv4 packets or data from external sockets
///
/// Attempts to receive a single DHCPv4 message over any of the open
/// IPv4 sockets. If reception is successful and all information about
/// its sender is obtained, Pkt4 object is created and returned.
///
/// This method also checks if data arrived over registered external socket.
/// This data may be of a different protocol family than AF_INET.
/// Wrapper around calls to either @c receive4Direct or @c
/// receive4Indirect. The former is called when packet queuing is
/// disabled, the latter when it is enabled.
///
/// @param timeout_sec specifies integral part of the timeout (in seconds)
/// @param timeout_usec specifies fractional part of the timeout
/// (in microseconds)
///
/// @throw isc::BadValue if timeout_usec is greater than one million
/// @throw isc::dhcp::SocketReadError if error occurred when receiving a
/// packet.
/// @throw isc::dhcp::SignalInterruptOnSelect when a call to select() is
/// interrupted by a signal.
///
/// @return Pkt4 object representing received packet (or NULL)
Pkt4Ptr receive4(uint32_t timeout_sec, uint32_t timeout_usec = 0);
Pkt4Ptr receive4Direct(uint32_t timeout_sec, uint32_t timeout_usec = 0);
Pkt4Ptr receive4Indirect(uint32_t timeout_sec, uint32_t timeout_usec = 0);
/// Opens UDP/IP socket and binds it to address, interface and port.
///
/// Specific type of socket (UDP/IPv4 or UDP/IPv6) depends on passed addr
......@@ -1125,6 +1101,50 @@ protected:
const uint16_t port, const bool receive_bcast = false,
const bool send_bcast = false);
/// @brief Receive IPv4 packets directly or data from external sockets.
///
/// Attempts to receive a single DHCPv4 message over any of the open
/// IPv4 sockets. If reception is successful and all information about
/// its sender is obtained, an Pkt4 object is created and returned.
///
/// This method also checks if data arrived over registered external socket.
/// This data may be of a different protocol family than AF_INET.
///
/// @param timeout_sec specifies integral part of the timeout (in seconds)
/// @param timeout_usec specifies fractional part of the timeout
/// (in microseconds)
///
/// @throw isc::BadValue if timeout_usec is greater than one million
/// @throw isc::dhcp::SocketReadError if error occurred when receiving a
/// packet.
/// @throw isc::dhcp::SignalInterruptOnSelect when a call to select() is
/// interrupted by a signal.
///
/// @return Pkt4 object representing received packet (or NULL)
Pkt4Ptr receive4Direct(uint32_t timeout_sec, uint32_t timeout_usec = 0);
/// @brief Receive IPv4 packets indirectly or data from external sockets.
///
/// Attempts to receive a single DHCPv4 message from the packet queue.
/// The queue is populated by the receiver thread. If a packet is waiting
/// in the queue, a Pkt4 returned.
///
/// This method also checks if data arrived over registered external socket.
/// This data may be of a different protocol family than AF_INET.
///
/// @param timeout_sec specifies integral part of the timeout (in seconds)
/// @param timeout_usec specifies fractional part of the timeout
/// (in microseconds)
///
/// @throw isc::BadValue if timeout_usec is greater than one million
/// @throw isc::dhcp::SocketReadError if error occurred when receiving a
/// packet.
/// @throw isc::dhcp::SignalInterruptOnSelect when a call to select() is
/// interrupted by a signal.
///
/// @return Pkt4 object representing received packet (or NULL)
Pkt4Ptr receive4Indirect(uint32_t timeout_sec, uint32_t timeout_usec = 0);
/// @brief Opens IPv6 socket.
///
/// Please do not use this method directly. Use openSocket instead.
......@@ -1142,6 +1162,51 @@ protected:
int openSocket6(Iface& iface, const isc::asiolink::IOAddress& addr,
uint16_t port, const bool join_multicast);
/// @brief Receive IPv6 packets directly or data from external sockets.
///
/// Attempts to receive a single DHCPv6 message over any of the open
/// IPv6 sockets. If reception is successful and all information about
/// its sender is obtained, an Pkt6 object is created and returned.
///
/// This method also checks if data arrived over registered external socket.
/// This data may be of a different protocol family than AF_INET.
///
/// @param timeout_sec specifies integral part of the timeout (in seconds)
/// @param timeout_usec specifies fractional part of the timeout
/// (in microseconds)
///
/// @throw isc::BadValue if timeout_usec is greater than one million
/// @throw isc::dhcp::SocketReadError if error occurred when receiving a
/// packet.
/// @throw isc::dhcp::SignalInterruptOnSelect when a call to select() is
/// interrupted by a signal.
///
/// @return Pkt6 object representing received packet (or NULL)
Pkt6Ptr receive6Direct(uint32_t timeout_sec, uint32_t timeout_usec = 0);
/// @brief Receive IPv6 packets indirectly or data from external sockets.
///
/// Attempts to receive a single DHCPv6 message from the packet queue.
/// The queue is populated by the receiver thread. If a packet is waiting
/// in the queue, a Pkt6 returned.
///
/// This method also checks if data arrived over registered external socket.
/// This data may be of a different protocol family than AF_INET.
///
/// @param timeout_sec specifies integral part of the timeout (in seconds)
/// @param timeout_usec specifies fractional part of the timeout
/// (in microseconds)
///
/// @throw isc::BadValue if timeout_usec is greater than one million
/// @throw isc::dhcp::SocketReadError if error occurred when receiving a
/// packet.
/// @throw isc::dhcp::SignalInterruptOnSelect when a call to select() is
/// interrupted by a signal.
///
/// @return Pkt6 object representing received packet (or NULL)
Pkt6Ptr receive6Indirect(uint32_t timeout_sec, uint32_t timeout_usec = 0);
/// @brief Stub implementation of network interface detection.
///
/// This implementations reads a single line from interfaces.txt file
......
......@@ -449,7 +449,7 @@ public:
/// @brief Tests the ability to send and receive DHCPv6 packets
///
/// This test calls @r IfaceMgr::configureDHCPqueue, passing int the
/// This test calls @r IfaceMgr::configureDHCPPacketQueue, passing in the
/// given queue configuration. It then calls IfaceMgr::startDHCPReceiver
/// and verifies whether or not the receive thread has been started as
/// expected. Next it creates a generic DHCPv6 packet and sends it over
......@@ -465,11 +465,11 @@ public:
// Testing socket operation in a portable way is tricky
// without interface detection implemented
// let's assume that every supported OS have lo interface
IOAddress loAddr("::1");
IOAddress lo_addr("::1");
int socket1 = 0, socket2 = 0;
EXPECT_NO_THROW(
socket1 = ifacemgr->openSocket(LOOPBACK, loAddr, 10547);
socket2 = ifacemgr->openSocket(LOOPBACK, loAddr, 10546);
socket1 = ifacemgr->openSocket(LOOPBACK, lo_addr, 10547);
socket2 = ifacemgr->openSocket(LOOPBACK, lo_addr, 10546);
);
EXPECT_GE(socket1, 0);
......@@ -537,7 +537,7 @@ public:
/// @brief Tests the ability to send and receive DHCPv4 packets
///
/// This test calls @r IfaceMgr::configureDHCPqueue, passing int the
/// This test calls @r IfaceMgr::configureDHCPPacketQueue, passing in the
/// given queue configuration. It then calls IfaceMgr::startDHCPReceiver
/// and verifies whether or not the receive thread has been started as
/// expected. Next it creates a DISCOVER packet and sends it over
......@@ -553,10 +553,10 @@ public:
// Testing socket operation in a portable way is tricky
// without interface detection implemented.
// Let's assume that every supported OS has lo interface
IOAddress loAddr("127.0.0.1");
IOAddress lo_addr("127.0.0.1");
int socket1 = 0;
EXPECT_NO_THROW(
socket1 = ifacemgr->openSocket(LOOPBACK, loAddr, DHCP4_SERVER_PORT + 10000);
socket1 = ifacemgr->openSocket(LOOPBACK, lo_addr, DHCP4_SERVER_PORT + 10000);
);
EXPECT_GE(socket1, 0);
......@@ -901,10 +901,10 @@ TEST_F(IfaceMgrTest, receiveTimeout6) {
scoped_ptr<NakedIfaceMgr> ifacemgr(new NakedIfaceMgr());
// Open socket on the lo interface.
IOAddress loAddr("::1");
IOAddress lo_addr("::1");
int socket1 = 0;
ASSERT_NO_THROW(
socket1 = ifacemgr->openSocket(LOOPBACK, loAddr, 10547)
socket1 = ifacemgr->openSocket(LOOPBACK, lo_addr, 10547)
);
// Socket is open if result is non-negative.
ASSERT_GE(socket1, 0);
......@@ -958,10 +958,10 @@ TEST_F(IfaceMgrTest, receiveTimeout4) {
scoped_ptr<NakedIfaceMgr> ifacemgr(new NakedIfaceMgr());
// Open socket on the lo interface.
IOAddress loAddr("127.0.0.1");
IOAddress lo_addr("127.0.0.1");
int socket1 = 0;
ASSERT_NO_THROW(
socket1 = ifacemgr->openSocket(LOOPBACK, loAddr, 10067)
socket1 = ifacemgr->openSocket(LOOPBACK, lo_addr, 10067)
);
// Socket is open if returned value is non-negative.
ASSERT_GE(socket1, 0);
......@@ -1023,10 +1023,10 @@ TEST_F(IfaceMgrTest, multipleSockets) {
init_sockets.push_back(socket1);
// Create socket #2
IOAddress loAddr("127.0.0.1");
IOAddress lo_addr("127.0.0.1");
int socket2 = 0;
ASSERT_NO_THROW(
socket2 = ifacemgr->openSocketFromRemoteAddress(loAddr, PORT2);
socket2 = ifacemgr->openSocketFromRemoteAddress(lo_addr, PORT2);
);
ASSERT_GE(socket2, 0);
init_sockets.push_back(socket2);
......@@ -1102,19 +1102,19 @@ TEST_F(IfaceMgrTest, sockets6) {
scoped_ptr<NakedIfaceMgr> ifacemgr(new NakedIfaceMgr());
IOAddress loAddr("::1");
IOAddress lo_addr("::1");
Pkt6 pkt6(DHCPV6_SOLICIT, 123);
pkt6.setIface(LOOPBACK);
// Bind multicast socket to port 10547
int socket1 = ifacemgr->openSocket(LOOPBACK, loAddr, 10547);
int socket1 = ifacemgr->openSocket(LOOPBACK, lo_addr, 10547);
EXPECT_GE(socket1, 0); // socket >= 0
EXPECT_EQ(socket1, ifacemgr->getSocket(pkt6));
// Bind unicast socket to port 10548
int socket2 = ifacemgr->openSocket(LOOPBACK, loAddr, 10548);
int socket2 = ifacemgr->openSocket(LOOPBACK, lo_addr, 10548);
EXPECT_GE(socket2, 0);
// Removed code for binding socket twice to the same address/port
......@@ -1133,7 +1133,7 @@ TEST_F(IfaceMgrTest, sockets6) {
// Use non-existing interface name.
EXPECT_THROW(
ifacemgr->openSocket("non_existing_interface", loAddr, 10548),
ifacemgr->openSocket("non_existing_interface", lo_addr, 10548),
BadValue
);
......@@ -1182,18 +1182,18 @@ TEST_F(IfaceMgrTest, socketsFromAddress) {
// Open v6 socket on loopback interface and bind to port
int socket1 = 0;
IOAddress loAddr6("::1");
IOAddress lo_addr6("::1");
EXPECT_NO_THROW(
socket1 = ifacemgr->openSocketFromAddress(loAddr6, PORT1);
socket1 = ifacemgr->openSocketFromAddress(lo_addr6, PORT1);
);
// socket descriptor must be non-negative integer
EXPECT_GE(socket1, 0);
// Open v4 socket on loopback interface and bind to different port
int socket2 = 0;
IOAddress loAddr("127.0.0.1");
IOAddress lo_addr("127.0.0.1");
EXPECT_NO_THROW(
socket2 = ifacemgr->openSocketFromAddress(loAddr, PORT2);
socket2 = ifacemgr->openSocketFromAddress(lo_addr, PORT2);
);
// socket descriptor must be positive integer
EXPECT_GE(socket2, 0);
......@@ -1219,17 +1219,17 @@ TEST_F(IfaceMgrTest, socketsFromRemoteAddress) {
// Loopback address is the only one that we know
// so let's treat it as remote address.
int socket1 = 0;
IOAddress loAddr6("::1");
IOAddress lo_addr6("::1");
EXPECT_NO_THROW(
socket1 = ifacemgr->openSocketFromRemoteAddress(loAddr6, PORT1);
socket1 = ifacemgr->openSocketFromRemoteAddress(lo_addr6, PORT1);
);
EXPECT_GE(socket1, 0);
// Open v4 socket to connect to remote address.
int socket2 = 0;
IOAddress loAddr("127.0.0.1");
IOAddress lo_addr("127.0.0.1");
EXPECT_NO_THROW(
socket2 = ifacemgr->openSocketFromRemoteAddress(loAddr, PORT2);
socket2 = ifacemgr->openSocketFromRemoteAddress(lo_addr, PORT2);
);
EXPECT_GE(socket2, 0);
......@@ -1255,7 +1255,7 @@ TEST_F(IfaceMgrTest, DISABLED_sockets6Mcast) {
scoped_ptr<NakedIfaceMgr> ifacemgr(new NakedIfaceMgr());
IOAddress loAddr("::1");
IOAddress lo_addr("::1");
IOAddress mcastAddr("ff02::1:2");
// bind multicast socket to port 10547
......@@ -1334,10 +1334,10 @@ TEST_F(IfaceMgrTest, setPacketFilter) {
// Try to open socket using IfaceMgr. It should call the openSocket() function
// on the packet filter object we have set.
IOAddress loAddr("127.0.0.1");
IOAddress lo_addr("127.0.0.1");
int socket1 = 0;
EXPECT_NO_THROW(
socket1 = iface_mgr->openSocket(LOOPBACK, loAddr, DHCP4_SERVER_PORT + 10000);
socket1 = iface_mgr->openSocket(LOOPBACK, lo_addr, DHCP4_SERVER_PORT + 10000);
);
// Check that openSocket function was called.
......@@ -1374,10 +1374,10 @@ TEST_F(IfaceMgrTest, setPacketFilter6) {
// Try to open socket using IfaceMgr. It should call the openSocket()
// function on the packet filter object we have set.
IOAddress loAddr("::1");
IOAddress lo_addr("::1");