Auxiliary library to define network in YAML format
Overview
Definition of test API to provide a way to set up test network defined in YAML files. More…
// global variables static const te_enum_map tapi_net_yaml_af_map[] = { {.name = "inet", .value = AF_INET}, {.name = "inet6", .value = AF_INET6}, TE_ENUM_MAP_END }; // global functions te_errno tapi_net_yaml_parse(const char* filename, tapi_net_ctx* net_ctx);
Detailed Documentation
Definition of test API to provide a way to set up test network defined in YAML files.
Global Variables
static const te_enum_map tapi_net_yaml_af_map[] = { {.name = "inet", .value = AF_INET}, {.name = "inet6", .value = AF_INET6}, TE_ENUM_MAP_END }
Mapping between an address family and its string representation used in the YAML configuration file.
Global Functions
te_errno tapi_net_yaml_parse(const char* filename, tapi_net_ctx* net_ctx)
Parse a YAML network configuration file.
The function reads a YAML document describing test agents, their base interfaces, and logical point-to-point networks built over those interfaces. On success it fills net_ctx with arrays of agents and networks that can be used to set up network for tests.
=== Data model (YAML schema, informal) ===
Root mapping contains:
“interfaces”: sequence (required)
“networks”: sequence (required)
interfaces: list of base NICs per agent. Each item is a mapping:
agent : string (required) // test agent name
names : sequence<string> // non-empty list of base ifaces
Parsed into: tapi_net_ta [] with per-agent lists of base interfaces as SLIST stacks (base at head). See tapi_net_ta/tapi_net_iface.
networks: list of point-to-point logical networks. Each item is a mapping with fields:
iface_type : enum { base, vlan, qinq, gre } (required)
af : enum { inet, inet6 } (required)
vlan_id : int >= 0 (VLAN only)
outer_id : int >= 0 (QinQ only, S-tag)
inner_id : int >= 0 (QinQ only, C-tag)
endpoints : sequence of exactly 2 mappings (required):
agent : string (required)
base_iface : string (required)
iface : string (optional; defaults to base_iface for ‘base’)
Behavior:
iface_type == base: No new logical interfaces are created; existing base interfaces are used as is.
iface_type in { vlan, qinq, gre }: Logical interfaces are created on top of the specified base interfaces and pushed into the per-base SLIST stack (e.g., GRE sub-interface can be based on VLAN sub-interface with vlan_id, which in turn can be based on one of the interfaces defined in the root ‘interfaces’ section). The endpoint “iface” field names the resulting logical interface.
Parsed into: tapi_net_link []; each net has name “test_net_<idx>”, address family, and two endpoints (agent/iface).
nat: list of NAT rules per agent (optional). Each item is a mapping:
agent : string (required)
rules : sequence<rule> (required)
rule mapping:
type : enum { snat, dnat } (required)
mode : enum { address, masquerade } (required)
from : { agent: string, iface: string } (required)
to : { agent: string, iface: string } (conditional)
Semantics:
For mode = “address”: Both
fromandtoendpoint objects are required. Static translation occurs between these two interfaces.For mode = “masquerade”: Supported only for
type= “snat”. Thetofield should be omitted. The configurator applies standard source NAT masquerading rules.
Parsed into: tapi_net_nat_rule [] associated with each tapi_net_ta in the network context.
=== Variable expansion ===
Scalar values in the YAML (strings and integers written as scalars) are passed through environment expansion.
Parameters:
filename |
Path to YAML configuration file. |
net_ctx |
Network configuration context. |
Returns:
Status code.