]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1112] Include client-supplied ciaddr in dhcpinform ack
authorThomas Markwalder <tmark@isc.org>
Tue, 4 Feb 2020 18:28:10 +0000 (13:28 -0500)
committerThomas Markwalder <tmark@isc.org>
Tue, 11 Feb 2020 16:39:57 +0000 (11:39 -0500)
Backport #992 changes to v1_6_0

Changes:
    ChangeLog
    src/bin/dhcp4/dhcp4_srv.cc
    src/bin/dhcp4/tests/inform_unittest.cc

ChangeLog
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/tests/inform_unittest.cc

index 2190483d8b5de3dcb29497d23a8c0a84a9ba964f..afa734d36bde77bc9930276078c25faf974842f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1663.  [func]          tmark
+       Client supplied ciaddr is now sent back when responding to
+       DHCPINFORM
+       (Gitlab #1112,#992)
+
 1662.  [bug]           tmark
        kea-dhcp4 and kea-dhcp6 now shutdown gracefully by executing
        the shutdown command, if connectivity with a backend database
index d6614f737b0da06c5f951756029f6197e94dbcf2..98f66725234d35183ff4079df7d82a8c29bf198c 100644 (file)
@@ -243,9 +243,13 @@ Dhcpv4Exchange::copyDefaultFields() {
 
     // explicitly set this to 0
     resp_->setSiaddr(IOAddress::IPV4_ZERO_ADDRESS());
-    // ciaddr is always 0, except for the Renew/Rebind state when it may
-    // be set to the ciaddr sent by the client.
-    resp_->setCiaddr(IOAddress::IPV4_ZERO_ADDRESS());
+    // ciaddr is always 0, except for the Renew/Rebind state and for
+    // Inform when it may be set to the ciaddr sent by the client.
+    if (query_->getType() == DHCPINFORM) {
+        resp_->setCiaddr(query_->getCiaddr());
+    } else {
+        resp_->setCiaddr(IOAddress::IPV4_ZERO_ADDRESS());
+    }
     resp_->setHops(query_->getHops());
 
     // copy MAC address
index 42a5cfe31bcb73b05af6d6dd22781bb69c95ecfc..1be526b4c3e18fed6c4e324390695f7e51ac729b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -175,6 +175,8 @@ TEST_F(InformTest, directClientBroadcast) {
     ASSERT_EQ(DHCPACK, static_cast<int>(resp->getType()));
     // Response should have been unicast to the ciaddr.
     EXPECT_EQ(IOAddress("10.0.0.56"), resp->getLocalAddr());
+    // The ciaddr should have been copied.
+    EXPECT_EQ(IOAddress("10.0.0.56"), resp->getCiaddr());
     // Response must not be relayed.
     EXPECT_FALSE(resp->isRelayed());
     // Make sure that the server id is present.
@@ -214,6 +216,8 @@ TEST_F(InformTest, directClientBroadcast) {
     ASSERT_EQ(DHCPACK, static_cast<int>(resp->getType()));
     // Response should have been unicast to the ciaddr.
     EXPECT_EQ(IOAddress("10.0.0.12"), resp->getLocalAddr());
+    // The ciaddr should have been copied.
+    EXPECT_EQ(IOAddress("10.0.0.12"), resp->getCiaddr());
     // Response must not be relayed.
     EXPECT_FALSE(resp->isRelayed());
 
@@ -265,6 +269,8 @@ TEST_F(InformTest, directClientUnicast) {
     ASSERT_EQ(DHCPACK, static_cast<int>(resp->getType()));
     // Response should have been unicast to the ciaddr.
     EXPECT_EQ(IOAddress("10.0.0.56"), resp->getLocalAddr());
+    // The ciaddr should have been copied.
+    EXPECT_EQ(IOAddress("10.0.0.56"), resp->getCiaddr());
     // Response must not be relayed.
     EXPECT_FALSE(resp->isRelayed());
     // Make sure that the server id is present.
@@ -295,8 +301,10 @@ TEST_F(InformTest, directClientNoCiaddr) {
     Pkt4Ptr resp = client.getContext().response_;
     // Make sure that the server has responded with DHCPACK.
     ASSERT_EQ(DHCPACK, static_cast<int>(resp->getType()));
-    // Response should have been unicast to the ciaddr.
+    // Response should have been unicast to the client address.
     EXPECT_EQ(IOAddress("10.0.0.56"), resp->getLocalAddr());
+    // The ciaddr should be 0.
+    EXPECT_EQ(IOAddress("0.0.0.0"), resp->getCiaddr());
     // Response must not be relayed.
     EXPECT_FALSE(resp->isRelayed());
     EXPECT_EQ(DHCP4_CLIENT_PORT, resp->getLocalPort());
@@ -334,6 +342,8 @@ TEST_F(InformTest, relayedClient) {
     ASSERT_EQ(DHCPACK, static_cast<int>(resp->getType()));
     // Response should have been unicast to the ciaddr.
     EXPECT_EQ(IOAddress("192.0.2.56"), resp->getLocalAddr());
+    // The ciaddr should have been copied.
+    EXPECT_EQ(IOAddress("192.0.2.56"), resp->getCiaddr());
     // Response is unicast to the client, so it must not be relayed.
     EXPECT_FALSE(resp->isRelayed());
     EXPECT_EQ(DHCP4_CLIENT_PORT, resp->getLocalPort());