On Fri, Mar 04, 2016 at 02:51:42PM +0800, Peng He wrote:
> Hi, 
>     I installed some rulesets generated by ClassBench (a ruleset benchmark 
> for generating ACL and FW rules) in Open vSwitch, and I find many megaflow's 
> mask has 
> discontiguous bits. Like mask = 0xfc in network byte order. After some code 
> investigation I find the problem is in the function *mask_set_prefix_bits*: 
> 
> 
> 
> 
> staticvoidmask_set_prefix_bits(struct flow_wildcards *wc, uint8_t be32ofs,
>                      unsignedint n_bits)
> {
>     ovs_be32 *mask = &((ovs_be32 *)&wc->masks)[be32ofs];
>     unsignedint i;
> 
>     for (i = 0; i < n_bits / 32; i++) {
>         mask[i] = OVS_BE32_MAX;
>     }if (n_bits % 32) {
>         mask[i] |= htonl(~0u << (32 - n_bits % 32));
>     }}
> For example, if the input n_bits = 6, the mask should be 0x2f, as there is 6 
> contiguous bits. However, the current code will generate 0xfc:
> (0xFFFFFFFF << (32 - 6) ) = 0xFC000000
> and htonl (0xFC000000) = 0xFC. 
> I am writing this to make sure that I am correct. The OVS code I use is 2.4 
> release version. 

0xffffffff << (32 - 6) == 0xfc000000, which yields the bytes "fc 00 00
00" in hex, or "11111100 00000000 00000000 00000000" in binary, when
stored into memory in network byte order.

I don't see the problem.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to