X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fofproto-sflow.c;h=208ad8c765762831108ba8fbfbec1aa1ce768201;hb=e53df2065c0fe1cd8e913102913cc8c939994984;hp=7fa2e1b94936a7ea6b1164a33cb9a336957f1bc7;hpb=fa49ca8008bc62173343a9319d0a4f7d31c51771;p=openvswitch diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c index 7fa2e1b9..208ad8c7 100644 --- a/ofproto/ofproto-sflow.c +++ b/ofproto/ofproto-sflow.c @@ -148,12 +148,14 @@ sflow_agent_get_counters(void *os_, SFLPoller *poller, counters->ifIndex = SFL_DS_INDEX(poller->dsi); counters->ifType = 6; if (!netdev_get_features(osp->netdev, ¤t, NULL, NULL, NULL)) { + /* The values of ifDirection come from MAU MIB (RFC 2668): 0 = unknown, + 1 = full-duplex, 2 = half-duplex, 3 = in, 4=out */ counters->ifSpeed = netdev_features_to_bps(current); counters->ifDirection = (netdev_features_is_full_duplex(current) ? 1 : 2); } else { counters->ifSpeed = 100000000; - counters->ifDirection = 1; + counters->ifDirection = 0; } if (!netdev_get_flags(osp->netdev, &flags) && flags & NETDEV_UP) { bool carrier; @@ -357,6 +359,13 @@ ofproto_sflow_set_options(struct ofproto_sflow *os, time_t now; int error; + if (!options->targets.n || !options->sampling_rate) { + /* No point in doing any work if there are no targets or nothing to + * sample. */ + ofproto_sflow_clear(os); + return; + } + options_changed = (!os->options || !ofproto_sflow_options_equal(options, os->options)); @@ -369,7 +378,8 @@ ofproto_sflow_set_options(struct ofproto_sflow *os, error = collectors_create(&options->targets, SFL_DEFAULT_COLLECTOR_PORT, &os->collectors); if (os->collectors == NULL) { - VLOG_WARN_RL(&rl, "no configured collectors, sFlow disabled"); + VLOG_WARN_RL(&rl, "no collectors could be initialized, " + "sFlow disabled"); ofproto_sflow_clear(os); return; } @@ -408,10 +418,10 @@ ofproto_sflow_set_options(struct ofproto_sflow *os, sflow_agent_send_packet_cb); receiver = sfl_agent_addReceiver(os->sflow_agent); - sfl_receiver_set_sFlowRcvrOwner(receiver, "OpenVSwitch sFlow"); + sfl_receiver_set_sFlowRcvrOwner(receiver, "Open vSwitch sFlow"); sfl_receiver_set_sFlowRcvrTimeout(receiver, 0xffffffff); - /* Add a single sampler to represent the whole switch (special :0 + /* Add a single sampler to represent the datapath (special :0 * datasource). The alternative is to model a physical switch more closely * and instantiate a separate sampler object for each interface, but then * unicasts would have to be offered to two samplers, and @@ -543,6 +553,9 @@ ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg) break; } } + + /* Set output port, as defined by http://www.sflow.org/sflow_version_5.txt + (search for "Input/output port information"). */ if (!n_outputs) { /* This value indicates that the packet was dropped for an unknown * reason. */