Skip to content

Commit c217732

Browse files
committed
[#3683] Some improvements
1 parent 845483a commit c217732

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

src/bin/dhcp6/dhcp6_messages.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ const char* values[] = {
184184
"DHCP6_ADDITIONAL_CLASS_EVAL_RESULT", "%1: Expression '%2' evaluated to %3",
185185
"DHCP6_ADDITIONAL_CLASS_NO_TEST", "additional class %1 has no test expression, adding it to client's classes unconditionally",
186186
"DHCP6_ADDITIONAL_CLASS_UNDEFINED", "additional class %1 has no definition",
187-
"DHCP6_ADDR_REG_INFORM_CLIENT_CHANGE", "received an addr-reg-inform for %1 from client '%2' but the address was registered by another client '%3'",
188-
"DHCP6_ADDR_REG_INFORM_FAIL", "error on addr-reg-inform from client %1: %2",
187+
"DHCP6_ADDR_REG_INFORM_CLIENT_CHANGE", "received an ADDR-REG-INFORM for %1 from client '%2' but the address was registered by another client '%3'",
188+
"DHCP6_ADDR_REG_INFORM_FAIL", "error on ADDR-REG-INFORM from client %1: %2",
189189
"DHCP6_ADD_GLOBAL_STATUS_CODE", "%1: adding Status Code to DHCPv6 packet: %2",
190190
"DHCP6_ADD_STATUS_CODE_FOR_IA", "%1: adding Status Code to IA with iaid=%2: %3",
191191
"DHCP6_ALREADY_RUNNING", "%1 already running? %2",
@@ -237,7 +237,7 @@ const char* values[] = {
237237
"DHCP6_DYNAMIC_RECONFIGURATION_FAIL", "dynamic server reconfiguration failed with file: %1",
238238
"DHCP6_DYNAMIC_RECONFIGURATION_SUCCESS", "dynamic server reconfiguration succeeded with file: %1",
239239
"DHCP6_FLEX_ID", "%1: flexible identifier generated for incoming packet: %2",
240-
"DHCP6_HOOK_ADDR6_REGISTER_SKIP", "%1: addr-reg-inform for %2 is dropped, because a callout set the next step to SKIP",
240+
"DHCP6_HOOK_ADDR6_REGISTER_SKIP", "%1: ADDR-REG-INFORM for %2 is dropped, because a callout set the next step to SKIP",
241241
"DHCP6_HOOK_BUFFER_RCVD_DROP", "received buffer from %1 to %2 over interface %3 was dropped because a callout set the drop flag",
242242
"DHCP6_HOOK_BUFFER_RCVD_SKIP", "received buffer from %1 to %2 over interface %3 is not parsed because a callout set the next step to SKIP",
243243
"DHCP6_HOOK_BUFFER_SEND_SKIP", "%1: prepared DHCPv6 response was dropped because a callout set the next step to SKIP",

src/bin/dhcp6/tests/addr_reg_unittest.cc

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ TEST_F(AddrRegTest, sanityCheck) {
262262
EXPECT_FALSE(srv_.sanityCheck(addr_reg_inf));
263263
}
264264

265+
// Test that more than one client-id are forbidden for Addr-reg-inform messages
266+
TEST_F(AddrRegTest, sanityCheck2) {
267+
Pkt6Ptr addr_reg_inf = Pkt6Ptr(new Pkt6(DHCPV6_ADDR_REG_INFORM, 1234));
268+
269+
// A message with more than one client-id options should fail.
270+
OptionPtr clientid = generateClientId();
271+
addr_reg_inf->addOption(clientid);
272+
addr_reg_inf->addOption(clientid);
273+
EXPECT_FALSE(srv_.sanityCheck(addr_reg_inf));
274+
}
275+
265276
// Test that subnet selection must return a subnet for processAddrRegInform.
266277
TEST_F(AddrRegTest, noSubnet) {
267278
Pkt6Ptr addr_reg_inf = Pkt6Ptr(new Pkt6(DHCPV6_ADDR_REG_INFORM, 1234));
@@ -312,7 +323,7 @@ TEST_F(AddrRegTest, noIA_NA) {
312323
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
313324

314325
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
315-
expected += "error on addr-reg-inform from client fe80::abcd: ";
326+
expected += "error on ADDR-REG-INFORM from client fe80::abcd: ";
316327
expected += "Exactly 1 IA_NA option expected, but 0 received";
317328
EXPECT_EQ(1, countFile(expected));
318329
}
@@ -346,7 +357,7 @@ TEST_F(AddrRegTest, twoIA_NAs) {
346357
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
347358

348359
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
349-
expected += "error on addr-reg-inform from client fe80::abcd: ";
360+
expected += "error on ADDR-REG-INFORM from client fe80::abcd: ";
350361
expected += "Exactly 1 IA_NA option expected, but 2 received";
351362
EXPECT_EQ(1, countFile(expected));
352363
}
@@ -379,7 +390,7 @@ TEST_F(AddrRegTest, noIA_NAsub) {
379390
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
380391

381392
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
382-
expected += "error on addr-reg-inform from client fe80::abcd: ";
393+
expected += "error on ADDR-REG-INFORM from client fe80::abcd: ";
383394
expected += "Exactly 1 IA_NA sub-option expected, but 0 received";
384395
EXPECT_EQ(1, countFile(expected));
385396
}
@@ -415,7 +426,7 @@ TEST_F(AddrRegTest, twoIA_NAsub) {
415426
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
416427

417428
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
418-
expected += "error on addr-reg-inform from client fe80::abcd: ";
429+
expected += "error on ADDR-REG-INFORM from client fe80::abcd: ";
419430
expected += "Exactly 1 IA_NA sub-option expected, but 2 received";
420431
EXPECT_EQ(1, countFile(expected));
421432
}
@@ -450,7 +461,7 @@ TEST_F(AddrRegTest, noAddrMatch) {
450461
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
451462

452463
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
453-
expected += "error on addr-reg-inform from client fe80::abcd: ";
464+
expected += "error on ADDR-REG-INFORM from client fe80::abcd: ";
454465
expected += "Address mismatch: client at fe80::abcd ";
455466
expected += "wants to register 2001:db8:1::1";
456467
EXPECT_EQ(1, countFile(expected));
@@ -492,7 +503,7 @@ TEST_F(AddrRegTest, noAddrMatchRelay) {
492503
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
493504

494505
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
495-
expected += "error on addr-reg-inform from client fe80::ef01: ";
506+
expected += "error on ADDR-REG-INFORM from client fe80::ef01: ";
496507
expected += "Address mismatch: client at fe80::ef01 ";
497508
expected += "wants to register 2001:db8:1::1";
498509
EXPECT_EQ(1, countFile(expected));
@@ -540,7 +551,7 @@ TEST_F(AddrRegTest, noAddrMatch2Relays) {
540551
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
541552

542553
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
543-
expected += "error on addr-reg-inform from client fe80::2345: ";
554+
expected += "error on ADDR-REG-INFORM from client fe80::2345: ";
544555
expected += "Address mismatch: client at fe80::2345 ";
545556
expected += "wants to register 2001:db8:1::1";
546557
EXPECT_EQ(1, countFile(expected));
@@ -576,7 +587,7 @@ TEST_F(AddrRegTest, noInSubnet) {
576587
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
577588

578589
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
579-
expected += "error on addr-reg-inform from client 2001:db8::1: ";
590+
expected += "error on ADDR-REG-INFORM from client 2001:db8::1: ";
580591
expected += "Address 2001:db8::1 is not in subnet ";
581592
expected += "2001:db8:1::/64 (id 1)";
582593
EXPECT_EQ(1, countFile(expected));
@@ -612,7 +623,7 @@ TEST_F(AddrRegTest, reserved) {
612623
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
613624

614625
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
615-
expected += "error on addr-reg-inform from client 2001:db8:1::10: ";
626+
expected += "error on ADDR-REG-INFORM from client 2001:db8:1::10: ";
616627
expected += "Address 2001:db8:1::10 is reserved";
617628
EXPECT_EQ(1, countFile(expected));
618629
}
@@ -655,7 +666,7 @@ AddrRegTest::testAddressInUse(const uint32_t state) {
655666
EXPECT_FALSE(srv_.processAddrRegInform(ctx));
656667

657668
string expected = "DHCP6_ADDR_REG_INFORM_FAIL ";
658-
expected += "error on addr-reg-inform from client 2001:db8:1::1: ";
669+
expected += "error on ADDR-REG-INFORM from client 2001:db8:1::1: ";
659670
expected += "Address 2001:db8:1::1 already in use Type:";
660671
EXPECT_EQ(1, countFile(expected));
661672
}
@@ -942,7 +953,7 @@ AddrRegTest::testAnother() {
942953
expected += "updating IPv6 lease for address 2001:db8:1::1";
943954
EXPECT_EQ(1, countFile(expected));
944955
expected = "DHCP6_ADDR_REG_INFORM_CLIENT_CHANGE ";
945-
expected += "received an addr-reg-inform for 2001:db8:1::1 from client '";
956+
expected += "received an ADDR-REG-INFORM for 2001:db8:1::1 from client '";
946957
expected += duid_->toText();
947958
expected += "' but the address was registered by another client ";
948959
expected += "'44:44:44:44:44:44:44:44'";
@@ -1480,6 +1491,8 @@ TEST_F(AddrRegTest, stats) {
14801491
static_cast<int64_t>(5));
14811492
StatsMgr::instance().setValue(cumulative_registered_nas_name_,
14821493
static_cast<int64_t>(10));
1494+
StatsMgr::instance().setValue("cumulative-registered-nas",
1495+
static_cast<int64_t>(20));
14831496

14841497
testBasic();
14851498

@@ -1491,6 +1504,8 @@ TEST_F(AddrRegTest, stats) {
14911504
stat = StatsMgr::instance().getObservation(cumulative_registered_nas_name_);
14921505
ASSERT_TRUE(stat);
14931506
EXPECT_EQ(11, stat->getInteger().first);
1507+
stat = StatsMgr::instance().getObservation("cumulative-registered-nas");
1508+
EXPECT_EQ(21, stat->getInteger().first);
14941509
}
14951510

14961511
// Check the statictics for the renew scenario.
@@ -1503,6 +1518,8 @@ TEST_F(AddrRegTest, statsRenew) {
15031518
static_cast<int64_t>(5));
15041519
StatsMgr::instance().setValue(cumulative_registered_nas_name_,
15051520
static_cast<int64_t>(10));
1521+
StatsMgr::instance().setValue("cumulative-registered-nas",
1522+
static_cast<int64_t>(20));
15061523

15071524
testRenew();
15081525

@@ -1514,6 +1531,8 @@ TEST_F(AddrRegTest, statsRenew) {
15141531
stat = StatsMgr::instance().getObservation(cumulative_registered_nas_name_);
15151532
ASSERT_TRUE(stat);
15161533
EXPECT_EQ(10, stat->getInteger().first);
1534+
stat = StatsMgr::instance().getObservation("cumulative-registered-nas");
1535+
EXPECT_EQ(20, stat->getInteger().first);
15171536
}
15181537

15191538
} // end of anonymous namespace

0 commit comments

Comments
 (0)