What priorities can be used in cgroups net_prio module

cgroupsnetworking

Cgroups has a module called net_prio, and by using this module I can set the priority of network traffic generated by various applications. As you can read here, this can be achieved by setting something similar to the following:

echo "eth0 5" > /sys/fs/cgroups/net_prio/iscsi/net_prio.ifpriomap

But there's no info as to what range of priorities I can use.

Let's say there's a program in my system that should have the lowest network priority. What should I use in the pace of 5 ? Are the priorities similar to nice priorities?

Best Answer

From the Kernel documentation titled: Network priority cgroup.

excerpt

net_prio.prioidx

This file is read-only, and is simply informative. It contains a unique integer value that the kernel uses as an internal representation of this cgroup.

net_prio.ifpriomap

This file contains a map of the priorities assigned to traffic originating from processes in this group and egressing the system on various interfaces. It contains a list of tuples in the form <ifname priority>. Contents of this file can be modified by echoing a string into the file using the same tuple format. for example:

   echo "eth0 5" > /sys/fs/cgroups/net_prio/iscsi/net_prio.ifpriomap

This command would force any traffic originating from processes belonging to the iscsi net_prio cgroup and egressing on interface eth0 to have the priority of said traffic set to the value 5. The parent accounting group also has a writeable 'net_prio.ifpriomap' file that can be used to set a system default priority.

I believe these priorities work where the higher the number, the higher the precedence. From the tc man page:

excerpt

   PRIO   The  PRIO  qdisc  is  a non-shaping container for a configurable 
          number of classes which are dequeued in order. This allows for 
          easy prioritization of traffic, where lower  classes  are
          only  able  to  send  if higher ones have no packets available. To 
          facilitate configuration, Type Of Service bits are honored by      
          default.

So if there are packets for a lower class they have to wait until there aren't any from a higher numbered class.

References

Related Question