Data Structures | Modules | Defines | Enumerations

Traffic Control
[Routing Family]

Data Structures

struct  rtnl_tc_ops
 Traffic control object operationsThis structure holds function pointers and settings implementing the features of each traffic control object implementation. More...

Modules

 Queueing Classes
 ClassID Management
 Classifiers
 Packet Location Aliasing
 

Packet Location Aliasing.


 Queueing Disciplines

Defines

#define TC_CAST(ptr)   ((struct rtnl_tc *) (ptr))
 Macro to cast qdisc/class/classifier to tc object.

Enumerations

enum  rtnl_tc_stat {
  RTNL_TC_PACKETS,
  RTNL_TC_BYTES,
  RTNL_TC_RATE_BPS,
  RTNL_TC_RATE_PPS,
  RTNL_TC_QLEN,
  RTNL_TC_BACKLOG,
  RTNL_TC_DROPS,
  RTNL_TC_REQUEUES,
  RTNL_TC_OVERLIMITS,
  __RTNL_TC_STATS_MAX
}
 

Traffic control statistical identifier.

More...

Attributes



void rtnl_tc_set_ifindex (struct rtnl_tc *tc, int ifindex)
 Set interface index of traffic control object.
int rtnl_tc_get_ifindex (struct rtnl_tc *tc)
 Return interface index of traffic control object.
void rtnl_tc_set_link (struct rtnl_tc *tc, struct rtnl_link *link)
 Set link of traffic control object.
void rtnl_tc_set_mtu (struct rtnl_tc *tc, uint32_t mtu)
 Set the Maximum Transmission Unit (MTU) of traffic control object.
uint32_t rtnl_tc_get_mtu (struct rtnl_tc *tc)
 Return the MTU of traffic control object.
void rtnl_tc_set_mpu (struct rtnl_tc *tc, uint32_t mpu)
 Set the Minimum Packet Unit (MPU) of a traffic control object.
uint32_t rtnl_tc_get_mpu (struct rtnl_tc *tc)
 Return the Minimum Packet Unit (MPU) of a traffic control object.
void rtnl_tc_set_overhead (struct rtnl_tc *tc, uint32_t overhead)
 Set per packet overhead of a traffic control object.
uint32_t rtnl_tc_get_overhead (struct rtnl_tc *tc)
 Return per packet overhead of a traffic control object.
void rtnl_tc_set_linktype (struct rtnl_tc *tc, uint32_t type)
 Set the linktype of a traffic control object.
uint32_t rtnl_tc_get_linktype (struct rtnl_tc *tc)
 Return the linktype of a traffic control object.
void rtnl_tc_set_handle (struct rtnl_tc *tc, uint32_t id)
 Set identifier of traffic control object.
uint32_t rtnl_tc_get_handle (struct rtnl_tc *tc)
 Return identifier of a traffic control object.
void rtnl_tc_set_parent (struct rtnl_tc *tc, uint32_t parent)
 Set the parent identifier of a traffic control object.
uint32_t rtnl_tc_get_parent (struct rtnl_tc *tc)
 Return parent identifier of a traffic control object.
int rtnl_tc_set_kind (struct rtnl_tc *tc, const char *kind)
 Define the type of traffic control object.
char * rtnl_tc_get_kind (struct rtnl_tc *tc)
 Return kind of traffic control object.
uint64_t rtnl_tc_get_stat (struct rtnl_tc *tc, enum rtnl_tc_stat id)
 Return value of a statistical counter of a traffic control object.

Utilities



int rtnl_tc_calc_txtime (int bufsize, int rate)
 Calculate time required to transmit buffer at a specific rate.
int rtnl_tc_calc_bufsize (int txtime, int rate)
 Calculate buffer size able to transmit in a specific time and rate.
int rtnl_tc_calc_cell_log (int cell_size)
 Calculate the binary logarithm for a specific cell size.

Rate Tables



int rtnl_tc_build_rate_table (struct rtnl_tc *tc, struct rtnl_ratespec *spec, uint32_t *dst)
 Compute a transmission time lookup table.

