]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: is_blacklisted() for addrvecs
authorSage Weil <sage@redhat.com>
Tue, 12 Jun 2018 16:44:36 +0000 (11:44 -0500)
committerSage Weil <sage@redhat.com>
Tue, 3 Jul 2018 18:01:24 +0000 (13:01 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 01b623318687d2c22896320aac7b975d78d8d6fd..e64e6edaf3ab6f31ac2bf223edbc118fa5e63bcc 100644 (file)
@@ -1204,6 +1204,30 @@ bool OSDMap::is_blacklisted(const entity_addr_t& a) const
   return false;
 }
 
+bool OSDMap::is_blacklisted(const entity_addrvec_t& av) const
+{
+  if (blacklist.empty())
+    return false;
+
+  for (auto& a : av.v) {
+    // this specific instance?
+    if (blacklist.count(a))
+      return true;
+
+    // is entire ip blacklisted?
+    if (a.is_ip()) {
+      entity_addr_t b = a;
+      b.set_port(0);
+      b.set_nonce(0);
+      if (blacklist.count(b)) {
+       return true;
+      }
+    }
+  }
+
+  return false;
+}
+
 void OSDMap::get_blacklist(list<pair<entity_addr_t,utime_t> > *bl) const
 {
    std::copy(blacklist.begin(), blacklist.end(), std::back_inserter(*bl));
index 753094d769fe84e91bb5046a32c49efd2f37eb83..29715e73479fefdeb5c68876c981c36badd628d8 100644 (file)
@@ -656,6 +656,7 @@ public:
   const utime_t& get_modified() const { return modified; }
 
   bool is_blacklisted(const entity_addr_t& a) const;
+  bool is_blacklisted(const entity_addrvec_t& a) const;
   void get_blacklist(list<pair<entity_addr_t,utime_t > > *bl) const;
   void get_blacklist(std::set<entity_addr_t> *bl) const;