This seems cleaner than having separate accessors for them.
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
error = xlate_receive(udpif->backer, packet, dupcall->key,
dupcall->key_len, &flow, &miss->key_fitness,
- &ofproto, &odp_in_port);
+ &ofproto, &ipfix, &sflow, NULL, &odp_in_port);
if (error) {
if (error == ENODEV) {
struct drop_key *drop_key;
switch (type) {
case SFLOW_UPCALL:
- sflow = xlate_get_sflow(ofproto);
if (sflow) {
union user_action_cookie cookie;
sizeof cookie.sflow);
dpif_sflow_received(sflow, dupcall->packet, &flow, odp_in_port,
&cookie);
- dpif_sflow_unref(sflow);
}
break;
case IPFIX_UPCALL:
- ipfix = xlate_get_ipfix(ofproto);
if (ipfix) {
dpif_ipfix_bridge_sample(ipfix, dupcall->packet, &flow);
- dpif_ipfix_unref(ipfix);
}
break;
case FLOW_SAMPLE_UPCALL:
- ipfix = xlate_get_ipfix(ofproto);
if (ipfix) {
union user_action_cookie cookie;
cookie.flow_sample.probability,
cookie.flow_sample.obs_domain_id,
cookie.flow_sample.obs_point_id);
- dpif_ipfix_unref(ipfix);
}
break;
case BAD_UPCALL:
NOT_REACHED();
}
+ dpif_ipfix_unref(ipfix);
+ dpif_sflow_unref(sflow);
+
list_remove(&upcall->list_node);
upcall_destroy(upcall);
}
* respectively), populates 'flow' with the result of odp_flow_key_to_flow().
* Optionally, if nonnull, populates 'fitnessp' with the fitness of 'flow' as
* returned by odp_flow_key_to_flow(). Also, optionally populates 'ofproto'
- * with the ofproto_dpif, and 'odp_in_port' with the datapath in_port, that
- * 'packet' ingressed.
+ * with the ofproto_dpif, 'odp_in_port' with the datapath in_port, that
+ * 'packet' ingressed, and 'ipfix', 'sflow', and 'netflow' with the appropriate
+ * handles for those protocols if they're enabled. Caller is responsible for
+ * unrefing them.
*
* If 'ofproto' is nonnull, requires 'flow''s in_port to exist. Otherwise sets
* 'flow''s in_port to OFPP_NONE.
xlate_receive(const struct dpif_backer *backer, struct ofpbuf *packet,
const struct nlattr *key, size_t key_len,
struct flow *flow, enum odp_key_fitness *fitnessp,
- struct ofproto_dpif **ofproto, odp_port_t *odp_in_port)
+ struct ofproto_dpif **ofproto, struct dpif_ipfix **ipfix,
+ struct dpif_sflow **sflow, struct netflow **netflow,
+ odp_port_t *odp_in_port)
{
enum odp_key_fitness fitness;
const struct xport *xport;
*ofproto = xport->xbridge->ofproto;
}
+ if (ipfix) {
+ *ipfix = dpif_ipfix_ref(xport->xbridge->ipfix);
+ }
+
+ if (sflow) {
+ *sflow = dpif_sflow_ref(xport->xbridge->sflow);
+ }
+
+ if (netflow) {
+ *netflow = netflow_ref(xport->xbridge->netflow);
+ }
+
exit:
if (fitnessp) {
*fitnessp = fitness;
ofpbuf_put(&dst->odp_actions, src->odp_actions.data,
src->odp_actions.size);
}
-
-/* Returns a reference to the sflow handled associated with ofproto, or NULL if
- * there is none. The caller is responsible for decrementing the results ref
- * count with dpif_sflow_unref(). */
-struct dpif_sflow *
-xlate_get_sflow(const struct ofproto_dpif *ofproto)
-{
- struct dpif_sflow *sflow = NULL;
- struct xbridge *xbridge;
-
- ovs_rwlock_rdlock(&xlate_rwlock);
- xbridge = xbridge_lookup(ofproto);
- if (xbridge) {
- sflow = dpif_sflow_ref(xbridge->sflow);
- }
- ovs_rwlock_unlock(&xlate_rwlock);
-
- return sflow;
-}
-
-/* Returns a reference to the ipfix handled associated with ofproto, or NULL if
- * there is none. The caller is responsible for decrementing the results ref
- * count with dpif_ipfix_unref(). */
-struct dpif_ipfix *
-xlate_get_ipfix(const struct ofproto_dpif *ofproto)
-{
- struct dpif_ipfix *ipfix = NULL;
- struct xbridge *xbridge;
-
- ovs_rwlock_rdlock(&xlate_rwlock);
- xbridge = xbridge_lookup(ofproto);
- if (xbridge) {
- ipfix = dpif_ipfix_ref(xbridge->ipfix);
- }
- ovs_rwlock_unlock(&xlate_rwlock);
-
- return ipfix;
-}
\f
static struct skb_priority_to_dscp *
get_skb_priority(const struct xport *xport, uint32_t skb_priority)
int xlate_receive(const struct dpif_backer *, struct ofpbuf *packet,
const struct nlattr *key, size_t key_len,
struct flow *, enum odp_key_fitness *,
- struct ofproto_dpif **, odp_port_t *odp_in_port)
+ struct ofproto_dpif **, struct dpif_ipfix **,
+ struct dpif_sflow **, struct netflow **,
+ odp_port_t *odp_in_port)
OVS_EXCLUDED(xlate_rwlock);
void xlate_actions(struct xlate_in *, struct xlate_out *)
void xlate_actions_for_side_effects(struct xlate_in *);
void xlate_out_copy(struct xlate_out *dst, const struct xlate_out *src);
-struct dpif_sflow *xlate_get_sflow(const struct ofproto_dpif *)
- OVS_EXCLUDED(xlate_rwlock);
-struct dpif_ipfix *xlate_get_ipfix(const struct ofproto_dpif *)
- OVS_EXCLUDED(xlate_rwlock);
-
int xlate_send_packet(const struct ofport_dpif *, struct ofpbuf *);
#endif /* ofproto-dpif-xlate.h */
error = xlate_receive(ofproto->backer, NULL, subfacet->key,
subfacet->key_len, &recv_flow, NULL,
- &recv_ofproto, NULL);
+ &recv_ofproto, NULL, NULL, NULL, NULL);
if (error
|| recv_ofproto != ofproto
|| facet != facet_find(ofproto, &recv_flow)) {
}
if (xlate_receive(backer, NULL, odp_key.data, odp_key.size, flow,
- NULL, ofprotop, NULL)) {
+ NULL, ofprotop, NULL, NULL, NULL, NULL)) {
error = "Invalid datapath flow";
goto exit;
}