From 1a1e3a0a28901e3fd0d93259835fe9a0a5e029fc Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Wed, 6 Mar 2013 18:15:06 -0800 Subject: [PATCH] ofproto-dpif: Add helper function to retrieve a subfacet from a facet. Signed-off-by: Justin Pettit --- ofproto/ofproto-dpif.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 228e28025..56b55f6d4 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -513,6 +513,8 @@ static void facet_push_stats(struct facet *); static void facet_learn(struct facet *); static void facet_account(struct facet *); +static struct subfacet *facet_get_subfacet(struct facet *); + static bool facet_is_controller_flow(struct facet *); struct ofport_dpif { @@ -4441,7 +4443,7 @@ static void facet_account(struct facet *facet) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(facet->rule->up.ofproto); - struct subfacet *subfacet; + struct subfacet *subfacet = facet_get_subfacet(facet); const struct nlattr *a; unsigned int left; ovs_be16 vlan_tci; @@ -4460,8 +4462,6 @@ facet_account(struct facet *facet) * * We use the actions from an arbitrary subfacet because they should all * be equally valid for our purpose. */ - subfacet = CONTAINER_OF(list_front(&facet->subfacets), - struct subfacet, list_node); vlan_tci = facet->flow.vlan_tci; NL_ATTR_FOR_EACH_UNSAFE (a, left, subfacet->actions, subfacet->actions_len) { @@ -4598,6 +4598,14 @@ facet_lookup_valid(struct ofproto_dpif *ofproto, const struct flow *flow, return facet; } +/* Return a subfacet from 'facet'. A facet consists of one or more + * subfacets, and this function returns one of them. */ +static struct subfacet *facet_get_subfacet(struct facet *facet) +{ + return CONTAINER_OF(list_front(&facet->subfacets), struct subfacet, + list_node); +} + static const char * subfacet_path_to_string(enum subfacet_path path) { @@ -4937,8 +4945,7 @@ flow_push_stats(struct facet *facet, const struct dpif_flow_stats *stats) { struct rule_dpif *rule = facet->rule; struct ofproto_dpif *ofproto = ofproto_dpif_cast(rule->up.ofproto); - struct subfacet *subfacet = CONTAINER_OF(list_front(&facet->subfacets), - struct subfacet, list_node); + struct subfacet *subfacet = facet_get_subfacet(facet); struct action_xlate_ctx ctx; ofproto_rule_update_used(&rule->up, stats->used); -- 2.43.0