TC implementation of cache functions



void rtnl_tc_free_data (struct nl_object *obj)
int rtnl_tc_clone (struct nl_object *dstobj, struct nl_object *srcobj)
void rtnl_tc_dump_line (struct nl_object *obj, struct nl_dump_params *p)
void rtnl_tc_dump_details (struct nl_object *obj, struct nl_dump_params *p)
void rtnl_tc_dump_stats (struct nl_object *obj, struct nl_dump_params *p)
int rtnl_tc_compare (struct nl_object *aobj, struct nl_object *bobj, uint32_t attrs, int flags)

Modules API



struct rtnl_tc_opsrtnl_tc_lookup_ops (enum rtnl_tc_type type, const char *kind)
struct rtnl_tc_opsrtnl_tc_get_ops (struct rtnl_tc *tc)
int rtnl_tc_register (struct rtnl_tc_ops *ops)
 Register a traffic control module.
void rtnl_tc_unregister (struct rtnl_tc_ops *ops)
 Unregister a traffic control module.
void * rtnl_tc_data (struct rtnl_tc *tc)
void rtnl_tc_type_register (struct rtnl_tc_type_ops *ops)
void rtnl_tc_type_unregister (struct rtnl_tc_type_ops *ops)

Define Documentation

#define TC_CAST (   ptr  )     ((struct rtnl_tc *) (ptr))

Macro to cast qdisc/class/classifier to tc object.

 rtnl_tc_set_mpu(TC_CAST(qdisc), 40);

Definition at line 40 of file tc.h.

Referenced by rtnl_class_dsmark_get_bitmask(), rtnl_class_dsmark_get_value(), rtnl_class_dsmark_set_bitmask(), rtnl_class_dsmark_set_value(), rtnl_class_foreach_child(), rtnl_htb_set_cbuffer(), rtnl_htb_set_ceil(), rtnl_htb_set_defcls(), rtnl_htb_set_quantum(), rtnl_htb_set_rate(), rtnl_htb_set_rbuffer(), rtnl_netem_get_corruption_correlation(), rtnl_netem_get_corruption_probability(), rtnl_netem_get_delay(), rtnl_netem_get_delay_correlation(), rtnl_netem_get_delay_distribution(), rtnl_netem_get_delay_distribution_size(), rtnl_netem_get_duplicate(), rtnl_netem_get_duplicate_correlation(), rtnl_netem_get_gap(), rtnl_netem_get_jitter(), rtnl_netem_get_limit(), rtnl_netem_get_loss(), rtnl_netem_get_loss_correlation(), rtnl_netem_get_reorder_correlation(), rtnl_netem_get_reorder_probability(), rtnl_netem_set_corruption_correlation(), rtnl_netem_set_corruption_probability(), rtnl_netem_set_delay(), rtnl_netem_set_delay_correlation(), rtnl_netem_set_delay_distribution(), rtnl_netem_set_duplicate(), rtnl_netem_set_duplicate_correlation(), rtnl_netem_set_gap(), rtnl_netem_set_jitter(), rtnl_netem_set_limit(), rtnl_netem_set_loss(), rtnl_netem_set_loss_correlation(), rtnl_netem_set_reorder_correlation(), rtnl_netem_set_reorder_probability(), rtnl_qdisc_dsmark_get_default_index(), rtnl_qdisc_dsmark_get_indices(), rtnl_qdisc_dsmark_get_set_tc_index(), rtnl_qdisc_dsmark_set_default_index(), rtnl_qdisc_dsmark_set_indices(), rtnl_qdisc_dsmark_set_set_tc_index(), rtnl_qdisc_fifo_get_limit(), rtnl_qdisc_fifo_set_limit(), rtnl_qdisc_foreach_child(), rtnl_qdisc_prio_get_bands(), rtnl_qdisc_prio_get_priomap(), rtnl_qdisc_prio_set_bands(), rtnl_qdisc_prio_set_priomap(), rtnl_qdisc_tbf_get_limit(), rtnl_qdisc_tbf_get_peakrate(), rtnl_qdisc_tbf_get_peakrate_bucket(), rtnl_qdisc_tbf_get_peakrate_cell(), rtnl_qdisc_tbf_get_rate(), rtnl_qdisc_tbf_get_rate_bucket(), rtnl_qdisc_tbf_get_rate_cell(), rtnl_qdisc_tbf_set_limit(), rtnl_qdisc_tbf_set_limit_by_latency(), rtnl_qdisc_tbf_set_peakrate(), rtnl_qdisc_tbf_set_rate(), rtnl_red_get_limit(), rtnl_red_set_limit(), rtnl_sfq_get_divisor(), rtnl_sfq_get_limit(), rtnl_sfq_get_perturb(), rtnl_sfq_get_quantum(), rtnl_sfq_set_limit(), rtnl_sfq_set_perturb(), rtnl_sfq_set_quantum(), and rtnl_u32_add_key().


