Browse Source

[5307] DHCPv6 server uses reserved client classes in shared network case.

Marcin Siodelski 7 years ago
parent
commit
4b7b40a2eb
2 changed files with 11 additions and 4 deletions
  1. 10 4
      src/bin/dhcp6/dhcp6_srv.cc
  2. 1 0
      src/bin/dhcp6/tests/shared_network_unittest.cc

+ 10 - 4
src/bin/dhcp6/dhcp6_srv.cc

@@ -912,10 +912,12 @@ Dhcpv6Srv::buildCfgOptionList(const Pkt6Ptr& question,
             // Skip it
             continue;
         }
+
         if (ccdef->getCfgOption()->empty()) {
             // Skip classes which don't configure options
             continue;
         }
+
         co_list.push_back(ccdef->getCfgOption());
     }
 
@@ -2441,7 +2443,6 @@ Dhcpv6Srv::processSolicit(const Pkt6Ptr& solicit) {
     // Let's create a simplified client context here.
     AllocEngine::ClientContext6 ctx;
     initContext(solicit, ctx);
-    setReservedClientClasses(solicit, ctx);
 
     Pkt6Ptr response(new Pkt6(DHCPV6_ADVERTISE, solicit->getTransid()));
 
@@ -2463,6 +2464,8 @@ Dhcpv6Srv::processSolicit(const Pkt6Ptr& solicit) {
     processClientFqdn(solicit, response, ctx);
     assignLeases(solicit, response, ctx);
 
+    setReservedClientClasses(solicit, ctx);
+
     copyClientOptions(solicit, response);
     CfgOptionList co_list;
     buildCfgOptionList(solicit, ctx, co_list);
@@ -2489,13 +2492,14 @@ Dhcpv6Srv::processRequest(const Pkt6Ptr& request) {
     // Let's create a simplified client context here.
     AllocEngine::ClientContext6 ctx;
     initContext(request, ctx);
-    setReservedClientClasses(request, ctx);
 
     Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, request->getTransid()));
 
     processClientFqdn(request, reply, ctx);
     assignLeases(request, reply, ctx);
 
+    setReservedClientClasses(request, ctx);
+
     copyClientOptions(request, reply);
     CfgOptionList co_list;
     buildCfgOptionList(request, ctx, co_list);
@@ -2518,13 +2522,14 @@ Dhcpv6Srv::processRenew(const Pkt6Ptr& renew) {
     // Let's create a simplified client context here.
     AllocEngine::ClientContext6 ctx;
     initContext(renew, ctx);
-    setReservedClientClasses(renew, ctx);
 
     Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, renew->getTransid()));
 
     processClientFqdn(renew, reply, ctx);
     extendLeases(renew, reply, ctx);
 
+    setReservedClientClasses(renew, ctx);
+
     copyClientOptions(renew, reply);
     CfgOptionList co_list;
     buildCfgOptionList(renew, ctx, co_list);
@@ -2547,13 +2552,14 @@ Dhcpv6Srv::processRebind(const Pkt6Ptr& rebind) {
     // Let's create a simplified client context here.
     AllocEngine::ClientContext6 ctx;
     initContext(rebind, ctx);
-    setReservedClientClasses(rebind, ctx);
 
     Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, rebind->getTransid()));
 
     processClientFqdn(rebind, reply, ctx);
     extendLeases(rebind, reply, ctx);
 
+    setReservedClientClasses(rebind, ctx);
+
     copyClientOptions(rebind, reply);
     CfgOptionList co_list;
     buildCfgOptionList(rebind, ctx, co_list);

+ 1 - 0
src/bin/dhcp6/tests/shared_network_unittest.cc

@@ -1097,6 +1097,7 @@ TEST_F(Dhcpv6SharedNetworkTest, variousFieldsInReservation) {
     client.setInterface("eth1");
     client.setDUID("00:03:00:01:11:22:33:44:55:66");
     ASSERT_NO_THROW(client.requestAddress(0xabcd));
+    ASSERT_NO_THROW(client.requestOption(D6O_NAME_SERVERS));
 
     ASSERT_NO_THROW(client.useFQDN(Option6ClientFqdn::FLAG_S,
                                    "bird.example.org",