Routing Table configuration

Overview

// typedefs

typedef struct tapi_rt_entry tapi_rt_entry_t;
typedef struct tapi_cfg_rt_nexthop tapi_cfg_rt_nexthop;
typedef struct tapi_cfg_rt_params tapi_cfg_rt_params;

// structs

struct tapi_cfg_rt_nexthop;
struct tapi_cfg_rt_params;
struct tapi_rt_entry;

// global functions

int tapi_cfg_get_route_table(const char* ta, int addr_family, tapi_rt_entry_t** rt_tbl, unsigned int* n);
void tapi_cfg_rt_params_init(tapi_cfg_rt_params* params);
int tapi_cfg_add_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, cfg_handle* rt_hndl);
int tapi_cfg_add_full_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, const char* type, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, int table, cfg_handle* cfg_hndl);
static int tapi_cfg_add_typed_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, const char* type, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, cfg_handle* cfg_hndl);
int tapi_cfg_modify_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, cfg_handle* rt_hndl);
te_errno tapi_cfg_modify_route2(const char* ta, tapi_cfg_rt_params* params, cfg_handle* rt_hndl);
int tapi_cfg_modify_full_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, const char* type, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, int table, cfg_handle* cfg_hndl);
static int tapi_cfg_modify_typed_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, const char* type, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, cfg_handle* cfg_hndl);
int tapi_cfg_del_route_tmp(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, uint32_t flags, int metric, int tos, int mtu, int win, int irtt);
int tapi_cfg_del_route(cfg_handle* rt_hndl);
static int tapi_cfg_add_route_via_gw(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr);
static int tapi_cfg_del_route_via_gw(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr);
te_errno tapi_cfg_add_route_simple(const char* ta, const struct sockaddr* target, int prefixlen, const struct sockaddr* gw, const char* dev);
te_errno tapi_cfg_del_route_simple(const char* ta, const struct sockaddr* target, int prefixlen, const struct sockaddr* gw, const char* dev);
te_errno tapi_cfg_add_route2(const char* ta, tapi_cfg_rt_params* params, cfg_handle* rt_hndl);

// macros

#define TAPI_RT_GW
#define TAPI_RT_IF
#define TAPI_RT_METRIC
#define TAPI_RT_SRC
#define TAPI_RT_TABLE
#define TAPI_RT_TABLE_LOCAL
#define TAPI_RT_TABLE_MAIN
#define TAPI_RT_TOS
#define TYPE_NAMESIZE

Detailed Documentation

Typedefs

typedef struct tapi_rt_entry tapi_rt_entry_t

Routing entry data structure

typedef struct tapi_cfg_rt_nexthop tapi_cfg_rt_nexthop

Nexthop of a multipath route.

typedef struct tapi_cfg_rt_params tapi_cfg_rt_params

Structure storing parameters of tapi_cfg_add_route2().

Global Functions

int tapi_cfg_get_route_table(const char* ta, int addr_family, tapi_rt_entry_t** rt_tbl, unsigned int* n)

Gets routing table on the specified Test Agent

Function allocates memory with malloc(), which should be freed with free() by the caller.

Parameters:

ta

Test Agent name

addr_family

Address family of the routes (AF_INET)

rt_tbl

Pointer to the routing table (OUT)

n

The number of entries in the table (OUT)

Returns:

0 on success, and TE errno in case of failure.

void tapi_cfg_rt_params_init(tapi_cfg_rt_params* params)

Initialize tapi_cfg_rt_params fields.

Parameters:

params

Pointer to tapi_cfg_rt_params structure.

int tapi_cfg_add_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, cfg_handle* rt_hndl)

Add a new route to some destination address with a lot of additional route attributes

For more information about the meaning of parameters see “man route”.

Parameters:

ta

Test agent name

addr_family

Address family of destination and gateway addresses

dst_addr

Destination address

prefix

Prefix for destination address

gw_addr

Gateway address

dev

Interface name (for direct route)

src_addr

Default source address

flags

Flags to be added for the route (see route flags in net/route.h system header)

metric

Route metric

tos

Type of service

mtu

TCP Maximum Segment Size (MSS) on the route

win

TCP window size for connections over this route

irtt

initial round trip time (irtt) for TCP connections over this route (in milliseconds)

rt_hndl

Route handle (OUT)

0

  • on success

Returns:

Status code

int tapi_cfg_add_full_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, const char* type, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, int table, cfg_handle* cfg_hndl)

Same as tapi_cfg_add_route() but allows to specify a route type and route table id NOTE: currently only “blackhole” and “unicast” types are supported.

static int tapi_cfg_add_typed_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, const char* type, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, cfg_handle* cfg_hndl)

Same as tapi_cfg_add_route() but allows to specify a route type NOTE: currently only “blackhole” and “unicast” types are supported.

int tapi_cfg_modify_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, cfg_handle* rt_hndl)

Changes attribute of the existing route.

For more information about the meaning of parameters see “man route”.

Parameters:

ta

Test agent name

addr_family

