On May 15, 2012, at 10:29 AM, Ben Pfaff wrote:

>>>> Do you think it's worth having the total be a #define, and then do a
>>>> build-time assertion that the total value is less than
>>>> ODPUTIL_FLOW_KEY_BYTES?
>>> 
>>> Can you explain how that would be different?
>> 
>> Right now, we have a chart that maps out the total number of bytes
>> needed to represent the largest flow.  When updating that chart it's
>> pretty obvious that the "total" field at the bottom needs to be
>> updated.  I feel like we've had issues in the past where "total" was
>> updated, but ODPUTIL_FLOW_KEY_BYTES was not.  This would serve as a
>> reminder.  It's pretty unlikely to occur, but I was thinking it would
>> be a good sanity-check.  We could also mandate a certain amount a
>> slack.  However, if you think it's unnecessary, I'm fine not adding
>> one, too.
> 
> Mostly I don't understand what you envision the code or comment looking
> like.  Can you show me?


I was thinking of something like the following:

-=-=-=-=-=-=-=-=-=-=-
 *                         struct  pad  nl hdr  total
 *                         ------  ---  ------  -----
 *  OVS_KEY_ATTR_PRIORITY      4    --     4      8
...
 *  OVS_KEY_ATTR_ND           28    --     4     32
 *  -------------------------------------------------*/
#define ODP_FLOW_KEY_MAX_TOTAL                  156

/* We include some slack space in case the calculation isn't quite right or we
 * add another field and forget to adjust this value.
 */
#define ODPUTIL_FLOW_KEY_BYTES 200

BUILD_ASSERT_DECL(ODP_FLOW_KEY_MAX_TOTAL < ODPUTIL_FLOW_KEY_BYTES)
-=-=-=-=-=-=-=-=-=-=-

However, ODPUTIL_FLOW_KEY_BYTES is defined pretty close to "total", so it's 
probably pointless.  I'll drop this, unless you've suddenly fallen in love with 
the idea.  :-)

--Justin


_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to