Skip to content

Commit

Permalink
northd: add qos_physical_network in port_binding config column
Browse files Browse the repository at this point in the history
Introduce qos_physical_network in port_binding config column in order to
indicate the name of the egress network name where traffic shaping will
be applied.
This is a preliminary patch to rework OVN QoS implementation in order to
configure it through OVS QoS table instead of running tc command
directly bypassing OVS.

Acked-by: Numan Siddique <numans@ovn.org>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
  • Loading branch information
LorenzoBianconi authored and putnopvut committed May 18, 2023
1 parent 7934602 commit 9387fa1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controller/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ static void update_lport_tracking(const struct sbrec_port_binding *pb,
struct qos_queue {
struct hmap_node node;

char *network;
char *port;

uint32_t queue_id;
Expand All @@ -165,6 +166,7 @@ find_qos_queue(struct hmap *queue_map, uint32_t hash, const char *port)
static void
qos_queue_erase_entry(struct qos_queue *q)
{
free(q->network);
free(q->port);
free(q);
}
Expand All @@ -186,6 +188,7 @@ get_qos_queue(const struct sbrec_port_binding *pb, struct hmap *queue_map)
uint32_t max_rate = smap_get_int(&pb->options, "qos_max_rate", 0);
uint32_t burst = smap_get_int(&pb->options, "qos_burst", 0);
uint32_t queue_id = smap_get_int(&pb->options, "qdisc_queue_id", 0);
const char *network = smap_get(&pb->options, "qos_physical_network");

if ((!min_rate && !max_rate && !burst) || !queue_id) {
/* Qos is not configured for this port. */
Expand All @@ -200,6 +203,9 @@ get_qos_queue(const struct sbrec_port_binding *pb, struct hmap *queue_map)
q->port = xstrdup(pb->logical_port);
q->queue_id = queue_id;
}

free(q->network);
q->network = network ? xstrdup(network) : NULL;
q->min_rate = min_rate;
q->max_rate = max_rate;
q->burst = burst;
Expand Down
10 changes: 10 additions & 0 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3505,7 +3505,17 @@ ovn_port_update_sbrec(struct ovsdb_idl_txn *ovnsb_txn,
}

smap_clone(&options, &op->nbsp->options);

if (queue_id) {
if (op->od->n_localnet_ports) {
struct ovn_port *port = op->od->localnet_ports[0];
const char *physical_network = smap_get(
&port->nbsp->options, "network_name");
if (physical_network) {
smap_add(&options, "qos_physical_network",
physical_network);
}
}
smap_add_format(&options,
"qdisc_queue_id", "%d", queue_id);
}
Expand Down
5 changes: 5 additions & 0 deletions ovn-sb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3691,6 +3691,11 @@ tcp.flags = RST;
interface, in bits.
</column>

<column name="options" key="qos_physical_network">
If set, indicates the name of the egress network name where traffic
shaping will be applied.
</column>

<column name="options" key="qdisc_queue_id"
type='{"type": "integer", "minInteger": 1, "maxInteger": 61440}'>
Indicates the queue number on the physical device. This is same as the
Expand Down
22 changes: 22 additions & 0 deletions tests/ovn-northd.at
Original file line number Diff line number Diff line change
Expand Up @@ -9064,3 +9064,25 @@ mac_binding_timestamp: true

AT_CLEANUP
])

OVN_FOR_EACH_NORTHD_NO_HV([
AT_SETUP([check OVN QoS])
AT_KEYWORDS([OVN-QoS])
ovn_start

check ovn-nbctl ls-add ls
check ovn-nbctl lsp-add ls public
check ovn-nbctl lsp-set-type public localnet
check ovn-nbctl lsp-set-addresses public unknown

check_column "" sb:Port_Binding options logical_port=public

check ovn-nbctl --wait=sb set Logical_Switch_Port public options:qos_min_rate=200000
AT_CHECK([fetch_column sb:Port_Binding options logical_port=public |grep -q 'qos_min_rate=200000'])
AT_CHECK([fetch_column sb:Port_Binding options logical_port=public |grep -q 'qos_physical_network'],[1])

check ovn-nbctl --wait=sb set Logical_Switch_Port public options:qos_min_rate=200000 options:network_name=phys
AT_CHECK([fetch_column sb:Port_Binding options logical_port=public |grep -q 'qos_physical_network=phys'])

AT_CLEANUP
])

0 comments on commit 9387fa1

Please sign in to comment.