libnl  3.2.21
Open vSwitch Datapath (Fast Path)

Data Structures

struct  ovs_dp
 Open vSwitch datapath object. More...

Enumerations

enum  ovs_dp_stat_id_t {
  OVS_DP_STAT_HIT,
  OVS_DP_STAT_MISSED,
  OVS_DP_STAT_LOST,
  OVS_DP_STAT_FLOWS,
  __OVS_DP_STAT_MAX
}
 Datapath statistic identifiers.

Retrieving and Lookup

int ovs_dp_alloc_cache (struct nl_sock *sk, struct nl_cache **result)
 Allocate cache and fill it with all configured datapaths.
struct ovs_dpovs_dp_lookup (struct nl_cache *cache, const char *name)
 Lookup datpath by name.

Addition / Deletion

int ovs_dp_build_add_request (const struct ovs_dp *dp, int flags, struct nl_msg **result)
 Build Generic Netlink message requesting addition of OVS datapath.
int ovs_dp_add (struct nl_sock *sk, const struct ovs_dp *dp, int flags)
 Add OVS datapath.
int ovs_dp_build_delete_request (const struct ovs_dp *dp, int flags, struct nl_msg **result)
 Build Generic Netlink message requesting deletion of OVS datapath.
int ovs_dp_delete (struct nl_sock *sk, const struct ovs_dp *dp, int flags)
 Delete OVS datapath.

Accessing Datapath Attributes

struct ovs_dpovs_dp_alloc (void)
 Allocate Open vSwitch Datapath.
void ovs_dp_put (struct ovs_dp *dp)
 Give up reference to a datpath object.
void ovs_dp_set_name (struct ovs_dp *dp, const char *name)
 Set datpath name.
const char * ovs_dp_get_name (const struct ovs_dp *dp)
 Return datpath name.
void ovs_dp_set_ifindex (struct ovs_dp *dp, int ifindex)
 Set interface index of datapath port.
int ovs_dp_get_ifindex (const struct ovs_dp *dp)
 Return interface index of datapath port.
void ovs_dp_set_upcall_pid (struct ovs_dp *dp, int pid)
 Set upcall PID.
int ovs_dp_get_upcall_pid (const struct ovs_dp *dp)
 Return upcall PID.

Statistics

uint64_t ovs_dp_get_stat (const struct ovs_dp *dp, ovs_dp_stat_id_t id)
 Return value of datapath statistics counter.
int ovs_dp_set_stat (struct ovs_dp *dp, ovs_dp_stat_id_t id, const uint64_t value)
 Set value of datpath statistics counter.
const char * ovs_dp_stat2str (ovs_dp_stat_id_t st, char *buf, size_t len)
 Translate datapath statistic ID to name.
int ovs_dp_str2stat (const char *name)
 Translate datapath statistic name to identifier.

Detailed Description


Function Documentation

int ovs_dp_alloc_cache ( struct nl_sock *  sk,
struct nl_cache **  result 
)

Allocate cache and fill it with all configured datapaths.

Parameters:
skNetlink socket.
resultPointer to store resulting cache.

Allocates and initializes a new datpath cache. A netlink message is sent to the kernel requesting a full dump of all configured datpaths. The returned messages are parsed and filled into the cache.

See also:
ovs_dp_lookup()
Returns:
0 on success or a negative error code.

Definition at line 195 of file datapath.c.

References nl_cache_alloc(), nl_cache_free(), and nl_cache_refill().

+ Here is the call graph for this function:

struct ovs_dp* ovs_dp_lookup ( struct nl_cache *  cache,
const char *  name 
)
read

Lookup datpath by name.

Parameters:
cacheDapath cache
nameName of datapath

Find a datapath in the cache matching the provided named.

