/* Gets the pointer to a TCP Buffer */ struct tcp_buf * get_tcp_buf(uint32_t flow_id){ int i; struct tcp_buf * new_buf; if(tcp_buffers_count == 0){ VLOG_DBG("Creating new tcp_buf, existing %d id %" PRIu32, tcp_buffers_count, flow_id); new_buf = create_new_tcp_buf(flow_id); ovs_tcp_buffer[tcp_buffers_count-1] = new_buf; return new_buf; } else{ for(i=0;i<tcp_buffers_count;i++){ if(!ovs_tcp_buffer[i]){ VLOG_ERR("Error! Buffer not found at %d", i); } else if(ovs_tcp_buffer[i]->flow_id == flow_id){ return ovs_tcp_buffer[i]; } } // If existing tcp_buf is not found VLOG_DBG("Creating new tcp_buf, existing %d", tcp_buffers_count); new_buf = create_new_tcp_buf(flow_id); ovs_tcp_buffer[tcp_buffers_count-1] = new_buf; return new_buf; } }
static int classifierd_reconfigure(void) { int rc = 0; unsigned int new_idl_seqno = 0; const struct ovsrec_port *port_row = NULL; const struct ovsrec_acl *acl_row = NULL; new_idl_seqno = ovsdb_idl_get_seqno(idl); if (new_idl_seqno == idl_seqno) { VLOG_DBG("%s: no change in the db\n",__FUNCTION__); /* There was no change in the dB. */ return 0; } /* get first port row from IDL cache */ port_row = ovsrec_port_first(idl); if(port_row) { /* if port table is not changed then do not go ahead */ if ( (!OVSREC_IDL_ANY_TABLE_ROWS_MODIFIED(port_row, idl_seqno)) && (!OVSREC_IDL_ANY_TABLE_ROWS_INSERTED(port_row, idl_seqno)) && (!OVSREC_IDL_ANY_TABLE_ROWS_DELETED(port_row, idl_seqno)) ) { VLOG_DBG("%s: not a port row change\n",__FUNCTION__); } else { /* Perform ports reconfigure event for ACL */ rc = acl_ports_reconfigure(idl,idl_seqno); } } /* get first acl row from IDL cache */ acl_row = ovsrec_acl_first(idl); if(acl_row) { /* if port table is not changed then do not go ahead */ if ( (!OVSREC_IDL_ANY_TABLE_ROWS_MODIFIED(acl_row, idl_seqno)) && (!OVSREC_IDL_ANY_TABLE_ROWS_INSERTED(acl_row, idl_seqno)) && (!OVSREC_IDL_ANY_TABLE_ROWS_DELETED(acl_row, idl_seqno)) ) { VLOG_DBG("%s: not a acl row change\n",__FUNCTION__); } else { /* Perform acl_list_reconfigure event for ACL */ rc = acl_reconfigure(idl,idl_seqno); } } /* Update idl_seqno after handling all OVSDB updates. */ idl_seqno = new_idl_seqno; /* Setup a poll timer to wake up the daemon */ classifierd_run_timer = true; return rc; } /* classifierd_reconfigure */
int main(int argc, char *argv[]) { enum ofputil_protocol usable_protocols; struct ofputil_flow_mod *fms = NULL; static struct classifier cls; struct cls_rule *rules; size_t n_fms, i; char *error; set_program_name(argv[0]); vlog_set_levels(NULL, VLF_ANY_FACILITY, VLL_DBG); if (argc < 2) { usage(); } if (!strncmp(argv[1], "hsa", 3)) { VLOG_DBG("Enabling HSA"); cls.enable_hsa = true; } VLOG_DBG("using file: %s", argv[2]); error = parse_ofp_flow_mod_file(argv[2], OFPFC_ADD, &fms, &n_fms, &usable_protocols); if (error) { ovs_fatal(0, "%s", error); } classifier_init(&cls, flow_segment_u32s); fat_rwlock_wrlock(&cls.rwlock); rules = xmalloc(n_fms * sizeof *rules); for (i = 0; i < n_fms; i++) { struct cls_rule *rule = &rules[i]; struct cls_rule *displaced_rule; cls_rule_init(rule, &fms[i].match, fms[i].priority); displaced_rule = classifier_replace(&cls, rule); if (displaced_rule) { cls_rule_destroy(displaced_rule); VLOG_WARN("TODO"); } } fat_rwlock_unlock(&cls.rwlock); benchmark(&cls); free(rules); free(fms); return 0; }
/** * Process ACL table changes to determine if in_progress_aces * needs to be updated or not */ int acl_reconfigure(struct ovsdb_idl *idl, unsigned int idl_seqno) { int rc = 0; const struct ovsrec_acl *acl_row = NULL; const char *status_version_str; uint64_t status_version; bool in_progress_cleared = false; VLOG_DBG("acl_reconfigure...\n"); ovs_assert(idl); OVSREC_ACL_FOR_EACH (acl_row, idl) { if (OVSREC_IDL_IS_ROW_INSERTED(acl_row, idl_seqno) || OVSREC_IDL_IS_ROW_MODIFIED(acl_row, idl_seqno)) { /* Get the status version */ status_version_str = smap_get(&acl_row->status, "version"); /* If the status version is valid, then update in_progress_aces * only when in_progress_version == status_version and * cfg_version > in_progress_version. */ if (status_version_str) { status_version = strtoull(status_version_str, NULL, 0); if (acl_row->in_progress_version[0] == status_version) { /* Clear the in_progress_aces as we have finished * processing the in_progress_aces. */ ovsrec_acl_set_in_progress_aces(acl_row, NULL, NULL, 0); in_progress_cleared = true; rc++; } } /* If status_version_str is NULL, it is the first time we are * programming anything into aces column. We need to update * in_progress_aces column. The other condition to check is * if UI made a change and in_progress_cleared flag is true */ if (!status_version_str || ((in_progress_cleared == true) && (acl_row->cfg_version[0] > acl_row->in_progress_version[0]))) { ovsrec_acl_set_in_progress_aces(acl_row, acl_row->key_cfg_aces, acl_row->value_cfg_aces, acl_row->n_cfg_aces); ovsrec_acl_set_in_progress_version(acl_row, acl_row->cfg_version,1); rc++; } } } /* for each acl ROW */ VLOG_DBG("%s: number of updates back to db: %d",__FUNCTION__,rc); return rc; } /* acl_reconfigure */
// map sensorstatus enum to the equivalent string static const char * sensor_status_to_string(enum sensorstatus status) { VLOG_DBG("sensor status is %d", status); if (status < sizeof(sensor_status)/sizeof(const char *)) { VLOG_DBG("sensor status is %s", sensor_status[status]); return(sensor_status[status]); } else { VLOG_DBG("sensor status is %s", sensor_status[SENSOR_STATUS_UNINITIALIZED]); return(sensor_status[SENSOR_STATUS_UNINITIALIZED]); } }
void classifierd_debug_dump(struct ds *ds, int argc, const char *argv[]) { bool list_all_ports = true; const char *port_name; const struct ovsrec_port *port_row = NULL; unsigned int iface_idx; struct ovsrec_interface *interface; if (argc > 1) { list_all_ports = false; port_name = argv[1]; } OVSREC_PORT_FOR_EACH (port_row, idl) { if (list_all_ports || (!strcmp(port_name, port_row->name))) { if(port_row->n_interfaces == 0) { VLOG_DBG("No interfaces assigned yet..\n"); continue; } if(port_row->n_interfaces == 1) { VLOG_DBG("single interface assigned to port..\n"); interface = port_row->interfaces[0]; ds_put_format(ds, "Port: name=%s\n", port_row->name); classifierd_debug_dump_port_acl_info(ds,port_row); classifierd_debug_dump_interface_info(ds, interface); ds_put_format(ds,"\n"); } else { /* LAG */ VLOG_DBG("LAG interfaces ..\n"); ds_put_format(ds, "LAG name=%s\n", port_row->name); classifierd_debug_dump_port_acl_info(ds,port_row); for(iface_idx = 0; iface_idx < port_row->n_interfaces;iface_idx++) { interface = port_row->interfaces[iface_idx]; classifierd_debug_dump_interface_info(ds, interface); } /* end for loop */ } /* LAG */ /* line between port row entries */ ds_put_cstr(ds,"\n"); } /* if list_all_ports or matching name */ } /* for each ROW */ } /* classifierd_debug_dump */
/**************************************************************************//** * This function determines if hw_ready_state can be set for the interface * associated with the port_row * * @param[in] port_row - Pointer to @see struct ovsrec_port * * @return true - If the hw_ready_state can be set * true * false - If the hw_ready_state is false *****************************************************************************/ static bool acl_ports_is_hw_ready(const struct ovsrec_port *port_row) { const char *status_str = NULL; int acl_type_iter; ovs_assert(port_row); /* set hw_ready_state to true for following conditions, * - If ACL is NOT configured for this port * - If ACL is configured and applied status is success */ for (acl_type_iter = ACL_CFG_MIN_PORT_TYPES; acl_type_iter <= ACL_CFG_MAX_PORT_TYPES; acl_type_iter++) { const struct ovsrec_acl *acl_row = acl_db_util_get_cfg(&acl_db_accessor[acl_type_iter], port_row); if(!acl_row) { VLOG_DBG("port %s: ACL not configured \n", port_row->name); /* do not block hw_ready on the interface due to this ACL */ } else { /* ACL is configured on this port so verify if * ACL is applied successfully in hw or not */ const struct smap acl_status = acl_db_util_get_cfg_status(&acl_db_accessor[acl_type_iter], port_row); if (smap_is_empty(&acl_status)) { return false; } status_str = smap_get(&acl_status, OPS_CLS_STATUS_CODE_STR); if (status_str == NULL) { return false; } VLOG_DBG("port %s: ACL %s configured, apply status %s \n", port_row->name, acl_row->name, status_str); if(strtoul(status_str, NULL, 10) != OPS_CLS_STATUS_SUCCESS) { /* block hw_ready on this interface */ return false; } } /* end if !applied */ } return true; }
/* Deletes a TCP buffer */ void delete_tcp_buf(struct tcp_buf *tcp_buffer){ int i,j; int del_index; VLOG_DBG("Deleting tcp_buf with id: % " PRIu32, tcp_buffer->flow_id); // Delete the buffer del_index = -1; for(i=0;i<tcp_buffers_count;i++){ if(!ovs_tcp_buffer[i]){ VLOG_ERR("Error! Buffer not found at %d", i); } else if(ovs_tcp_buffer[i] == tcp_buffer){ del_index = i; free(tcp_buffer); break; } } // Compact the array if(del_index!=-i-1){ tcp_buffers_count--; for(i=del_index;i<tcp_buffers_count;i++){ ovs_tcp_buffer[i] = ovs_tcp_buffer[i+1]; } } }
void classifierd_run(void) { struct ovsdb_idl_txn *txn; /* Process a batch of messages from OVSDB. */ ovsdb_idl_run(idl); if (ovsdb_idl_is_lock_contended(idl)) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); VLOG_ERR_RL(&rl, "Another classifierd process is running, " "disabling this process until it goes away"); return; } else if (!ovsdb_idl_has_lock(idl)) { return; } /* Nothing to do until system has been configured, i.e. cur_cfg > 0. */ if (!classifierd_system_is_configured()) { return; } /* Update the local configuration and push any changes to the dB. */ txn = ovsdb_idl_txn_create(idl); if (classifierd_reconfigure()) { VLOG_DBG("%s: Committing changes\n",__FUNCTION__); /* Some OVSDB write needs to happen. */ ovsdb_idl_txn_commit_block(txn); } ovsdb_idl_txn_destroy(txn); return; } /* classifierd_run */
/* Create a connection to the OVSDB at db_path and create a dB cache * for this daemon. */ void classifierd_ovsdb_init(const char *db_path) { VLOG_DBG("%s: db_path = %s\n",__FUNCTION__,db_path); /* Initialize IDL through a new connection to the dB. */ idl = ovsdb_idl_create(db_path, &ovsrec_idl_class, false, true); idl_seqno = ovsdb_idl_get_seqno(idl); ovsdb_idl_set_lock(idl, "ops_classifierd"); /* Reject writes to columns which are not marked write-only using * ovsdb_idl_omit_alert(). */ ovsdb_idl_verify_write_only(idl); /* Choose some OVSDB tables and columns to cache. */ ovsdb_idl_add_table(idl, &ovsrec_table_system); ovsdb_idl_add_table(idl, &ovsrec_table_subsystem); /* Monitor the following columns, marking them read-only. */ ovsdb_idl_add_column(idl, &ovsrec_system_col_cur_cfg); /* Initialize ovsdb interfaces for ACL */ acl_ovsdb_init(idl); } /* classifierd_ovsdb_init */
static void jsonrpc_log_msg(const struct jsonrpc *rpc, const char *title, const struct jsonrpc_msg *msg) { if (VLOG_IS_DBG_ENABLED()) { struct ds s = DS_EMPTY_INITIALIZER; if (msg->method) { ds_put_format(&s, ", method=\"%s\"", msg->method); } if (msg->params) { ds_put_cstr(&s, ", params="); json_to_ds(msg->params, 0, &s); } if (msg->result) { ds_put_cstr(&s, ", result="); json_to_ds(msg->result, 0, &s); } if (msg->error) { ds_put_cstr(&s, ", error="); json_to_ds(msg->error, 0, &s); } if (msg->id) { ds_put_cstr(&s, ", id="); json_to_ds(msg->id, 0, &s); } VLOG_DBG("%s: %s %s%s", rpc->name, title, jsonrpc_msg_type_to_string(msg->type), ds_cstr(&s)); ds_destroy(&s); } }
/* Prepare to start a process whose command-line arguments are given by the * null-terminated 'argv' array. Returns 0 if successful, otherwise a * positive errno value. */ static int process_prestart(char **argv) { char *binary; process_init(); /* Log the process to be started. */ if (VLOG_IS_DBG_ENABLED()) { char *args = process_escape_args(argv); VLOG_DBG("starting subprocess: %s", args); free(args); } /* execvp() will search PATH too, but the error in that case is more * obscure, since it is only reported post-fork. */ binary = process_search_path(argv[0]); if (!binary) { VLOG_ERR("%s not found in PATH", argv[0]); return ENOENT; } free(binary); return 0; }
/*----------------------------------------------------------------------------- | Function: vtysh_ovsdb_config_logmsg | Responsibility : logs info/dbg/err/warn level message | Parameters: loglevel - logging level INFO/DBG/ERR/WARN | fmt - log message foramt | elipses - variable args | Return: void -----------------------------------------------------------------------------*/ void vtysh_ovsdb_config_logmsg(int loglevel, char *fmt, ...) { va_list args; va_start(args, fmt); switch (loglevel) { case VTYSH_OVSDB_CONFIG_ERR: VLOG_ERR(fmt, args); break; case VTYSH_OVSDB_CONFIG_WARN: VLOG_WARN(fmt, args); break; case VTYSH_OVSDB_CONFIG_INFO: VLOG_INFO(fmt, args); break; case VTYSH_OVSDB_CONFIG_DBG: VLOG_DBG(fmt, args); break; default : break; } va_end(args); }
static int netdev_windows_system_construct(struct netdev *netdev_) { struct netdev_windows *netdev = netdev_windows_cast(netdev_); struct netdev_windows_netdev_info info; struct ofpbuf *buf; int ret; /* Query the attributes and runtime status of the netdev. */ ret = query_netdev(netdev_get_name(&netdev->up), &info, &buf); if (ret) { return ret; } ofpbuf_delete(buf); netdev->change_seq = 1; netdev->dev_type = info.ovs_type; netdev->port_no = info.port_no; netdev->mac = info.mac_address; netdev->cache_valid = VALID_ETHERADDR; netdev->ifindex = -EOPNOTSUPP; netdev->mtu = info.mtu; netdev->cache_valid |= VALID_MTU; netdev->ifi_flags = dp_to_netdev_ifi_flags(info.ifi_flags); netdev->cache_valid |= VALID_IFFLAG; VLOG_DBG("construct device %s, ovs_type: %u.", netdev_get_name(&netdev->up), info.ovs_type); return 0; }
void handle_bufmon_counter_mgmt(bufmon_counter_info_t *counter, counter_operations_t type) { int statid = 0; const realm_helper_t *realm_list = get_all_realm_list(); int index = INVALID; if (!counter->name) { return ; } statid = get_realm_stat_id(counter->name); INPUT_PARAM_VALIDATE(statid); index = get_realm_index(statid, counter->name); INPUT_PARAM_VALIDATE(index); /* Call the bufmon handler specific to realm */ if ((index) < MAX_STATS) { realm_list[index].bufmon_counter_handler(statid, type, counter); VLOG_DBG("%s counter value %" PRId64 " ", (counter)->name, (counter)->counter_value); } return; }/* handle_bufmon_counter_mgmt */
/** * programs qos trust for a port * called from bridge reconfigure after all ports in a bridge or VRF * have been configured. * * @param ofproto - pointer to bridge or VRF descriptor * @param aux - opaque pointer passed through to provider layer, * is a bridge_reconfigure "struct port" pointer * @param port_cfg - Port row in IDL * @param idl_seqno - current transaction sequence number */ void qos_trust_send_change(struct ofproto *ofproto, void *aux, const struct ovsrec_port *port_cfg, unsigned int idl_seqno) { bool send_trust_change = false; if (global_trust_changed) { if (smap_get(&port_cfg->qos_config, "qos_trust") == NULL) { send_trust_change = true; } } if (send_trust_change || OVSREC_IDL_IS_ROW_MODIFIED(port_cfg, idl_seqno)) { /* Make sure this port has interfaces that are 'system' type. QoS should not affect other types. */ if ( ! strcmp(port_cfg->interfaces[0]->type, OVSREC_INTERFACE_TYPE_SYSTEM)) { VLOG_DBG("%s: port %s TRUST change", __FUNCTION__, port_cfg->name); ofproto_set_port_qos_cfg(ofproto, aux, global_qos_trust, &port_cfg->qos_config, &port_cfg->other_config); } } }
/* * Populates the global status table with classifier common status messages */ void ops_cls_status_msgs_populate() { unsigned int n_entries; /* populate global status table for classifier common status codes */ n_entries = (unsigned int) (sizeof(ops_cls_status_msgs)/ sizeof(ops_cls_status_msgs[0])); VLOG_DBG("Populating global_status_table for %d ops_cls_status_msg " "entries",n_entries); ops_cls_status_table_populate(&ops_cls_status_msgs[0],n_entries); }
/**************************************************************************//** * This function processes port table changes to determine if interface * hw_ready_state needs to be set to true or false for each port row entry * * @param[in] idl - Pointer to @see struct ovsdb_idl * @param[in] idl_seqno - IDL batch sequence number * * @return A non-zero value if a transaction commit to * OVSDB is required *****************************************************************************/ int acl_ports_reconfigure(struct ovsdb_idl *idl, unsigned int idl_seqno) { int rc = 0; const struct ovsrec_port *port_row = NULL; VLOG_DBG("%s: idl_seqno %d\n",__FUNCTION__,idl_seqno); ovs_assert(idl); OVSREC_PORT_FOR_EACH (port_row, idl) { if(port_row->n_interfaces == 0) { VLOG_DBG("Port %s: No interfaces assigned yet.\n",port_row->name); continue; } rc += acl_port_update_hw_ready_state(port_row); } /* for each port ROW */ VLOG_DBG("%s: number of updates back to db: %d",__FUNCTION__,rc); return rc; } /* acl_ports_reconfigure */
/* ==================================================================== * * @brief pe_crew_destory() * Free all the memory and kill the specified work crew. * * @param0 <old_crew> - I/O * pointer to the crew structure that is to be destroyed * @return <status> - O * 0 if sucessful, else the return from the pthread calls. * **/ void pe_crew_destroy() { static char mod[] = "pe_crew_destroy"; rb_cond_vars_t *cond_list; int crew_index = 0; DBUG_ENTER(mod); VLOG_DBG("%s: -->", mod); pe_set_crew_quit_status(true); rb_broadcast_cond_variables(); //signal threads to wake up and die VLOG_DBG("%s: Broadcast for termination.", mod); for (crew_index = 0; crew_index < crew.size; crew_index++) xpthread_join(crew.worker[crew_index]->thread, NULL); ovs_rwlock_destroy(&crew.rwlock); DBUG_LEAVE; }
/*----------------------------------------------------------------------------- | Function: vtysh_context_addclient | Responsibility : Add client callback to the given context | Parameters: | vtysh_contextid contextid : contextid value | int clientid: clientid value | vtysh_context_client *p_client: client param | Return: int : returns e_vtysh_ok if client callabck added successfully | else e_vtysh_error -----------------------------------------------------------------------------*/ vtysh_ret_val vtysh_context_addclient(vtysh_contextid contextid, int clientid, vtysh_context_client *p_client) { vtysh_context_client *povs_client = NULL; VLOG_DBG("vtysh_context_addclient called with context id %d clientid %d", contextid,clientid); if(NULL == p_client) { VLOG_ERR("add_client: NULL Client callback for contextid %d, client id %d",contextid, clientid); return e_vtysh_error; } if (e_vtysh_ok != vtysh_isvalid_contextclientid(contextid, clientid)) { VLOG_ERR("add_client:Invalid client id %d for given context id %d", clientid, contextid); return e_vtysh_error; } povs_client = &(*vtysh_context_table[contextid].clientlist)[clientid-1]; if (NULL == povs_client->p_callback) { /* add client call back */ povs_client->p_client_name = p_client->p_client_name; povs_client->client_id = p_client->client_id; povs_client->p_callback = p_client->p_callback; VLOG_DBG("add_client: Client id %d callback successfully registered with context id %d",clientid, contextid); } else { /* client callback is already registered */ VLOG_ERR("add_client: Client callback exists for client id %d in context id %d", clientid, contextid); return e_vtysh_error; } return e_vtysh_ok; }
/*----------------------------------------------------------------------------- | Function: vtysh_context_removeclient | Responsibility : Remove client callback to the given context | Parameters: | vtysh_contextid contextid : contextid value | int clientid: clientid value | vtysh_context_client *p_client: client param | Return: int : returns e_vtysh_ok if client callback removed successfully | else e_vtysh_error -----------------------------------------------------------------------------*/ vtysh_ret_val vtysh_context_removeclient(vtysh_contextid contextid, int clientid, vtysh_context_client *p_client) { vtysh_context_client *povs_client = NULL; if (NULL == p_client) { VLOG_ERR("remove_client: Inavlid client callback param"); return e_vtysh_error; } if (e_vtysh_ok != vtysh_isvalid_contextclientid(contextid, clientid)) { VLOG_ERR("remove_client: Invalid client id %d for given contextid %d", clientid, contextid); return e_vtysh_error; } povs_client = &(*vtysh_context_table[contextid].clientlist)[clientid-1]; if (povs_client->p_callback == p_client->p_callback) { /*client callback matches with registered callback, proceed with unregistering client callback */ povs_client->p_client_name= NULL; povs_client->client_id = 0; povs_client->p_callback = NULL; VLOG_DBG("remove_client: clientid %d callback successfully unregistered for contextid %d", clientid, contextid); } else { /* client registered details unmatched */ VLOG_DBG("remove_client: clientid %d callback param unmatched with registered callback param in contextid %d", clientid, contextid); return e_vtysh_error; } return e_vtysh_ok; }
/*----------------------------------------------------------------------------- | Function: vtysh_ovsdb_read_config | Responsibility : reads ovsdb config by traversing the vtysh_ovsdb_tables | Parameters: | FILE *fp : file pointer to write data to | Return: void -----------------------------------------------------------------------------*/ void vtysh_ovsdb_read_config(FILE *fp) { vtysh_contextid contextid=0; vtysh_ovsdb_cbmsg msg; VLOG_DBG("readconfig:before- idl 0x%p seq no %d", idl, ovsdb_idl_get_seqno(idl)); msg.fp = fp; msg.idl = idl; msg.contextid = 0; msg.clientid = 0; VLOG_DBG("readconfig:after idl 0x%p seq no %d", idl, ovsdb_idl_get_seqno(idl)); fprintf(fp, "!\n"); for(contextid = 0; contextid < e_vtysh_context_id_max; contextid++) { msg.contextid = contextid; msg.clientid = 0; vtysh_context_iterateoverclients(contextid, &msg); } }
static int ecmp_config_set_status (bool status, const char * field) { const struct ovsrec_system *ovs_row = NULL; enum ovsdb_idl_txn_status txn_status; struct ovsdb_idl_txn *status_txn = cli_do_config_start (); bool rc = false; struct smap smap_ecmp_config; if (status_txn == NULL) { VLOG_ERR (OVSDB_TXN_CREATE_ERROR); cli_do_config_abort (status_txn); return CMD_OVSDB_FAILURE; } /* Need to set ecmp_config status */ ovs_row = ovsrec_system_first (idl); if (!ovs_row) { VLOG_ERR (OVSDB_ROW_FETCH_ERROR); cli_do_config_abort (status_txn); return CMD_OVSDB_FAILURE; } rc = smap_get_bool (&ovs_row->ecmp_config, field, SYSTEM_ECMP_CONFIG_ENABLE_DEFAULT); if (rc != status) { smap_clone (&smap_ecmp_config, &ovs_row->ecmp_config); smap_replace (&smap_ecmp_config, field, status ? "true" : "false"); VLOG_DBG ("%s Set the ecmp config to status = %s old state = %s", __func__, status ? "enabled" : "disabled", rc ? "enabled" : "disabled"); ovsrec_system_set_ecmp_config (ovs_row, &smap_ecmp_config); smap_destroy (&smap_ecmp_config); } txn_status = cli_do_config_finish (status_txn); if (txn_status == TXN_SUCCESS || txn_status == TXN_UNCHANGED) return CMD_SUCCESS; else { VLOG_ERR (OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } }
/* Configure QOS COS maps for a particular bridge. */ void qos_configure_global_cos_map(struct ofproto *ofproto, struct ovsdb_idl *idl, unsigned int idl_seqno) { int n_modified; const struct ovsrec_qos_cos_map_entry *ovsrec_cos_map_entry; struct cos_map_settings cos_map_settings; /* How many rows in the COS map are modified? */ cos_map_settings.n_entries = 0; OVSREC_QOS_COS_MAP_ENTRY_FOR_EACH(ovsrec_cos_map_entry, idl) { if (OVSREC_IDL_IS_ROW_MODIFIED(ovsrec_cos_map_entry, idl_seqno) || OVSREC_IDL_IS_ROW_INSERTED(ovsrec_cos_map_entry, idl_seqno)) { VLOG_DBG("%s: MODIFIED %s %d", __FUNCTION__, ovsrec_cos_map_entry->description, (int)ovsrec_cos_map_entry->code_point); cos_map_settings.n_entries++; } } if (cos_map_settings.n_entries > 0) { /* build the settings struct, call provider API */ cos_map_settings.entries = malloc(sizeof(struct cos_map_entry) * cos_map_settings.n_entries); if (cos_map_settings.entries == NULL) { /* Out of memory, get out. Called again at next notification. */ return; } n_modified = 0; OVSREC_QOS_COS_MAP_ENTRY_FOR_EACH(ovsrec_cos_map_entry, idl) { if (OVSREC_IDL_IS_ROW_MODIFIED(ovsrec_cos_map_entry, idl_seqno) || OVSREC_IDL_IS_ROW_INSERTED(ovsrec_cos_map_entry, idl_seqno)) { cos_map_settings.entries[n_modified].color = qos_get_color(ovsrec_cos_map_entry->color); cos_map_settings.entries[n_modified].codepoint = ovsrec_cos_map_entry->code_point; cos_map_settings.entries[n_modified].local_priority = ovsrec_cos_map_entry->local_priority; n_modified++; } } if (n_modified != cos_map_settings.n_entries) { VLOG_WARN("%s: mismatched cos_map request rows_chgd=%d != modified=%d", __FUNCTION__, cos_map_settings.n_entries, n_modified); } ofproto_set_cos_map(ofproto, NULL, &cos_map_settings); free(cos_map_settings.entries); }
/* Delete zones that do not exist in above sset. */ SIMAP_FOR_EACH_SAFE(ct_zone, ct_zone_next, ct_zones) { if (!sset_contains(&all_users, ct_zone->name)) { VLOG_DBG("removing ct zone %"PRId32" for '%s'", ct_zone->data, ct_zone->name); struct ct_zone_pending_entry *pending = xmalloc(sizeof *pending); pending->state = CT_ZONE_DB_QUEUED; /* Skip flushing zone. */ pending->zone = ct_zone->data; pending->add = false; shash_add(pending_ct_zones, ct_zone->name, pending); bitmap_set0(ct_zone_bitmap, ct_zone->data); simap_delete(ct_zones, ct_zone); } }
static inline bool classifierd_system_is_configured(void) { const struct ovsrec_system *sysrow = NULL; if (system_configured) { return true; } sysrow = ovsrec_system_first(idl); if (sysrow && sysrow->cur_cfg > INT64_C(0)) { VLOG_DBG("System now configured (cur_cfg=%" PRId64 ").", sysrow->cur_cfg); return (system_configured = true); } return false; } /* classifierd_system_is_configured */
int sysd_create_link_to_hwdesc_files(void) { char *manufacturer = NULL; char *product_name = NULL; char cmd_path[50]; int rc = 0; memset(cmd_path, 0, sizeof(cmd_path)); #ifdef PLATFORM_SIMULATION /* For x86/simulation assign the manufacturer and product name */ manufacturer = strdup(GENERIC_X86_MANUFACTURER); product_name = strdup(GENERIC_X86_PRODUCT_NAME); #else /* OPS_TODO: Add other methods to find manuf/prodname. * Run dmidecode command (if it exists) to get system info. */ rc = dmidecode_exists(cmd_path); if (rc) { VLOG_ERR("Unable to locate \"dmidecode\" command"); return -1; } get_manuf_and_prodname(cmd_path, &manufacturer, &product_name); if ((manufacturer == NULL) || (product_name == NULL)) { return -1; } #endif VLOG_DBG("manufacturer=%s product_name=%s", manufacturer, product_name); rc = create_link_to_desc_files(manufacturer, product_name); if (rc) { VLOG_ERR("Failed to create link to HW descriptor files"); return -1; } free(manufacturer); free(product_name); return 0; } /* sysd_create_link_to_hwdesc_files */
static int unix_open(const char *name, char *suffix, struct stream **streamp, uint8_t dscp OVS_UNUSED) { char *connect_path; int fd; connect_path = abs_file_name(ovs_rundir(), suffix); fd = make_unix_socket(SOCK_STREAM, true, NULL, connect_path); if (fd < 0) { VLOG_DBG("%s: connection failed (%s)", connect_path, ovs_strerror(-fd)); free(connect_path); return -fd; } free(connect_path); return new_fd_stream(name, fd, check_connection_completion(fd), streamp); }
log_wakeup(const struct backtrace *backtrace, const char *format, ...) { struct ds ds; va_list args; ds_init(&ds); va_start(args, format); ds_put_format_valist(&ds, format, args); va_end(args); if (backtrace) { int i; ds_put_char(&ds, ':'); for (i = 0; i < backtrace->n_frames; i++) { ds_put_format(&ds, " 0x%x", backtrace->frames[i]); } } VLOG_DBG("%s", ds_cstr(&ds)); ds_destroy(&ds); }
static int windows_open(const char *name, char *suffix, struct stream **streamp, uint8_t dscp) { int error, port; FILE *file; char *suffix_new, *path; /* If the path does not contain a ':', assume it is relative to * OVS_RUNDIR. */ if (!strchr(suffix, ':')) { path = xasprintf("%s/%s", ovs_rundir(), suffix); } else { path = xstrdup(suffix); } file = fopen(path, "r"); if (!file) { error = errno; VLOG_DBG("%s: could not open %s (%s)", name, suffix, ovs_strerror(error)); return error; } error = fscanf(file, "%d", &port); if (error != 1) { VLOG_ERR("failed to read port from %s", suffix); fclose(file); return EINVAL; } fclose(file); suffix_new = xasprintf("127.0.0.1:%d", port); error = tcp_open(name, suffix_new, streamp, dscp); free(suffix_new); free(path); return error; }