From ce3955bed734b7459a8bdb3180284bf35dddaa7b Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Wed, 30 Oct 2013 16:29:58 -0700 Subject: [PATCH 1/1] ofproto: Handle netflow similarly to ipfix and sflow in xlate. This patch changes how ofproto-dpif-xlate handles netflow so that it's more similar to how ipfix and sflow are handled. This not only simplifies the code, but it will allow xlate to call netflow in future if necessary. Signed-off-by: Ethan Jackson Acked-by: Ben Pfaff --- ofproto/ofproto-dpif-xlate.c | 15 ++++++++++----- ofproto/ofproto-dpif-xlate.h | 5 +++-- ofproto/ofproto-dpif.c | 5 ++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index aec17c014..ac273e944 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -76,6 +76,7 @@ struct xbridge { struct mbridge *mbridge; /* Mirroring. */ struct dpif_sflow *sflow; /* SFlow handle, or null. */ struct dpif_ipfix *ipfix; /* Ipfix handle, or null. */ + struct netflow *netflow; /* Netflow handle, or null. */ struct stp *stp; /* STP or null if disabled. */ /* Special rules installed by ofproto-dpif. */ @@ -83,7 +84,6 @@ struct xbridge { struct rule_dpif *no_packet_in_rule; enum ofp_config_flags frag; /* Fragmentation handling. */ - bool has_netflow; /* Bridge runs netflow? */ bool has_in_band; /* Bridge has in band control? */ bool forward_bpdu; /* Bridge forwards STP BPDUs? */ }; @@ -246,8 +246,9 @@ xlate_ofproto_set(struct ofproto_dpif *ofproto, const char *name, const struct mac_learning *ml, struct stp *stp, const struct mbridge *mbridge, const struct dpif_sflow *sflow, - const struct dpif_ipfix *ipfix, enum ofp_config_flags frag, - bool forward_bpdu, bool has_in_band, bool has_netflow) + const struct dpif_ipfix *ipfix, + const struct netflow *netflow, enum ofp_config_flags frag, + bool forward_bpdu, bool has_in_band) { struct xbridge *xbridge = xbridge_lookup(ofproto); @@ -285,13 +286,17 @@ xlate_ofproto_set(struct ofproto_dpif *ofproto, const char *name, xbridge->stp = stp_ref(stp); } + if (xbridge->netflow != netflow) { + netflow_unref(xbridge->netflow); + xbridge->netflow = netflow_ref(netflow); + } + free(xbridge->name); xbridge->name = xstrdup(name); xbridge->dpif = dpif; xbridge->forward_bpdu = forward_bpdu; xbridge->has_in_band = has_in_band; - xbridge->has_netflow = has_netflow; xbridge->frag = frag; xbridge->miss_rule = miss_rule; xbridge->no_packet_in_rule = no_packet_in_rule; @@ -3080,7 +3085,7 @@ xlate_actions__(struct xlate_in *xin, struct xlate_out *xout) wc->masks.nw_frag |= FLOW_NW_FRAG_MASK; tnl_may_send = tnl_xlate_init(&ctx.base_flow, flow, wc); - if (ctx.xbridge->has_netflow) { + if (ctx.xbridge->netflow) { netflow_mask_wc(flow, wc); } diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h index 7dd353408..11a180ae0 100644 --- a/ofproto/ofproto-dpif-xlate.h +++ b/ofproto/ofproto-dpif-xlate.h @@ -121,8 +121,9 @@ void xlate_ofproto_set(struct ofproto_dpif *, const char *name, struct rule_dpif *no_packet_in_rule, const struct mac_learning *, struct stp *, const struct mbridge *, const struct dpif_sflow *, - const struct dpif_ipfix *, enum ofp_config_flags, - bool forward_bpdu, bool has_in_band, bool has_netflow) + const struct dpif_ipfix *, const struct netflow *, + enum ofp_config_flags, bool forward_bpdu, + bool has_in_band) OVS_REQ_WRLOCK(xlate_rwlock); void xlate_remove_ofproto(struct ofproto_dpif *) OVS_REQ_WRLOCK(xlate_rwlock); diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 693bb0ac8..9168da1df 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -800,10 +800,9 @@ type_run(const char *type) ofproto->no_packet_in_rule, ofproto->ml, ofproto->stp, ofproto->mbridge, ofproto->sflow, ofproto->ipfix, - ofproto->up.frag_handling, + ofproto->netflow, ofproto->up.frag_handling, ofproto->up.forward_bpdu, - connmgr_has_in_band(ofproto->up.connmgr), - ofproto->netflow != NULL); + connmgr_has_in_band(ofproto->up.connmgr)); HMAP_FOR_EACH (bundle, hmap_node, &ofproto->bundles) { xlate_bundle_set(ofproto, bundle, bundle->name, -- 2.43.0