On Aug 27, 2013, at 11:12 AM, Ben Pfaff <b...@nicira.com> wrote: > Suggested-by: pritesh <pritesh.koth...@cisco.com> > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > ofproto/tunnel.c | 100 +++++++++++++++++++++++++----------------------------- > 1 file changed, 46 insertions(+), 54 deletions(-) > > diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c > index 202358b..4729f5f 100644 > --- a/ofproto/tunnel.c > +++ b/ofproto/tunnel.c ... > +/* Returns the tnl_port that is the best match for the tunnel data in 'flow', > + * or NULL if no tnl_port matches 'flow'. */ > static struct tnl_port * > -tnl_find(struct tnl_match *match_) OVS_REQ_RDLOCK(rwlock) > +tnl_find(const struct flow *flow) OVS_REQ_RDLOCK(rwlock) > { > - struct tnl_match match = *match_; > - struct tnl_port *tnl_port; > + enum ip_src_type { > + IP_SRC_EXACT, /* ip_src must match exactly. */ > + IP_SRC_ANY, /* Any ip_src is acceptable. */ > + IP_SRC_FLOW /* ip_src is handled in flow table. */ > + }; > + > + struct tnl_match_pattern { > + bool in_key_flow; > + bool ip_dst_flow; > + enum ip_src_type ip_src; > + }; > + > + static const struct tnl_match_pattern patterns[] = { > + { false, false, IP_SRC_EXACT }, /* remote_ip, local_ip, in_key. */ > + { false, false, IP_SRC_ANY }, /* remote_ip, in_key. */ > + { true, false, IP_SRC_EXACT }, /* remote_ip, local_ip. */ > + { true, false, IP_SRC_ANY }, /* remote_ip. */ > + { true, true, IP_SRC_ANY }, /* Flow-based remote. */ > + { true, true, IP_SRC_FLOW }, /* Flow-based everything. */ > + }; > +
Sorry to mention this now rather than sooner, but the above would be even more self explanatory if the booleans were replaced with enums, like this: + static const struct tnl_match_pattern patterns[] = { + { KEY_CFG, IP_DST_CFG, IP_SRC_CFG }, /* remote_ip, local_ip, in_key. */ + { KEY_CFG, IP_DST_CFG, IP_SRC_ANY }, /* remote_ip, in_key. */ + { KEY_FLOW, IP_DST_CFG, IP_SRC_CFG }, /* remote_ip, local_ip. */ + { KEY_FLOW, IP_DST_CFG, IP_SRC_ANY }, /* remote_ip. */ + { KEY_FLOW, IP_DST_FLOW, IP_SRC_ANY }, /* Flow-based remote. */ + { KEY_FLOW, IP_DST_FLOW, IP_SRC_FLOW }, /* Flow-based everything. */ + }; The key and dst fields could still be used like booleans, so no code needs to change because of this. (Note the renamed IP_SRC_EXACT -> IP_SRC_CFG also.) Jarno _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev