X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vswitchd%2Fbridge.c;h=ec3633c405a9947b10bbe0ec2b819058ce0f521d;hb=a5ae88ff8a276e86c842ac102145432662bf711a;hp=578c67871248c1c63ef4870ef09f714bc1622bf3;hpb=33735fe5042cc69af7db6d34d59ed6a4ebc7946d;p=sliver-openvswitch.git diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 578c67871..ec3633c40 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -18,6 +18,7 @@ #include #include #include +#include "async-append.h" #include "bfd.h" #include "bitmap.h" #include "bond.h" @@ -367,6 +368,7 @@ bridge_init(const char *remote) ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_state); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_resets); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_mac_in_use); + ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_ifindex); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_mtu); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_ofport); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_statistics); @@ -471,10 +473,9 @@ collect_in_band_managers(const struct ovsrec_open_vswitch *ovs_cfg, SSET_FOR_EACH (target, &targets) { struct sockaddr_in *sin = &managers[n_managers]; - if (stream_parse_target_with_default_ports(target, - JSONRPC_TCP_PORT, - JSONRPC_SSL_PORT, - sin)) { + if (stream_parse_target_with_default_port(target, + OVSDB_OLD_PORT, + sin)) { n_managers++; } } @@ -500,6 +501,9 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) smap_get_int(&ovs_cfg->other_config, "flow-eviction-threshold", OFPROTO_FLOW_EVICTION_THRESHOLD_DEFAULT)); + ofproto_set_n_handler_threads( + smap_get_int(&ovs_cfg->other_config, "n-handler-threads", 0)); + bridge_configure_flow_miss_model(smap_get(&ovs_cfg->other_config, "force-miss-model")); @@ -543,7 +547,6 @@ bridge_reconfigure_ofp(void) long long int deadline; struct bridge *br; - time_refresh(); deadline = time_msec() + OFP_PORT_ACTION_WINDOW; /* The kernel will reject any attempt to add a given port to a datapath if @@ -562,7 +565,6 @@ bridge_reconfigure_ofp(void) list_remove(&garbage->list_node); free(garbage); - time_refresh(); if (time_msec() >= deadline) { return false; } @@ -575,7 +577,6 @@ bridge_reconfigure_ofp(void) HMAP_FOR_EACH_SAFE (if_cfg, next, hmap_node, &br->if_cfg_todo) { iface_create(br, if_cfg, OFPP_NONE); - time_refresh(); if (time_msec() >= deadline) { return false; } @@ -695,7 +696,7 @@ bridge_update_ofprotos(void) error = ofproto_port_del(br2->ofproto, ofproto_port.ofp_port); if (error) { VLOG_ERR("failed to delete port %s: %s", ofproto_port.name, - strerror(error)); + ovs_strerror(error)); } ofproto_port_destroy(&ofproto_port); } @@ -704,7 +705,7 @@ bridge_update_ofprotos(void) error = ofproto_create(br->name, br->type, &br->ofproto); if (error) { VLOG_ERR("failed to create bridge %s: %s", br->name, - strerror(error)); + ovs_strerror(error)); bridge_destroy(br); } } @@ -842,7 +843,7 @@ bridge_configure_datapath_id(struct bridge *br) static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); VLOG_ERR_RL(&rl, "bridge %s: failed to set bridge " "Ethernet address: %s", - br->name, strerror(error)); + br->name, ovs_strerror(error)); } } memcpy(br->ea, ea, ETH_ADDR_LEN); @@ -1020,6 +1021,12 @@ bridge_configure_ipfix(struct bridge *br) if (be_cfg->obs_point_id) { be_opts.obs_point_id = *be_cfg->obs_point_id; } + if (be_cfg->cache_active_timeout) { + be_opts.cache_active_timeout = *be_cfg->cache_active_timeout; + } + if (be_cfg->cache_max_flows) { + be_opts.cache_max_flows = *be_cfg->cache_max_flows; + } } if (n_fe_opts > 0) { @@ -1032,6 +1039,10 @@ bridge_configure_ipfix(struct bridge *br) sset_init(&opts->targets); sset_add_array(&opts->targets, fe_cfg->ipfix->targets, fe_cfg->ipfix->n_targets); + opts->cache_active_timeout = fe_cfg->ipfix->cache_active_timeout + ? *fe_cfg->ipfix->cache_active_timeout : 0; + opts->cache_max_flows = fe_cfg->ipfix->cache_max_flows + ? *fe_cfg->ipfix->cache_max_flows : 0; opts++; } } @@ -1320,7 +1331,7 @@ iface_set_netdev_config(const struct ovsrec_interface *iface_cfg, error = netdev_set_config(netdev, &iface_cfg->options); if (error) { VLOG_WARN("could not configure network device %s (%s)", - iface_cfg->name, strerror(error)); + iface_cfg->name, ovs_strerror(error)); } return error; } @@ -1461,7 +1472,7 @@ iface_do_create(const struct bridge *br, iface_get_type(iface_cfg, br->cfg), &netdev); if (error) { VLOG_WARN("could not open network device %s (%s)", - iface_cfg->name, strerror(error)); + iface_cfg->name, ovs_strerror(error)); goto error; } @@ -1575,7 +1586,7 @@ iface_create(struct bridge *br, struct if_cfg *if_cfg, ofp_port_t ofp_port) netdev_close(netdev); } else { VLOG_WARN("could not open network device %s (%s)", - port->name, strerror(error)); + port->name, ovs_strerror(error)); } } else { /* Already exists, nothing to do. */ @@ -1810,6 +1821,7 @@ iface_refresh_status(struct iface *iface) int mtu; int64_t mtu_64; uint8_t mac[ETH_ADDR_LEN]; + int64_t ifindex64; int error; if (iface_is_synthetic(iface)) { @@ -1855,6 +1867,14 @@ iface_refresh_status(struct iface *iface) } else { ovsrec_interface_set_mac_in_use(iface->cfg, NULL); } + + /* The netdev may return a negative number (such as -EOPNOTSUPP) + * if there is no valid ifindex number. */ + ifindex64 = netdev_get_ifindex(iface->netdev); + if (ifindex64 < 0) { + ifindex64 = 0; + } + ovsrec_interface_set_ifindex(iface->cfg, &ifindex64, 1); } /* Writes 'iface''s CFM statistics to the database. 'iface' must not be @@ -1904,6 +1924,8 @@ iface_refresh_cfm_stats(struct iface *iface) } else { ovsrec_interface_set_cfm_health(cfg, NULL, 0); } + + free(status.rmps); } } @@ -2236,11 +2258,10 @@ instant_stats_run(void) iface_refresh_cfm_stats(iface); smap_init(&smap); - if (!ofproto_port_get_bfd_status(br->ofproto, iface->ofp_port, - &smap)) { - ovsrec_interface_set_bfd_status(iface->cfg, &smap); - smap_destroy(&smap); - } + ofproto_port_get_bfd_status(br->ofproto, iface->ofp_port, + &smap); + ovsrec_interface_set_bfd_status(iface->cfg, &smap); + smap_destroy(&smap); } } } @@ -2434,6 +2455,8 @@ bridge_run(void) * process that forked us to exit successfully. */ daemonize_complete(); + vlog_enable_async(); + VLOG_INFO_ONCE("%s (Open vSwitch) %s", program_name, VERSION); } } @@ -2529,13 +2552,11 @@ struct qos_unixctl_show_cbdata { }; static void -qos_unixctl_show_cb(unsigned int queue_id, - const struct smap *details, - void *aux) +qos_unixctl_show_queue(unsigned int queue_id, + const struct smap *details, + struct iface *iface, + struct ds *ds) { - struct qos_unixctl_show_cbdata *data = aux; - struct ds *ds = data->ds; - struct iface *iface = data->iface; struct netdev_queue_stats stats; struct smap_node *node; int error; @@ -2566,7 +2587,7 @@ qos_unixctl_show_cb(unsigned int queue_id, } } else { ds_put_format(ds, "\tFailed to get statistics for queue %u: %s", - queue_id, strerror(error)); + queue_id, ovs_strerror(error)); } } @@ -2579,8 +2600,6 @@ qos_unixctl_show(struct unixctl_conn *conn, int argc OVS_UNUSED, struct iface *iface; const char *type; struct smap_node *node; - struct qos_unixctl_show_cbdata data; - int error; iface = iface_find(argv[1]); if (!iface) { @@ -2591,19 +2610,22 @@ qos_unixctl_show(struct unixctl_conn *conn, int argc OVS_UNUSED, netdev_get_qos(iface->netdev, &type, &smap); if (*type != '\0') { + struct netdev_queue_dump dump; + struct smap details; + unsigned int queue_id; + ds_put_format(&ds, "QoS: %s %s\n", iface->name, type); SMAP_FOR_EACH (node, &smap) { ds_put_format(&ds, "%s: %s\n", node->key, node->value); } - data.ds = &ds; - data.iface = iface; - error = netdev_dump_queues(iface->netdev, qos_unixctl_show_cb, &data); - - if (error) { - ds_put_format(&ds, "failed to dump queues: %s", strerror(error)); + smap_init(&details); + NETDEV_QUEUE_FOR_EACH (&queue_id, &details, &dump, iface->netdev) { + qos_unixctl_show_queue(queue_id, &details, iface, &ds); } + smap_destroy(&details); + unixctl_command_reply(conn, ds_cstr(&ds)); } else { ds_put_format(&ds, "QoS not configured on %s\n", iface->name); @@ -3534,7 +3556,7 @@ iface_set_mac(struct iface *iface) int error = netdev_set_etheraddr(iface->netdev, ea); if (error) { VLOG_ERR("interface %s: setting MAC failed (%s)", - iface->name, strerror(error)); + iface->name, ovs_strerror(error)); } } } @@ -3572,14 +3594,10 @@ iface_clear_db_record(const struct ovsrec_interface *if_cfg) ovsrec_interface_set_cfm_remote_mpids(if_cfg, NULL, 0); ovsrec_interface_set_lacp_current(if_cfg, NULL, 0); ovsrec_interface_set_statistics(if_cfg, NULL, NULL, 0); + ovsrec_interface_set_ifindex(if_cfg, NULL, 0); } } -struct iface_delete_queues_cbdata { - struct netdev *netdev; - const struct ovsdb_datum *queues; -}; - static bool queue_ids_include(const struct ovsdb_datum *queues, int64_t target) { @@ -3589,17 +3607,6 @@ queue_ids_include(const struct ovsdb_datum *queues, int64_t target) return ovsdb_datum_find_key(queues, &atom, OVSDB_TYPE_INTEGER) != UINT_MAX; } -static void -iface_delete_queues(unsigned int queue_id, - const struct smap *details OVS_UNUSED, void *cbdata_) -{ - struct iface_delete_queues_cbdata *cbdata = cbdata_; - - if (!queue_ids_include(cbdata->queues, queue_id)) { - netdev_delete_queue(cbdata->netdev, queue_id); - } -} - static void iface_configure_qos(struct iface *iface, const struct ovsrec_qos *qos) { @@ -3610,7 +3617,10 @@ iface_configure_qos(struct iface *iface, const struct ovsrec_qos *qos) if (!qos || qos->type[0] == '\0' || qos->n_queues < 1) { netdev_set_qos(iface->netdev, NULL, NULL); } else { - struct iface_delete_queues_cbdata cbdata; + const struct ovsdb_datum *queues; + struct netdev_queue_dump dump; + unsigned int queue_id; + struct smap details; bool queue_zero; size_t i; @@ -3618,10 +3628,15 @@ iface_configure_qos(struct iface *iface, const struct ovsrec_qos *qos) netdev_set_qos(iface->netdev, qos->type, &qos->other_config); /* Deconfigure queues that were deleted. */ - cbdata.netdev = iface->netdev; - cbdata.queues = ovsrec_qos_get_queues(qos, OVSDB_TYPE_INTEGER, - OVSDB_TYPE_UUID); - netdev_dump_queues(iface->netdev, iface_delete_queues, &cbdata); + queues = ovsrec_qos_get_queues(qos, OVSDB_TYPE_INTEGER, + OVSDB_TYPE_UUID); + smap_init(&details); + NETDEV_QUEUE_FOR_EACH (&queue_id, &details, &dump, iface->netdev) { + if (!queue_ids_include(queues, queue_id)) { + netdev_delete_queue(iface->netdev, queue_id); + } + } + smap_destroy(&details); /* Configure queues for 'iface'. */ queue_zero = false; @@ -4075,10 +4090,10 @@ collect_splinter_vlans(const struct ovsrec_open_vswitch *ovs_cfg) if (!netdev_open(vlan_dev->name, "system", &netdev)) { if (!netdev_get_in4(netdev, NULL, NULL) || !netdev_get_in6(netdev, NULL)) { - vlandev_del(vlan_dev->name); - } else { /* It has an IP address configured, so we don't own * it. Don't delete it. */ + } else { + vlandev_del(vlan_dev->name); } netdev_close(netdev); }