From 7cf7be726eba9dca93ee9e128e097a849db8034a Mon Sep 17 00:00:00 2001 From: Willem Jan Withagen Date: Sat, 14 Jan 2017 00:29:43 +0100 Subject: [PATCH] common/pick_address.cc: Copy public_netw to cluset_netw if cluster empty - When public network is set, but cluster network is not, then the cluster-bindings would be on 0.0.0.0 which could be unexpeted. In this commit we copy the public network into the cluster network to make sure that the cluster backend is not bound on 0.0.0.0 Which could be consideren an insecure, or unexpected, action. Signed-off-by: Willem Jan Withagen --- src/common/pick_address.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/common/pick_address.cc b/src/common/pick_address.cc index a47a1d946a4c..ebce2d553d71 100644 --- a/src/common/pick_address.cc +++ b/src/common/pick_address.cc @@ -112,6 +112,7 @@ void pick_addresses(CephContext *cct, int needs) exit(1); } + if ((needs & CEPH_PICK_ADDRESS_PUBLIC) && cct->_conf->public_addr.is_blank_ip() && !cct->_conf->public_network.empty()) { @@ -119,9 +120,16 @@ void pick_addresses(CephContext *cct, int needs) } if ((needs & CEPH_PICK_ADDRESS_CLUSTER) - && cct->_conf->cluster_addr.is_blank_ip() - && !cct->_conf->cluster_network.empty()) { - fill_in_one_address(cct, ifa, cct->_conf->cluster_network, "cluster_addr"); + && cct->_conf->cluster_addr.is_blank_ip()) { + if (!cct->_conf->cluster_network.empty()) { + fill_in_one_address(cct, ifa, cct->_conf->cluster_network, "cluster_addr"); + } else { + if (!cct->_conf->public_network.empty()) { + lderr(cct) << "Public network was set, but cluster network was not set " << dendl; + lderr(cct) << " Using public network also for cluster network" << dendl; + fill_in_one_address(cct, ifa, cct->_conf->public_network, "cluster_addr"); + } + } } freeifaddrs(ifa); -- 2.47.3