ClientHandler::ClientByHWAddrContainer ClientHandler::clients_hwaddr_;
-ClientHandler::ClientHandler() : locked_client_id_(), locked_hwaddr_() {
+ClientHandler::ClientHandler()
+ : client_(), locked_client_id_(), locked_hwaddr_() {
}
ClientHandler::~ClientHandler() {
unLockByHWAddr();
}
locked_hwaddr_.reset();
+ client_.reset();
}
ClientHandler::Client::Client(Pkt4Ptr query, DuidPtr client_id,
if (it == clients_client_id_.end()) {
return (0);
}
- return (ClientPtr(new Client(*it)));
+ return (*it);
}
ClientHandler::ClientPtr
if (it == clients_hwaddr_.end()) {
return (0);
}
- return (ClientPtr(new Client(*it)));
+ return (*it);
}
void
-ClientHandler::lockById(Client client) {
+ClientHandler::lockById() {
if (!locked_client_id_) {
isc_throw(Unexpected, "nothing to lock in ClientHandler::lock (id)");
}
// Assume insert will never fail so not checking its result.
- clients_client_id_.insert(client);
+ clients_client_id_.insert(client_);
}
void
-ClientHandler::lockByHWAddr(Client client) {
+ClientHandler::lockByHWAddr() {
if (!locked_hwaddr_) {
isc_throw(Unexpected, "nothing to lock in ClientHandler::lock (hw)");
}
// Assume insert will never fail so not checking its result.
- clients_hwaddr_.insert(client);
+ clients_hwaddr_.insert(client_);
}
void
return (false);
}
- ClientPtr holder_id = 0;
- ClientPtr holder_hw = 0;
- Client client(query, duid, hwaddr);
+ ClientPtr holder_id;
+ ClientPtr holder_hw;
// Try first duid.
if (duid) {
holder_id = lookup(duid);
if (!holder_id) {
locked_client_id_ = duid;
- lockById(client);
+ client_.reset(new Client(query, duid, hwaddr));
+ lockById();
}
}
if (!holder_id) {
holder_hw = lookup(hwaddr);
if (!holder_hw) {
locked_hwaddr_ = hwaddr;
- lockByHWAddr(client);
+ client_.reset(new Client(query, duid, hwaddr));
+ lockByHWAddr();
return (false);
}
}
#include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
+#include <boost/shared_ptr.hpp>
#include <mutex>
#include <thread>
std::thread::id thread_;
};
- /// @brief The type of unique pointers to clients by ID.
- typedef std::unique_ptr<Client> ClientPtr;
+ /// @brief The type of shared pointers to clients by ID.
+ typedef boost::shared_ptr<Client> ClientPtr;
+
+ /// @brief Local client.
+ ClientPtr client_;
/// @brief Client ID locked by this handler.
DuidPtr locked_client_id_;
/// @brief Acquire a client by client ID option.
///
/// The by-id mutex must be held by the caller.
- ///
- /// @param client The filled client object.
- void lockById(Client client);
+ void lockById();
/// @brief Acquire a client by hardware address.
///
/// The by-hwaddr mutex must be held by the caller.
- ///
- /// @param client The filled client object.
- void lockByHWAddr(Client client);
+ void lockByHWAddr();
/// @brief Release a client by client ID option.
///
/// @brief The type of the client-by-id container.
typedef boost::multi_index_container<
- // This container stores client-by-id objects.
- Client,
+ // This container stores pointers to client-by-id objects.
+ ClientPtr,
// Start specification of indexes here.
boost::multi_index::indexed_by<
/// @brief The type of the client-by-hwaddr container.
typedef boost::multi_index_container<
- // This container stores client-by-hwaddr objects.
- Client,
+ // This container stores pointers to client-by-hwaddr objects.
+ ClientPtr,
// Start specification of indexes here.
boost::multi_index::indexed_by<
-// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Wed May 13 2020 16:50
+// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Sat May 09 2020 12:24
#include <cstddef>
#include <log/message_types.h>
extern const isc::log::MessageID DHCP4_DECLINE_LEASE_NOT_FOUND = "DHCP4_DECLINE_LEASE_NOT_FOUND";
extern const isc::log::MessageID DHCP4_DEFERRED_OPTION_MISSING = "DHCP4_DEFERRED_OPTION_MISSING";
extern const isc::log::MessageID DHCP4_DEFERRED_OPTION_UNPACK_FAIL = "DHCP4_DEFERRED_OPTION_UNPACK_FAIL";
-extern const isc::log::MessageID DHCP4_DEVELOPMENT_VERSION = "DHCP4_DEVELOPMENT_VERSION";
extern const isc::log::MessageID DHCP4_DHCP4O6_BAD_PACKET = "DHCP4_DHCP4O6_BAD_PACKET";
extern const isc::log::MessageID DHCP4_DHCP4O6_PACKET_RECEIVED = "DHCP4_DHCP4O6_PACKET_RECEIVED";
extern const isc::log::MessageID DHCP4_DHCP4O6_PACKET_SEND = "DHCP4_DHCP4O6_PACKET_SEND";
extern const isc::log::MessageID DHCP4_PACKET_DROP_0008 = "DHCP4_PACKET_DROP_0008";
extern const isc::log::MessageID DHCP4_PACKET_DROP_0009 = "DHCP4_PACKET_DROP_0009";
extern const isc::log::MessageID DHCP4_PACKET_DROP_0010 = "DHCP4_PACKET_DROP_0010";
+extern const isc::log::MessageID DHCP4_PACKET_DROP_0011 = "DHCP4_PACKET_DROP_0011";
+extern const isc::log::MessageID DHCP4_PACKET_DROP_0012 = "DHCP4_PACKET_DROP_0012";
extern const isc::log::MessageID DHCP4_PACKET_NAK_0001 = "DHCP4_PACKET_NAK_0001";
extern const isc::log::MessageID DHCP4_PACKET_NAK_0002 = "DHCP4_PACKET_NAK_0002";
extern const isc::log::MessageID DHCP4_PACKET_NAK_0003 = "DHCP4_PACKET_NAK_0003";
"DHCP4_DECLINE_LEASE_NOT_FOUND", "Received DHCPDECLINE for addr %1 from client %2, but no such lease found.",
"DHCP4_DEFERRED_OPTION_MISSING", "can find deferred option code %1 in the query",
"DHCP4_DEFERRED_OPTION_UNPACK_FAIL", "An error unpacking the deferred option %1: %2",
- "DHCP4_DEVELOPMENT_VERSION", "This software is a development branch of Kea. It is not recommended for production use.",
"DHCP4_DHCP4O6_BAD_PACKET", "received malformed DHCPv4o6 packet: %1",
"DHCP4_DHCP4O6_PACKET_RECEIVED", "received DHCPv4o6 packet from DHCPv4 server (type %1) for %2 on interface %3",
"DHCP4_DHCP4O6_PACKET_SEND", "%1: trying to send packet %2 (type %3) to %4 port %5 on interface %6 encapsulating %7: %8 (type %9)",
"DHCP4_PACKET_DROP_0008", "%1: DHCP service is globally disabled",
"DHCP4_PACKET_DROP_0009", "%1: Option 53 missing (no DHCP message type), is this a BOOTP packet?",
"DHCP4_PACKET_DROP_0010", "dropped as member of the special class 'DROP': %1",
+ "DHCP4_PACKET_DROP_0011", "dropped as sent by the same client than a packet being processed by another thread: dropped %1 by thread %2 as duplicate of %3 processed by %4",
+ "DHCP4_PACKET_DROP_0012", "dropped as sent by the same client than a packet being processed by another thread: dropped %1 by thread %2 as duplicate of %3 processed by %4",
"DHCP4_PACKET_NAK_0001", "%1: failed to select a subnet for incoming packet, src %2, type %3",
"DHCP4_PACKET_NAK_0002", "%1: invalid address %2 requested by INIT-REBOOT",
"DHCP4_PACKET_NAK_0003", "%1: failed to advertise a lease, client sent ciaddr %2, requested-ip-address %3",
"DHCP4_SRV_D2STOP_ERROR", "error stopping IO with DHCP_DDNS during shutdown: %1",
"DHCP4_SRV_DHCP4O6_ERROR", "error stopping IO with DHCPv4o6 during shutdown: %1",
"DHCP4_STARTED", "Kea DHCPv4 server version %1 started",
- "DHCP4_STARTING", "Kea DHCPv4 server version %1 (%2) starting",
+ "DHCP4_STARTING", "Kea DHCPv4 server version %1 starting",
"DHCP4_START_INFO", "pid: %1, server port: %2, client port: %3, verbose: %4",
"DHCP4_SUBNET_DATA", "%1: the selected subnet details: %2",
"DHCP4_SUBNET_DYNAMICALLY_CHANGED", "%1: changed selected subnet %2 to subnet %3 from shared network %4 for client assignments",
-// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Wed May 13 2020 16:50
+// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Sat May 09 2020 12:24
#ifndef DHCP4_MESSAGES_H
#define DHCP4_MESSAGES_H
extern const isc::log::MessageID DHCP4_DECLINE_LEASE_NOT_FOUND;
extern const isc::log::MessageID DHCP4_DEFERRED_OPTION_MISSING;
extern const isc::log::MessageID DHCP4_DEFERRED_OPTION_UNPACK_FAIL;
-extern const isc::log::MessageID DHCP4_DEVELOPMENT_VERSION;
extern const isc::log::MessageID DHCP4_DHCP4O6_BAD_PACKET;
extern const isc::log::MessageID DHCP4_DHCP4O6_PACKET_RECEIVED;
extern const isc::log::MessageID DHCP4_DHCP4O6_PACKET_SEND;
extern const isc::log::MessageID DHCP4_PACKET_DROP_0008;
extern const isc::log::MessageID DHCP4_PACKET_DROP_0009;
extern const isc::log::MessageID DHCP4_PACKET_DROP_0010;
+extern const isc::log::MessageID DHCP4_PACKET_DROP_0011;
+extern const isc::log::MessageID DHCP4_PACKET_DROP_0012;
extern const isc::log::MessageID DHCP4_PACKET_NAK_0001;
extern const isc::log::MessageID DHCP4_PACKET_NAK_0002;
extern const isc::log::MessageID DHCP4_PACKET_NAK_0003;
ClientHandler::ClientContainer ClientHandler::clients_;
-ClientHandler::ClientHandler() : locked_() {
+ClientHandler::ClientHandler() : client_(), locked_() {
}
ClientHandler::~ClientHandler() {
unLock();
}
locked_.reset();
+ client_.reset();
}
ClientHandler::Client::Client(Pkt6Ptr query, DuidPtr client_id)
if (it == clients_.end()) {
return (0);
}
- return (ClientPtr(new Client(*it)));
+ return (*it);
}
void
-ClientHandler::lock(Client client) {
+ClientHandler::lock() {
if (!locked_) {
isc_throw(Unexpected, "nothing to lock in ClientHandler::lock");
}
// Assume insert will never fail so not checking its result.
- clients_.insert(client);
+ clients_.insert(client_);
}
void
// A lot of code assumes this will never happen...
isc_throw(Unexpected, "empty DUID in ClientHandler::tryLock");
}
- ClientPtr holder = 0;
+ ClientPtr holder;
{
// Try to acquire the lock and return the holder when it failed.
lock_guard<mutex> lock_(mutex_);
holder = lookup(duid);
if (!holder) {
locked_ = duid;
- lock(Client(query, duid));
+ client_.reset(new Client(query, duid));
+ lock();
return (false);
}
}
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
+#include <boost/shared_ptr.hpp>
#include <mutex>
#include <thread>
std::thread::id thread_;
};
- /// @brief The type of unique pointers to clients.
- typedef std::unique_ptr<Client> ClientPtr;
+ /// @brief The type of shared pointers to clients.
+ typedef boost::shared_ptr<Client> ClientPtr;
+
+ /// @brief Local client.
+ ClientPtr client_;
/// @brief Client ID locked by this handler.
DuidPtr locked_;
/// @brief Acquire a client.
///
/// The mutex must be held by the caller.
- ///
- /// @param client The filled client object.
- void lock(Client client);
+ void lock();
/// @brief Release a client.
///
/// @brief The type of the client container.
typedef boost::multi_index_container<
- // This container stores client objects.
- Client,
+ // This container stores pointers to client objects.
+ ClientPtr,
// Start specification of indexes here.
boost::multi_index::indexed_by<
-// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Wed May 13 2020 16:52
+// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Sat May 09 2020 12:13
#include <cstddef>
#include <log/message_types.h>
extern const isc::log::MessageID DHCP6_DECLINE_FAIL_NO_LEASE = "DHCP6_DECLINE_FAIL_NO_LEASE";
extern const isc::log::MessageID DHCP6_DECLINE_LEASE = "DHCP6_DECLINE_LEASE";
extern const isc::log::MessageID DHCP6_DECLINE_PROCESS_IA = "DHCP6_DECLINE_PROCESS_IA";
-extern const isc::log::MessageID DHCP6_DEVELOPMENT_VERSION = "DHCP6_DEVELOPMENT_VERSION";
extern const isc::log::MessageID DHCP6_DHCP4O6_PACKET_RECEIVED = "DHCP6_DHCP4O6_PACKET_RECEIVED";
extern const isc::log::MessageID DHCP6_DHCP4O6_RECEIVE_FAIL = "DHCP6_DHCP4O6_RECEIVE_FAIL";
extern const isc::log::MessageID DHCP6_DHCP4O6_RECEIVING = "DHCP6_DHCP4O6_RECEIVING";
extern const isc::log::MessageID DHCP6_OPEN_SOCKET_FAIL = "DHCP6_OPEN_SOCKET_FAIL";
extern const isc::log::MessageID DHCP6_PACKET_DROP_DHCP_DISABLED = "DHCP6_PACKET_DROP_DHCP_DISABLED";
extern const isc::log::MessageID DHCP6_PACKET_DROP_DROP_CLASS = "DHCP6_PACKET_DROP_DROP_CLASS";
+extern const isc::log::MessageID DHCP6_PACKET_DROP_DUPLICATE = "DHCP6_PACKET_DROP_DUPLICATE";
extern const isc::log::MessageID DHCP6_PACKET_DROP_PARSE_FAIL = "DHCP6_PACKET_DROP_PARSE_FAIL";
extern const isc::log::MessageID DHCP6_PACKET_DROP_SERVERID_MISMATCH = "DHCP6_PACKET_DROP_SERVERID_MISMATCH";
extern const isc::log::MessageID DHCP6_PACKET_DROP_UNICAST = "DHCP6_PACKET_DROP_UNICAST";
"DHCP6_DECLINE_FAIL_NO_LEASE", "Client %1 sent DECLINE for address %2, but there's no lease for it",
"DHCP6_DECLINE_LEASE", "Client %1 sent DECLINE for address %2 and the server marked it as declined. The lease will be recovered in %3 seconds.",
"DHCP6_DECLINE_PROCESS_IA", "Processing of IA (IAID: %1) from client %2 started.",
- "DHCP6_DEVELOPMENT_VERSION", "This software is a development branch of Kea. It is not recommended for production use.",
"DHCP6_DHCP4O6_PACKET_RECEIVED", "received DHCPv4o6 packet from DHCPv4 server (type %1) for %2 port %3 on interface %4",
"DHCP6_DHCP4O6_RECEIVE_FAIL", "failed to receive DHCPv4o6: %1",
"DHCP6_DHCP4O6_RECEIVING", "receiving DHCPv4o6 packet from DHCPv4 server",
"DHCP6_OPEN_SOCKET_FAIL", "failed to open socket: %1",
"DHCP6_PACKET_DROP_DHCP_DISABLED", "%1: DHCP service is globally disabled",
"DHCP6_PACKET_DROP_DROP_CLASS", "dropped as member of the special class 'DROP': %1",
+ "DHCP6_PACKET_DROP_DUPLICATE", "dropped as sent by the same client than a packet being processed by another thread: dropped %1 by thread %2 as duplicate of %3 processed by %4",
"DHCP6_PACKET_DROP_PARSE_FAIL", "failed to parse packet from %1 to %2, received over interface %3, reason: %4",
"DHCP6_PACKET_DROP_SERVERID_MISMATCH", "%1: dropping packet with server identifier: %2, server is using: %3",
"DHCP6_PACKET_DROP_UNICAST", "%1: dropping unicast %2 packet as this packet should be sent to multicast",
"DHCP6_SRV_D2STOP_ERROR", "error stopping IO with DHCP_DDNS during shutdown: %1",
"DHCP6_STANDALONE", "skipping message queue, running standalone",
"DHCP6_STARTED", "Kea DHCPv6 server version %1 started",
- "DHCP6_STARTING", "Kea DHCPv6 server version %1 (%2) starting",
+ "DHCP6_STARTING", "Kea DHCPv6 server version %1 starting",
"DHCP6_START_INFO", "pid: %1, server port: %2, client port: %3, verbose: %4",
"DHCP6_SUBNET_DATA", "%1: the selected subnet details: %2",
"DHCP6_SUBNET_DYNAMICALLY_CHANGED", "%1: changed selected subnet %2 to subnet %3 from shared network %4 for client assignments",
-// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Wed May 13 2020 16:52
+// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Sat May 09 2020 12:13
#ifndef DHCP6_MESSAGES_H
#define DHCP6_MESSAGES_H
extern const isc::log::MessageID DHCP6_DECLINE_FAIL_NO_LEASE;
extern const isc::log::MessageID DHCP6_DECLINE_LEASE;
extern const isc::log::MessageID DHCP6_DECLINE_PROCESS_IA;
-extern const isc::log::MessageID DHCP6_DEVELOPMENT_VERSION;
extern const isc::log::MessageID DHCP6_DHCP4O6_PACKET_RECEIVED;
extern const isc::log::MessageID DHCP6_DHCP4O6_RECEIVE_FAIL;
extern const isc::log::MessageID DHCP6_DHCP4O6_RECEIVING;
extern const isc::log::MessageID DHCP6_OPEN_SOCKET_FAIL;
extern const isc::log::MessageID DHCP6_PACKET_DROP_DHCP_DISABLED;
extern const isc::log::MessageID DHCP6_PACKET_DROP_DROP_CLASS;
+extern const isc::log::MessageID DHCP6_PACKET_DROP_DUPLICATE;
extern const isc::log::MessageID DHCP6_PACKET_DROP_PARSE_FAIL;
extern const isc::log::MessageID DHCP6_PACKET_DROP_SERVERID_MISMATCH;
extern const isc::log::MessageID DHCP6_PACKET_DROP_UNICAST;