Enumeration Type Documentation

Traffic control statistical identifier.

 uint64_t n = rtnl_tc_get_stat(TC_CAST(class), RTNL_TC_PACKETS);
Enumerator:
RTNL_TC_PACKETS 

Number of packets seen.

RTNL_TC_BYTES 

Total bytes seen.

RTNL_TC_RATE_BPS 

Current bits/s (rate estimator).

RTNL_TC_RATE_PPS 

Current packet/s (rate estimator).

RTNL_TC_QLEN 

Current queue length.

RTNL_TC_BACKLOG 

Current backlog length.

RTNL_TC_DROPS 

Total number of packets dropped.

RTNL_TC_REQUEUES 

Total number of requeues.

RTNL_TC_OVERLIMITS 

Total number of overlimits.

Definition at line 50 of file tc.h.


Function Documentation

void rtnl_tc_set_ifindex ( struct rtnl_tc *  tc,
int  ifindex 
)

Set interface index of traffic control object.

Parameters:
tc traffic control object
ifindex interface index.

Sets the interface index of a traffic control object. The interface index defines the network device which this tc object is attached to. This function will overwrite any network device assigned with previous calls to rtnl_tc_set_ifindex() or rtnl_tc_set_link().

Definition at line 250 of file tc.c.

Referenced by rtnl_class_foreach_child(), rtnl_class_foreach_cls(), rtnl_qdisc_foreach_child(), and rtnl_qdisc_foreach_cls().

Here is the caller graph for this function:

int rtnl_tc_get_ifindex ( struct rtnl_tc *  tc  ) 

Return interface index of traffic control object.

Parameters:
tc traffic control object

Definition at line 265 of file tc.c.

void rtnl_tc_set_link ( struct rtnl_tc *  tc,
struct rtnl_link *  link 
)

Set link of traffic control object.

Parameters:
tc traffic control object
link link object

Sets the link of a traffic control object. This function serves the same purpose as rtnl_tc_set_ifindex() but due to the continued allowed access to the link object it gives it the possibility to retrieve sane default values for the the MTU and the linktype. Always prefer this function over rtnl_tc_set_ifindex() if you can spare to have an additional link object around.

Definition at line 282 of file tc.c.

References nl_object_get().

Here is the call graph for this function:

void rtnl_tc_set_mtu ( struct rtnl_tc *  tc,
uint32_t  mtu 
)

Set the Maximum Transmission Unit (MTU) of traffic control object.

Parameters:
tc traffic control object
mtu largest packet size expected

Sets the MTU of a traffic control object. Not all traffic control objects will make use of this but it helps while calculating rate tables. This value is typically derived directly from the link the tc object is attached to if the link has been assigned via rtnl_tc_set_link(). It is usually not necessary to set the MTU manually, this function is provided to allow overwriting the derived value.

Definition at line 308 of file tc.c.

uint32_t rtnl_tc_get_mtu ( struct rtnl_tc *  tc  ) 

Return the MTU of traffic control object.

Parameters:
tc traffic control object

Returns the MTU of a traffic control object which has been set via:

  1. User specified value set via rtnl_tc_set_mtu()
  2. Dervied from link set via rtnl_tc_set_link()
  3. Fall back to default: ethernet = 1600