Address family of destination and gateway addresses

dst_addr

Destination address

prefix

Prefix for destination address

gw_addr

Gateway address

dev

Interface name (for direct route)

src_addr

Default source address

flags

Flags to be added for the route (see route flags in net/route.h system header)

metric

Route metric

tos

Route type of service

mtu

TCP Maximum Segment Size (MSS) on the route

win

TCP window size for connections over this route

irtt

initial round trip time (irtt) for TCP connections over this route (in milliseconds)

rt_hndl

Route handle (OUT)

0

  • on success

Returns:

Status code

te_errno tapi_cfg_modify_route2(const char* ta, tapi_cfg_rt_params* params, cfg_handle* rt_hndl)

Modify existing route.

Parameters:

ta

Test Agent name.

params

Route parameters.

rt_hndl

Where to save configurator handle of a route (may be NULL).

Returns:

Status code.

int tapi_cfg_modify_full_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, const char* type, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, int table, cfg_handle* cfg_hndl)

Same as tapi_cfg_modify_route() but allows to specify a route type and route table id NOTE: currently only “blackhole” and “unicast” types are supported.

static int tapi_cfg_modify_typed_route(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, const char* type, uint32_t flags, int metric, int tos, int mtu, int win, int irtt, cfg_handle* cfg_hndl)

Same as tapi_cfg_modify_route() but allows to specify a route type. NOTE: currently “unicast” type is supported, so the function behaves exactly like tapi_cfg_modify_route().

int tapi_cfg_del_route_tmp(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr, const char* dev, const void* src_addr, uint32_t flags, int metric, int tos, int mtu, int win, int irtt)

Delete specified route

For more information about the meaning of parameters see “man route”.

Parameters:

ta

Test agent name

addr_family

Address family of destination and gateway addresses

dst_addr

Destination address

prefix

Prefix for destination address

gw_addr

Gateway address

dev

Interface name (for direct route)

src_addr

Default source address

flags

Flags to be added for the route (see route flags in net/route.h system header)

metric

Route metric

tos

Route type of service

mtu

TCP Maximum Segment Size (MSS) on the route

win

TCP window size for connections over this route

irtt

initial round trip time (irtt) for TCP connections over this route (in milliseconds)

0

  • on success

Returns:

Status code

int tapi_cfg_del_route(cfg_handle* rt_hndl)

Delete route by handle got with tapi_cfg_add_route() function

Parameters:

rt_hndl

Route handle

Returns:

0 on success, and TE errno on failure

static int tapi_cfg_add_route_via_gw(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr)

Add a new indirect route (via a gateway) on specified Test agent

Parameters:

ta

Test agent

addr_family

Address family of destination and gateway addresses

dst_addr

Destination address

prefix

Prefix for destination address

gw_addr

Gateway address

Returns:

0 - on success, or TE error code

static int tapi_cfg_del_route_via_gw(const char* ta, int addr_family, const void* dst_addr, int prefix, const void* gw_addr)

Deletes route added with ‘tapi_cfg_add_route_via_gw’ function

Parameters:

ta

Test agent name

addr_family

Address family of destination and gateway addresses

dst_addr

Destination address

prefix

Prefix for destination address

gw_addr

Gateway address

Returns:

0 - on success, or TE error code

te_errno tapi_cfg_add_route_simple(const char* ta, const struct sockaddr* target, int prefixlen, const struct sockaddr* gw, const char* dev)

Add a new simple route to destination network or host address

Added route can be removed with tapi_cfg_del_route_simple()

Parameters:

ta

Test agent name

target

Destination network or host address

prefixlen

Prefix length of destination address

gw

Gateway address to route packets via a gateway, may be NULL for direct route

dev

Interface name, force the route to be associated with the specified device. May be NULL if gw is defined

Returns:

Status code

See also:

tapi_cfg_add_route_via_gw, tapi_cfg_add_route

te_errno tapi_cfg_del_route_simple(const char* ta, const struct sockaddr* target, int prefixlen, const struct sockaddr* gw, const char* dev)

Delete a route added with tapi_cfg_add_route_simple(), use the same argument values

te_errno tapi_cfg_add_route2(const char* ta, tapi_cfg_rt_params* params, cfg_handle* rt_hndl)

Add a new route.

Parameters:

ta

Test Agent name.

params

Route parameters.

rt_hndl

Where to save configurator handle of a new route (may be NULL).

Returns:

Status code.

Macros

#define TAPI_RT_GW

Route is indirect and has gateway address

#define TAPI_RT_IF

Route is direct, so interface name is specified

#define TAPI_RT_METRIC

Metric is specified for the route

#define TAPI_RT_SRC

Default source address is specified for the route

#define TAPI_RT_TABLE

Table ID for the route

#define TAPI_RT_TABLE_LOCAL

Local table maintained by kernel

#define TAPI_RT_TABLE_MAIN

Default table for normal rules

#define TAPI_RT_TOS

Type of service is specified for the route

#define TYPE_NAMESIZE

Maximum length of the route type name