From d0e52ad6334a6936c31ebcdc746fc48b1fde9906 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 15 Feb 2019 09:46:26 +0100 Subject: [PATCH] netem: set fwmark only on linux --- include/villas/node.h | 4 +++- lib/node.c | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/villas/node.h b/include/villas/node.h index 213a27b0d..c97bf7914 100644 --- a/include/villas/node.h +++ b/include/villas/node.h @@ -84,12 +84,14 @@ struct node { struct node_direction in, out; -#ifdef WITH_NETEM +#ifdef __linux__ int fwmark; /**< Socket mark for netem, routing and filtering */ +#ifdef WITH_NETEM struct rtnl_qdisc *tc_qdisc; /**< libnl3: Network emulator queuing discipline */ struct rtnl_cls *tc_classifier; /**< libnl3: Firewall mark classifier */ #endif /* WITH_NETEM */ +#endif /* __linux__ */ struct node_type *_vt; /**< Virtual functions (C++ OOP style) */ void *_vd; /**< Virtual data (used by struct node::_vt functions) */ diff --git a/lib/node.c b/lib/node.c index bf460a6d4..97702de0a 100644 --- a/lib/node.c +++ b/lib/node.c @@ -225,7 +225,9 @@ int node_init(struct node *n, struct node_type *vt) n->_name = NULL; n->_name_long = NULL; +#ifdef __linux__ n->fwmark = -1; +#endif /* __linux__ * #ifdef WITH_NETEM n->tc_qdisc = NULL; @@ -282,16 +284,23 @@ int node_parse(struct node *n, json_t *json, const char *name) n->name = strdup(name); - ret = json_unpack_ex(json, &err, 0, "{ s: s, s?: { s?: o }, s?: { s?: o, s: i } }", + ret = json_unpack_ex(json, &err, 0, "{ s: s, s?: { s?: o } }", "type", &type, "in", - "signals", &json_signals, + "signals", &json_signals + ); + if (ret) + jerror(&err, "Failed to parse node %s", node_name(n)); + +#ifdef __linux__ + ret = json_unpack_ex(json, &err, 0, "{ s?: { s: o, s: i } }", "out", "netem", &json_netem, "fwmark", &n->fwmark ); if (ret) jerror(&err, "Failed to parse node %s", node_name(n)); +#endif /* __linux__ */ nt = node_type_lookup(type); assert(nt == node_type(n));