Version: v1.3.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2021 License: Apache-2.0 Imports: 1 Imported by: 0



Package cookie implements a cookie allocator. The preallocated cookies are used to classify flows in the vSwitch, which simplifies management of these flows.



View Source
const (
	BitwidthRound           = 16
	BitwidthCategory        = 8
	BitwidthReserved        = 64 - BitwidthCategory - BitwidthRound
	RoundMask        uint64 = 0xffff_0000_0000_0000
	CategoryMask     uint64 = 0x0000_ff00_0000_0000


This section is empty.


func CookieMaskForRound

func CookieMaskForRound(round uint64) (uint64, uint64)

CookieMaskForRound returns a cookie and mask value that can be used to select all flows belonging to the provided round.


type Allocator

type Allocator interface {
	// Request gets a cookie IDs of the flow category.
	Request(cat Category) ID
	// RequestWithObjectID gets a cookie ID of the flow category and objectID.
	RequestWithObjectID(cat Category, objectID uint32) ID

Allocator defines operations of a cookie ID allocator.

func NewAllocator

func NewAllocator(round uint64) Allocator

NewAllocator creates a cookie ID allocator by using the given round number. Only last 16 bits of the round number would be used.

type Category

type Category uint64

Category represents the flow entry category.

const (
	Default Category = iota

func (Category) String

func (c Category) String() string

type ID

type ID uint64

ID defines segments a cookie ID contains. An ID is composed like:

|------------------------- ID --------------------------|
|- round 16bits -|- category 8bits -|- reserved 8bits -|- objectID 32bits -|

The round segment represents the round id. The category segment represents the category of flow this ID belongs.

func (ID) Category

func (i ID) Category() Category

Category returns the category of the ID.

func (ID) Raw

func (i ID) Raw() uint64

Raw returns the unit64 type value of the ID.

func (ID) Round

func (i ID) Round() uint64

Round returns the round number of the ID.

func (ID) String

func (i ID) String() string

String returns the string representation of the ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL