[ovs-dev] [bug 4566 1/2] ofp-util: Make NXM required for 64-bit cookies in is_nxm_required().

Justin Pettit jpettit at nicira.com
Mon Feb 28 23:06:39 UTC 2011


Looks good.

--Justin


On Feb 22, 2011, at 1:44 PM, Ben Pfaff wrote:

> Only NXM supports 64-bit cookies, but this code didn't properly check
> for that.  This commit fixes the problem and makes the code much more
> explicit about what it is checking.
> 
> This will hide bug #4566, but the following commit actually fixes it.
> ---
> lib/ofp-util.c |   23 +++++++++++++++++------
> 1 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> index 1125b83..f017fc9 100644
> --- a/lib/ofp-util.c
> +++ b/lib/ofp-util.c
> @@ -856,7 +856,8 @@ is_nxm_required(const struct cls_rule *rule, bool cookie_support,
>                 ovs_be64 cookie)
> {
>     const struct flow_wildcards *wc = &rule->wc;
> -    ovs_be32 cookie_hi;
> +    uint32_t cookie_hi;
> +    uint64_t tun_id;
> 
>     /* Only NXM supports separately wildcards the Ethernet multicast bit. */
>     if (!(wc->wildcards & FWW_DL_DST) != !(wc->wildcards & FWW_ETH_MCAST)) {
> @@ -885,11 +886,21 @@ is_nxm_required(const struct cls_rule *rule, bool cookie_support,
>         break;
> 
>     case CONSTANT_HTONLL(UINT64_MAX):
> -        /* Only NXM supports matching tunnel ID, unless there is a cookie and
> -         * the top 32 bits of the cookie are the desired tunnel ID value. */
> -        cookie_hi = htonl(ntohll(cookie) >> 32);
> -        if (!cookie_support
> -            || (cookie_hi && cookie_hi != ntohll(rule->flow.tun_id))) {
> +        /* Only NXM supports tunnel ID matching without a cookie. */
> +        if (!cookie_support) {
> +            return true;
> +        }
> +
> +        /* Only NXM supports 64-bit tunnel IDs. */
> +        tun_id = ntohll(rule->flow.tun_id);
> +        if (tun_id > UINT32_MAX) {
> +            return true;
> +        }
> +
> +        /* Only NXM supports a cookie whose top 32 bits conflict with the
> +         * tunnel ID. */
> +        cookie_hi = ntohll(cookie) >> 32;
> +        if (cookie_hi && cookie_hi != tun_id) {
>             return true;
>         }
>         break;
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list