From 37196e0a98db4666f8fa16bf7164d8f072a22790 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Tue, 19 Nov 2019 07:01:12 +0100 Subject: [PATCH 1/2] [992-include-the-client-supplied-ciaddr-when-acking-dhcpinform] Copy ciaddr to inform responses --- src/bin/dhcp4/dhcp4_srv.cc | 10 +++++++--- src/bin/dhcp4/tests/inform_unittest.cc | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 1b4b155561..8d9691c134 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -264,9 +264,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 diff --git a/src/bin/dhcp4/tests/inform_unittest.cc b/src/bin/dhcp4/tests/inform_unittest.cc index 42a5cfe31b..1be526b4c3 100644 --- a/src/bin/dhcp4/tests/inform_unittest.cc +++ b/src/bin/dhcp4/tests/inform_unittest.cc @@ -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(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(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(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(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(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()); -- GitLab From 11fac400c28a65909b494d2d38b610de90589571 Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Mon, 9 Dec 2019 20:07:47 +0100 Subject: [PATCH 2/2] [#992] ChangeLog added --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 781b4dd775..5e16bc4595 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1693. [func] fdupont + Client supplied ciaddr is now sent back when responding to + DHCPINFORM + (Gitlab #992) + 1692. [build] fdupont Better support for google test 1.10.0. (Gitlab #954) -- GitLab