2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

netdev-linux: Avoid minor number 0 in traffic control.

Linux traffic control handles with minor number 0 refer to qdiscs, not
to classes.  This commit deals with this by using a conversion function:
OpenFlow queue 0 maps to minor 1, queue 1 to minor 2, and so on.
This commit is contained in:
Ben Pfaff 2010-07-16 15:50:57 -07:00
parent 3c4de644d2
commit 17ee3c1ffd
2 changed files with 12 additions and 8 deletions

View File

@ -463,7 +463,7 @@ dpif_linux_queue_to_priority(const struct dpif *dpif OVS_UNUSED,
uint32_t queue_id, uint32_t *priority) uint32_t queue_id, uint32_t *priority)
{ {
if (queue_id < 0xf000) { if (queue_id < 0xf000) {
*priority = TC_H_MAKE(1 << 16, queue_id); *priority = TC_H_MAKE(1 << 16, queue_id + 1);
return 0; return 0;
} else { } else {
return EINVAL; return EINVAL;

View File

@ -2341,8 +2341,10 @@ htb_parse_tcmsg__(struct ofpbuf *tcmsg, unsigned int *queue_id,
error = tc_parse_class(tcmsg, &handle, &nl_options, stats); error = tc_parse_class(tcmsg, &handle, &nl_options, stats);
if (!error && queue_id) { if (!error && queue_id) {
if (tc_get_major(handle) == 1 && tc_get_minor(handle) < HTB_N_QUEUES) { unsigned int major = tc_get_major(handle);
*queue_id = tc_get_minor(handle); unsigned int minor = tc_get_minor(handle);
if (major == 1 && minor > 0 && minor <= HTB_N_QUEUES) {
*queue_id = minor - 1;
} else { } else {
error = EPROTO; error = EPROTO;
} }
@ -2567,7 +2569,7 @@ htb_class_set(struct netdev *netdev, unsigned int queue_id,
return error; return error;
} }
error = htb_setup_class__(netdev, tc_make_handle(1, queue_id), error = htb_setup_class__(netdev, tc_make_handle(1, queue_id + 1),
tc_make_handle(1, 0xfffe), &hc); tc_make_handle(1, 0xfffe), &hc);
if (error) { if (error) {
return error; return error;
@ -2587,7 +2589,7 @@ htb_class_delete(struct netdev *netdev, unsigned int queue_id)
hc = port_array_get(&htb->tc.queues, queue_id); hc = port_array_get(&htb->tc.queues, queue_id);
assert(hc != NULL); assert(hc != NULL);
error = tc_delete_class(netdev, tc_make_handle(1, queue_id)); error = tc_delete_class(netdev, tc_make_handle(1, queue_id + 1));
if (!error) { if (!error) {
free(hc); free(hc);
port_array_delete(&htb->tc.queues, queue_id); port_array_delete(&htb->tc.queues, queue_id);
@ -2599,7 +2601,7 @@ static int
htb_class_get_stats(const struct netdev *netdev, unsigned int queue_id, htb_class_get_stats(const struct netdev *netdev, unsigned int queue_id,
struct netdev_queue_stats *stats) struct netdev_queue_stats *stats)
{ {
return htb_query_class__(netdev, tc_make_handle(1, queue_id), return htb_query_class__(netdev, tc_make_handle(1, queue_id + 1),
tc_make_handle(1, 0xfffe), NULL, stats); tc_make_handle(1, 0xfffe), NULL, stats);
} }
@ -2609,7 +2611,7 @@ htb_class_dump_stats(const struct netdev *netdev OVS_UNUSED,
netdev_dump_queue_stats_cb *cb, void *aux) netdev_dump_queue_stats_cb *cb, void *aux)
{ {
struct netdev_queue_stats stats; struct netdev_queue_stats stats;
unsigned int handle; unsigned int handle, major, minor;
int error; int error;
error = tc_parse_class(nlmsg, &handle, NULL, &stats); error = tc_parse_class(nlmsg, &handle, NULL, &stats);
@ -2617,7 +2619,9 @@ htb_class_dump_stats(const struct netdev *netdev OVS_UNUSED,
return error; return error;
} }
if (tc_get_major(handle) == 1 && tc_get_minor(handle) < HTB_N_QUEUES) { major = tc_get_major(handle);
minor = tc_get_minor(handle);
if (major == 1 && minor > 0 && minor <= HTB_N_QUEUES) {
(*cb)(tc_get_minor(handle), &stats, aux); (*cb)(tc_get_minor(handle), &stats, aux);
} }
return 0; return 0;