.. _example_traffic_selector_rule_cos-mark_cos-mark:
########
Cos-Mark
########
The following scenarios shows how to filter packets based on
the cos-mark attribute using traffic selectors.
***************************
Test Cos-mark Regular Hooks
***************************
Description
===========
A ``traffic policy`` ``SET_COS`` is attached to DUT0's
ethernet interface (``eth0``) in the ``local-out``
hook to set the CoS mark to 5 on locally-generated packets.
A second ``traffic policy`` ``MATCH_COS`` is attached to
the same interface in the ``out`` (postrouting) hook and
uses a ``traffic selector`` to filter packets with
``cos-mark 5``, logging matches with prefix ``MATCH_COS``.
A regular ping (no VLAN tagging) verifies that the CoS
mark set in ``local-out`` is correctly visible to the
``out`` hook on the same interface.
Scenario
========
.. include:: cos-mark/testcos-markregularhooks
.. raw:: html
********************
Test Cos-mark 802.1Q
********************
Description
===========
A ``traffic policy`` ``SET_INNER_COS`` is configured on DUT0's
VLAN 100 sub-interface (``eth0 vif 100``) to set
the CoS mark to 5 on outgoing packets. On the parent
interface (``eth0``), a second ``traffic policy``
``MATCH_COS`` uses a ``traffic selector`` to filter packets
with ``cos-mark 5`` and logs matches with prefix
``MATCH_COS``. A ping through the 802.1Q VLAN verifies
that the CoS mark set on the sub-interface is correctly
propagated and matched on the parent interface.
Scenario
========
.. include:: cos-mark/testcos-mark802.1q
.. raw:: html
************************
Test Not Cos-mark 802.1Q
************************
Description
===========
Same scenario as the 802.1Q test case, but the
``traffic selector`` uses ``not cos-mark 3`` instead
of ``cos-mark 5``. Since ``SET_INNER_COS`` sets
``cos 5`` on the sub-interface, the actual CoS mark
is not 3, so ``not cos-mark 3`` matches rule 1 and
logs with prefix ``MATCH_COS``.
Scenario
========
.. include:: cos-mark/testnotcos-mark802.1q
.. raw:: html
******************
Test Cos-mark QinQ
******************
Description
===========
This scenario shows that when both the outer VLAN
(``eth0 vif 100``) and the inner VLAN
(``eth0 vif 100 vif-c 200``) have a ``set cos``
policy configured, the ``traffic selector`` ``MATCH_COS``
on the parent interface only matches the CoS value set by
the last ``set cos`` applied in the chain.
Scenario
========
.. include:: cos-mark/testcos-markqinq
.. raw:: html