Supporting a new traffic filter type

The steps to add support for a new queuing discipline are:

  1. Creation of a new Python class that inherits from TrafficFilter; the convention is to name such a class xxxFilter where xxx is the name of the filter

    xxxFilter.__init__() should expect as optional arguments:

    • the filter priority (an integer)

    • the Handle of the destination queuing class

    • the filter-specific parameters

  2. The xxxFilter class must implement the filter_creation_args() method; this method should return the filter-specific tc(8) arguments for creating the filter

  3. The xxxFilter class must implement the class method parse() to create a xxxFilter instance from the FilterOutput instance that is passed as an argument.

  4. The xxxFilter class must be registered by invoking the TrafficFilterParser.register_filter() method

  5. The xxxFilter class should implement the get_description() method

  6. The xxxFilter class should implement the get_match_name() method

  7. The xxxFilter class should implement getter methods for the filter-specific parameters

  8. The xxxFilter class may implement setter methods for the filter-specific parameters


TrafficFilter

class TrafficFilter(protocol: str, prio: Optional[int], filter_type: str, *, dest_class_handle: Optional[Handle] = None, filter_name: Optional[str] = None)[source]

Generic filter class. It cannot be instantiated. It is subclassed based on filter type.

Parameters:
  • protocol – protocol

  • prio – optional filter priority (a number); defaults to -1

  • filter_type – a string indicating one of the currently supported filter types: u32, fw

  • dest_class_handleHandle of class where this filter will direct traffic

  • filter_name – user-friendly filter name

filter_creation_args() List[str][source]

Returns a list of tc(8) arguments to create this filter

is_instantiated() bool[source]

Returns True if the filter is in the kernel

get_description() str[source]

Returns a string with detail info about the filter

get_match_name() Optional[str][source]

Returns a string with the name that describes the traffic matched by the filter, or None.

This method should be defined in derived classes.

get_filter_type() str[source]

Returns the filter type

get_prio() int[source]

Returns the filter priority

set_prio(prio: int)[source]

Set the filter priority.

Raises TcError if the filter is instantiated.

get_filter_name() Optional[str][source]

Returns the filter name

set_filter_name(filter_name: str)[source]

Set the filter name

get_dest_handle() Optional[Handle][source]

Returns the Handle of the QClass where this filter will send traffic

set_dest_handle(handle: Handle)[source]

Sets the handle of the class where this filter will send traffic.

Raises TcError if the filter is instantiated.

get_actions() List[TrafficAction][source]

Returns the action list for this filter

add_action(action: TrafficAction) None[source]

Add a filter action