]> git.proxmox.com Git - ceph.git/blob - ceph/src/common/pick_address.h
update ceph source to reef 18.2.0
[ceph.git] / ceph / src / common / pick_address.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #ifndef CEPH_PICK_ADDRESS_H
4 #define CEPH_PICK_ADDRESS_H
5
6 #include <string>
7 #include <list>
8
9 #include "include/common_fwd.h"
10
11 struct entity_addr_t;
12 class entity_addrvec_t;
13
14
15 #define CEPH_PICK_ADDRESS_PUBLIC 0x01
16 #define CEPH_PICK_ADDRESS_CLUSTER 0x02
17 #define CEPH_PICK_ADDRESS_MSGR1 0x04
18 #define CEPH_PICK_ADDRESS_MSGR2 0x08
19 #define CEPH_PICK_ADDRESS_IPV4 0x10
20 #define CEPH_PICK_ADDRESS_IPV6 0x20
21 #define CEPH_PICK_ADDRESS_PREFER_IPV4 0x40
22 #define CEPH_PICK_ADDRESS_DEFAULT_MON_PORTS 0x80
23 #define CEPH_PICK_ADDRESS_PUBLIC_BIND 0x100
24
25 #ifndef WITH_SEASTAR
26 /*
27 Pick addresses based on subnets if needed.
28
29 If an address is not explicitly given, and a list of subnets is
30 given, find an assigned IP address in the subnets and set that.
31
32 cluster_addr is set based on cluster_network, public_addr is set
33 based on public_network.
34
35 cluster_network and public_network are a list of ip/prefix pairs.
36
37 All IP addresses assigned to all local network interfaces are
38 potential matches.
39
40 If multiple IP addresses match the subnet, one of them will be
41 picked, effectively randomly.
42
43 This function will exit on error.
44 */
45 void pick_addresses(CephContext *cct, int needs);
46
47 #endif // !WITH_SEASTAR
48
49 int pick_addresses(CephContext *cct, unsigned flags, entity_addrvec_t *addrs,
50 int preferred_numa_node = -1);
51 int pick_addresses(CephContext *cct, unsigned flags, struct ifaddrs *ifa,
52 entity_addrvec_t *addrs,
53 int preferred_numa_node = -1);
54
55 /**
56 * Find a network interface whose address matches the address/netmask
57 * in `network`.
58 */
59 std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network);
60
61 /**
62 * check for a locally configured address
63 *
64 * check if any of the listed addresses is configured on the local host.
65 *
66 * @param cct context
67 * @param ls list of addresses
68 * @param match [out] pointer to match, if an item in @a ls is found configured locally.
69 */
70 bool have_local_addr(CephContext *cct, const std::list<entity_addr_t>& ls, entity_addr_t *match);
71
72 /**
73 * filter the addresses in @c ifa with specified interfaces, networks and IPv
74 *
75 * @param cct
76 * @param ifa a list of network interface addresses to be filtered
77 * @param ipv bitmask of CEPH_PICK_ADDRESS_IPV4 and CEPH_PICK_ADDRESS_IPV6.
78 * it is used to filter the @c networks
79 * @param networks a comma separated list of networks as the allow list. only
80 * the addresses in the specified networks are allowed. all addresses
81 * are accepted if it is empty.
82 * @param interfaces a comma separated list of interfaces for the allow list.
83 * all addresses are accepted if it is empty
84 * @param exclude_lo_iface filter out network interface named "lo"
85 */
86 const struct sockaddr *find_ip_in_subnet_list(
87 CephContext *cct,
88 const struct ifaddrs *ifa,
89 unsigned ipv,
90 const std::string &networks,
91 const std::string &interfaces,
92 int numa_node=-1);
93
94 int get_iface_numa_node(
95 const std::string& iface,
96 int *node);
97
98 #endif