Do not use -1 as an OpenFlow flow cookie

The OpenFlow spec forbids use of -1 as a flow cookie,
although it is very unlikely that a 64-bit random number equals -1.

Change-Id: I5dcf9709ffcaa5771bb5d9b17efe7d2a42bbe61f
This commit is contained in:
IWAMOTO Toshihiro 2017-03-16 15:52:05 +09:00
parent 125c043017
commit f9516a1ada
1 changed files with 3 additions and 1 deletions

View File

@ -16,6 +16,7 @@
import collections
import itertools
import operator
import random
import time
import uuid
@ -741,7 +742,8 @@ def _build_flow_expr_str(flow_dict, cmd):
def generate_random_cookie():
return uuid.uuid4().int & UINT64_BITMASK
# The OpenFlow spec forbids use of -1
return random.randrange(UINT64_BITMASK)
def check_cookie_mask(cookie):