|
libosmocore 1.13.1.12-8e6ea
Osmocom core library
|
Network namespace convenience functions. More...
Files | |
| file | netns.c |
Macros | |
| #define | _GNU_SOURCE |
| #define | NETNS_PREFIX_PATH "/var/run/netns" |
| #define | NETNS_CURRENT_PATH "/proc/self/ns/net" |
Functions | |
| int | osmo_netns_switch_enter (int nsfd, struct osmo_netns_switch_state *state) |
| switch to a (non-default) namespace, store existing signal mask in oldmask. More... | |
| int | osmo_netns_switch_exit (struct osmo_netns_switch_state *state) |
| switch back to the previous namespace, restoring signal mask. More... | |
| static int | create_netns (const char *name) |
| int | osmo_netns_open_fd (const char *name) |
| Open a file descriptor for the network namespace with provided name. More... | |
Network namespace convenience functions.
| #define _GNU_SOURCE |
| #define NETNS_CURRENT_PATH "/proc/self/ns/net" |
| #define NETNS_PREFIX_PATH "/var/run/netns" |
|
static |
References ENOTSUP, MAXPATHLEN, name, NETNS_CURRENT_PATH, and NETNS_PREFIX_PATH.
Referenced by osmo_netns_open_fd().
| int osmo_netns_open_fd | ( | const char * | name | ) |
Open a file descriptor for the network namespace with provided name.
Creates /var/run/netns/ directory if it doesn't exist already.
| [in] | name | Name of the network namespace (in /var/run/netns/) |
References create_netns(), MAXPATHLEN, name, and NETNS_PREFIX_PATH.
Referenced by netdev_netns_ctx_init(), and osmo_tundev_open().
| int osmo_netns_switch_enter | ( | int | nsfd, |
| struct osmo_netns_switch_state * | state | ||
| ) |
switch to a (non-default) namespace, store existing signal mask in oldmask.
| [in] | nsfd | file descriptor representing the namespace to which we shall switch |
| [out] | state | caller-provided memory location to which state of previous netns is stored |
References ENOTSUP, osmo_netns_switch_state::prev_nsfd, and osmo_netns_switch_state::prev_sigmask.
Referenced by netdev_netns_ctx_init(), and osmo_tundev_open().
| int osmo_netns_switch_exit | ( | struct osmo_netns_switch_state * | state | ) |
switch back to the previous namespace, restoring signal mask.
| [in] | state | information about previous netns, filled by osmo_netns_switch_enter() |
References ENOTSUP, osmo_netns_switch_state::prev_nsfd, and osmo_netns_switch_state::prev_sigmask.
Referenced by netdev_netns_ctx_init(), and osmo_tundev_open().