I would like to understand how the Metadata are calculated in an Open Flow rule.
cookie=0x6900000, duration=228925.519s, table=17, n_packets=384, n_bytes=35436, priority=10,metadata=0xf30000000000/0xffffff0000000000 actions=write_metadata:0xc000f30000000000/0xfffffffffffffffe,goto_table:211
Example: I have a flow very similar to this.
How are exactly the Metadata are Calculated.
And how to Intrepret the Metadata Values and Mask
Some says
new_metadata = old_metadata & ~mask | value & Mask
Honestly i do not understand it, could some one explain it
The purpose of the value
and metadata
fields in the write_metadata
action are explained in the Open vSwitch documentation:
write_metadata:value[/mask]
Updates the metadata field for the flow. If mask is omit‐
ted, the metadata field is set exactly to value; if mask
is specified, then a 1-bit in mask indicates that the
corresponding bit in the metadata field will be replaced
with the corresponding bit from value. Both value and
mask are 64-bit values that are decimal by default; use a
0x prefix to specify them in hexadecimal.
The preceding explanation is indeed equivalent to:
new_metadata = (old_metadata & ~mask) | (value & mask)
In other words, we first erase bits of the old metadata value set to 1 in the mask (old_metadata & ~mask
) and then set to 1 the bits of the value that are also set to 1 in the mask (| (value & mask)
).