Phys (host machine)¶
-
group
phys
Functions for manipulating and configuring phys objects.
Phys is a representation of a physical machine that hosts tenants of virtual networks. Its
interface
attribute specifies the name of the network interface that is connected to the host network. In addition, some network types require IP addresses of physes.In order to start connecting virts, a phys must be attached to a virtual network. That only marks the phys as a participant in that network; a single phys can be attached to any number of networks.
In the network model, all physes must be represented on all machines. To select the current machine and configure network viewpoint, you must call lsdn_phys_claim_local. Kernel rules are then generated from the viewpoint of that phys.
It is possible to have multiple physes on the same machine and claimed local. This is useful in situations where the host machine has more than one interface connecting to a host network, or if the machine connects to more than one host network.
Defines
-
lsdn_mk_phys_name
(ctx)¶ Generate unique name for a phys.
- See
- lsdn_mk_name
- Parameters
ctx
: LSDN context.
Functions
-
struct lsdn_phys*
lsdn_phys_new
(struct lsdn_context * ctx)¶ Create a new phys.
Allocates and initializes a lsdn_phys structure.
- Return
- newly allocated lsdn_phys structure.
- Parameters
ctx
: LSDN context.
-
lsdn_err_t
lsdn_phys_set_name
(struct lsdn_phys * phys, const char * name)¶ Set a name for phys.
- Parameters
phys
: Phys.name
: New name string. Can beNULL
.
- Return Value
LSDNE_OK
: Name set successfully.LSDNE_DUPLICATE
: Phys with the same name already exists.LSDNE_NOMEM
: Failed to allocate memory for name.
-
const char*
lsdn_phys_get_name
(struct lsdn_phys * phys)¶ Get the phys’s name.
- Return
- pointer to phys’s name.
- Parameters
phys
: Phys.
-
struct lsdn_phys*
lsdn_phys_by_name
(struct lsdn_context * ctx, const char * name)¶ Find a phys by name.
- Return
- lsdn_phys structure if a phys with this name exists.
NULL
otherwise. - Parameters
ctx
: LSDN context.name
: Requested name.
-
void
lsdn_phys_free
(struct lsdn_phys * phys)¶ Free a phys.
Ensures that all virts on this phys are disconnected first.
- Parameters
phys
: Phys.
-
lsdn_err_t
lsdn_phys_attach
(struct lsdn_phys * phys, struct lsdn_net * net)¶ Attach phys to a virtual network.
Marks the phys as a participant in virtual network
net
. This must be done before any virts are allowed to connect tonet
through this phys.You can attach a phys to multiple virtual networks.
- Parameters
phys
: Phys.net
: Virtual network.
- Return Value
LSDNE_OK
: Attachment succeededLSDNE_NOMEM
: Failed to allocate memory for attachment.
-
void
lsdn_phys_detach
(struct lsdn_phys * phys, struct lsdn_net * net)¶ Detach phys from a virtual network.
After detaching, virts won’t be allowed to connect to a given network through this phys.
- Warning
- This will not disconnect currently connected virts. They must be disconnected explicitly. Otherwise, the next commit will fail validation.
- Parameters
phys
: Phys.net
: Virtual network.
-
lsdn_err_t
lsdn_phys_claim_local
(struct lsdn_phys * phys)¶ Assign a local phys.
All participants in a LSDN network must share a compatible memory model. That means that every host’s model contains all the physes in the network. This function configures a particular phys to be the local machine. Only rules related to virts on the local phys are entered into the kernel tables.
-
lsdn_err_t
lsdn_phys_set_ip
(struct lsdn_phys * object, lsdn_ip_t value)¶ Set IP address of a phys .
- Parameters
object
: phys to modify.value
: IP address .
-
const lsdn_ip_t*
lsdn_phys_get_ip
(struct lsdn_phys * object)¶ Get IP address of a phys .
The pointer is valid until the attribute is changed or object freed.
- Return
- value of IP address attribute, or
NULL
if unset. - Parameters
object
: phys to query.
-
void
lsdn_phys_clear_ip
(struct lsdn_phys * object)¶ Clear IP address of a phys .
- Parameters
object
: phys to modify.
-
lsdn_err_t
lsdn_phys_set_iface
(struct lsdn_phys * object, const char * value)¶ Set interface of a phys .
- Parameters
object
: phys to modify.value
: interface .
-
struct
lsdn_phys
¶ - #include <lsdn.h>
Phys.
Represents a kernel interface for a host node, e.g., eth0 on lsdn1. Physes are attached to network, and then virts can connect through them.
See Phys (host machine).
See Virtual network.
-