Definition at line 323 of file tc.c.

Referenced by rtnl_tc_build_rate_table().

Here is the caller graph for this function:

void rtnl_tc_set_mpu ( struct rtnl_tc *  tc,
uint32_t  mpu 
)

Set the Minimum Packet Unit (MPU) of a traffic control object.

Parameters:
tc traffic control object
mpu minimum packet size expected

Sets the MPU of a traffic contorl object. It specifies the minimum packet size to ever hit this traffic control object. Not all traffic control objects will make use of this but it helps while calculating rate tables.

Definition at line 343 of file tc.c.

uint32_t rtnl_tc_get_mpu ( struct rtnl_tc *  tc  ) 

Return the Minimum Packet Unit (MPU) of a traffic control object.

Parameters:
tc traffic control object
Returns:
The MPU previously set via rtnl_tc_set_mpu() or 0.

Definition at line 355 of file tc.c.

Referenced by rtnl_tc_build_rate_table().

Here is the caller graph for this function:

void rtnl_tc_set_overhead ( struct rtnl_tc *  tc,
uint32_t  overhead 
)

Set per packet overhead of a traffic control object.

Parameters:
tc traffic control object
overhead overhead per packet in bytes

Sets the per packet overhead in bytes occuring on the link not seen by the kernel. This value can be used to correct size calculations if the packet size on the wire does not match the packet sizes seen in the network stack. Not all traffic control objects will make use this but it helps while calculating accurate packet sizes in the kernel.

Definition at line 372 of file tc.c.

uint32_t rtnl_tc_get_overhead ( struct rtnl_tc *  tc  ) 

Return per packet overhead of a traffic control object.

Parameters:
tc traffic control object
Returns:
The overhead previously set by rtnl_tc_set_overhead() or 0.

Definition at line 384 of file tc.c.

Referenced by rtnl_tc_build_rate_table().

Here is the caller graph for this function:

void rtnl_tc_set_linktype ( struct rtnl_tc *  tc,
uint32_t  type 
)

Set the linktype of a traffic control object.

Parameters:
tc traffic control object
type type of link (e.g. ARPHRD_ATM, ARPHRD_ETHER)

Overwrites the type of link this traffic control object is attached to. This value is typically derived from the link this tc object is attached if the link has been assigned via rtnl_tc_set_link(). It is usually not necessary to set the linktype manually. This function is provided to allow overwriting the linktype.

Definition at line 400 of file tc.c.

uint32_t rtnl_tc_get_linktype ( struct rtnl_tc *  tc  ) 

Return the linktype of a traffic control object.

Parameters:
tc traffic control object

Returns the linktype of the link the traffic control object is attached to:

  1. User specified value via rtnl_tc_set_linktype()
  2. Value derived from link set via rtnl_tc_set_link()
  3. Default fall-back: ARPHRD_ETHER

Definition at line 415 of file tc.c.

Referenced by rtnl_tc_build_rate_table().

Here is the caller graph for this function:

void rtnl_tc_set_handle ( struct rtnl_tc *  tc,
uint32_t  id 
)

Set identifier of traffic control object.

Parameters:
tc traffic control object
id unique identifier

Definition at line 430 of file tc.c.

uint32_t rtnl_tc_get_handle ( struct rtnl_tc *  tc  ) 

Return identifier of a traffic control object.

Parameters:
tc traffic control object

Definition at line 440 of file tc.c.

void rtnl_tc_set_parent ( struct rtnl_tc *  tc,
uint32_t  parent 
)

Set the parent identifier of a traffic control object.

Parameters:
tc traffic control object
parent identifier of parent traffif control object

Definition at line 451 of file tc.c.

Referenced by rtnl_class_foreach_child(), rtnl_class_foreach_cls(), rtnl_qdisc_foreach_child(), and rtnl_qdisc_foreach_cls().

Here is the caller graph for this function:

uint32_t rtnl_tc_get_parent ( struct rtnl_tc *  tc  ) 

