nat

package
v1.7.8 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 10 Imported by: 14

Documentation

Overview

Package nat implements the BPF NAT map interaction code. +groupName=maps

Index

Constants

View Source
const (
	// MapNameSnat4Global represents global IPv4 NAT table.
	MapNameSnat4Global = "cilium_snat_v4_external"
	// MapNameSnat6Global represents global IPv6 NAT table.
	MapNameSnat6Global = "cilium_snat_v6_external"

	// MinPortSnatDefault represents default min port from range.
	MinPortSnatDefault = 1024
	// MaxPortSnatDefault represents default max port from range.
	MaxPortSnatDefault = 65535
)

Variables

This section is empty.

Functions

func NatDumpCreated

func NatDumpCreated(dumpStart, entryCreated uint64) string

NatDumpCreated returns time in seconds when NAT entry was created.

Types

type Map

type Map struct {
	bpf.Map
	// contains filtered or unexported fields
}

Map represents a NAT map.

func GlobalMaps

func GlobalMaps(ipv4, ipv6 bool) (ipv4Map, ipv6Map *Map)

GlobalMaps returns all global NAT maps.

func NewMap

func NewMap(name string, v4 bool, entries int) *Map

NewMap instantiates a Map.

func (*Map) DeleteMapping

func (m *Map) DeleteMapping(key tuple.TupleKey) error

DeleteMapping removes a NAT mapping from the global NAT table.

func (*Map) DumpEntries

func (m *Map) DumpEntries() (string, error)

DumpEntries iterates through Map m and writes the values of the nat entries in m to a string.

func (*Map) Flush

func (m *Map) Flush() int

Flush deletes all NAT mappings from the given table.

type NatEntry

type NatEntry interface {
	bpf.MapValue

	// ToHost converts fields to host byte order.
	ToHost() NatEntry

	// Dumps the Nat entry as string.
	Dump(key NatKey, start uint64) string
}

NatEntry is the interface describing values to the NAT map.

type NatEntry4

type NatEntry4 struct {
	Created   uint64     `align:"created"`
	HostLocal uint64     `align:"host_local"`
	Pad1      uint64     `align:"pad1"`
	Pad2      uint64     `align:"pad2"`
	Addr      types.IPv4 `align:"to_saddr"`
	Port      uint16     `align:"to_sport"`
}

NatEntry4 represents an IPv4 entry in the NAT table. +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapValue

func (*NatEntry4) DeepCopy added in v1.5.1

func (in *NatEntry4) DeepCopy() *NatEntry4

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatEntry4.

func (*NatEntry4) DeepCopyInto added in v1.5.1

func (in *NatEntry4) DeepCopyInto(out *NatEntry4)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*NatEntry4) DeepCopyMapValue added in v1.5.1

func (in *NatEntry4) DeepCopyMapValue() bpf.MapValue

DeepCopyMapValue is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapValue.

func (*NatEntry4) Dump

func (n *NatEntry4) Dump(key NatKey, start uint64) string

Dump dumps NAT entry to string.

func (*NatEntry4) GetValuePtr added in v1.5.0

func (n *NatEntry4) GetValuePtr() unsafe.Pointer

GetValuePtr returns the unsafe.Pointer for n.

func (*NatEntry4) String

func (n *NatEntry4) String() string

String returns the readable format.

func (*NatEntry4) ToHost

func (n *NatEntry4) ToHost() NatEntry

ToHost converts NatEntry4 ports to host byte order.

type NatEntry6

type NatEntry6 struct {
	Created   uint64     `align:"created"`
	HostLocal uint64     `align:"host_local"`
	Pad1      uint64     `align:"pad1"`
	Pad2      uint64     `align:"pad2"`
	Addr      types.IPv6 `align:"to_saddr"`
	Port      uint16     `align:"to_sport"`
}

NatEntry6 represents an IPv6 entry in the NAT table. +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapValue

func (*NatEntry6) DeepCopy added in v1.5.1

func (in *NatEntry6) DeepCopy() *NatEntry6

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatEntry6.

func (*NatEntry6) DeepCopyInto added in v1.5.1

func (in *NatEntry6) DeepCopyInto(out *NatEntry6)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*NatEntry6) DeepCopyMapValue added in v1.5.1

