2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 13:37:55 +00:00

[#2543] Add RAI Link Selection preferences

This commit is contained in:
Dan Theisen 2022-09-21 03:34:04 -07:00
parent a21c75b673
commit e91c44cfdb
8 changed files with 58 additions and 13 deletions

View File

@ -105,7 +105,11 @@
"compatibility": {
// Parse options more leniently where fields can be deduced
// deterministically even if against RFC or common practice.
"lenient-option-parsing": true
"lenient-option-parsing": true,
// Ignore Relay Agent Information Link Selection suboption if set
// to true. This will use normal subnet selection logic instead of
// attempting to use the subnet specified by the suboption.
"ignore-rai-link-selection": false
},
// Command control socket configuration parameters for Kea DHCPv4 server.

View File

@ -105,7 +105,11 @@
"compatibility": {
// Parse options more leniently where fields can be deduced
// deterministically even if against RFC or common practice.
"lenient-option-parsing": true
"lenient-option-parsing": true,
// Ignore Relay Agent Information Link Selection suboption if set
// to true. This will use normal subnet selection logic instead of
// attempting to use the subnet specified by the suboption.
"ignore-rai-link-selection": false
},
// Command control socket configuration parameters for Kea DHCPv4 server.

View File

@ -990,8 +990,10 @@ This grammar is generated from ``dhcp4_parser.yy``. See :ref:`dhcp4` for more de
| compatibility_params "," compatibility_param
| compatibility_params ","
compatibility_param ::= lenient_option_parsing
compatibility_param ::= lenient_option_parsing | ignore-rai-link-selection |
| unknown_map_entry
lenient_option_parsing ::= "lenient-option-parsing" ":" BOOLEAN
ignore-rai-link-selection ::= "ignore-rai-link-selection" ":" BOOLEAN

View File

@ -2847,6 +2847,7 @@ compatibility_params: compatibility_param
;
compatibility_param: lenient_option_parsing
| ignore-rai-link-selection
| unknown_map_entry
;
@ -2856,6 +2857,12 @@ lenient_option_parsing: LENIENT_OPTION_PARSING COLON BOOLEAN {
ctx.stack_.back()->set("lenient-option-parsing", b);
};
ignore-rai-link-selection: IGNORE_RAI_LINK_SEL COLON BOOLEAN {
ctx.unique("ignore-rai-link-selection", ctx.loc2pos(@1));
ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("lenient-option-parsing", b);
}
%%
void

View File

@ -598,6 +598,10 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
CfgMgr::instance().getStagingCfg()->setLenientOptionParsing(
kv.second->boolValue());
}
if (kv.first == "ignore-rai-link-selection") {
CfgMgr::instance().getStagingCfg()->setIgnoreRAILinkSelection(
kv.second->boolValue());
}
}
}

View File

@ -7,6 +7,7 @@
#include <config.h>
#include <dhcp/iface_mgr.h>
#include <dhcp/option_custom.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/cfg_subnets4.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/lease_mgr_factory.h>
@ -224,14 +225,19 @@ CfgSubnets4::initSelector(const Pkt4Ptr& query) {
OptionCustomPtr rai_custom =
boost::dynamic_pointer_cast<OptionCustom>(rai);
if (rai_custom) {
OptionPtr link_select =
rai_custom->getOption(RAI_OPTION_LINK_SELECTION);
if (link_select) {
OptionBuffer link_select_buf = link_select->getData();
if (link_select_buf.size() == sizeof(uint32_t)) {
selector.option_select_ =
IOAddress::fromBytes(AF_INET, &link_select_buf[0]);
return (selector);
// If Relay Agent Information Link Selection is ignored in the configuration, skip
// returning the related subnet selector here, and move on to normal subnet selection.
bool ignore_link_sel = CfgMgr::instance().getCurrentCfg()->getIgnoreRAILinkSelection();
if (!ignore_link_sel) {
OptionPtr link_select =
rai_custom->getOption(RAI_OPTION_LINK_SELECTION);
if (link_select) {
OptionBuffer link_select_buf = link_select->getData();
if (link_select_buf.size() == sizeof(uint32_t)) {
selector.option_select_ =
IOAddress::fromBytes(AF_INET, &link_select_buf[0]);
return (selector);
}
}
}
}

View File

@ -47,7 +47,8 @@ SrvConfig::SrvConfig()
decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0),
d2_client_config_(new D2ClientConfig()),
configured_globals_(new CfgGlobals()), cfg_consist_(new CfgConsistency()),
lenient_option_parsing_(false), reservations_lookup_first_(false) {
lenient_option_parsing_(false), ignore_rai_link_selection_(false),
reservations_lookup_first_(false) {
}
SrvConfig::SrvConfig(const uint32_t sequence)
@ -65,7 +66,8 @@ SrvConfig::SrvConfig(const uint32_t sequence)
decline_timer_(0), echo_v4_client_id_(true), dhcp4o6_port_(0),
d2_client_config_(new D2ClientConfig()),
configured_globals_(new CfgGlobals()), cfg_consist_(new CfgConsistency()),
lenient_option_parsing_(false), reservations_lookup_first_(false) {
lenient_option_parsing_(false), ignore_rai_link_selection_(false),
reservations_lookup_first_(false) {
}
std::string

View File

@ -984,6 +984,21 @@ public:
return lenient_option_parsing_;
}
/// @brief Set ignore RAI Link Selection compatibility flag.
///
/// @param value the boolean value to be set when configuring RAI Link
/// Selection usage preferences
void setIgnoreRAILinkSelection(bool const value) {
ignore_rai_link_selection_ = value;
}
/// @brief Get ignore RAI Link Selection compatibility flag.
///
/// @return the configured value for RAI Link Selection usage preferences
bool getIgnoreRAILinkSelection() const {
return ignore_rai_link_selection_;
}
/// @brief Convenience method to propagate configuration parameters through
/// inversion of control.
///
@ -1148,6 +1163,7 @@ private:
/// @brief Compatibility flags
/// @{
bool lenient_option_parsing_;
bool ignore_rai_link_selection_;
/// @}
/// @brief Flag which indicates if the server should do host reservations