![]() |
MySQL 26.10.0
Source Code Documentation
|
#include <netdb.h>#include <cstdlib>#include <string_view>#include "xcom/node_no.h"#include "xcom/server_struct.h"#include "xcom/simset.h"#include "xcom/site_struct.h"#include "xcom/task.h"#include "xcom/x_platform.h"#include "xcom/xcom_cfg.h"#include "xcom/xcom_detector.h"#include "xcom/xcom_memory.h"#include "xcom/xcom_profile.h"#include "xcom/xcom_scope_guard.h"#include "xdr_gen/xcom_vp.h"#include "xcom/sock_probe_ix.h"Functions | |
| bool_t | sockaddr_default_eq (struct sockaddr *x, struct sockaddr *y) |
| void | set_port_matcher (port_matcher x) |
| port_matcher | get_port_matcher () |
| static struct addrinfo * | probe_get_addrinfo (const char *name) |
| static void | probe_free_addrinfo (struct addrinfo *addr) |
| static bool | is_xcom_identity_configured () |
| Check whether an explicit XCom identity is currently configured. More... | |
| static bool | is_address_on_valid_local_interface (sock_probe *s, struct sockaddr *candidate_addr, bool using_net_ns) |
| Check whether one resolved address matches a valid local interface in the current network context. More... | |
| static bool | has_address_on_valid_local_interface (sock_probe *s, struct addrinfo *candidate_addr, bool using_net_ns) |
| Check whether any resolved address in an addrinfo list matches a valid local interface in the current network context. More... | |
| static bool | is_candidate_endpoint_configured_self (sock_probe *s, bool using_net_ns, char const *candidate_host_or_ip, xcom_port candidate_port) |
| Check whether a candidate endpoint is the configured XCom identity in the current network context. More... | |
| node_no | xcom_find_node_index (node_list *nodes) |
| Find the index of the local node within a node_list. More... | |
| node_no | xcom_mynode_match (const char *name, xcom_port port) |
| Check whether a candidate endpoint identifies this local node. More... | |
Variables | |
| static port_matcher | match_port |
| port_matcher get_port_matcher | ( | ) |
|
static |
Check whether any resolved address in an addrinfo list matches a valid local interface in the current network context.
This helper iterates over all addresses in the supplied addrinfo chain and applies is_address_on_valid_local_interface() to each entry until one valid local match is found.
This helper assumes the caller has already switched to the intended network namespace, if any, before creating the sock_probe passed here.
| [in] | s | The socket probe snapshot that exposes the local interfaces to check against. |
| [in] | candidate_addr | The head of the resolved addrinfo list to validate. |
| [in] | using_net_ns | Whether the caller is running inside a configured network namespace. When true, interfaces in the probe are not filtered by active state. |
| true | At least one resolved address in the list matches a valid local interface in the current network context. |
| false | No resolved address in the list matches a valid local interface, or the list is empty. |
|
static |
Check whether one resolved address matches a valid local interface in the current network context.
This helper compares a single resolved socket address against the interfaces currently visible through the supplied sock_probe. When a configured network namespace is active, all interfaces in the probe are considered eligible; otherwise, only interfaces reported as active are accepted.
This helper assumes the caller has already switched to the intended network namespace, if any, before creating the sock_probe passed here.
| [in] | s | The socket probe snapshot that exposes the local interfaces to check against. |
| [in] | candidate_addr | The resolved socket address to validate as local. |
| [in] | using_net_ns | Whether the caller is running inside a configured network namespace. When true, interfaces in the probe are not filtered by active state. |
| true | The resolved address matches a valid local interface in the current network context. |
| false | The resolved address is null, does not match any visible local interface, or only matches interfaces that are not valid for the current network context. |
|
static |
Check whether a candidate endpoint is the configured XCom identity in the current network context.
When XCom identity is configured, self-detection must use that configured endpoint instead of relying only on matching any local interface on the same port. Both the candidate endpoint and the configured identity may identify their host part either as a hostname or as an IP address. The configured identity is read from cfg_app_xcom_get_identity() and split into its host/IP part and port.
Matching is performed only when the candidate port equals the configured identity port. The host/IP parts are then compared in two stages: first, by direct textual comparison of the candidate host/IP part against the configured identity host/IP part; second, if the textual comparison does not match, by resolving both names and checking whether any resolved socket address is shared by both endpoints.
After an endpoint match is established, the configured identity address must still be validated against the local interfaces visible in the current network namespace.
This helper assumes the caller has already switched to the intended network namespace, if any, before creating the sock_probe passed here.
| [in] | s | The socket probe snapshot used to validate that the matched address exists on a valid local interface. |
| [in] | using_net_ns | Whether the caller is running inside a configured network namespace. When true, interfaces in the probe are not filtered by active state. |
| [in] | candidate_host_or_ip | The host or IP part of the candidate endpoint being checked. It may be either a hostname or an IP address. |
| [in] | candidate_port | The port portion of the candidate endpoint being checked. |
| true | The candidate endpoint matches the configured XCom identity and the matched address resolves to a valid local interface in the current network context. |
| false | The candidate endpoint does not match the configured identity, the configured identity cannot be resolved or validated, or the matched address does not correspond to a valid local interface in the current network context. |
|
inlinestatic |
Check whether an explicit XCom identity is currently configured.
An identity is considered configured only when cfg_app_xcom_get_identity() returns a node address and that node address contains a non-null endpoint string.
| true | XCom identity is configured and contains an address. |
| false | XCom identity is not configured or does not contain an address. |
|
inlinestatic |
|
inlinestatic |
| void set_port_matcher | ( | port_matcher | x | ) |
| node_no xcom_find_node_index | ( | node_list * | nodes | ) |
Find the index of the local node within a node_list.
This function scans the supplied XCom node list and identifies the first entry that matches the local node. It first applies the globally configured port matcher. If an explicit XCom identity is configured, matching is based on that configured endpoint; otherwise, the function falls back to matching the candidate addresses against the local interfaces visible to the current process.
The function evaluates global XCom state, namely the installed port matcher, the configured XCom identity, and the configured network namespace manager. The caller does not need to switch to the configured network namespace before invoking this function; if a namespace is configured, the function enters and restores it internally before probing interfaces.
| [in] | nodes | The node list to scan. |
| node_no xcom_mynode_match | ( | const char * | name, |
| xcom_port | port | ||
| ) |
Check whether a candidate endpoint identifies this local node.
This function first applies the globally configured port matcher to the candidate port. If an explicit XCom identity is configured, matching is based on that configured endpoint; otherwise, the function falls back to resolving the candidate host/IP and comparing it against the local interfaces visible to the current process.
The function evaluates global XCom state, namely the installed port matcher, the configured XCom identity, and the configured network namespace manager. The caller does not need to switch to the configured network namespace before invoking this function; if a namespace is configured, the function enters and restores it internally before probing interfaces.
| [in] | name | The candidate host or IP to classify. |
| [in] | port | The candidate XCom port to classify. |
| 1 | The candidate endpoint was classified as this local node. |
| 0 | The candidate endpoint was not classified as this local node, or the local probe state could not be initialized. |
|
static |