/* Configure management interface as dhcp mode. * On success, returns CMD_SUCCESS. On failure, returns CMD_OVSDB_FAILURE. */ static int mgmt_intf_set_dhcp() { const struct ovsrec_system *row = NULL; struct ovsdb_idl_txn* status_txn = NULL; enum ovsdb_idl_txn_status status; struct smap smap = SMAP_INITIALIZER(&smap); status_txn = cli_do_config_start(); if (NULL == status_txn) { VLOG_ERR(OVSDB_TXN_CREATE_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } row = ovsrec_system_first(idl); if (!row) { VLOG_ERR(OVSDB_ROW_FETCH_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } /* If current mode is static remove static configs from DB. */ smap_clone(&smap, &row->mgmt_intf); if (is_mode_static(row)) { mgmt_intf_clear_ipv4_config_db(row, &smap); mgmt_intf_clear_ipv6_config_db(row, &smap); } smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_MODE, SYSTEM_MGMT_INTF_MAP_MODE_DHCP); ovsrec_system_set_mgmt_intf(row, &smap); smap_destroy(&smap); status = cli_do_config_finish(status_txn); if (TXN_SUCCESS == status || TXN_UNCHANGED == status) { return CMD_SUCCESS; } else { VLOG_ERR(OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } }
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; } }
/*----------------------------------------------------------------------------- | Function : sftp_server_enable_disable | Responsibility : To enable/disable SFTP server. | Parameters : | bool enable: If true, enable SFTP server and if false | disable the SFTP server. | Return : On success returns CMD_SUCCESS, | On failure returns CMD_OVSDB_FAILURE -----------------------------------------------------------------------------*/ static int sftp_server_enable_disable (bool enable) { const struct ovsrec_system *row = NULL; enum ovsdb_idl_txn_status txn_status; struct ovsdb_idl_txn *status_txn = cli_do_config_start(); struct smap smap; if (status_txn == NULL) { VLOG_ERR(OVSDB_TXN_CREATE_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } row = ovsrec_system_first(idl); if (!row) { VLOG_ERR(OVSDB_ROW_FETCH_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } smap_clone(&smap, &row->other_config); if (enable) { smap_replace(&smap, SFTP_SERVER_CONFIG, "true"); } else { smap_replace(&smap, SFTP_SERVER_CONFIG, "false"); } ovsrec_system_set_other_config(row, &smap); txn_status = cli_do_config_finish(status_txn); smap_destroy(&smap); if (txn_status == TXN_SUCCESS || txn_status == TXN_UNCHANGED) { return CMD_SUCCESS; } else { VLOG_ERR(OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } }
/** * Executes the qos_cos_map_command for the given * code_point, local_priority, color, and description. */ static int qos_cos_map_command(int64_t code_point, int64_t local_priority, const char *color, const char *description) { if (description != NULL) { if (!qos_is_valid_string(description)) { vty_out(vty, QOS_INVALID_STRING_ERROR_MESSAGE, VTY_NEWLINE); return CMD_OVSDB_FAILURE; } } /* Retrieve the row. */ struct ovsrec_qos_cos_map_entry *cos_map_row = qos_cos_map_row_for_code_point(code_point); if (cos_map_row == NULL) { vty_out(vty, "COS Map code point %" PRId64 " does not exist.%s", code_point, VTY_NEWLINE); return CMD_OVSDB_FAILURE; } struct ovsdb_idl_txn *txn = cli_do_config_start(); if (txn == NULL) { vty_out(vty, "Unable to start transaction.%s", VTY_NEWLINE); VLOG_ERR(OVSDB_TXN_CREATE_ERROR); return CMD_OVSDB_FAILURE; } /* Update the row. */ ovsrec_qos_cos_map_entry_set_local_priority(cos_map_row, local_priority); ovsrec_qos_cos_map_entry_set_color(cos_map_row, (color == NULL ? QOS_COLOR_DEFAULT : color)); ovsrec_qos_cos_map_entry_set_description(cos_map_row, (description == NULL ? QOS_DESCRIPTION_DEFAULT : description)); enum ovsdb_idl_txn_status status = cli_do_config_finish(txn); if (status != TXN_SUCCESS && status != TXN_UNCHANGED) { vty_out(vty, "Unable to commit transaction.%s", VTY_NEWLINE); VLOG_ERR(OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } return CMD_SUCCESS; }
/*----------------------------------------------------------------------------- | Function : udpfwd_globalconfig | Responsibility : To enable/disable udp broadcast forwarding and dhcp-relay. | Parameters : | status : If true, enable UDP broadcast forwarding/dhcp-relay and | if false disable the UDP broadcast forwarding/dhcp-relay | Return : On success returns CMD_SUCCESS, | On failure returns CMD_OVSDB_FAILURE -----------------------------------------------------------------------------*/ int8_t udpfwd_globalconfig(const char *status) { const struct ovsrec_system *ovs_row = NULL; struct ovsdb_idl_txn *status_txn = cli_do_config_start(); struct smap smap_status_value; enum ovsdb_idl_txn_status txn_status; char *key = NULL; if (status_txn == NULL) { VLOG_ERR(OVSDB_TXN_CREATE_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } 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; } key = SYSTEM_OTHER_CONFIG_MAP_UDP_BCAST_FWD_ENABLED; smap_clone(&smap_status_value, &ovs_row->other_config); /* Update the latest config status. */ smap_replace(&smap_status_value, key, status); ovsrec_system_set_other_config(ovs_row, &smap_status_value); smap_destroy(&smap_status_value); 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; } }
/* Sets logrotation period value in DB*/ static int set_logrotate_period(const char *period_value) { const struct ovsrec_system *ovs = NULL; enum ovsdb_idl_txn_status txn_status; struct ovsdb_idl_txn *txn = cli_do_config_start(); if (NULL == txn) { VLOG_ERR_LOGROTATE_TRANSACTION_CREATE_FAILED; cli_do_config_abort(txn); return CMD_OVSDB_FAILURE; } ovs = ovsrec_system_first(idl); if (NULL == ovs) { VLOG_ERR_LOGROTATE_OPENVSWITCH_READ_FAILED; cli_do_config_abort(txn); return CMD_OVSDB_FAILURE; } if(NULL != period_value) { smap_replace((struct smap *)&ovs->logrotate_config, SYSTEM_LOGROTATE_CONFIG_MAP_PERIOD, period_value); } ovsrec_system_set_logrotate_config(ovs, &ovs->logrotate_config); txn_status = cli_do_config_finish(txn); if(txn_status == TXN_SUCCESS || txn_status == TXN_UNCHANGED) { return CMD_SUCCESS; } else { VLOG_ERR(OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } }
/* Configuring management interface DNS server. * On success, returns CMD_SUCCESS. On failure, returns CMD_OVSDB_FAILURE. */ static int mgmt_intf_set_dns(bool set, const char *dns1, const char *dns2) { const struct ovsrec_system *row = NULL; struct smap smap = SMAP_INITIALIZER(&smap); const char *cfg_dns1 = NULL; const char *cfg_dns2 = NULL; struct ovsdb_idl_txn* status_txn = NULL; enum ovsdb_idl_txn_status status; status_txn = cli_do_config_start(); if (NULL == status_txn) { VLOG_ERR(OVSDB_TXN_CREATE_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } row = ovsrec_system_first(idl); if (!row) { VLOG_ERR(OVSDB_ROW_FETCH_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } smap_clone(&smap, &row->mgmt_intf); /* Handle primary DNS server configuration. */ if (set) { smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_DNS_SERVER_1, dns1); if (dns2) { smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_DNS_SERVER_2, dns2); } else { smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_DNS_SERVER_2, MGMT_INTF_DEFAULT_IP); } } else { cfg_dns1 = smap_get(&smap, SYSTEM_MGMT_INTF_MAP_DNS_SERVER_1); if (!cfg_dns1 || strcmp(dns1, cfg_dns1) != 0) { vty_out(vty, " %s %s", OVSDB_INVALID_VALUE_ERROR, VTY_NEWLINE); cli_do_config_abort(status_txn); smap_destroy(&smap); return CMD_SUCCESS; } cfg_dns2 = smap_get(&smap, SYSTEM_MGMT_INTF_MAP_DNS_SERVER_2); if (dns2) { if (!cfg_dns2 || strcmp(dns2, cfg_dns2) != 0) { vty_out(vty, " %s %s", OVSDB_INVALID_VALUE_ERROR, VTY_NEWLINE); cli_do_config_abort(status_txn); smap_destroy(&smap); return CMD_SUCCESS; } smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_DNS_SERVER_2, MGMT_INTF_DEFAULT_IP); } else if (cfg_dns2 && strcmp(cfg_dns2, MGMT_INTF_DEFAULT_IP) != 0) { vty_out(vty, " %s %s", OVSDB_DNS_DEPENDENCY_ERROR, VTY_NEWLINE); cli_do_config_abort(status_txn); smap_destroy(&smap); return CMD_SUCCESS; } smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_DNS_SERVER_1, MGMT_INTF_DEFAULT_IP); } ovsrec_system_set_mgmt_intf(row, &smap); smap_destroy(&smap); status = cli_do_config_finish(status_txn); if (TXN_SUCCESS == status || TXN_UNCHANGED == status) { return CMD_SUCCESS; } else { VLOG_ERR(OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } }
/* Configuring IPv6 default gateway on management interface. * On success, returns CMD_SUCCESS. On failure, returns CMD_OVSDB_FAILURE. */ static int mgmt_intf_set_default_gw_ipv6(bool set, const char *gw_v6) { const struct ovsrec_system *row = NULL; struct smap smap = SMAP_INITIALIZER(&smap); const char *cfg_gw = NULL; struct ovsdb_idl_txn* status_txn = NULL; enum ovsdb_idl_txn_status status; if (!is_valid_ip_address(gw_v6)) { vty_out(vty, " %s %s", OVSDB_INVALID_IPV4_IPV6_ERROR,VTY_NEWLINE); return CMD_SUCCESS; } status_txn = cli_do_config_start(); if (NULL == status_txn) { VLOG_ERR(OVSDB_TXN_CREATE_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } row = ovsrec_system_first(idl); if (!row) { VLOG_ERR(OVSDB_ROW_FETCH_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } if (!is_mode_static(row)) { vty_out(vty, " %s %s", OVSDB_MODE_ERROR, VTY_NEWLINE); cli_do_config_abort(status_txn); return CMD_SUCCESS; } smap_clone(&smap, &row->mgmt_intf); if(!smap_get(&smap, SYSTEM_MGMT_INTF_MAP_IPV6)) { vty_out(vty, " %s %s", OVSDB_NO_IP_ERROR, VTY_NEWLINE); cli_do_config_abort(status_txn); smap_destroy(&smap); return CMD_SUCCESS; } if (set) { smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_DEFAULT_GATEWAY_V6, gw_v6); } else { cfg_gw = smap_get(&smap, SYSTEM_MGMT_INTF_MAP_DEFAULT_GATEWAY_V6); if (!cfg_gw || strcmp(gw_v6, cfg_gw) != 0) { vty_out(vty, " %s %s", OVSDB_INVALID_VALUE_ERROR, VTY_NEWLINE); cli_do_config_abort(status_txn); smap_destroy(&smap); return CMD_SUCCESS; } smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_DEFAULT_GATEWAY_V6, MGMT_INTF_DEFAULT_IPV6); } ovsrec_system_set_mgmt_intf(row, &smap); smap_destroy(&smap); status = cli_do_config_finish(status_txn); if (TXN_SUCCESS == status || TXN_UNCHANGED == status) { return CMD_SUCCESS; } else { VLOG_ERR(OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } }
/* Configuring static ip on management interface. * On success, returns CMD_SUCCESS. On failure, returns CMD_OVSDB_FAILURE. */ static int mgmt_intf_set_static(bool set, const char *ip, enum ip_type type) { const struct ovsrec_system *row = NULL; struct smap smap = SMAP_INITIALIZER(&smap); struct ovsdb_idl_txn* status_txn = NULL; enum ovsdb_idl_txn_status status; const char *subnet = NULL; const char *ip_addr = NULL; unsigned short subnet_in = 0; char buf[MAX_IPV4_OR_IPV6_SUBNET_CIDR_STR_LEN]; if (!is_valid_ip_address(ip)) { vty_out(vty, " %s %s", OVSDB_INVALID_IPV4_IPV6_ERROR, VTY_NEWLINE); return CMD_SUCCESS; } memset(buf, 0, MAX_IPV4_OR_IPV6_SUBNET_CIDR_STR_LEN); strncpy(buf, ip, MAX_IPV4_OR_IPV6_SUBNET_CIDR_STR_LEN); ip_addr = strtok(buf, "/"); subnet = strtok(NULL, "\0"); subnet_in = atoi(subnet); if (IPV4 == type) { if (IS_INVALID_IPV4_SUBNET(subnet_in)) { vty_out(vty, " %s %s", OVSDB_INVALID_SUBNET_ERROR, VTY_NEWLINE); return CMD_SUCCESS; } }else if (IPV6 == type) { if (IS_INVALID_IPV6_SUBNET(subnet_in)) { vty_out(vty, " %s %s", OVSDB_INVALID_SUBNET_ERROR, VTY_NEWLINE); return CMD_SUCCESS; } } status_txn = cli_do_config_start(); if (NULL == status_txn) { VLOG_ERR(OVSDB_TXN_CREATE_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } row = ovsrec_system_first(idl); if (!row) { VLOG_ERR(OVSDB_ROW_FETCH_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } smap_clone(&smap, &row->mgmt_intf); if (set) smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_MODE, SYSTEM_MGMT_INTF_MAP_MODE_STATIC); if (IPV4 == type) { if (set) { smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_IP, ip_addr); smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_SUBNET_MASK, subnet); } else { if (mgmt_intf_remove_static_ipv4_address(&smap, ip_addr, subnet) != CMD_SUCCESS) { cli_do_config_abort(status_txn); smap_destroy(&smap); return CMD_SUCCESS; } } }else if (IPV6 == type) { if (set) smap_replace(&smap, SYSTEM_MGMT_INTF_MAP_IPV6, ip); else { if (mgmt_intf_remove_static_ipv6_address(&smap, ip) != CMD_SUCCESS) { cli_do_config_abort(status_txn); smap_destroy(&smap); return CMD_SUCCESS; } } } ovsrec_system_set_mgmt_intf(row, &smap); smap_destroy(&smap); status = cli_do_config_finish(status_txn); if (TXN_SUCCESS == status || TXN_UNCHANGED == status) { return CMD_SUCCESS; } else { VLOG_ERR(OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } }
struct ovsrec_port *port_row = port_row_for_name(port_name); if (port_row == NULL) { vty_out(vty, "Port %s does not exist.%s", port_name, VTY_NEWLINE); return CMD_OVSDB_FAILURE; } const char *qos_trust_name = qos_trust_port_get_value(port_row); if (qos_trust_name == NULL || strncmp(qos_trust_name, QOS_TRUST_NONE_STRING, QOS_CLI_STRING_BUFFER_SIZE) != 0) { vty_out(vty, "QoS COS override is only allowed\ if the trust mode is 'none'.%s", VTY_NEWLINE); return CMD_OVSDB_FAILURE; } struct ovsdb_idl_txn *txn = cli_do_config_start(); if (txn == NULL) { vty_out(vty, "Unable to start transaction.%s", VTY_NEWLINE); VLOG_ERR(OVSDB_TXN_CREATE_ERROR); return CMD_OVSDB_FAILURE; } struct smap smap; smap_clone(&smap, &port_row->qos_config); smap_replace(&smap, QOS_COS_OVERRIDE_KEY, cos_map_index); ovsrec_port_set_qos_config(port_row, &smap); smap_destroy(&smap); enum ovsdb_idl_txn_status status = cli_do_config_finish(txn); if (status != TXN_SUCCESS && status != TXN_UNCHANGED) { vty_out(vty, "Unable to commit transaction.%s", VTY_NEWLINE);
/*----------------------------------------------------------------------------- | Function : udpfwd_serverconfig | Responsibility : set/unset UDP forward-protocol. | Parameters : | *udpfwdServ : Pointer containing user input details | set : Flag to set or unset | Return : On success returns CMD_SUCCESS, | On failure returns CMD_OVSDB_FAILURE -----------------------------------------------------------------------------*/ int8_t udpfwd_serverconfig(udpfwd_server *udpfwdServ, bool set) { const struct ovsrec_udp_bcast_forwarder_server *row_serv = NULL; struct ovsdb_idl_txn *status_txn = cli_do_config_start(); enum ovsdb_idl_txn_status txn_status; bool isAddrMatch = false, isMaxEntries = false; UDPFWD_FEATURE type = UDP_BCAST_FORWARDER; if (status_txn == NULL) { VLOG_ERR(OVSDB_TXN_CREATE_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } /* lookup for the record in the UDP broadcast server table */ row_serv = udp_bcast_server_row_lookup((char*)vty->index, DEFAULT_VRF_NAME, udpfwdServ); if (row_serv) { isAddrMatch = find_udpfwd_server_ip(row_serv->ipv4_ucast_server, row_serv->n_ipv4_ucast_server, udpfwdServ); } if (set) { isMaxEntries = server_address_maxcount_reached ((char*)vty->index, type); if (isMaxEntries) { vty_out(vty, "%s: Entry not allowed as maximum " "entries per interface exceeded.%s", udpfwdServ->ipAddr, VTY_NEWLINE); cli_do_config_abort(status_txn); return CMD_SUCCESS; } if (NULL == row_serv) { /* * First set of UDP forward-protocol */ row_serv = ovsrec_udp_bcast_forwarder_server_insert(status_txn); if (!row_serv) { VLOG_ERR(OVSDB_ROW_FETCH_ERROR); cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } /* Update the UDP broadcast forwarder server table. */ if (!udpfwd_setcommoncolumn((void *)row_serv, type)) { cli_do_config_abort(status_txn); return CMD_OVSDB_FAILURE; } /* Update the dst udp port */ ovsrec_udp_bcast_forwarder_server_set_udp_dport (row_serv, udpfwdServ->udpPort); /* Update the protocol server IP */ udpfwd_serverupdate((void *)row_serv, true, udpfwdServ, type); } else { if (!isAddrMatch) { /* set action */ udpfwd_serverupdate((void *)row_serv, true, udpfwdServ, type); } else { /* Existing entry */ vty_out(vty, "This entry already exists.%s", VTY_NEWLINE); cli_do_config_abort(status_txn); return CMD_SUCCESS; } } } else { if (NULL == row_serv) { vty_out(vty, "UDP forward-protocol is not present. %s", VTY_NEWLINE); cli_do_config_abort(status_txn); return CMD_SUCCESS; } else { if (!isAddrMatch) { vty_out(vty, "No such entries are present. %s", VTY_NEWLINE); cli_do_config_abort(status_txn); return CMD_SUCCESS; } else { /* * If this is the last entry then after unset remove * the complete row. */ if (row_serv->n_ipv4_ucast_server == 1) { ovsrec_udp_bcast_forwarder_server_delete(row_serv); } else { /* No set action */ udpfwd_serverupdate((void *)row_serv, false, udpfwdServ, type); } } } } 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; } }
/* Sets logrotation target uri in DB*/ static int set_logrotate_target(const char *uri) { const struct ovsrec_system *ovs = NULL; enum ovsdb_idl_txn_status txn_status; struct ovsdb_idl_txn *txn; const char *ip_value; struct in_addr addr; struct in6_addr addrv6; boolean is_ipv4 = TRUE; if(strncmp(uri,SYSTEM_LOGROTATE_CONFIG_MAP_TARGET_DEFAULT,5)) { if(strlen(uri) <= 7) { VLOG_ERR("URI not valid\n"); return CMD_ERR_NOTHING_TODO; } if(strncmp(uri,"tftp://",7)) { VLOG_ERR("Only tftp protocol is supported\n"); return CMD_ERR_NOTHING_TODO; } ip_value = uri+7; if(inet_pton(AF_INET, ip_value,&addr) <= 0) { if(inet_pton(AF_INET6, ip_value, &addrv6) <= 0) { VLOG_ERR("Invalid IPv4 or IPv6 address\n"); return CMD_ERR_NOTHING_TODO; } is_ipv4 = FALSE; } if(is_ipv4 && (!IS_VALID_IPV4(htonl(addr.s_addr)))) { VLOG_ERR("IPv4 :Broadcast, multicast and loopback addresses are not allowed\n"); return CMD_ERR_NOTHING_TODO; } if((!is_ipv4) && (!IS_VALID_IPV6(&addrv6))) { VLOG_ERR("IPv6 :Multicast and loopback addresses are not allowed\n"); return CMD_ERR_NOTHING_TODO; } } txn = cli_do_config_start(); if (NULL == txn) { VLOG_ERR_LOGROTATE_TRANSACTION_CREATE_FAILED; cli_do_config_abort(txn); return CMD_OVSDB_FAILURE; } ovs = ovsrec_system_first(idl); if (NULL == ovs) { VLOG_ERR_LOGROTATE_OPENVSWITCH_READ_FAILED; cli_do_config_abort(txn); return CMD_OVSDB_FAILURE; } if((NULL != uri) && (strncmp(uri,SYSTEM_LOGROTATE_CONFIG_MAP_TARGET_DEFAULT,5))) { smap_replace((struct smap *)&ovs->logrotate_config, SYSTEM_LOGROTATE_CONFIG_MAP_TARGET, uri); } else { smap_remove((struct smap *)&ovs->logrotate_config, SYSTEM_LOGROTATE_CONFIG_MAP_TARGET); } ovsrec_system_set_logrotate_config(ovs, &ovs->logrotate_config); txn_status = cli_do_config_finish(txn); if(txn_status == TXN_SUCCESS || txn_status == TXN_UNCHANGED) { return CMD_SUCCESS; } else { VLOG_ERR(OVSDB_TXN_COMMIT_ERROR); return CMD_OVSDB_FAILURE; } }