diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/common/pick_address.h | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/common/pick_address.h')
-rw-r--r-- | src/common/pick_address.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/common/pick_address.h b/src/common/pick_address.h new file mode 100644 index 00000000..ba9473a9 --- /dev/null +++ b/src/common/pick_address.h @@ -0,0 +1,88 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +#ifndef CEPH_PICK_ADDRESS_H +#define CEPH_PICK_ADDRESS_H + +#include <string> +#include <list> + +class CephContext; +struct entity_addr_t; +class entity_addrvec_t; + + +#define CEPH_PICK_ADDRESS_PUBLIC 0x01 +#define CEPH_PICK_ADDRESS_CLUSTER 0x02 +#define CEPH_PICK_ADDRESS_MSGR1 0x04 +#define CEPH_PICK_ADDRESS_MSGR2 0x08 +#define CEPH_PICK_ADDRESS_IPV4 0x10 +#define CEPH_PICK_ADDRESS_IPV6 0x20 +#define CEPH_PICK_ADDRESS_PREFER_IPV4 0x40 +#define CEPH_PICK_ADDRESS_DEFAULT_MON_PORTS 0x80 + +enum IfaceType { + IFACE_DEFAULT = 0, + IFACE_PHY_PORT = 1, + IFACE_BOND_PORT = 2 +}; + +#ifndef WITH_SEASTAR +/* + Pick addresses based on subnets if needed. + + If an address is not explicitly given, and a list of subnets is + given, find an assigned IP address in the subnets and set that. + + cluster_addr is set based on cluster_network, public_addr is set + based on public_network. + + cluster_network and public_network are a list of ip/prefix pairs. + + All IP addresses assigned to all local network interfaces are + potential matches. + + If multiple IP addresses match the subnet, one of them will be + picked, effectively randomly. + + This function will exit on error. + */ +void pick_addresses(CephContext *cct, int needs); + +#endif // !WITH_SEASTAR + +int pick_addresses(CephContext *cct, unsigned flags, entity_addrvec_t *addrs, + int preferred_numa_node = -1); +int pick_addresses(CephContext *cct, unsigned flags, struct ifaddrs *ifa, + entity_addrvec_t *addrs, + int preferred_numa_node = -1); + +/** + * Find a network interface whose address matches the address/netmask + * in `network`. + */ +std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network); + +/** + * check for a locally configured address + * + * check if any of the listed addresses is configured on the local host. + * + * @param cct context + * @param ls list of addresses + * @param match [out] pointer to match, if an item in @a ls is found configured locally. + */ +bool have_local_addr(CephContext *cct, const std::list<entity_addr_t>& ls, entity_addr_t *match); + +const struct sockaddr *find_ip_in_subnet_list( + CephContext *cct, + const struct ifaddrs *ifa, + unsigned ipv, + const std::string &networks, + const std::string &interfaces, + int numa_node=-1); + +int get_iface_numa_node( + const std::string& iface, + int *node); + +#endif |