Documentation ¶
Index ¶
- Constants
- type AuthRequirement
- type AuthType
- type AuthTypes
- type CachedSelectionUser
- type CachedSelector
- type CachedSelectorSlice
- type Key
- func (k Key) PortProtoIsBroader(c Key) bool
- func (k Key) String() string
- func (k Key) WithIdentity(nid identity.NumericIdentity) Key
- func (k Key) WithPort(port uint16) Key
- func (k Key) WithPortPrefix(port uint16, prefixLen uint8) Key
- func (k Key) WithPortProto(proto u8proto.U8proto, port uint16) Key
- func (k Key) WithPortProtoPrefix(proto u8proto.U8proto, port uint16, prefixLen uint8) Key
- func (k Key) WithProto(proto u8proto.U8proto) Key
- func (k Key) WithSCTPPort(port uint16) Key
- func (k Key) WithSCTPPortPrefix(port uint16, prefixLen uint8) Key
- func (k Key) WithTCPPort(port uint16) Key
- func (k Key) WithTCPPortPrefix(port uint16, prefixLen uint8) Key
- func (k Key) WithUDPPort(port uint16) Key
- func (k Key) WithUDPPortPrefix(port uint16, prefixLen uint8) Key
- type Keys
- type LPMKey
- func (k LPMKey) BitValueAt(i uint) uint8
- func (k LPMKey) CommonPrefix(b LPMKey) uint
- func (k LPMKey) EndPort() uint16
- func (k LPMKey) HasPortWildcard() bool
- func (k LPMKey) IsEgress() bool
- func (k LPMKey) IsIngress() bool
- func (k LPMKey) PortIsBroader(c Key) bool
- func (k LPMKey) PortIsEqual(c Key) bool
- func (k LPMKey) PortPrefixLen() uint8
- func (k LPMKey) PortProtoIsEqual(c Key) bool
- func (k LPMKey) PrefixLength() uint
- func (k LPMKey) TrafficDirection() trafficdirection.TrafficDirection
- func (k LPMKey) Value() LPMKey
Constants ¶
const MapStatePrefixLen = uint(32)
MapStatePrefixLen is the length, in bits, of the Key when converted to binary minus the sizeof the identity field (which is not indexed).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthRequirement ¶
type AuthRequirement AuthType
AuthRequirement is a combination of an AuthType with an 'explicit' flag on the highest bit This is defined in order to keep MapStateEntry smaller and to simplify code wiring this to the bpf datapath.
NOTE: This type is part of the bpf policy API.
This type reflects the layout of the 'auth_type' field in the bpf policy map and is used in pkg/maps/policymap. This layout must not be changed!
const ( NoAuthRequirement AuthRequirement = 0 AuthTypeIsExplicit AuthRequirement = 1 << 7 )
func (AuthRequirement) AsDerived ¶
func (a AuthRequirement) AsDerived() AuthRequirement
asDerived returns the auth requirement with the 'explicit' flag cleared.
func (AuthRequirement) AuthType ¶
func (a AuthRequirement) AuthType() AuthType
func (AuthRequirement) IsExplicit ¶
func (a AuthRequirement) IsExplicit() bool
type AuthType ¶
type AuthType uint8
AuthType enumerates the supported authentication types in api. Numerically higher type takes precedence in case of conflicting auth types.
func (AuthType) AsDerivedRequirement ¶
func (a AuthType) AsDerivedRequirement() AuthRequirement
func (AuthType) AsExplicitRequirement ¶
func (a AuthType) AsExplicitRequirement() AuthRequirement
type AuthTypes ¶
type AuthTypes map[AuthType]struct{}
AuthTypes is a set of AuthTypes, usually nil if empty
type CachedSelectionUser ¶
type CachedSelectionUser interface { // The caller is responsible for making sure the same identity is not // present in both 'added' and 'deleted'. IdentitySelectionUpdated(selector CachedSelector, added, deleted []identity.NumericIdentity) // IdentitySelectionCommit tells the user that all IdentitySelectionUpdated calls relating // to a specific added or removed identity have been made. IdentitySelectionCommit(*versioned.Tx) // IsPeerSelector returns true if the selector is used by the policy // engine for selecting traffic for remote peers. False if used for // selecting policy subjects. IsPeerSelector() bool }
CachedSelectionUser inserts selectors into the cache and gets update callbacks whenever the set of selected numeric identities change for the CachedSelectors pushed by it. Callbacks are executed from a separate goroutine that does not take the selector cache lock, so the implemenations generally may call back to the selector cache.
type CachedSelector ¶
type CachedSelector interface { // GetSelections returns the cached set of numeric identities // selected by the CachedSelector. The retuned slice must NOT // be modified, as it is shared among multiple users. GetSelections(*versioned.VersionHandle) identity.NumericIdentitySlice // GetMetadataLabels returns metadata labels for additional context // surrounding the selector. These are typically the labels associated with // Cilium rules. GetMetadataLabels() labels.LabelArray // Selects return 'true' if the CachedSelector selects the given // numeric identity. Selects(*versioned.VersionHandle, identity.NumericIdentity) bool // IsWildcard returns true if the endpoint selector selects // all endpoints. IsWildcard() bool // IsNone returns true if the selector never selects anything IsNone() bool // String returns the string representation of this selector. // Used as a map key. String() string }
CachedSelector represents an identity selector owned by the selector cache
type CachedSelectorSlice ¶
type CachedSelectorSlice []CachedSelector
CachedSelectorSlice is a slice of CachedSelectors that can be sorted.
func (CachedSelectorSlice) Len ¶
func (s CachedSelectorSlice) Len() int
func (CachedSelectorSlice) Less ¶
func (s CachedSelectorSlice) Less(i, j int) bool
func (CachedSelectorSlice) MarshalJSON ¶
func (s CachedSelectorSlice) MarshalJSON() ([]byte, error)
MarshalJSON returns the CachedSelectors as JSON formatted buffer
func (CachedSelectorSlice) SelectsAllEndpoints ¶
func (s CachedSelectorSlice) SelectsAllEndpoints() bool
SelectsAllEndpoints returns whether the CachedSelectorSlice selects all endpoints, which is true if the wildcard endpoint selector is present in the slice.
func (CachedSelectorSlice) Swap ¶
func (s CachedSelectorSlice) Swap(i, j int)
type Key ¶
type Key struct { LPMKey // Identity is the numeric identity to / from which traffic is allowed. Identity identity.NumericIdentity }
func IngressKey ¶
func IngressKey() Key
func KeyForDirection ¶
func KeyForDirection(direction trafficdirection.TrafficDirection) Key
func (Key) PortProtoIsBroader ¶
PortProtoIsBroader returns true if the receiver Key has broader port-protocol than the argument Key. That is a port-protocol that covers the argument Key's port-protocol and is larger. An equal port-protocol will return false.
func (Key) WithIdentity ¶
func (k Key) WithIdentity(nid identity.NumericIdentity) Key
func (Key) WithPortProtoPrefix ¶
func (Key) WithSCTPPort ¶
func (Key) WithTCPPort ¶
func (Key) WithUDPPort ¶
type LPMKey ¶
type LPMKey struct { // NextHdr is the protocol which is allowed. Nexthdr u8proto.U8proto // DestPort is the port at L4 to / from which traffic is allowed, in // host-byte order. DestPort uint16 // contains filtered or unexported fields }
Key is the userspace representation of a policy key in BPF. It is intentionally duplicated from pkg/maps/policymap to avoid pulling in the BPF dependency to this package.
func (LPMKey) BitValueAt ¶
BitValueAt implements the BitValueAt method for the bitlpm.Key interface.
func (LPMKey) CommonPrefix ¶
CommonPrefix implements the CommonPrefix method for the bitlpm.Key interface. Identity is not indexed and is instead, saved as a simple map per TrafficDirection-Protocol-Port index key.
func (LPMKey) HasPortWildcard ¶
func (LPMKey) PortIsBroader ¶
PortIsBroader returns true if the receiver Key's port range covers the argument Key's port range, but returns false if they are equal.
func (LPMKey) PortIsEqual ¶
PortIsEqual returns true if the port ranges between the two keys are exactly equal.
func (LPMKey) PortPrefixLen ¶
PortPrefixLen returns the length of the bitwise mask that should be applied to the DestPort.
func (LPMKey) PortProtoIsEqual ¶
PortProtoIsEqual returns true if the port-protocols of the two keys are exactly equal.
func (LPMKey) PrefixLength ¶
PrefixLength returns the prefix lenth of the key for indexing it for the userspace cache (not the BPF map or datapath).
func (LPMKey) TrafficDirection ¶
func (k LPMKey) TrafficDirection() trafficdirection.TrafficDirection
TrafficDirection() returns the direction of the Key, 0 == ingress, 1 == egress