- yajl_val row;
- port_list_t *portentry = NULL;
- if (port && YAJL_IS_OBJECT(port)) {
- row = yajl_tree_get(port, new, yajl_t_object);
- if (row && YAJL_IS_OBJECT(row)) {
- yajl_val port_name = yajl_tree_get(row, name, yajl_t_string);
- if (port_name && YAJL_IS_STRING(port_name)) {
- portentry = ovs_stats_get_port(uuid);
- if (portentry == NULL)
- portentry = ovs_stats_new_port(NULL, uuid);
- if (portentry) {
- pthread_mutex_lock(&g_stats_lock);
- sstrncpy(portentry->name, YAJL_GET_STRING(port_name),
- sizeof(portentry->name));
- pthread_mutex_unlock(&g_stats_lock);
-
- yajl_val ifaces_root = ovs_utils_get_value_by_key(row, "interfaces");
- char *ifaces_root_key =
- YAJL_GET_STRING(YAJL_GET_ARRAY(ifaces_root)->values[0]);
-
- char *iface_uuid_str = NULL;
-
- if (strcmp("set", ifaces_root_key) == 0) {
- // ifaces_root is ["set", [[ "uuid", "<some_uuid>" ], [ "uuid",
- // "<another_uuid>" ], ... ]]
- yajl_val ifaces_list = YAJL_GET_ARRAY(ifaces_root)->values[1];
-
- // ifaces_list is [[ "uuid", "<some_uuid>" ], [ "uuid",
- // "<another_uuid>" ], ... ]]
- for (int i = 0; i < YAJL_GET_ARRAY(ifaces_list)->len; i++) {
- yajl_val iface_tuple = YAJL_GET_ARRAY(ifaces_list)->values[i];
-
- // iface_tuple is [ "uuid", "<some_uuid>" ]
- iface_uuid_str =
- YAJL_GET_STRING(YAJL_GET_ARRAY(iface_tuple)->values[1]);
-
- interface_list_t *iface =
- ovs_stats_get_port_interface(portentry, iface_uuid_str);
-
- if (iface == NULL) {
- iface = ovs_stats_new_port_interface(portentry, iface_uuid_str);
- }
- }
- } else {
- // ifaces_root is [ "uuid", "<some_uuid>" ]
- iface_uuid_str =
- YAJL_GET_STRING(YAJL_GET_ARRAY(ifaces_root)->values[1]);