]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/pick_address.h
import ceph 16.2.7
[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
7c673cae 23
11fdf7f2 24#ifndef WITH_SEASTAR
7c673cae
FG
25/*
26 Pick addresses based on subnets if needed.
27
28 If an address is not explicitly given, and a list of subnets is
29 given, find an assigned IP address in the subnets and set that.
30
31 cluster_addr is set based on cluster_network, public_addr is set
32 based on public_network.
33
34 cluster_network and public_network are a list of ip/prefix pairs.
35
36 All IP addresses assigned to all local network interfaces are
37 potential matches.
38
39 If multiple IP addresses match the subnet, one of them will be
40 picked, effectively randomly.
41
42 This function will exit on error.
43 */
44void pick_addresses(CephContext *cct, int needs);
45
11fdf7f2
TL
46#endif // !WITH_SEASTAR
47
48int pick_addresses(CephContext *cct, unsigned flags, entity_addrvec_t *addrs,
49 int preferred_numa_node = -1);
50int pick_addresses(CephContext *cct, unsigned flags, struct ifaddrs *ifa,
51 entity_addrvec_t *addrs,
52 int preferred_numa_node = -1);
53
b5b8bbf5
FG
54/**
55 * Find a network interface whose address matches the address/netmask
56 * in `network`.
57 */
58std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network);
59
7c673cae
FG
60/**
61 * check for a locally configured address
62 *
63 * check if any of the listed addresses is configured on the local host.
64 *
65 * @param cct context
66 * @param ls list of addresses
67 * @param match [out] pointer to match, if an item in @a ls is found configured locally.
68 */
11fdf7f2 69bool have_local_addr(CephContext *cct, const std::list<entity_addr_t>& ls, entity_addr_t *match);
3efd9988 70
522d829b
TL
71/**
72 * filter the addresses in @c ifa with specified interfaces, networks and IPv
73 *
74 * @param cct
75 * @param ifa a list of network interface addresses to be filtered
76 * @param ipv bitmask of CEPH_PICK_ADDRESS_IPV4 and CEPH_PICK_ADDRESS_IPV6.
77 * it is used to filter the @c networks
78 * @param networks a comma separated list of networks as the allow list. only
79 * the addresses in the specified networks are allowed. all addresses
80 * are accepted if it is empty.
81 * @param interfaces a comma separated list of interfaces for the allow list.
82 * all addresses are accepted if it is empty
83 * @param exclude_lo_iface filter out network interface named "lo"
84 */
3efd9988
FG
85const struct sockaddr *find_ip_in_subnet_list(
86 CephContext *cct,
87 const struct ifaddrs *ifa,
11fdf7f2 88 unsigned ipv,
3efd9988 89 const std::string &networks,
11fdf7f2
TL
90 const std::string &interfaces,
91 int numa_node=-1);
92
93int get_iface_numa_node(
94 const std::string& iface,
95 int *node);
3efd9988 96
7c673cae 97#endif