]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3322] Relay address used in relay-info can now be used in getSubnet{4,6}
authorTomek Mrugalski <tomasz@isc.org>
Wed, 12 Feb 2014 14:51:04 +0000 (15:51 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Wed, 12 Feb 2014 14:51:04 +0000 (15:51 +0100)
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/lib/dhcpsrv/cfgmgr.cc
src/lib/dhcpsrv/cfgmgr.h

index bcafaefd2de7adca8f96e01db1b5230b78592394..fea837a48800936f1bc4605f078c4d33875e94ad 100644 (file)
@@ -1415,7 +1415,8 @@ Dhcpv4Srv::selectSubnet(const Pkt4Ptr& question) const {
     // level functions.
     if (question->isRelayed()) {
         subnet = CfgMgr::instance().getSubnet4(question->getGiaddr(),
-                                               question->classes_);
+                                               question->classes_,
+                                               true);
 
     // The message is not relayed so it is sent directly by a client. But
     // the client may be renewing its lease and in such case it unicasts
index 9fcf0862e5d06bb5e2e81dfdb362e0ef442c0691..b3ece4cc91e8929dd1a56ea58ea91a685a37aff4 100644 (file)
@@ -885,7 +885,7 @@ Dhcpv6Srv::selectSubnet(const Pkt6Ptr& question) {
             // if relay filled in link_addr field, then let's use it
             if (link_addr != IOAddress("::")) {
                 subnet = CfgMgr::instance().getSubnet6(link_addr,
-                                                       question->classes_);
+                                                       question->classes_, true);
             }
         }
     }
index 960cfd22610ac8d552033704df249a71b0d93744..1f7be14f3d71bc5078002230345cfeac4328bc70 100644 (file)
@@ -154,7 +154,8 @@ CfgMgr::getSubnet6(const std::string& iface,
 
 Subnet6Ptr
 CfgMgr::getSubnet6(const isc::asiolink::IOAddress& hint,
-                   const isc::dhcp::ClientClasses& classes) {
+                   const isc::dhcp::ClientClasses& classes,
+                   bool relay) {
 
     // If there's only one subnet configured, let's just use it
     // The idea is to keep small deployments easy. In a small network - one
@@ -180,6 +181,12 @@ CfgMgr::getSubnet6(const isc::asiolink::IOAddress& hint,
             continue;
         }
 
+        // If the hint is a relay address, and there is relay info specified
+        // for this subnet and those two match, then use this subnet.
+        if (relay && ((*subnet)->getRelayInfo().addr_ == hint) ) {
+            return (*subnet);
+        }
+
         if ((*subnet)->inRange(hint)) {
             LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE,
                       DHCPSRV_CFGMGR_SUBNET6)
@@ -232,7 +239,8 @@ void CfgMgr::addSubnet6(const Subnet6Ptr& subnet) {
 
 Subnet4Ptr
 CfgMgr::getSubnet4(const isc::asiolink::IOAddress& hint,
-                   const isc::dhcp::ClientClasses& classes) const {
+                   const isc::dhcp::ClientClasses& classes,
+                   bool relay /* = false */) const {
     // Iterate over existing subnets to find a suitable one for the
     // given address.
     for (Subnet4Collection::const_iterator subnet = subnets4_.begin();
@@ -243,6 +251,12 @@ CfgMgr::getSubnet4(const isc::asiolink::IOAddress& hint,
             continue;
         }
 
+        // If the hint is a relay address, and there is relay info specified
+        // for this subnet and those two match, then use this subnet.
+        if (relay && ((*subnet)->getRelayInfo().addr_ == hint) ) {
+            return (*subnet);
+        }
+
         // Let's check if the client belongs to the given subnet
         if ((*subnet)->inRange(hint)) {
             LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE,
index 20c162dbb971ba3bb64220488a1f8a5a0b9a47ef..9f4917eaf4e9750f7f3e384f5334023992f84714 100644 (file)
@@ -169,12 +169,19 @@ public:
     /// If there are any classes specified in a subnet, that subnet
     /// will be selected only if the client belongs to appropriate class.
     ///
+    /// If relay is true then relay info overrides (i.e. value the sysadmin
+    /// can configure in Dhcp4/subnet6[X]/relay/ip-address) can be used.
+    /// That is true only for relays. Those overrides must not be used
+    /// for client address or for client hints. They are for giaddr only.
+    ///
     /// @param hint an address that belongs to a searched subnet
     /// @param classes classes the client belongs to
+    /// @param relay true if address specified in hint is a relay
     ///
     /// @return a subnet object (or NULL if no suitable match was fount)
     Subnet6Ptr getSubnet6(const isc::asiolink::IOAddress& hint,
-                          const isc::dhcp::ClientClasses& classes);
+                          const isc::dhcp::ClientClasses& classes,
+                          bool relay = false);
 
     /// @brief get IPv6 subnet by interface name
     ///
@@ -262,12 +269,19 @@ public:
     /// If there are any classes specified in a subnet, that subnet
     /// will be selected only if the client belongs to appropriate class.
     ///
+    /// If relay is true then relay info overrides (i.e. value the sysadmin
+    /// can configure in Dhcp4/subnet4[X]/relay/ip-address) can be used.
+    /// That is true only for relays. Those overrides must not be used
+    /// for client address or for client hints. They are for giaddr only.
+    ///
     /// @param hint an address that belongs to a searched subnet
     /// @param classes classes the client belongs to
+    /// @param relay true if address specified in hint is a relay
     ///
     /// @return a subnet object
     Subnet4Ptr getSubnet4(const isc::asiolink::IOAddress& hint,
-                          const isc::dhcp::ClientClasses& classes) const;
+                          const isc::dhcp::ClientClasses& classes,
+                          bool relay = false) const;
 
     /// @brief Returns a subnet for the specified local interface.
     ///