The Haskell ConfD client was assuming internet addresses to be IPv4. This
patch modifies the client so that it behaves like the ConfD server, querying
ssconf to find out what kind of protocol it should use.

Signed-off-by: Michele Tartara <[email protected]>
---
 src/Ganeti/Confd/Client.hs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Ganeti/Confd/Client.hs b/src/Ganeti/Confd/Client.hs
index 78a7820..f757096 100644
--- a/src/Ganeti/Confd/Client.hs
+++ b/src/Ganeti/Confd/Client.hs
@@ -41,6 +41,7 @@ import Ganeti.Confd.Utils
 import qualified Ganeti.Constants as C
 import Ganeti.Hash
 import Ganeti.Ssconf
+import Ganeti.Utils
 
 -- | Builds a properly initialized ConfdClient
 getConfdClient :: IO ConfdClient
@@ -110,7 +111,9 @@ queryOneServer semaphore answer crType cQuery hmac (host, 
port) = do
   let signedMsg =
         signMessage hmac timestamp (J.encodeStrict request)
       completeMsg = C.confdMagicFourcc ++ J.encodeStrict signedMsg
-  s <- S.socket S.AF_INET S.Datagram S.defaultProtocol
+  ipFam <- getPrimaryIPFamily Nothing
+  af_family <- exitIfBad "Unable to obtain the IP Family from Ssconf" ipFam
+  s <- S.socket af_family S.Datagram S.defaultProtocol
   hostAddr <- S.inet_addr host
   _ <- S.sendTo s completeMsg $ S.SockAddrInet port hostAddr
   replyMsg <- S.recv s C.maxUdpDataSize
-- 
1.8.2.1

Reply via email to