Return parent identifier of a traffic control object.

Parameters:
tc traffic control object

Definition at line 461 of file tc.c.

int rtnl_tc_set_kind ( struct rtnl_tc *  tc,
const char *  kind 
)

Define the type of traffic control object.

Parameters:
tc traffic control object
kind name of the tc object type
Returns:
0 on success or a negative error code

Definition at line 473 of file tc.c.

Referenced by rtnl_class_foreach_child(), and rtnl_qdisc_foreach_child().

Here is the caller graph for this function:

char* rtnl_tc_get_kind ( struct rtnl_tc *  tc  ) 

Return kind of traffic control object.

Parameters:
tc traffic control object
Returns:
Kind of traffic control object or NULL if not set.

Definition at line 493 of file tc.c.

uint64_t rtnl_tc_get_stat ( struct rtnl_tc *  tc,
enum rtnl_tc_stat  id 
)

Return value of a statistical counter of a traffic control object.

Parameters:
tc traffic control object
id identifier of statistical counter
Returns:
Value of requested statistic counter or 0.

Definition at line 508 of file tc.c.

int rtnl_tc_calc_txtime ( int  bufsize,
int  rate 
)

Calculate time required to transmit buffer at a specific rate.

Parameters:
bufsize Size of buffer to be transmited in bytes.
rate Transmit rate in bytes per second.

Calculates the number of micro seconds required to transmit a specific buffer at a specific transmit rate.

\[ txtime=\frac{bufsize}{rate}10^6 \]

Returns:
Required transmit time in micro seconds.

Definition at line 537 of file tc.c.

Referenced by rtnl_qdisc_tbf_set_peakrate(), rtnl_qdisc_tbf_set_rate(), and rtnl_tc_build_rate_table().

Here is the caller graph for this function:

int rtnl_tc_calc_bufsize ( int  txtime,
int  rate 
)

Calculate buffer size able to transmit in a specific time and rate.

Parameters:
txtime Available transmit time in micro seconds.
rate Transmit rate in bytes per second.

Calculates the size of the buffer that can be transmitted in a specific time period at a specific transmit rate.

\[ bufsize=\frac{{txtime} \times {rate}}{10^6} \]

Returns:
Size of buffer in bytes.

Definition at line 560 of file tc.c.

int rtnl_tc_calc_cell_log ( int  cell_size  ) 

Calculate the binary logarithm for a specific cell size.

Parameters:
cell_size Size of cell, must be a power of two.
Returns:
Binary logirhtm of cell size or a negative error code.

Definition at line 574 of file tc.c.

Referenced by rtnl_qdisc_tbf_set_rate().

Here is the caller graph for this function:

int rtnl_tc_build_rate_table ( struct rtnl_tc *  tc,
struct rtnl_ratespec *  spec,
uint32_t *  dst 
)

Compute a transmission time lookup table.

Parameters:
tc traffic control object
spec Rate specification
dst Destination buffer of RTNL_TC_RTABLE_SIZE uint32_t[].

Computes a table of RTNL_TC_RTABLE_SIZE entries specyfing the transmission times for various packet sizes, e.g. the transmission time for a packet of size pktsize could be looked up:

 txtime = table[pktsize >> log2(mtu)];

Definition at line 648 of file tc.c.

References rtnl_tc_calc_txtime(), rtnl_tc_get_linktype(), rtnl_tc_get_mpu(), rtnl_tc_get_mtu(), and rtnl_tc_get_overhead().

Here is the call graph for this function:

int rtnl_tc_register ( struct rtnl_tc_ops ops  ) 

Register a traffic control module.

Parameters:
ops traffic control module operations

Definition at line 914 of file tc.c.

References rtnl_tc_ops::to_kind, rtnl_tc_ops::to_list, and rtnl_tc_ops::to_type.

void rtnl_tc_unregister ( struct rtnl_tc_ops ops  ) 

Unregister a traffic control module.

Parameters:
ops traffic control module operations

Definition at line 948 of file tc.c.

References rtnl_tc_ops::to_list.