1. Ingress policing : interface rate limiting
2. Egress shaping : Port QoS policy。
目前只支援 HTB class,一個 port可分配多個QoS policy,每個QoS policy包含一個class和一個qdisc,class和qdisc採用Linux kernel的tc工具來實現。
HTB(Hierarchical Token Bucket) 一種演算法。
qdisc : queuing discipline排隊規則。
OVS本身並不實現QoS,QoS功能的實現是在Linux Kernel的TC中,OVS只是能夠使用部分OVS支援的QoS類型。
如果需要某些OVS無法使用的QoS功能,那麼要看Linux Kernel QoS是否支援該功能,再自己提交Patch以支持該功能的OVS配置。 也可以直接傳統的【TC】工具在Linux中配置該功能。
TC : Linux kernel 內的 traffic control。
bridge_run
: ovs-vswitchd.c
bridge_reconfigure
: bridge.c
將設定變更推到下層的ofproto Layer,例如刪除ofproto, port或重新設定port,以及對ofproto設定相關限制參數。
iface_configure_qos
: bridge.c
設定 top-level Qos 跟 queues for 'iface'. 還有複製封包到queues_buf的尾巴。
netdev_set_qos
: netdev.c
嘗試重新設定 'netdev' 跟 'type' 還有 'details' 裡面的 QoS 資料。
ovs-vsctl ...... create qos type=linux-htb other-config: max-rate=1000000
Attempts to reconfigure QoS on 'netdev', changing the form of QoS to 'type' with details of configuration from 'details'. When this function changes the type of QoS (not just 'details'), this also resets all queue configuration for 'netdev' to their defaults (which depend on the specific type of QoS).
netdev_linux_set_qos
: netdev-linux.c
tc_lookup_ovs_name
:
根據OVS command的type (如linux-htb) 找到對應的Linux qdisc class。
tc_query_qdisc
:
找到Linux Kernel中對應的qdisc class,然後建立qdisc class。類似 tc 指令tc qdisc add dev <dev> root handle 1: kind
。
如果不是同一種則調用tc_del_qdisc
刪除存在的qdisc,調用ops->tc_install
,即htb_tc_install
,創建qdisc和class。
netdev_set_queue
: netdev.c
將queue_id跟netdev,用key-value string pairs的方式綁定在netdev上面。其中queue_id要在netdev所能支援的queue數範圍內。
netdev_linux_set_queue
: netdev-linux.c
tc_query_qdisc
:
找到Linux Kernel中對應的qdisc class,然後建立qdisc class。
ofproto_port_set_queues
: ofproto.c
告訴port上面有哪些queues存在。將meta-data和n_qdscp綁到ofport上面。設定Queue的DSCP。
(DSCP跟ToS都是QoS的分類標準,在封包IP header的8個bit進行編碼,來劃分服務類別,區分服務的優先級。)
Registers meta-data associated with the 'n_qdscp' Qualities of Service 'queues' attached to 'ofport'. This data is not intended to be sufficient to implement QoS. Instead, it is used to implement features which require knowledge of what queues exist on a port, and some basic information about them.
netdev_set_policing
: netdev.c
設定ingress policing的地方,設定限速跟burst。
ovs-vsctl set interface eth0 ingress_policing_rate=1000
ovs-vsctl set interface eth0 ingress_policing_burst=100
Attempts to set input rate limiting (policing) policy, such that up to 'kbits_rate' kbps of traffic is accepted, with a maximum accumulative burst size of 'kbits' kb.
netdev_linux_set_policing
: netdev-linux.c
Attempts to set input rate limiting (policing) policy. 設定 kbits_rate 跟 kbits_burst 。
tc_add_del_ingress_qdisc
: netdev-linux.c
透過netlink傳相關參數到kernel後再調用tc指令完成ingress QoS限速。
This function is equivalent to running the following when 'add' or 'delete' is true: /sbin/tc qdisc add dev <devname> handle ffff: ingress