[ovs-dev] [cfm 6/6] cfm: cfm_run() return ccm instead of packet.

Ben Pfaff blp at nicira.com
Wed Mar 23 17:28:13 UTC 2011


On Tue, Mar 22, 2011 at 06:32:58PM -0700, Ethan Jackson wrote:
> It doesn't really make sense for the CFM code to be composing
> packets.  Its caller is better placed to compose the appropriate
> L2 header.  This commit pulls that logic out of the CFM library.

I don't really like the use of a static object.

May I propose another alternative?  First, drop the sending logic from
cfm_run() entirely and change its return type to void.  Then add two
new functions roughly like this:

bool
cfm_should_send_ccm(const struct cfm *cfm)
{
    const struct cfm_internal *cfmi = cfm_to_internal(cfm);

    return time_msec() >= cfmi->ccm_sent + cfmi->ccm_interval_ms;
}

void
cfm_compose_ccm(struct cfm *cfm, struct ccm *ccm)
{
    struct cfm_internal *cfmi = cfm_to_internal(cfm);

    cfmi->ccm_sent = time_msec();
    compose_ccm(cfmi->cfm.mpid, cfmi->cfm.maid, cfmi->ccm_interval,
                ++cfmi->seq, ccm);
}



More information about the dev mailing list