func (in *NatEntry6) DeepCopyMapValue() bpf.MapValue

DeepCopyMapValue is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapValue.

func (*NatEntry6) Dump

func (n *NatEntry6) Dump(key NatKey, start uint64) string

Dump dumps NAT entry to string.

func (*NatEntry6) GetValuePtr added in v1.5.0

func (n *NatEntry6) GetValuePtr() unsafe.Pointer

GetValuePtr returns the unsafe.Pointer for n.

func (*NatEntry6) String

func (n *NatEntry6) String() string

String returns the readable format.

func (*NatEntry6) ToHost

func (n *NatEntry6) ToHost() NatEntry

ToHost converts NatEntry4 ports to host byte order.

type NatKey

type NatKey interface {
	bpf.MapKey

	// ToNetwork converts fields to network byte order.
	ToNetwork() NatKey

	// ToHost converts fields to host byte order.
	ToHost() NatKey

	// Dump contents of key to buffer. Returns true if successful.
	Dump(buffer *bytes.Buffer, reverse bool) bool

	// GetFlags flags containing the direction of the TupleKey.
	GetFlags() uint8
}

type NatKey4

type NatKey4 struct {
	tuple.TupleKey4Global
}

NatKey4 is needed to provide NatEntry type to Lookup values +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapKey

func (*NatKey4) DeepCopy added in v1.6.0

func (in *NatKey4) DeepCopy() *NatKey4

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatKey4.

func (*NatKey4) DeepCopyInto added in v1.6.0

func (in *NatKey4) DeepCopyInto(out *NatKey4)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*NatKey4) DeepCopyMapKey added in v1.6.0

func (in *NatKey4) DeepCopyMapKey() bpf.MapKey

DeepCopyMapKey is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapKey.

func (*NatKey4) GetKeyPtr added in v1.6.0

func (k *NatKey4) GetKeyPtr() unsafe.Pointer

GetKeyPtr returns the unsafe.Pointer for k.

func (*NatKey4) NewValue added in v1.6.0

func (k *NatKey4) NewValue() bpf.MapValue

NewValue creates a new bpf.MapValue.

func (*NatKey4) ToHost

func (k *NatKey4) ToHost() NatKey

ToHost converts ports to host byte order.

This is necessary to prevent callers from implicitly converting the NatKey4 type here into a local key type in the nested TupleKey4Global field.

func (*NatKey4) ToNetwork

func (k *NatKey4) ToNetwork() NatKey

ToNetwork converts ports to network byte order.

This is necessary to prevent callers from implicitly converting the NatKey4 type here into a local key type in the nested TupleKey4Global field.

type NatKey6

type NatKey6 struct {
	tuple.TupleKey6Global
}

NatKey6 is needed to provide NatEntry type to Lookup values +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapKey

func (*NatKey6) DeepCopy added in v1.6.0

func (in *NatKey6) DeepCopy() *NatKey6

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatKey6.

func (*NatKey6) DeepCopyInto added in v1.6.0

func (in *NatKey6) DeepCopyInto(out *NatKey6)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*NatKey6) DeepCopyMapKey added in v1.6.0

func (in *NatKey6) DeepCopyMapKey() bpf.MapKey

DeepCopyMapKey is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapKey.

func (*NatKey6) GetKeyPtr added in v1.6.0

func (k *NatKey6) GetKeyPtr() unsafe.Pointer

GetKeyPtr returns the unsafe.Pointer for k.

func (*NatKey6) NewValue added in v1.6.0

func (k *NatKey6) NewValue() bpf.MapValue

NewValue creates a new bpf.MapValue.

func (*NatKey6) ToHost

func (k *NatKey6) ToHost() NatKey

ToHost converts ports to host byte order.

This is necessary to prevent callers from implicitly converting the NatKey6 type here into a local key type in the nested TupleKey6Global field.

func (*NatKey6) ToNetwork

func (k *NatKey6) ToNetwork() NatKey

ToNetwork converts ports to network byte order.

This is necessary to prevent callers from implicitly converting the NatKey6 type here into a local key type in the nested TupleKey6Global field.

Jump to

Keyboard shortcuts

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