diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-02-10 09:45:24 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-03-02 07:46:28 +0100 |
commit | 2a0963311795677a43fdb2b9ae9c3dfbfee83ac6 (patch) | |
tree | 29eea74c4398c12527672dcb232f489ea2487010 /src | |
parent | Merge pull request #14990 from keszybz/nss-homed-fix (diff) | |
download | systemd-2a0963311795677a43fdb2b9ae9c3dfbfee83ac6.tar.xz systemd-2a0963311795677a43fdb2b9ae9c3dfbfee83ac6.zip |
network: tc: make Parent= take class id
Diffstat (limited to 'src')
-rw-r--r-- | src/network/tc/qdisc.c | 20 | ||||
-rw-r--r-- | src/network/tc/tc-util.c | 30 | ||||
-rw-r--r-- | src/network/tc/tc-util.h | 1 |
3 files changed, 43 insertions, 8 deletions
diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c index 0619e894cc..988167f8b4 100644 --- a/src/network/tc/qdisc.c +++ b/src/network/tc/qdisc.c @@ -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; diff --git a/src/network/tc/tc-util.c b/src/network/tc/tc-util.c index c46550f955..47371a841b 100644 --- a/src/network/tc/tc-util.c +++ b/src/network/tc/tc-util.c @@ -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; +} diff --git a/src/network/tc/tc-util.h b/src/network/tc/tc-util.h index c901f50691..38b9d0786d 100644 --- a/src/network/tc/tc-util.h +++ b/src/network/tc/tc-util.h @@ -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); |