projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ovsdb-tool: Remove reference to non-implemented "extract-schema" command
[openvswitch]
/
ofproto
/
ofproto-sflow.c
diff --git
a/ofproto/ofproto-sflow.c
b/ofproto/ofproto-sflow.c
index 85f9f9ff47b6d936c4e1b930896e90f890d5a675..c74c7360ef5e4db6b738421655cd693880ad943f 100644
(file)
--- a/
ofproto/ofproto-sflow.c
+++ b/
ofproto/ofproto-sflow.c
@@
-30,10
+30,10
@@
#include "sflow_api.h"
#include "socket-util.h"
#include "timeval.h"
#include "sflow_api.h"
#include "socket-util.h"
#include "timeval.h"
-
-#define THIS_MODULE VLM_sflow
#include "vlog.h"
#include "vlog.h"
+VLOG_DEFINE_THIS_MODULE(sflow)
+
struct ofproto_sflow_port {
struct netdev *netdev; /* Underlying network device, for stats. */
SFLDataSource_instance dsi; /* sFlow library's notion of port number. */
struct ofproto_sflow_port {
struct netdev *netdev; /* Underlying network device, for stats. */
SFLDataSource_instance dsi; /* sFlow library's notion of port number. */
@@
-239,9
+239,6
@@
success:
void
ofproto_sflow_clear(struct ofproto_sflow *os)
{
void
ofproto_sflow_clear(struct ofproto_sflow *os)
{
- struct ofproto_sflow_port *osp;
- unsigned int odp_port;
-
if (os->sflow_agent) {
sfl_agent_release(os->sflow_agent);
os->sflow_agent = NULL;
if (os->sflow_agent) {
sfl_agent_release(os->sflow_agent);
os->sflow_agent = NULL;
@@
-251,11
+248,6
@@
ofproto_sflow_clear(struct ofproto_sflow *os)
ofproto_sflow_options_destroy(os->options);
os->options = NULL;
ofproto_sflow_options_destroy(os->options);
os->options = NULL;
- PORT_ARRAY_FOR_EACH (osp, &os->ports, odp_port) {
- ofproto_sflow_del_port(os, odp_port);
- }
- port_array_clear(&os->ports);
-
/* Turn off sampling to save CPU cycles. */
dpif_set_sflow_probability(os->dpif, 0);
}
/* Turn off sampling to save CPU cycles. */
dpif_set_sflow_probability(os->dpif, 0);
}
@@
-282,7
+274,13
@@
void
ofproto_sflow_destroy(struct ofproto_sflow *os)
{
if (os) {
ofproto_sflow_destroy(struct ofproto_sflow *os)
{
if (os) {
+ struct ofproto_sflow_port *osp;
+ unsigned int odp_port;
+
ofproto_sflow_clear(os);
ofproto_sflow_clear(os);
+ PORT_ARRAY_FOR_EACH (osp, &os->ports, odp_port) {
+ ofproto_sflow_del_port(os, odp_port);
+ }
port_array_destroy(&os->ports);
free(os);
}
port_array_destroy(&os->ports);
free(os);
}
@@
-301,12
+299,11
@@
ofproto_sflow_add_poller(struct ofproto_sflow *os,
static void
ofproto_sflow_add_sampler(struct ofproto_sflow *os,
static void
ofproto_sflow_add_sampler(struct ofproto_sflow *os,
- struct ofproto_sflow_port *osp,
- u_int32_t sampling_rate, u_int32_t header_len)
+ struct ofproto_sflow_port *osp)
{
SFLSampler *sampler = sfl_agent_addSampler(os->sflow_agent, &osp->dsi);
{
SFLSampler *sampler = sfl_agent_addSampler(os->sflow_agent, &osp->dsi);
- sfl_sampler_set_sFlowFsPacketSamplingRate(sampler, sampling_rate);
- sfl_sampler_set_sFlowFsMaximumHeaderSize(sampler, header_len);
+ sfl_sampler_set_sFlowFsPacketSamplingRate(sampler,
os->options->
sampling_rate);
+ sfl_sampler_set_sFlowFsMaximumHeaderSize(sampler,
os->options->
header_len);
sfl_sampler_set_sFlowFsReceiver(sampler, RECEIVER_INDEX);
}
sfl_sampler_set_sFlowFsReceiver(sampler, RECEIVER_INDEX);
}
@@
-339,9
+336,10
@@
ofproto_sflow_add_port(struct ofproto_sflow *os, uint16_t odp_port,
SFL_DS_SET(osp->dsi, 0, ifindex, 0);
port_array_set(&os->ports, odp_port, osp);
SFL_DS_SET(osp->dsi, 0, ifindex, 0);
port_array_set(&os->ports, odp_port, osp);
- /* Add poller. */
+ /* Add poller
and sampler
. */
if (os->sflow_agent) {
ofproto_sflow_add_poller(os, osp, odp_port);
if (os->sflow_agent) {
ofproto_sflow_add_poller(os, osp, odp_port);
+ ofproto_sflow_add_sampler(os, osp);
}
}
}
}
@@
-356,7
+354,7
@@
ofproto_sflow_del_port(struct ofproto_sflow *os, uint16_t odp_port)
}
netdev_close(osp->netdev);
free(osp);
}
netdev_close(osp->netdev);
free(osp);
- port_array_
set(&os->ports, odp_port, NULL
);
+ port_array_
delete(&os->ports, odp_port
);
}
}
}
}
@@
-417,7
+415,7
@@
ofproto_sflow_set_options(struct ofproto_sflow *os,
sfl_agent_release(os->sflow_agent);
}
os->sflow_agent = xcalloc(1, sizeof *os->sflow_agent);
sfl_agent_release(os->sflow_agent);
}
os->sflow_agent = xcalloc(1, sizeof *os->sflow_agent);
- now = time_
now
();
+ now = time_
wall
();
sfl_agent_init(os->sflow_agent,
&agentIP,
options->sub_id,
sfl_agent_init(os->sflow_agent,
&agentIP,
options->sub_id,
@@
-439,8
+437,8
@@
ofproto_sflow_set_options(struct ofproto_sflow *os,
/* Add samplers and pollers for the currently known ports. */
PORT_ARRAY_FOR_EACH (osp, &os->ports, odp_port) {
/* Add samplers and pollers for the currently known ports. */
PORT_ARRAY_FOR_EACH (osp, &os->ports, odp_port) {
- ofproto_sflow_add_
sampler(os, osp,
-
options->sampling_rate, options->header_len
);
+ ofproto_sflow_add_
poller(os, osp, odp_port);
+
ofproto_sflow_add_sampler(os, osp
);
}
}
}
}
@@
-519,8
+517,11
@@
ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg)
hdrElem.tag = SFLFLOW_HEADER;
header = &hdrElem.flowType.header;
header->header_protocol = SFLHEADER_ETHERNET_ISO8023;
hdrElem.tag = SFLFLOW_HEADER;
header = &hdrElem.flowType.header;
header->header_protocol = SFLHEADER_ETHERNET_ISO8023;
- header->frame_length = payload.size;
- header->stripped = 4; /* Ethernet FCS stripped off. */
+ /* The frame_length should include the Ethernet FCS (4 bytes),
+ but it has already been stripped, so we need to add 4 here. */
+ header->frame_length = payload.size + 4;
+ /* Ethernet FCS stripped off. */
+ header->stripped = 4;
header->header_length = MIN(payload.size,
sampler->sFlowFsMaximumHeaderSize);
header->header_bytes = payload.data;
header->header_length = MIN(payload.size,
sampler->sFlowFsMaximumHeaderSize);
header->header_bytes = payload.data;
@@
-530,7
+531,9
@@
ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg)
switchElem.tag = SFLFLOW_EX_SWITCH;
switchElem.flowType.sw.src_vlan = ntohs(flow.dl_vlan);
switchElem.flowType.sw.src_priority = -1; /* XXX */
switchElem.tag = SFLFLOW_EX_SWITCH;
switchElem.flowType.sw.src_vlan = ntohs(flow.dl_vlan);
switchElem.flowType.sw.src_priority = -1; /* XXX */
- switchElem.flowType.sw.dst_vlan = -1; /* Filled in correctly below. */
+ /* Initialize the output VLAN and priority to be the same as the input,
+ but these fields can be overriden below if affected by an action. */
+ switchElem.flowType.sw.dst_vlan = switchElem.flowType.sw.src_vlan;
switchElem.flowType.sw.dst_priority = switchElem.flowType.sw.src_priority;
/* Figure out the output ports. */
switchElem.flowType.sw.dst_priority = switchElem.flowType.sw.src_priority;
/* Figure out the output ports. */
@@
-594,7
+597,7
@@
ofproto_sflow_run(struct ofproto_sflow *os)
if (ofproto_sflow_is_enabled(os)) {
time_t now = time_now();
if (now >= os->next_tick) {
if (ofproto_sflow_is_enabled(os)) {
time_t now = time_now();
if (now >= os->next_tick) {
- sfl_agent_tick(os->sflow_agent,
now
);
+ sfl_agent_tick(os->sflow_agent,
time_wall()
);
os->next_tick = now + 1;
}
}
os->next_tick = now + 1;
}
}
@@
-604,6
+607,6
@@
void
ofproto_sflow_wait(struct ofproto_sflow *os)
{
if (ofproto_sflow_is_enabled(os)) {
ofproto_sflow_wait(struct ofproto_sflow *os)
{
if (ofproto_sflow_is_enabled(os)) {
- poll_timer_wait
(os->next_tick * 1000 - time_msec()
);
+ poll_timer_wait
_until(os->next_tick * 1000LL
);
}
}
}
}