ovn/controller/pinctrl.c
static void
send_garp_update(const struct sbrec_port_binding *binding_rec,
                 struct shash *nat_addresses)
{
    volatile struct garp_data *garp = NULL;
    /* Update GARP for NAT IP if it exists.  Consider port bindings with type
     * "l3gateway" for logical switch ports attached to gateway routers, and
     * port bindings with type "patch" for logical switch ports attached to
     * distributed gateway ports. */
    if (!strcmp(binding_rec->type, "l3gateway")
        || !strcmp(binding_rec->type, "patch")) {
        struct lport_addresses *laddrs = NULL;
        while ((laddrs = shash_find_and_delete(nat_addresses,
                                               binding_rec->logical_port))) {
            int i;
            for (i = 0; i < laddrs->n_ipv4_addrs; i++) {
                char *name = xasprintf("%s-%s", binding_rec->logical_port,
                                                laddrs->ipv4_addrs[i].addr_s);
                garp = shash_find_data(&send_garp_data, name);
                if (garp) {
                    garp->dp_key = binding_rec->datapath->tunnel_key;
                    garp->port_key = binding_rec->tunnel_key;
                } else {
                    add_garp(name, laddrs->ea,
                             laddrs->ipv4_addrs[i].addr,
                             binding_rec->datapath->tunnel_key,
                             binding_rec->tunnel_key);
                }
                free(name);
            }
            destroy_lport_addresses(laddrs);
            free(laddrs);
        }
        return;
    }

    /* Update GARP for vif if it exists. */
    garp = shash_find_data(&send_garp_data, binding_rec->logical_port);
    if (garp) {
        garp->dp_key = binding_rec->datapath->tunnel_key;
        garp->port_key = binding_rec->tunnel_key;
        return;
    }

    /* Add GARP for new vif. */
    int i;
    for (i = 0; i < binding_rec->n_mac; i++) {
        struct lport_addresses laddrs;
        if (!extract_lsp_addresses(binding_rec->mac[i], &laddrs)
            || !laddrs.n_ipv4_addrs) {
            continue;
        }

        add_garp(binding_rec->logical_port,
                 laddrs.ea, laddrs.ipv4_addrs[0].addr,
                 binding_rec->datapath->tunnel_key, binding_rec->tunnel_key);

        destroy_lport_addresses(&laddrs);
        break;
    }
}
/* Add or update a vif for which GARPs need to be announced. */
Add or update a vif for which GARPs need to be announced.
Add or update a vif for which GARPs need to be announced .
static void
send_garp_update(const struct sbrec_port_binding *binding_rec,
                 struct shash *nat_addresses)
{
    volatile struct garp_data *garp = NULL;
    if (!strcmp(binding_rec->type, "l3gateway")
        || !strcmp(binding_rec->type, "patch")) {
        struct lport_addresses *laddrs = NULL;
        while ((laddrs = shash_find_and_delete(nat_addresses,
                                               binding_rec->logical_port))) {
            int i;
            for (i = 0; i < laddrs->n_ipv4_addrs; i++) {
                char *name = xasprintf("%s-%s", binding_rec->logical_port,
                                                laddrs->ipv4_addrs[i].addr_s);
                garp = shash_find_data(&send_garp_data, name);
                if (garp) {
                    garp->dp_key = binding_rec->datapath->tunnel_key;
                    garp->port_key = binding_rec->tunnel_key;
                } else {
                    add_garp(name, laddrs->ea,
                             laddrs->ipv4_addrs[i].addr,
                             binding_rec->datapath->tunnel_key,
                             binding_rec->tunnel_key);
                }
                free(name);
            }
            destroy_lport_addresses(laddrs);
            free(laddrs);
        }
        return;
    }
    garp = shash_find_data(&send_garp_data, binding_rec->logical_port);
    if (garp) {
        garp->dp_key = binding_rec->datapath->tunnel_key;
        garp->port_key = binding_rec->tunnel_key;
        return;
    }
    int i;
    for (i = 0; i < binding_rec->n_mac; i++) {
        struct lport_addresses laddrs;
        if (!extract_lsp_addresses(binding_rec->mac[i], &laddrs)
            || !laddrs.n_ipv4_addrs) {
            continue;
        }
        add_garp(binding_rec->logical_port,
                 laddrs.ea, laddrs.ipv4_addrs[0].addr,
                 binding_rec->datapath->tunnel_key, binding_rec->tunnel_key);
        destroy_lport_addresses(&laddrs);
        break;
    }
}
static void send_garp_update ( const struct sbrec_port_binding * binding_rec , struct shash * nat_addresses ) { volatile struct garp_data * garp = NULL ; if ( ! strcmp ( binding_rec -> type , " " ) || ! strcmp ( binding_rec -> type , " " ) ) { struct lport_addresses * laddrs = NULL ; while ( ( laddrs = shash_find_and_delete ( nat_addresses , binding_rec -> logical_port ) ) ) { int i ; for ( i = 0 ; i < laddrs -> n_ipv4_addrs ; i ++ ) { char * name = xasprintf ( " " , binding_rec -> logical_port , laddrs -> ipv4_addrs [ i ] . addr_s ) ; garp = shash_find_data ( & send_garp_data , name ) ; if ( garp ) { garp -> dp_key = binding_rec -> datapath -> tunnel_key ; garp -> port_key = binding_rec -> tunnel_key ; } else { add_garp ( name , laddrs -> ea , laddrs -> ipv4_addrs [ i ] . addr , binding_rec -> datapath -> tunnel_key , binding_rec -> tunnel_key ) ; } free ( name ) ; } destroy_lport_addresses ( laddrs ) ; free ( laddrs ) ; } return ; } garp = shash_find_data ( & send_garp_data , binding_rec -> logical_port ) ; if ( garp ) { garp -> dp_key = binding_rec -> datapath -> tunnel_key ; garp -> port_key = binding_rec -> tunnel_key ; return ; } int i ; for ( i = 0 ; i < binding_rec -> n_mac ; i ++ ) { struct lport_addresses laddrs ; if ( ! extract_lsp_addresses ( binding_rec -> mac [ i ] , & laddrs ) || ! laddrs . n_ipv4_addrs ) { continue ; } add_garp ( binding_rec -> logical_port , laddrs . ea , laddrs . ipv4_addrs [ 0 ] . addr , binding_rec -> datapath -> tunnel_key , binding_rec -> tunnel_key ) ; destroy_lport_addresses ( & laddrs ) ; break ; } }
Add or update a vif for which GARPs need to be announced.
Add or update a vif for which GARPs need to be announced .
/* Update GARP for NAT IP if it exists.  Consider port bindings with type
     * "l3gateway" for logical switch ports attached to gateway routers, and
     * port bindings with type "patch" for logical switch ports attached to
     * distributed gateway ports. */ /* Update GARP for vif if it exists. */ /* Add GARP for new vif. */