Attention:
The reference counter of the returned datpath object will be incremented. Use ovs_dp_put() to release the reference.
See also:
ovs_dp_alloc_cache(0
ovs_dp_put()
Returns:
Datpath object or NULL if no match was found.

Definition at line 227 of file datapath.c.

References nl_object_get().

+ Here is the call graph for this function:

int ovs_dp_build_add_request ( const struct ovs_dp dp,
int  flags,
struct nl_msg **  result 
)

Build Generic Netlink message requesting addition of OVS datapath.

Parameters:
dpDatapath object
flagsAdditional netlink message flags (unused)
resultPointer to store resulting Netlink message

Identical to ovs_dp_add() but returns message instead of sending it to the kernel.

See also:
ovs_dp_add()
Returns:
0 on success or a negative error code.

Definition at line 364 of file datapath.c.

Referenced by ovs_dp_add().

+ Here is the caller graph for this function:

int ovs_dp_add ( struct nl_sock *  sk,
const struct ovs_dp dp,
int  flags 
)

Add OVS datapath.

Parameters:
skNetlink socket.
dpDatapath object
flagsAdditional netlink message flags (unused)

Builds a Generic Netlink message with command OVS_DP_CMD_NEW requesting the addition of a new Open vSwitch datapath and sends the message to the kernel.

After sending, the function will wait for the ACK or an eventual error message and thus blocks until the operation has been completed.

See also:
ovs_dp_build_add_request()

Attention:
Disabling Auto-ACK (nl_socket_disable_auto_ack()) will cause this function to return immediately after sending the netlink message. The function will not wait for an eventual error message. It is the responsibility of the caller to handle any error messages or ACKs returned.

Returns:
0 on success or a negative error code.

Definition at line 389 of file datapath.c.

References nl_send_sync(), and ovs_dp_build_add_request().

+ Here is the call graph for this function:

int ovs_dp_build_delete_request ( const struct ovs_dp dp,
int  flags,
struct nl_msg **  result 
)

Build Generic Netlink message requesting deletion of OVS datapath.

Parameters:
dpDatapath object to delete
flagsAdditional netlink message flags (unused)
resultPointer to store resulting Netlink message

Identical to ovs_dp_delete() but returns message instead of sending it to the kernel.

See also:
ovs_dp_delete()
Returns:
0 on success or a negative error code.

Definition at line 414 of file datapath.c.

Referenced by ovs_dp_delete().

+ Here is the caller graph for this function:

int ovs_dp_delete ( struct nl_sock *  sk,
const struct ovs_dp dp,
int  flags 
)

Delete OVS datapath.

Parameters:
skNetlink socket.
dpDatapath object
flagsAdditional netlink message flags (unused)

Builds a Generic Netlink message with command OVS_DP_CMD_DEL requesting the deletion of a new Open vSwitch datapath and sends the message to the kernel.

After sending, the function will wait for the ACK or an eventual error message and thus blocks until the operation has been completed.

See also:
ovs_dp_build_add_request()

Attention:
Disabling Auto-ACK (nl_socket_disable_auto_ack()) will cause this function to return immediately after sending the netlink message. The function will not wait for an eventual error message. It is the responsibility of the caller to handle any error messages or ACKs returned.

Returns:
0 on success or a negative error code.

Definition at line 439 of file datapath.c.

References nl_send_sync(), and ovs_dp_build_delete_request().

+ Here is the call graph for this function:

struct ovs_dp* ovs_dp_alloc ( void  )
read

Allocate Open vSwitch Datapath.

See also:
ovs_dp_put()
Returns:
New datapath object or NULL if allocation failed

Definition at line 463 of file datapath.c.

References nl_object_alloc().

+ Here is the call graph for this function:

void ovs_dp_put ( struct ovs_dp dp)

Give up reference to a datpath object.

Parameters:
dpDatapath object

Definition at line 472 of file datapath.c.

References nl_object_put().

+ Here is the call graph for this function:

void ovs_dp_set_name ( struct ovs_dp dp,
const char *  name 
)

Set datpath name.

Parameters:
dpDatapath object
nameNew name

Note:
The attribute this accessor is modifying is a read-only attribute which can not be modified in the kernel. Any changes to the attribute only have an effect on the local copy of the object. The accessor function is provided solely for the purpose of creating objects for comparison and filtering.

See also:
ovs_dp_get_name()

Definition at line 485 of file datapath.c.

const char* ovs_dp_get_name ( const struct ovs_dp dp)

Return datpath name.

Parameters:
dpDatapath object
See also:
ovs_dp_set_name()
Returns:
Datapath name or NULL if name is not specified

Definition at line 498 of file datapath.c.

void ovs_dp_set_ifindex ( struct ovs_dp dp,
int  ifindex 
)

Set interface index of datapath port.

Parameters:
dpDatapath object
ifindexInterface index
See also:
ovs_dp_get_ifindex()

Definition at line 510 of file datapath.c.

int ovs_dp_get_ifindex ( const struct ovs_dp dp)

Return interface index of datapath port.

Parameters:
dpDatapath object
See also:
ovs_dp_set_ifindex()
Returns:
Interface index or 0 if not set.

Definition at line 524 of file datapath.c.

void ovs_dp_set_upcall_pid ( struct ovs_dp dp,
int  pid 
)

Set upcall PID.

Parameters:
dpDatapath object
pidUpcall PID
See also:
ovs_dp_get_upcall_pid()

Definition at line 536 of file datapath.c.

int ovs_dp_get_upcall_pid ( const struct ovs_dp dp)

Return upcall PID.

Parameters:
dpDatapath object
See also:
ovs_dp_set_upcall_pid()
Returns:
Upcall PID or 0 if not set.

Definition at line 550 of file datapath.c.

uint64_t ovs_dp_get_stat ( const struct ovs_dp dp,
ovs_dp_stat_id_t  id 
)

Return value of datapath statistics counter.

Parameters:
dpDatapath object
idIdentifier of statistical counter
Returns:
Value of counter or 0 if not specified.

Definition at line 569 of file datapath.c.

int ovs_dp_set_stat ( struct ovs_dp dp,
ovs_dp_stat_id_t  id,
const uint64_t  value 
)

Set value of datpath statistics counter.

Parameters:
dpDatpath object
idIdentifier of statistical counter
valueNew value
Note:
Changing the value of a statistical counter will not change the value in the kernel.
Returns:
0 on success or a negative error code

Definition at line 588 of file datapath.c.

const char* ovs_dp_stat2str ( ovs_dp_stat_id_t  st,
char *  buf,
size_t  len 
)

Translate datapath statistic ID to name.

Parameters:
stDatapath statistic identifier
bufBuffer to store name
lenLength of buffer
Returns:
Pointer to buffer

Definition at line 615 of file datapath.c.

int ovs_dp_str2stat ( const char *  name)

Translate datapath statistic name to identifier.

Parameters:
nameName of datapath statistic identifier
Returns:
Numeric identifier if found or NULL

Definition at line 626 of file datapath.c.