ovn/controller/ofctrl.c
void
ofctrl_add_flow(struct hmap *desired_flows,
                uint8_t table_id, uint16_t priority, uint64_t cookie,
                const struct match *match,
                const struct ofpbuf *actions)
{
    struct ovn_flow *f = xmalloc(sizeof *f);
    f->table_id = table_id;
    f->priority = priority;
    f->match = *match;
    f->ofpacts = xmemdup(actions->data, actions->size);
    f->ofpacts_len = actions->size;
    f->hmap_node.hash = ovn_flow_hash(f);
    f->cookie = cookie;

    if (ovn_flow_lookup(desired_flows, f)) {
        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);
        if (!VLOG_DROP_INFO(&rl)) {
            char *s = ovn_flow_to_string(f);
            VLOG_INFO("dropping duplicate flow: %s", s);
            free(s);
        }

        ovn_flow_destroy(f);
        return;
    }

    hmap_insert(desired_flows, &f->hmap_node, f->hmap_node.hash);
}
/* Adds a flow to 'desired_flows' with the specified 'match' and 'actions' to
 * the OpenFlow table numbered 'table_id' with the given 'priority' and
 * OpenFlow 'cookie'.  The caller retains ownership of 'match' and 'actions'.
 *
 * This just assembles the desired flow table in memory.  Nothing is actually
 * sent to the switch until a later call to ofctrl_put().
 *
 * The caller should initialize its own hmap to hold the flows. */


This just assembles the desired flow table in memory.  Nothing is actually
sent to the switch until a later call to ofctrl_put().

The caller should initialize its own hmap to hold the flows.
This just assembles the desired flow table in memory . Nothing is actually sent to the switch until a later call to ofctrl_put () . The caller should initialize its own hmap to hold the flows .
void
ofctrl_add_flow(struct hmap *desired_flows,
                uint8_t table_id, uint16_t priority, uint64_t cookie,
                const struct match *match,
                const struct ofpbuf *actions)
{
    struct ovn_flow *f = xmalloc(sizeof *f);
    f->table_id = table_id;
    f->priority = priority;
    f->match = *match;
    f->ofpacts = xmemdup(actions->data, actions->size);
    f->ofpacts_len = actions->size;
    f->hmap_node.hash = ovn_flow_hash(f);
    f->cookie = cookie;
    if (ovn_flow_lookup(desired_flows, f)) {
        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5);
        if (!VLOG_DROP_INFO(&rl)) {
            char *s = ovn_flow_to_string(f);
            VLOG_INFO("dropping duplicate flow: %s", s);
            free(s);
        }
        ovn_flow_destroy(f);
        return;
    }
    hmap_insert(desired_flows, &f->hmap_node, f->hmap_node.hash);
}
void ofctrl_add_flow ( struct hmap * desired_flows , uint8_t table_id , uint16_t priority , uint64_t cookie , const struct match * match , const struct ofpbuf * actions ) { struct ovn_flow * f = xmalloc ( sizeof * f ) ; f -> table_id = table_id ; f -> priority = priority ; f -> match = * match ; f -> ofpacts = xmemdup ( actions -> data , actions -> size ) ; f -> ofpacts_len = actions -> size ; f -> hmap_node . hash = ovn_flow_hash ( f ) ; f -> cookie = cookie ; if ( ovn_flow_lookup ( desired_flows , f ) ) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT ( 5 , 5 ) ; if ( ! VLOG_DROP_INFO ( & rl ) ) { char * s = ovn_flow_to_string ( f ) ; VLOG_INFO ( " " , s ) ; free ( s ) ; } ovn_flow_destroy ( f ) ; return ; } hmap_insert ( desired_flows , & f -> hmap_node , f -> hmap_node . hash ) ; }
Adds a flow to 'desired_flows' with the specified 'match' and 'actions' to
 the OpenFlow table numbered 'table_id' with the given 'priority' and
 OpenFlow 'cookie'.
Adds a flow to ' desired_flows ' with the specified ' match ' and ' actions ' to the OpenFlow table numbered ' table_id ' with the given ' priority ' and OpenFlow ' cookie ' .