summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@vmware.com>2019-10-30 19:13:33 +0100
committerSusant Sahani <ssahani@vmware.com>2019-10-31 10:36:28 +0100
commit6edfb1f5406f45e8f3e933c695bad3d6749ed4e0 (patch)
treecfaa6add7e69d1b0af495737c81916a7b0dcb670 /src
parentb9c5aa3c65b5f223f79aaa0db549c0aaf2aeee25 (diff)
downloadsystemd-6edfb1f5406f45e8f3e933c695bad3d6749ed4e0.tar.gz
systemd-6edfb1f5406f45e8f3e933c695bad3d6749ed4e0.tar.bz2
systemd-6edfb1f5406f45e8f3e933c695bad3d6749ed4e0.zip
tc: qdisc remove some duplicate code
Diffstat (limited to 'src')
-rw-r--r--src/network/tc/qdisc.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c
index ed4a11d265..7f4b2b53cb 100644
--- a/src/network/tc/qdisc.c
+++ b/src/network/tc/qdisc.c
@@ -116,6 +116,7 @@ static int qdisc_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int qdisc_configure(Link *link, QDiscs *qdisc) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
+ _cleanup_free_ char *tca_kind = NULL;
int r;
assert(link);
@@ -132,25 +133,31 @@ int qdisc_configure(Link *link, QDiscs *qdisc) {
return log_link_error_errno(link, r, "Could not create tcm_parent message: %m");
if (qdisc->parent == TC_H_CLSACT) {
+ tca_kind = strdup("clsact");
+ if (!tca_kind)
+ return log_oom();
+
r = sd_rtnl_message_set_qdisc_handle(req, TC_H_MAKE(TC_H_CLSACT, 0));
if (r < 0)
return log_link_error_errno(link, r, "Could not set tcm_handle message: %m");
-
- r = sd_netlink_message_append_string(req, TCA_KIND, "clsact");
- if (r < 0)
- return log_link_error_errno(link, r, "Could not append TCA_KIND attribute: %m");
}
if (qdisc->has_network_emulator) {
- r = sd_netlink_message_append_string(req, TCA_KIND, "netem");
+ r = free_and_strdup(&tca_kind, "netem");
if (r < 0)
- return log_link_error_errno(link, r, "Could not append TCA_KIND attribute: %m");
+ return log_oom();
r = network_emulator_fill_message(link, qdisc, req);
if (r < 0)
return r;
}
+ if (tca_kind) {
+ r = sd_netlink_message_append_string(req, TCA_KIND, tca_kind);
+ if (r < 0)
+ return log_link_error_errno(link, r, "Could not append TCA_KIND attribute: %m");
+ }
+
r = netlink_call_async(link->manager->rtnl, NULL, req, qdisc_handler, link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");