From: Marcin Siodelski Date: Thu, 5 Oct 2017 17:52:46 +0000 (+0200) Subject: [5377] Several little fixes as a result of the review. X-Git-Tag: trac5297_base~15^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7c36e002fa4e50356dde1c95ddb8a181118a0819;p=thirdparty%2Fkea.git [5377] Several little fixes as a result of the review. This covers changes by Tomek which add parsing of the outbound-interface parameter. --- diff --git a/doc/examples/kea4/advanced.json b/doc/examples/kea4/advanced.json index 039b4257e8..327047bcd2 100644 --- a/doc/examples/kea4/advanced.json +++ b/doc/examples/kea4/advanced.json @@ -35,8 +35,8 @@ // interface the query came in. This is the default ("same-as-inbound"). // However, sometimes it is useful to have the ability to send the // packet as plain UDP packet and let the kernel and the routing tables - // to determine the right interface ("use-routing"). This option is - // expected to work only for dhcp-socket-type set to udp. + // determine the right interface ("use-routing"). This option only works + // for "dhcp-socket-type" set to "udp" and is ignored otherwise. "outbound-interface": "use-routing", // This makes interfaces to be re-detected at each (re-)configuration. diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index 0d1a91dceb..219cb87438 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -720,19 +720,20 @@ temporarily override a list of interface names and listen on all interfaces. fall back to use IP/UDP sockets. - In typical environment the DHCP server is expected to send back its - responses on the same network interface as the query packets come in. This is - the default behavior. However, in some deployments it is expected the outbound - (response) packets will be sent as regular traffic and the outbound interface - will be determined by the routing tables. This kind of asymetric traffic - is uncommon, but valid. Kea now supports a parameter called - outbound-interface that control this behavior. It supports + In typical environment the DHCP server is expected to send back a + response on the same network interface on which the query is received. This is + the default behavior. However, in some deployments it is desired that the + outbound (response) packets will be sent as regular traffic and the outbound + interface will be determined by the routing tables. This kind of asymetric + traffic is uncommon, but valid. Kea now supports a parameter called + outbound-interface that controls this behavior. It supports two values. The first one, same-as-inbound, tells Kea - to send back the response on the same inteface the query packet came in. This + to send back the response on the same inteface the query packet is received. This is the default behavior. The second one, use-routing tells Kea to send regular UDP packets and let the kernel's routing table to - determine most appropriate interface. This only works when dhcp-socket-type is - set to udp. An example configuration looks as follows: + determine most appropriate interface. This only works when + dhcp-socket-type is set to udp. + An example configuration looks as follows: "Dhcp4": { "interfaces-config": { diff --git a/src/lib/dhcpsrv/cfg_iface.cc b/src/lib/dhcpsrv/cfg_iface.cc index 419e884904..049407154f 100644 --- a/src/lib/dhcpsrv/cfg_iface.cc +++ b/src/lib/dhcpsrv/cfg_iface.cc @@ -235,9 +235,12 @@ CfgIface::getOutboundIface() const { std::string CfgIface::outboundTypeToText() const { switch (outbound_iface_) { - case SAME_AS_INBOUND: return ("same-as-inbound"); - case USE_ROUTING: return ("use-routing"); - default: isc_throw(Unexpected, "unsupported outbound-type " << socket_type_); + case SAME_AS_INBOUND: + return ("same-as-inbound"); + case USE_ROUTING: + return ("use-routing"); + default: + isc_throw(Unexpected, "unsupported outbound-type " << socket_type_); } } @@ -257,7 +260,7 @@ CfgIface::textToOutboundIface(const std::string& txt) { } void -CfgIface::setOutboundIface(const OutboundIface& traffic_type) { +CfgIface::setOutboundIface(const OutboundIface& outbound_iface) { outbound_iface_ = traffic_type; } diff --git a/src/lib/dhcpsrv/cfg_iface.h b/src/lib/dhcpsrv/cfg_iface.h index 0a09b36292..f591745194 100644 --- a/src/lib/dhcpsrv/cfg_iface.h +++ b/src/lib/dhcpsrv/cfg_iface.h @@ -137,9 +137,12 @@ public: SOCKET_UDP }; + /// @brief Indicates how outbound interface is selected for relayed traffic. enum OutboundIface { + /// Server sends responses over the same interface on which queries are + /// received. SAME_AS_INBOUND, - + /// Server uses routing to determine the right interface to send response. USE_ROUTING }; @@ -233,24 +236,25 @@ public: /// @brief Returns the socket type in the textual format. std::string socketTypeToText() const; - /// @brief Sets outbound interface type + /// @brief Sets outbound interface selection mode. /// - /// @param traffic_type sets the type of traffic - void setOutboundIface(const OutboundIface& traffic_type); + /// @param outbound_iface New outbound interface selection mode setting. + void setOutboundIface(const OutboundIface& outbound_iface); - /// @brief Returns outbound interface traffic type + /// @brief Returns outbound interface selection mode. /// - /// @return type of traffic (use-routing or same-as-inbound) + /// @return Outbound interface selection mode. OutboundIface getOutboundIface() const; - /// @brief Returns outbound type as string + /// @brief Returns outbound interface selection mode as string. /// - /// @return text representation of the outbound type + /// @return text representation of the outbound interface selection mode. std::string outboundTypeToText() const; - /// @brief Converts text to outbound interface + /// @brief Converts text to outbound interface selection mode. + /// /// @param txt either 'same-as-inbound' or 'use-routing' - /// @return converted value + /// @return Outbound interface selection mode. static OutboundIface textToOutboundIface(const std::string& txt); /// @brief Converts the socket type in the textual format to the type @@ -367,6 +371,7 @@ private: /// @brief A boolean value which reflects current re-detect setting bool re_detect_; + /// @brief Indicates how outbound interface is selected for relayed traffic. OutboundIface outbound_iface_; };