network: tc: make Parent= take class id
This commit is contained in:
+12
-8
@@ -12,6 +12,8 @@
|
||||
#include "qdisc.h"
|
||||
#include "set.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "tc-util.h"
|
||||
|
||||
const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX] = {
|
||||
[QDISC_KIND_CODEL] = &codel_vtable,
|
||||
@@ -279,19 +281,21 @@ int config_parse_qdisc_parent(
|
||||
qdisc->parent = TC_H_INGRESS;
|
||||
qdisc->handle = TC_H_MAKE(TC_H_INGRESS, 0);
|
||||
} else {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse 'Parent=', ignoring assignment: %s",
|
||||
rvalue);
|
||||
return 0;
|
||||
r = parse_handle(rvalue, &qdisc->parent);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Failed to parse 'Parent=', ignoring assignment: %s",
|
||||
rvalue);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (streq(rvalue, "root"))
|
||||
qdisc->tca_kind = mfree(qdisc->tca_kind);
|
||||
else {
|
||||
if (STR_IN_SET(rvalue, "clsact", "ingress")) {
|
||||
r = free_and_strdup(&qdisc->tca_kind, rvalue);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
}
|
||||
} else
|
||||
qdisc->tca_kind = mfree(qdisc->tca_kind);
|
||||
|
||||
qdisc = NULL;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright © 2019 VMware, Inc. */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "extract-word.h"
|
||||
#include "fileio.h"
|
||||
#include "parse-util.h"
|
||||
#include "tc-util.h"
|
||||
@@ -92,3 +93,32 @@ int tc_fill_ratespec_and_table(struct tc_ratespec *rate, uint32_t *rtab, uint32_
|
||||
rate->linklayer = TC_LINKLAYER_ETHERNET;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_handle(const char *t, uint32_t *ret) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
uint16_t major, minor;
|
||||
int r;
|
||||
|
||||
assert(t);
|
||||
assert(ret);
|
||||
|
||||
/* Extract the major number. */
|
||||
r = extract_first_word(&t, &word, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
return -EINVAL;
|
||||
if (!t)
|
||||
return -EINVAL;
|
||||
|
||||
r = safe_atou16_full(word, 16, &major);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = safe_atou16_full(t, 16, &minor);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = ((uint32_t) major << 16) | minor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,3 +10,4 @@ int tc_time_to_tick(usec_t t, uint32_t *ret);
|
||||
int parse_tc_percent(const char *s, uint32_t *percent);
|
||||
int tc_transmit_time(uint64_t rate, uint32_t size, uint32_t *ret);
|
||||
int tc_fill_ratespec_and_table(struct tc_ratespec *rate, uint32_t *rtab, uint32_t mtu);
|
||||
int parse_handle(const char *t, uint32_t *ret);
|
||||
|
||||
Reference in New Issue
Block a user