This patch allows the lookup functions to take NULL as an argument as a convenience.
Signed-off-by: Ethan Jackson <et...@nicira.com> --- ofproto/ofproto-dpif-xlate.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index aa90edf..810cb29 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -201,7 +201,7 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); static struct xbridge *xbridge_lookup(const struct ofproto_dpif *); static struct xbundle *xbundle_lookup(const struct ofbundle *); -static struct xport *xport_lookup(struct ofport_dpif *); +static struct xport *xport_lookup(const struct ofport_dpif *); static struct xport *get_ofp_port(const struct xbridge *, ofp_port_t ofp_port); static struct skb_priority_to_dscp *get_skb_priority(const struct xport *, uint32_t skb_priority); @@ -406,7 +406,7 @@ xlate_ofport_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle, if (xport->peer) { xport->peer->peer = NULL; } - xport->peer = peer ? xport_lookup(peer) : NULL; + xport->peer = xport_lookup(peer); if (xport->peer) { xport->peer->peer = xport; } @@ -414,7 +414,7 @@ xlate_ofport_set(struct ofproto_dpif *ofproto, struct ofbundle *ofbundle, if (xport->xbundle) { list_remove(&xport->bundle_node); } - xport->xbundle = ofbundle ? xbundle_lookup(ofbundle) : NULL; + xport->xbundle = xbundle_lookup(ofbundle); if (xport->xbundle) { list_insert(&xport->xbundle->xports, &xport->bundle_node); } @@ -472,6 +472,10 @@ xbridge_lookup(const struct ofproto_dpif *ofproto) { struct xbridge *xbridge; + if (!ofproto) { + return NULL; + } + HMAP_FOR_EACH_IN_BUCKET (xbridge, hmap_node, hash_pointer(ofproto, 0), &xbridges) { if (xbridge->ofproto == ofproto) { @@ -486,6 +490,10 @@ xbundle_lookup(const struct ofbundle *ofbundle) { struct xbundle *xbundle; + if (!ofbundle) { + return NULL; + } + HMAP_FOR_EACH_IN_BUCKET (xbundle, hmap_node, hash_pointer(ofbundle, 0), &xbundles) { if (xbundle->ofbundle == ofbundle) { @@ -496,10 +504,14 @@ xbundle_lookup(const struct ofbundle *ofbundle) } static struct xport * -xport_lookup(struct ofport_dpif *ofport) +xport_lookup(const struct ofport_dpif *ofport) { struct xport *xport; + if (!ofport) { + return NULL; + } + HMAP_FOR_EACH_IN_BUCKET (xport, hmap_node, hash_pointer(ofport, 0), &xports) { if (xport->ofport == ofport) { @@ -882,7 +894,7 @@ output_normal(struct xlate_ctx *ctx, const struct xbundle *out_xbundle, ofport = bond_choose_output_slave(out_xbundle->bond, &ctx->xin->flow, &ctx->xout->wc, vid); - xport = ofport ? xport_lookup(ofport) : NULL; + xport = xport_lookup(ofport); if (!xport) { /* No slaves enabled, so drop packet. */ -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev