Commit 4fa4c9a0 authored by Francis Dupont's avatar Francis Dupont
Browse files

[3389a] Rebased (but still many things to do)

parent 3188ae9a
...@@ -29,7 +29,11 @@ ...@@ -29,7 +29,11 @@
// 'udp' is generally better if you have only relayed traffic. Kea // 'udp' is generally better if you have only relayed traffic. Kea
// than opens up normal UDP socket and the kernel does all the // than opens up normal UDP socket and the kernel does all the
// Ethernet/IP stack processing. // Ethernet/IP stack processing.
"dhcp-socket-type": "udp" "dhcp-socket-type": "udp",
// This makes interfaces to be re-detected at each (re-)configuration.
// By default it is true.
"re-detect": true
}, },
// We need to specify the the database used to store leases. As of // We need to specify the the database used to store leases. As of
......
...@@ -16,7 +16,11 @@ ...@@ -16,7 +16,11 @@
{ {
// Kea is told to listen on ethX network interface only. // Kea is told to listen on ethX network interface only.
"interfaces-config": { "interfaces-config": {
"interfaces": [ "ethX" ] "interfaces": [ "ethX" ],
// This makes interfaces to be re-detected at each (re-)configuration.
// By default it is true.
"re-detect": true
}, },
// We need to specify the the database used to store leases. As of // We need to specify the the database used to store leases. As of
......
...@@ -226,6 +226,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -226,6 +226,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"re-detect\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::INTERFACES_CONFIG:
return isc::dhcp::Dhcp4Parser::make_RE_DETECT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("re-detect", driver.loc_);
}
}
\"lease-database\" { \"lease-database\" {
switch(driver.ctx_) { switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP4: case isc::dhcp::Parser4Context::DHCP4:
......
...@@ -55,6 +55,7 @@ using namespace std; ...@@ -55,6 +55,7 @@ using namespace std;
DHCP_SOCKET_TYPE "dhcp-socket-type" DHCP_SOCKET_TYPE "dhcp-socket-type"
RAW "raw" RAW "raw"
UDP "udp" UDP "udp"
RE_DETECT "re-detect"
ECHO_CLIENT_ID "echo-client-id" ECHO_CLIENT_ID "echo-client-id"
MATCH_CLIENT_ID "match-client-id" MATCH_CLIENT_ID "match-client-id"
...@@ -456,6 +457,7 @@ interfaces_config_params: interfaces_config_param ...@@ -456,6 +457,7 @@ interfaces_config_params: interfaces_config_param
interfaces_config_param: interfaces_list interfaces_config_param: interfaces_list
| dhcp_socket_type | dhcp_socket_type
| re_detect
; ;
sub_interfaces4: LCURLY_BRACKET { sub_interfaces4: LCURLY_BRACKET {
...@@ -487,6 +489,12 @@ socket_type: RAW { $$ = ElementPtr(new StringElement("raw", ctx.loc2pos(@1))); } ...@@ -487,6 +489,12 @@ socket_type: RAW { $$ = ElementPtr(new StringElement("raw", ctx.loc2pos(@1))); }
| UDP { $$ = ElementPtr(new StringElement("udp", ctx.loc2pos(@1))); } | UDP { $$ = ElementPtr(new StringElement("udp", ctx.loc2pos(@1))); }
; ;
re_detect: RE_DETECT COLON BOOLEAN {
ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("re-detect", b);
};
lease_database: LEASE_DATABASE { lease_database: LEASE_DATABASE {
ElementPtr i(new MapElement(ctx.loc2pos(@1))); ElementPtr i(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("lease-database", i); ctx.stack_.back()->set("lease-database", i);
......
...@@ -416,6 +416,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} ...@@ -416,6 +416,15 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
} }
} }
\"re-detect\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::INTERFACES_CONFIG:
return isc::dhcp::Dhcp6Parser::make_RE_DETECT(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("re-detect", driver.loc_);
}
}
\"lease-database\" { \"lease-database\" {
switch(driver.ctx_) { switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DHCP6: case isc::dhcp::Parser6Context::DHCP6:
......
...@@ -52,6 +52,7 @@ using namespace std; ...@@ -52,6 +52,7 @@ using namespace std;
DHCP6 "Dhcp6" DHCP6 "Dhcp6"
INTERFACES_CONFIG "interfaces-config" INTERFACES_CONFIG "interfaces-config"
INTERFACES "interfaces" INTERFACES "interfaces"
RE_DETECT "re-detect"
LEASE_DATABASE "lease-database" LEASE_DATABASE "lease-database"
HOSTS_DATABASE "hosts-database" HOSTS_DATABASE "hosts-database"
...@@ -449,7 +450,7 @@ interfaces_config: INTERFACES_CONFIG { ...@@ -449,7 +450,7 @@ interfaces_config: INTERFACES_CONFIG {
ctx.stack_.back()->set("interfaces-config", i); ctx.stack_.back()->set("interfaces-config", i);
ctx.stack_.push_back(i); ctx.stack_.push_back(i);
ctx.enter(ctx.INTERFACES_CONFIG); ctx.enter(ctx.INTERFACES_CONFIG);
} COLON LCURLY_BRACKET interface_config_map RCURLY_BRACKET { } COLON LCURLY_BRACKET interfaces_config_params RCURLY_BRACKET {
ctx.stack_.pop_back(); ctx.stack_.pop_back();
ctx.leave(); ctx.leave();
}; };
...@@ -458,11 +459,19 @@ sub_interfaces6: LCURLY_BRACKET { ...@@ -458,11 +459,19 @@ sub_interfaces6: LCURLY_BRACKET {
// Parse the interfaces-config map // Parse the interfaces-config map
ElementPtr m(new MapElement(ctx.loc2pos(@1))); ElementPtr m(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.push_back(m); ctx.stack_.push_back(m);
} interface_config_map RCURLY_BRACKET { } interfaces_config_params RCURLY_BRACKET {
// parsing completed // parsing completed
}; };
interface_config_map: INTERFACES { interfaces_config_params: interfaces_config_param
| interfaces_config_params COMMA interfaces_config_param
;
interfaces_config_param: interfaces_list
| re_detect
;
interfaces_list: INTERFACES {
ElementPtr l(new ListElement(ctx.loc2pos(@1))); ElementPtr l(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("interfaces", l); ctx.stack_.back()->set("interfaces", l);
ctx.stack_.push_back(l); ctx.stack_.push_back(l);
...@@ -472,6 +481,12 @@ interface_config_map: INTERFACES { ...@@ -472,6 +481,12 @@ interface_config_map: INTERFACES {
ctx.leave(); ctx.leave();
}; };
re_detect: RE_DETECT COLON BOOLEAN {
ElementPtr b(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("re-detect", b);
};
lease_database: LEASE_DATABASE { lease_database: LEASE_DATABASE {
ElementPtr i(new MapElement(ctx.loc2pos(@1))); ElementPtr i(new MapElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("lease-database", i); ctx.stack_.back()->set("lease-database", i);
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2015,2017 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // 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 // License, v. 2.0. If a copy of the MPL was not distributed with this
...@@ -20,7 +20,7 @@ namespace dhcp { ...@@ -20,7 +20,7 @@ namespace dhcp {
void void
IfacesConfigParser::parseInterfacesList(const CfgIfacePtr& cfg_iface, IfacesConfigParser::parseInterfacesList(const CfgIfacePtr& cfg_iface,
ConstElementPtr ifaces_list) { ConstElementPtr ifaces_list) {
BOOST_FOREACH(ConstElementPtr iface, ifaces_list->listValue()) { BOOST_FOREACH(ConstElementPtr iface, ifaces_list->listValue()) {
std::string iface_name = iface->stringValue(); std::string iface_name = iface->stringValue();
try { try {
...@@ -45,6 +45,15 @@ IfacesConfigParser::parse(const CfgIfacePtr& cfg, ...@@ -45,6 +45,15 @@ IfacesConfigParser::parse(const CfgIfacePtr& cfg,
bool socket_type_specified = false; bool socket_type_specified = false;
BOOST_FOREACH(ConfigPair element, ifaces_config->mapValue()) { BOOST_FOREACH(ConfigPair element, ifaces_config->mapValue()) {
try { try {
// Check for re-detect before calling parseInterfacesList()
if (element.first == "re-detect") {
if (element.second->boolValue()) {
IfaceMgr::instance().clearIfaces();
IfaceMgr::instance().detectIfaces();
}
continue;
}
if (element.first == "interfaces") { if (element.first == "interfaces") {
parseInterfacesList(cfg, element.second); parseInterfacesList(cfg, element.second);
continue; continue;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment