[ovs-discuss] Help needed to understand code snippet

Andy Zhou azhou at nicira.com
Wed Sep 23 20:00:00 UTC 2015


On Wed, Sep 23, 2015 at 5:55 AM, neeraj mehta <mehtaneeraj07 at gmail.com> wrote:
> Hello Team,
>
> Can you help me in understanding below snippet.
>
> I was looking at the code in bond.c:bond_compose_learning_packet( ). In
> this, function choose_output_slave ( ) can return NULL. And returned pointer
> is used as  "*port_aux = slave->aux".
> How will it work?
> ====================================================
> static struct bond_slave *
> choose_output_slave(const struct bond *bond, const struct flow *flow,
>                     struct flow_wildcards *wc, uint16_t vlan)
> {
>     struct bond_entry *e;
>     int balance;
>
>     balance = bond->balance;
>     if (bond->lacp_status == LACP_CONFIGURED) {
>         /* LACP has been configured on this bond but negotiations were
>          * unsuccussful. If lacp_fallback_ab is enabled use active-
>          * backup mode else drop all traffic. */
>         if (!bond->lacp_fallback_ab) {
>             return NULL;
>         }
>
> .....
> ===================================================
>
> ===================================================
> slave = choose_output_slave(bond, &flow, NULL, vlan);
>
>     packet = ofpbuf_new(0);
>     compose_rarp(packet, eth_src);
>     if (vlan) {
>         eth_push_vlan(packet, htons(ETH_TYPE_VLAN), htons(vlan));
>     }
>
>     *port_aux = slave->aux;
>     ovs_rwlock_unlock(&rwlock);
>     }
> ======================================================
>
The may_send_learning_packets() check above should make this code safe.



More information about the discuss mailing list