]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
7c673cae FG |
3 | #ifndef CEPH_PICK_ADDRESS_H |
4 | #define CEPH_PICK_ADDRESS_H | |
5 | ||
11fdf7f2 TL |
6 | #include <string> |
7 | #include <list> | |
7c673cae FG |
8 | |
9 | class CephContext; | |
11fdf7f2 TL |
10 | struct entity_addr_t; |
11 | class entity_addrvec_t; | |
7c673cae FG |
12 | |
13 | ||
11fdf7f2 TL |
14 | #define CEPH_PICK_ADDRESS_PUBLIC 0x01 |
15 | #define CEPH_PICK_ADDRESS_CLUSTER 0x02 | |
16 | #define CEPH_PICK_ADDRESS_MSGR1 0x04 | |
17 | #define CEPH_PICK_ADDRESS_MSGR2 0x08 | |
18 | #define CEPH_PICK_ADDRESS_IPV4 0x10 | |
19 | #define CEPH_PICK_ADDRESS_IPV6 0x20 | |
20 | #define CEPH_PICK_ADDRESS_PREFER_IPV4 0x40 | |
21 | #define CEPH_PICK_ADDRESS_DEFAULT_MON_PORTS 0x80 | |
7c673cae | 22 | |
92f5a8d4 TL |
23 | enum IfaceType { |
24 | IFACE_DEFAULT = 0, | |
25 | IFACE_PHY_PORT = 1, | |
26 | IFACE_BOND_PORT = 2 | |
27 | }; | |
28 | ||
11fdf7f2 | 29 | #ifndef WITH_SEASTAR |
7c673cae FG |
30 | /* |
31 | Pick addresses based on subnets if needed. | |
32 | ||
33 | If an address is not explicitly given, and a list of subnets is | |
34 | given, find an assigned IP address in the subnets and set that. | |
35 | ||
36 | cluster_addr is set based on cluster_network, public_addr is set | |
37 | based on public_network. | |
38 | ||
39 | cluster_network and public_network are a list of ip/prefix pairs. | |
40 | ||
41 | All IP addresses assigned to all local network interfaces are | |
42 | potential matches. | |
43 | ||
44 | If multiple IP addresses match the subnet, one of them will be | |
45 | picked, effectively randomly. | |
46 | ||
47 | This function will exit on error. | |
48 | */ | |
49 | void pick_addresses(CephContext *cct, int needs); | |
50 | ||
11fdf7f2 TL |
51 | #endif // !WITH_SEASTAR |
52 | ||
53 | int pick_addresses(CephContext *cct, unsigned flags, entity_addrvec_t *addrs, | |
54 | int preferred_numa_node = -1); | |
55 | int pick_addresses(CephContext *cct, unsigned flags, struct ifaddrs *ifa, | |
56 | entity_addrvec_t *addrs, | |
57 | int preferred_numa_node = -1); | |
58 | ||
b5b8bbf5 FG |
59 | /** |
60 | * Find a network interface whose address matches the address/netmask | |
61 | * in `network`. | |
62 | */ | |
63 | std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network); | |
64 | ||
7c673cae FG |
65 | /** |
66 | * check for a locally configured address | |
67 | * | |
68 | * check if any of the listed addresses is configured on the local host. | |
69 | * | |
70 | * @param cct context | |
71 | * @param ls list of addresses | |
72 | * @param match [out] pointer to match, if an item in @a ls is found configured locally. | |
73 | */ | |
11fdf7f2 | 74 | bool have_local_addr(CephContext *cct, const std::list<entity_addr_t>& ls, entity_addr_t *match); |
3efd9988 FG |
75 | |
76 | const struct sockaddr *find_ip_in_subnet_list( | |
77 | CephContext *cct, | |
78 | const struct ifaddrs *ifa, | |
11fdf7f2 | 79 | unsigned ipv, |
3efd9988 | 80 | const std::string &networks, |
11fdf7f2 TL |
81 | const std::string &interfaces, |
82 | int numa_node=-1); | |
83 | ||
84 | int get_iface_numa_node( | |
85 | const std::string& iface, | |
86 | int *node); | |
3efd9988 | 87 | |
7c673cae | 88 | #endif |