Parcourir la source

[5377] Several little fixes as a result of the review.

This covers changes by Tomek which add parsing of the outbound-interface
parameter.
Marcin Siodelski il y a 7 ans
Parent
commit
7c36e002fa

+ 2 - 2
doc/examples/kea4/advanced.json

@@ -35,8 +35,8 @@
         // interface the query came in. This is the default ("same-as-inbound").
         // interface the query came in. This is the default ("same-as-inbound").
         // However, sometimes it is useful to have the ability to send the
         // 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
         // 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",
         "outbound-interface": "use-routing",
 
 
         // This makes interfaces to be re-detected at each (re-)configuration.
         // This makes interfaces to be re-detected at each (re-)configuration.

+ 11 - 10
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.</para>
     fall back to use IP/UDP sockets.</para>
   </note>
   </note>
 
 
-  <para>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
-  <command>outbound-interface</command> that control this behavior. It supports
+  <para>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
+  <command>outbound-interface</command> that controls this behavior. It supports
   two values. The first one, <userinput>same-as-inbound</userinput>, tells Kea
   two values. The first one, <userinput>same-as-inbound</userinput>, 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, <userinput>use-routing</userinput>
   is the default behavior. The second one, <userinput>use-routing</userinput>
   tells Kea to send regular UDP packets and let the kernel's routing table to
   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
+  <command>dhcp-socket-type</command> is  set to <userinput>udp</userinput>.
+  An example configuration looks as follows:
   <screen>
   <screen>
 "Dhcp4": {
 "Dhcp4": {
     "interfaces-config": {
     "interfaces-config": {

+ 7 - 4
src/lib/dhcpsrv/cfg_iface.cc

@@ -235,9 +235,12 @@ CfgIface::getOutboundIface() const {
 std::string
 std::string
 CfgIface::outboundTypeToText() const {
 CfgIface::outboundTypeToText() const {
     switch (outbound_iface_) {
     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
 void
-CfgIface::setOutboundIface(const OutboundIface& traffic_type) {
+CfgIface::setOutboundIface(const OutboundIface& outbound_iface) {
     outbound_iface_ = traffic_type;
     outbound_iface_ = traffic_type;
 }
 }
 
 

+ 15 - 10
src/lib/dhcpsrv/cfg_iface.h

@@ -137,9 +137,12 @@ public:
         SOCKET_UDP
         SOCKET_UDP
     };
     };
 
 
+    /// @brief Indicates how outbound interface is selected for relayed traffic.
     enum OutboundIface {
     enum OutboundIface {
+        /// Server sends responses over the same interface on which queries are
+        /// received.
         SAME_AS_INBOUND,
         SAME_AS_INBOUND,
-
+        /// Server uses routing to determine the right interface to send response.
         USE_ROUTING
         USE_ROUTING
     };
     };
 
 
@@ -233,24 +236,25 @@ public:
     /// @brief Returns the socket type in the textual format.
     /// @brief Returns the socket type in the textual format.
     std::string socketTypeToText() const;
     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;
     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;
     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'
     /// @param txt either 'same-as-inbound' or 'use-routing'
-    /// @return converted value
+    /// @return Outbound interface selection mode.
     static OutboundIface textToOutboundIface(const std::string& txt);
     static OutboundIface textToOutboundIface(const std::string& txt);
 
 
     /// @brief Converts the socket type in the textual format to the type
     /// @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
     /// @brief A boolean value which reflects current re-detect setting
     bool re_detect_;
     bool re_detect_;
 
 
+    /// @brief Indicates how outbound interface is selected for relayed traffic.
     OutboundIface outbound_iface_;
     OutboundIface outbound_iface_;
 };
 };