MySQL 9.1.0
Source Code Documentation
net_ns.cc File Reference
#include "sql-common/net_ns.h"
#include <assert.h>
#include <sched.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <map>
#include <mutex>
#include <unordered_map>
#include "my_sys.h"
#include "mysql/components/services/log_builtins.h"
#include "mysqld_error.h"

Macros

#define _GNU_SOURCE
 

Typedefs

using namespaces_registry_t = std::map< std::string, int >
 

Functions

static bool open_network_namespace (const std::string &network_namespace, int *fd)
 Open a network namespace specified by function argument. More...
 
static bool save_original_network_namespace (int *orig_ns_fd)
 Remember a file descriptor corresponding to the current active network namespace. More...
 
bool set_network_namespace (const std::string &network_namespace)
 Set active network namespace specified by a name. More...
 
bool restore_original_network_namespace ()
 Restore original network namespace used to be active before a new network namespace has been set. More...
 
void release_network_namespace_resources ()
 Close file descriptors for every opened network namespace file and release a memory used by internal cache of opened network namespaces. More...
 

Variables

static namespaces_registry_t opened_namespaces
 
static std::mutex lock
 
static int original_ns_fd = -1
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Typedef Documentation

◆ namespaces_registry_t

using namespaces_registry_t = std::map<std::string, int>

Function Documentation

◆ open_network_namespace()

static bool open_network_namespace ( const std::string &  network_namespace,
int *  fd 
)
static

Open a network namespace specified by function argument.

Parameters
network_namespacea name of the network namespace to open
[out]fdfile descriptor corresponding to the opened network namespace
Returns
false on success, true on failure

◆ release_network_namespace_resources()

void release_network_namespace_resources ( )

Close file descriptors for every opened network namespace file and release a memory used by internal cache of opened network namespaces.

◆ restore_original_network_namespace()

bool restore_original_network_namespace ( )

Restore original network namespace used to be active before a new network namespace has been set.

Returns
false on success, true on failure

◆ save_original_network_namespace()

static bool save_original_network_namespace ( int *  orig_ns_fd)
static

Remember a file descriptor corresponding to the current active network namespace.

Parameters
[out]orig_ns_fdfile descriptor corresponding to a network namespace used to be active before
Returns
false on success, true on failure

◆ set_network_namespace()

bool set_network_namespace ( const std::string &  network_namespace)

Set active network namespace specified by a name.

Parameters
network_namespacethe name of a network namespace to be set active
Returns
false on success, true on error
Note
all opened descriptors used during function run are closed on error

Variable Documentation

◆ lock

std::mutex lock
static

◆ opened_namespaces

namespaces_registry_t opened_namespaces
static

◆ original_ns_fd

int original_ns_fd = -1
static