Skip to content

Commit 73fe603

Browse files
committed
[#4443] Changed to reset N
1 parent ada7e88 commit 73fe603

7 files changed

Lines changed: 29 additions & 15 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[func] fdupont
22
Extended lenient parsing of v4 "fqdn" and v6 "client-fqdn"
3-
options to skip options with bad flags.
3+
options to fix options with bad flags.
44
(Gitlab #4443)

doc/sphinx/arm/dhcp4-srv.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8872,7 +8872,8 @@ or in terms of the log message above, the tuple length ``y`` becomes ``x``.
88728872
88738873
Starting with Kea version 2.5.8, this parsing is extended to silently ignore
88748874
FQDN (81) options with some invalid domain names, and starting with Kea
8875-
version 3.1.9 with invalid flags (i.e. 'S" and 'N' flags set to 1).
8875+
version 3.1.9 to fix invalid flags, i.e. when 'S' and 'N' flags set to 1
8876+
the 'N' flag is reset to 0 for compatibility with ISC DHCP behavior.
88768877

88778878
Ignore DHCP Server Identifier
88788879
-----------------------------

doc/sphinx/arm/dhcp6-srv.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8740,7 +8740,8 @@ MiNID.
87408740
87418741
Starting with Kea version 2.5.8, this parsing is extended to silently ignore
87428742
client-fqdn (39) options with some invalid domain names, and starting with Kea
8743-
version 3.1.9 with invalid flags (i.e. 'S" and 'N' flags set to 1).
8743+
version 3.1.9 to fix invalid flags, i.e. when 'S' and 'N' flags set to 1
8744+
the 'N' flag is reset to 0 for compatibility with ISC DHCP behavior.
87448745

87458746
.. _dhcp6_allocation_strategies:
87468747

src/lib/dhcp/option4_client_fqdn.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Option4ClientFqdnImpl::Option4ClientFqdnImpl(OptionBufferConstIter first,
153153
checkFlags(flags_, false);
154154
} catch (const InvalidOption4FqdnFlags& ex) {
155155
if (Option::lenient_parsing_) {
156-
isc_throw(SkipThisOptionError, ex.what());
156+
flags_ &= ~Option4ClientFqdn::FLAG_N;
157157
} else {
158158
throw;
159159
}
@@ -521,7 +521,7 @@ Option4ClientFqdn::unpack(OptionBufferConstIter first,
521521
impl_->checkFlags(impl_->flags_, false);
522522
} catch (const InvalidOption4FqdnFlags& ex) {
523523
if (Option::lenient_parsing_) {
524-
isc_throw(SkipThisOptionError, ex.what());
524+
impl_->flags_ &= ~Option4ClientFqdn::FLAG_N;
525525
} else {
526526
throw;
527527
}

src/lib/dhcp/option6_client_fqdn.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Option6ClientFqdnImpl::Option6ClientFqdnImpl(OptionBufferConstIter first,
126126
checkFlags(flags_, false);
127127
} catch (const InvalidOption6FqdnFlags& ex) {
128128
if (Option::lenient_parsing_) {
129-
isc_throw(SkipThisOptionError, ex.what());
129+
flags_ &= ~Option6ClientFqdn::FLAG_N;
130130
} else {
131131
throw;
132132
}
@@ -441,7 +441,7 @@ Option6ClientFqdn::unpack(OptionBufferConstIter first,
441441
impl_->checkFlags(impl_->flags_, false);
442442
} catch (const InvalidOption6FqdnFlags& ex) {
443443
if (Option::lenient_parsing_) {
444-
isc_throw(SkipThisOptionError, ex.what());
444+
impl_->flags_ &= ~Option6ClientFqdn::FLAG_N;
445445
} else {
446446
throw;
447447
}

src/lib/dhcp/tests/option4_client_fqdn_unittest.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,13 @@ TEST(Option4ClientFqdnTest, constructFromWireInvalidFlags) {
462462
LenientOptionParsing lop(false);
463463
EXPECT_THROW(Option4ClientFqdn(in_buf.begin(), in_buf.end()),
464464
InvalidOption4FqdnFlags);
465+
// Lenient parsing allows this but reset the N bit.
465466
Option::lenient_parsing_ = true;
466-
EXPECT_THROW(Option4ClientFqdn(in_buf.begin(), in_buf.end()),
467-
SkipThisOptionError);
467+
boost::scoped_ptr<Option4ClientFqdn> option;
468+
EXPECT_NO_THROW(option.reset(new Option4ClientFqdn(in_buf.begin(), in_buf.end())));
469+
ASSERT_TRUE(option);
470+
EXPECT_TRUE(option->getFlag(Option4ClientFqdn::FLAG_S));
471+
EXPECT_FALSE(option->getFlag(Option4ClientFqdn::FLAG_N));
468472
}
469473

470474
// This test verifies that if invalid domain name is used the constructor
@@ -844,9 +848,11 @@ TEST(Option4ClientFqdnTest, unpack) {
844848
LenientOptionParsing lop(false);
845849
EXPECT_THROW(option->unpack(in_buf.begin(), in_buf.end()),
846850
InvalidOption4FqdnFlags);
851+
// Lenient parsing allows bad flags but reset the N bit.
847852
Option::lenient_parsing_ = true;
848-
EXPECT_THROW(option->unpack(in_buf.begin(), in_buf.end()),
849-
SkipThisOptionError);
853+
ASSERT_NO_THROW(option->unpack(in_buf.begin(), in_buf.end()));
854+
EXPECT_TRUE(option->getFlag(Option4ClientFqdn::FLAG_S));
855+
EXPECT_FALSE(option->getFlag(Option4ClientFqdn::FLAG_N));
850856
}
851857

852858
// This test verifies that on-wire option data holding partial domain name

src/lib/dhcp/tests/option6_client_fqdn_unittest.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,13 @@ TEST(Option6ClientFqdnTest, constructFromWireInvalidFlags) {
413413
LenientOptionParsing lop(false);
414414
EXPECT_THROW(Option6ClientFqdn(in_buf.begin(), in_buf.end()),
415415
InvalidOption6FqdnFlags);
416+
// Lenient parsing allows this but reset the N bit.
416417
Option::lenient_parsing_ = true;
417-
EXPECT_THROW(Option6ClientFqdn(in_buf.begin(), in_buf.end()),
418-
SkipThisOptionError);
418+
boost::scoped_ptr<Option6ClientFqdn> option;
419+
EXPECT_NO_THROW(option.reset(new Option6ClientFqdn(in_buf.begin(), in_buf.end())));
420+
ASSERT_TRUE(option);
421+
EXPECT_TRUE(option->getFlag(Option6ClientFqdn::FLAG_S));
422+
EXPECT_FALSE(option->getFlag(Option6ClientFqdn::FLAG_N));
419423
}
420424

421425
// This test verifies that if invalid domain name is used the constructor
@@ -712,9 +716,11 @@ TEST(Option6ClientFqdnTest, unpack) {
712716
LenientOptionParsing lop(false);
713717
EXPECT_THROW(option->unpack(in_buf.begin(), in_buf.end()),
714718
InvalidOption6FqdnFlags);
719+
// Lenient parsing allows bad flags but reset the N bit.
715720
Option::lenient_parsing_ = true;
716-
EXPECT_THROW(option->unpack(in_buf.begin(), in_buf.end()),
717-
SkipThisOptionError);
721+
ASSERT_NO_THROW(option->unpack(in_buf.begin(), in_buf.end()));
722+
EXPECT_TRUE(option->getFlag(Option6ClientFqdn::FLAG_S));
723+
EXPECT_FALSE(option->getFlag(Option6ClientFqdn::FLAG_N));
718724
}
719725

720726
// This test verifies that on-wire option data holding partial domain name

0 commit comments

Comments
 (0)