]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/pick_address.h
import ceph quincy 17.2.6
[ceph.git] / ceph / src / common / pick_address.h
CommitLineData
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 8
9f95a23c
TL
9#include "include/common_fwd.h"
10
11fdf7f2
TL
11struct entity_addr_t;
12class entity_addrvec_t;
7c673cae
FG
13
14
11fdf7f2
TL
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
39ae355f 23#define CEPH_PICK_ADDRESS_PUBLIC_BIND 0x100
7c673cae 24
11fdf7f2 25#ifndef WITH_SEASTAR
7c673cae
FG
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 */
45void pick_addresses(CephContext *cct, int needs);
46
11fdf7f2
TL
47#endif // !WITH_SEASTAR
48
49int pick_addresses(CephContext *cct, unsigned flags, entity_addrvec_t *addrs,
50 int preferred_numa_node = -1);
51int pick_addresses(CephContext *cct, unsigned flags, struct ifaddrs *ifa,
52 entity_addrvec_t *addrs,
53 int preferred_numa_node = -1);
54
b5b8bbf5
FG
55/**
56 * Find a network interface whose address matches the address/netmask
57 * in `network`.
58 */
59std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network);
60
7c673cae
FG
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 */
11fdf7f2 70bool have_local_addr(CephContext *cct, const std::list<entity_addr_t>& ls, entity_addr_t *match);
3efd9988 71
522d829b
TL
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 */
3efd9988
FG
86const struct sockaddr *find_ip_in_subnet_list(
87 CephContext *cct,
88 const struct ifaddrs *ifa,
11fdf7f2 89 unsigned ipv,
3efd9988 90 const std::string &networks,
11fdf7f2
TL
91 const std::string &interfaces,
92 int numa_node=-1);
93
94int get_iface_numa_node(
95 const std::string& iface,
96 int *node);
3efd9988 97
7c673cae 98#endif