From 5f9c4eec3c69bb08684969ea118a1eb00cf8dd1b Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Tue, 12 Feb 2013 10:11:15 +0100 Subject: [PATCH 1/5] [2704] Use the selectSubnet() subnet function to pick the suitable subnet. The selectSubnet() function offers two ways to find a subnet for a particular interface: using the name of the interface that the subnet is configured for; and using the packet source address. Also, the redundant warning is removed if suitable subnet was not found as this warning is already issued elsewhere. --- src/bin/dhcp6/dhcp6_messages.mes | 12 ------------ src/bin/dhcp6/dhcp6_srv.cc | 24 ++++++++---------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 65ad74b720..ff3868962f 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -132,18 +132,6 @@ IPv6 DHCP server but it is not running. During startup the IPv6 DHCP server failed to detect any network interfaces and is therefore shutting down. -% DHCP6_NO_SUBNET_DEF_OPT failed to find subnet for address %1 when adding default options -This warning message indicates that when attempting to add default options -to a response, the server found that it was not configured to support -the subnet from which the DHCPv6 request was received. The packet has -been ignored. - -% DHCP6_NO_SUBNET_REQ_OPT failed to find subnet for address %1 when adding requested options -This warning message indicates that when attempting to add requested -options to a response, the server found that it was not configured -to support the subnet from which the DHCPv6 request was received. -The packet has been ignored. - % DHCP6_OPEN_SOCKET opening sockets on port %1 A debug message issued during startup, this indicates that the IPv6 DHCP server is about to open sockets on the specified port. diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 851f405de3..01e554cecb 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -393,29 +393,21 @@ Dhcpv6Srv::copyDefaultOptions(const Pkt6Ptr& question, Pkt6Ptr& answer) { } void -Dhcpv6Srv::appendDefaultOptions(const Pkt6Ptr& question, Pkt6Ptr& answer) { +Dhcpv6Srv::appendDefaultOptions(const Pkt6Ptr&, Pkt6Ptr& answer) { // add server-id answer->addOption(getServerID()); - - // Get the subnet object. It holds options to be sent to the client - // that belongs to the particular subnet. - Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(question->getRemoteAddr()); - // Warn if subnet is not supported and quit. - if (!subnet) { - LOG_WARN(dhcp6_logger, DHCP6_NO_SUBNET_DEF_OPT) - .arg(question->getRemoteAddr().toText()); - return; - } - } void Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer) { - // Get the subnet for a particular address. - Subnet6Ptr subnet = CfgMgr::instance().getSubnet6(question->getRemoteAddr()); + // Get the configured subnet suitable for the incoming packet. + Subnet6Ptr subnet = selectSubnet(question); + // Leave if there is no subnet matching the incoming packet. + // There is no need to log the error message here because + // it will be logged in the assignLease() when it fails to + // pick the suitable subnet. We don't want to duplicate + // error messages in such case. if (!subnet) { - LOG_WARN(dhcp6_logger, DHCP6_NO_SUBNET_REQ_OPT) - .arg(question->getRemoteAddr().toText()); return; } From b57fc0894581ef07334a8f6c5bd0a6129d5289a1 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Tue, 12 Feb 2013 15:24:57 +0200 Subject: [PATCH 2/5] [2719] Emergency fix for renew when there are no subnets configured. --- ChangeLog | 5 +++++ src/bin/dhcp6/dhcp6_messages.mes | 10 ++++++++++ src/bin/dhcp6/dhcp6_srv.cc | 19 ++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d9b0ee171a..4edcc8b0c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +5XX. [bug] tmark, tomek + b10-dhcp6: Server aborts operation when receiving renew and there + are no IPv6 subnets configured. + (Trac 2719, git TBD) + 573. [bug] stephen Fixed problem whereby the DHCP server crashed if it ran out of addresses. Such a condition now causes a packet to be returned diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index a2fee47e83..905c57f77c 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -222,6 +222,16 @@ as a hint for possible requested address. % DHCP6_QUERY_DATA received packet length %1, data length %2, data is %3 A debug message listing the data received from the client or relay. +% DHCP6_RENEW_UNKNOWN_SUBNET RENEW message received from client on unknown subnet (duid=%1, iaid=%2) +A warning message indicating that a client is attempting to renew his lease, +but the server does not have any information about the subnet this client belongs +to. This may mean that faulty the mobile client changed its location and is trying to +renew its old address (client is supposed to send confirm, not rewew in such cases, +according to RFC3315) or the server configuration has changed and information about +existing subnet was removed. Note that in a sense this is worse case of DHCP6_UNKNOWN_RENEW, +as not only the lease is unknown, but also the subnet is. Depending on the reasons +of this condition, it may or may not correct on its own. + % DHCP6_REQUIRED_OPTIONS_CHECK_FAIL %1 message received from %2 failed the following check: %3 This message indicates that received DHCPv6 packet is invalid. This may be due to a number of reasons, e.g. the mandatory client-id option is missing, diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index b37e003910..3a5eec5661 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -714,6 +714,21 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid, OptionPtr Dhcpv6Srv::renewIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid, Pkt6Ptr /* question */, boost::shared_ptr ia) { + if (!subnet) { + // There's no subnet select for this client. There's nothing to renew. + boost::shared_ptr ia_rsp(new Option6IA(D6O_IA_NA, ia->getIAID())); + + // Insert status code NoAddrsAvail. + ia_rsp->addOption(createStatusCode(STATUS_NoBinding, + "Sorry, no known leases for this duid/iaid.")); + + LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_RENEW_UNKNOWN_SUBNET) + .arg(duid->toText()) + .arg(ia->getIAID()); + + return (ia_rsp); + } + Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(*duid, ia->getIAID(), subnet->getID()); @@ -777,7 +792,9 @@ Dhcpv6Srv::renewLeases(const Pkt6Ptr& renew, Pkt6Ptr& reply) { // perhaps this should be logged on some higher level? This is most likely // configuration bug. - LOG_ERROR(dhcp6_logger, DHCP6_SUBNET_SELECTION_FAILED); + LOG_ERROR(dhcp6_logger, DHCP6_SUBNET_SELECTION_FAILED) + .arg(renew->getRemoteAddr().toText()) + .arg(renew->getName()); } else { LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL_DATA, DHCP6_SUBNET_SELECTED) .arg(subnet->toText()); From 4982a87469884b80b077ec4ad9dc5445aeea6dc3 Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Tue, 12 Feb 2013 16:28:45 +0100 Subject: [PATCH 3/5] [master] Added a ChangeLog entry for #2704. Also, trivial change: removed spurious brackets in the previous entry. --- ChangeLog | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b30c17a05..31c3c1fcc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,18 @@ -574. [func] tmark +575. [bug] marcin + b10-dhcp6: Fixed the bug whereby the subnet for the incoming + packet was selected using only its source address. The subnet + is now selected using either source address or the name of the + server's interface on which the packet has been received. + (Trac #2704, git 1cbacf19a28bdae50bb9bd3767bca0147fde37ed) + +574. [func] tmark b10-dhcp4, b10-dhcp6: Composite key indexes were added to the lease tables to reduce lease search time. The lease4 table now has two additional indexes: a) hwaddr/subnet_id and b) client_id/subnet_id. The lease6 now has the one additional index: iaid/subnet_id/duid. Adding these indexes significantly improves lease acquisition performance. - (Trac #2699,#2703, git 54bbed5fcbe237c5a49b515ae4c55148723406ce)}}} + (Trac #2699,#2703, git 54bbed5fcbe237c5a49b515ae4c55148723406ce) 573. [bug] stephen Fixed problem whereby the DHCP server crashed if it ran out of From 3132b8b19495470bbfd0f2ba0fe7da443926034b Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Tue, 12 Feb 2013 16:58:48 +0100 Subject: [PATCH 4/5] [2719] Adjusted logging level, unnecessary comments removed. --- src/bin/dhcp6/dhcp6_srv.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 3a5eec5661..c2e743cd14 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -564,9 +564,7 @@ Dhcpv6Srv::assignLeases(const Pkt6Ptr& question, Pkt6Ptr& answer) { // thing this client can get is some global information (like DNS // servers). - // perhaps this should be logged on some higher level? This is most likely - // configuration bug. - LOG_ERROR(dhcp6_logger, DHCP6_SUBNET_SELECTION_FAILED) + LOG_WARN(dhcp6_logger, DHCP6_SUBNET_SELECTION_FAILED) .arg(question->getRemoteAddr().toText()) .arg(question->getName()); @@ -790,9 +788,7 @@ Dhcpv6Srv::renewLeases(const Pkt6Ptr& renew, Pkt6Ptr& reply) { // thing this client can get is some global information (like DNS // servers). - // perhaps this should be logged on some higher level? This is most likely - // configuration bug. - LOG_ERROR(dhcp6_logger, DHCP6_SUBNET_SELECTION_FAILED) + LOG_WARN(dhcp6_logger, DHCP6_SUBNET_SELECTION_FAILED) .arg(renew->getRemoteAddr().toText()) .arg(renew->getName()); } else { From 70632300d70401c696161dff39ad126ff98663df Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Tue, 12 Feb 2013 23:21:08 +0530 Subject: [PATCH 5/5] [master] Add missing ChangeLog entry for #1756 --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index f57ae6b893..4e31a75763 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +577. [func] muks + Added an SQLite3 index on records(rname, rdtype). This decreases + insert performance by ~28% and adds about ~20% to the file size, + but increases zone iteration performance. As it introduces a new + index, a database upgrade would be required. + (Trac #1756, git 9b3c959af13111af1fa248c5010aa33ee7e307ee) + 576. [bug] tmark, tomek b10-dhcp6: Fixed bug when the server aborts operation when receiving renew and there are no IPv6 subnets configured.