From c1e98da15f5481c44dd71fd271221526203cc6f9 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 6 Jan 2010 10:24:52 -0800 Subject: [PATCH] sflow: Report port ifIndexes instead of datapath port numbers. Reported-by: Neil McKee --- ofproto/ofproto-sflow.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c index 608abe905..29f7e3458 100644 --- a/ofproto/ofproto-sflow.c +++ b/ofproto/ofproto-sflow.c @@ -427,6 +427,14 @@ ofproto_sflow_set_options(struct ofproto_sflow *os, } } +static int +ofproto_sflow_odp_port_to_ifindex(const struct ofproto_sflow *os, + uint16_t odp_port) +{ + struct ofproto_sflow_port *osp = port_array_get(&os->ports, odp_port); + return osp ? SFL_DS_INDEX(osp->dsi) : 0; +} + void ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg) { @@ -475,7 +483,7 @@ ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg) /* Build a flow sample */ memset(&fs, 0, sizeof fs); - fs.input = msg->port == ODPP_LOCAL ? 0x3fffffff : msg->port; + fs.input = ofproto_sflow_odp_port_to_ifindex(os, msg->port); fs.output = 0; /* Filled in correctly below. */ fs.sample_pool = hdr->sample_pool; @@ -505,7 +513,7 @@ ofproto_sflow_received(struct ofproto_sflow *os, struct odp_msg *msg) switch (a->type) { case ODPAT_OUTPUT: - fs.output = a->output.port; + fs.output = ofproto_sflow_odp_port_to_ifindex(os, a->output.port); n_outputs++; break; -- 2.43.0