From: lijaiwei1 Date: Tue, 24 Dec 2019 14:34:46 +0000 (+0800) Subject: common: skip interfaces starting with "lo" in find_ipv{4,6}_in_subnet() X-Git-Tag: v15.1.0~361^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5cf0fa872231f4eaf8ce6565a04ed675ba5b689b;p=ceph.git common: skip interfaces starting with "lo" in find_ipv{4,6}_in_subnet() This will solve the issue that the osd can't restart after seting a virtual local loopback IP. In find_ipv4_in_subnet() and find_ipv6_in_subnet(), I use boost::starts_with(addrs->ifa_name, "lo") to ship the interfaces starting with "lo". Fixes: https://tracker.ceph.com/issues/43417 Signed-off-by: Jiawei Li --- diff --git a/src/common/ipaddr.cc b/src/common/ipaddr.cc index debf4ba2b2aa..a899df697856 100644 --- a/src/common/ipaddr.cc +++ b/src/common/ipaddr.cc @@ -3,6 +3,7 @@ #include #include #include +#include #if defined(__FreeBSD__) #include #include @@ -50,13 +51,12 @@ const struct ifaddrs *find_ipv4_in_subnet(const struct ifaddrs *addrs, struct in_addr want, temp; netmask_ipv4(&net->sin_addr, prefix_len, &want); - for (; addrs != NULL; addrs = addrs->ifa_next) { if (addrs->ifa_addr == NULL) continue; - if (strcmp(addrs->ifa_name, "lo") == 0) + if (boost::starts_with(addrs->ifa_name, "lo")) continue; if (numa_node >= 0 && !match_numa_node(addrs->ifa_name, numa_node)) @@ -98,13 +98,12 @@ const struct ifaddrs *find_ipv6_in_subnet(const struct ifaddrs *addrs, struct in6_addr want, temp; netmask_ipv6(&net->sin6_addr, prefix_len, &want); - for (; addrs != NULL; addrs = addrs->ifa_next) { if (addrs->ifa_addr == NULL) continue; - if (strcmp(addrs->ifa_name, "lo") == 0) + if (boost::starts_with(addrs->ifa_name, "lo")) continue; if (numa_node >= 0 && !match_numa_node(addrs->ifa_name, numa_node))