#else
#pragma message "Jansson dev libs unavailable, not including JSON parsing"
#endif
+#include <rte_string_fns.h>
#include <rte_log.h>
#include <rte_memory.h>
#include <rte_malloc.h>
strcpy(pkt->vm_name, json_string_value(value));
} else if (!strcmp(key, "command")) {
char command[32];
- snprintf(command, 32, "%s", json_string_value(value));
+ strlcpy(command, json_string_value(value), 32);
if (!strcmp(command, "power")) {
pkt->command = CPU_POWER;
} else if (!strcmp(command, "create")) {
}
} else if (!strcmp(key, "policy_type")) {
char command[32];
- snprintf(command, 32, "%s", json_string_value(value));
+ strlcpy(command, json_string_value(value), 32);
if (!strcmp(command, "TIME")) {
pkt->policy_to_use = TIME;
} else if (!strcmp(command, "TRAFFIC")) {
}
} else if (!strcmp(key, "workload")) {
char command[32];
- snprintf(command, 32, "%s", json_string_value(value));
+ strlcpy(command, json_string_value(value), 32);
if (!strcmp(command, "HIGH")) {
pkt->workload = HIGH;
} else if (!strcmp(command, "MEDIUM")) {
for (i = 0; i < size; i++) {
char mac[32];
- snprintf(mac, 32, "%s", json_string_value(
- json_array_get(value, i)));
+ strlcpy(mac,
+ json_string_value(json_array_get(value, i)),
+ 32);
set_policy_mac(pkt, i, mac);
}
pkt->nb_mac_to_monitor = size;
(uint32_t)json_integer_value(value);
} else if (!strcmp(key, "unit")) {
char unit[32];
- snprintf(unit, 32, "%s", json_string_value(value));
+ strlcpy(unit, json_string_value(value), 32);
if (!strcmp(unit, "SCALE_UP")) {
pkt->unit = CPU_POWER_SCALE_UP;
} else if (!strcmp(unit, "SCALE_DOWN")) {
static int
process_request(struct channel_packet *pkt, struct channel_info *chan_info)
{
+ int ret;
+
if (chan_info == NULL)
return -1;
else
core_num = pkt->resource_id;
+ RTE_LOG(DEBUG, CHANNEL_MONITOR, "Processing requested cmd for cpu:%d\n",
+ core_num);
+
switch (pkt->unit) {
case(CPU_POWER_SCALE_MIN):
power_manager_scale_core_min(core_num);
}
if (pkt->command == PKT_POLICY_REMOVE) {
- RTE_LOG(INFO, CHANNEL_MONITOR,
- "Removing policy %s\n", pkt->vm_name);
- remove_policy(pkt);
+ ret = remove_policy(pkt);
+ if (ret == 0)
+ RTE_LOG(INFO, CHANNEL_MONITOR,
+ "Removed policy %s\n", pkt->vm_name);
+ else
+ RTE_LOG(INFO, CHANNEL_MONITOR,
+ "Policy %s does not exist\n", pkt->vm_name);
}
/*