Documentation ¶
Overview ¶
Package nat implements the BPF NAT map interaction code. +groupName=maps
Index ¶
- Constants
- func DoDumpEntries(m NatMap) (string, error)
- func InitDummyPerClusterNATMaps(ipv4, ipv6 bool, innerMapEntries int) error
- func InitPerClusterNATMaps(ipv4, ipv6 bool, innerMapEntries int) error
- func NatDumpCreated(dumpStart, entryCreated uint64) string
- type Map
- func (m *Map) Delete(k bpf.MapKey) (deleted bool, err error)
- func (m *Map) DeleteMapping(key tuple.TupleKey) error
- func (m *Map) DumpEntries() (string, error)
- func (m *Map) DumpReliablyWithCallback(cb bpf.DumpCallback, stats *bpf.DumpStats) error
- func (m *Map) DumpStats() *bpf.DumpStats
- func (m *Map) Flush() int
- type NatEntry
- type NatEntry4
- func (in *NatEntry4) DeepCopy() *NatEntry4
- func (in *NatEntry4) DeepCopyInto(out *NatEntry4)
- func (in *NatEntry4) DeepCopyMapValue() bpf.MapValue
- func (n *NatEntry4) Dump(key NatKey, start uint64) string
- func (n *NatEntry4) GetValuePtr() unsafe.Pointer
- func (n *NatEntry4) String() string
- func (n *NatEntry4) ToHost() NatEntry
- type NatEntry6
- func (in *NatEntry6) DeepCopy() *NatEntry6
- func (in *NatEntry6) DeepCopyInto(out *NatEntry6)
- func (in *NatEntry6) DeepCopyMapValue() bpf.MapValue
- func (n *NatEntry6) Dump(key NatKey, start uint64) string
- func (n *NatEntry6) GetValuePtr() unsafe.Pointer
- func (n *NatEntry6) String() string
- func (n *NatEntry6) ToHost() NatEntry
- type NatKey
- type NatKey4
- func (in *NatKey4) DeepCopy() *NatKey4
- func (in *NatKey4) DeepCopyInto(out *NatKey4)
- func (in *NatKey4) DeepCopyMapKey() bpf.MapKey
- func (k *NatKey4) GetKeyPtr() unsafe.Pointer
- func (k *NatKey4) GetNextHeader() u8proto.U8proto
- func (k *NatKey4) NewValue() bpf.MapValue
- func (k *NatKey4) ToHost() NatKey
- func (k *NatKey4) ToNetwork() NatKey
- type NatKey6
- func (in *NatKey6) DeepCopy() *NatKey6
- func (in *NatKey6) DeepCopyInto(out *NatKey6)
- func (in *NatKey6) DeepCopyMapKey() bpf.MapKey
- func (k *NatKey6) GetKeyPtr() unsafe.Pointer
- func (k *NatKey6) GetNextHeader() u8proto.U8proto
- func (k *NatKey6) NewValue() bpf.MapValue
- func (k *NatKey6) ToHost() NatKey
- func (k *NatKey6) ToNetwork() NatKey
- type NatMap
- type NatMapRecord
- type PerClusterNATMap
- type PerClusterNATMapKey
- func (in *PerClusterNATMapKey) DeepCopy() *PerClusterNATMapKey
- func (in *PerClusterNATMapKey) DeepCopyInto(out *PerClusterNATMapKey)
- func (in *PerClusterNATMapKey) DeepCopyMapKey() bpf.MapKey
- func (k *PerClusterNATMapKey) GetKeyPtr() unsafe.Pointer
- func (k *PerClusterNATMapKey) NewValue() bpf.MapValue
- func (k *PerClusterNATMapKey) String() string
- type PerClusterNATMapVal
- func (in *PerClusterNATMapVal) DeepCopy() *PerClusterNATMapVal
- func (in *PerClusterNATMapVal) DeepCopyInto(out *PerClusterNATMapVal)
- func (in *PerClusterNATMapVal) DeepCopyMapValue() bpf.MapValue
- func (v *PerClusterNATMapVal) GetValuePtr() unsafe.Pointer
- func (v *PerClusterNATMapVal) String() string
- type PerClusterNATMapper
Constants ¶
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 )
const SizeofNatEntry4 = int(unsafe.Sizeof(NatEntry4{}))
SizeofNatEntry4 is the size of the NatEntry4 type in bytes.
const SizeofNatEntry6 = int(unsafe.Sizeof(NatEntry6{}))
SizeofNatEntry6 is the size of the NatEntry6 type in bytes.
const SizeofNatKey4 = int(unsafe.Sizeof(NatKey4{}))
SizeofNatKey4 is the size of the NatKey4 type in bytes.
const SizeofNatKey6 = int(unsafe.Sizeof(NatKey6{}))
SizeofNatKey6 is the size of the NatKey6 type in bytes.
Variables ¶
This section is empty.
Functions ¶
func DoDumpEntries ¶
DoDumpEntries iterates through Map m and writes the values of the nat entries in m to a string.
func InitDummyPerClusterNATMaps ¶ added in v1.14.0
func InitPerClusterNATMaps ¶ added in v1.14.0
func NatDumpCreated ¶
NatDumpCreated returns time in seconds when NAT entry was created.
Types ¶
type Map ¶
Map represents a NAT map. It also implements the NatMap interface.
func GlobalMaps ¶
GlobalMaps returns all global NAT maps.
func (*Map) DeleteMapping ¶
DeleteMapping removes a NAT mapping from the global NAT table.
func (*Map) DumpEntries ¶
DumpEntries iterates through Map m and writes the values of the nat entries in m to a string.
func (*Map) DumpReliablyWithCallback ¶
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
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatEntry4.
func (*NatEntry4) DeepCopyInto ¶ added in v1.5.1
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
DeepCopyMapValue is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapValue.
func (*NatEntry4) GetValuePtr ¶ added in v1.5.0
GetValuePtr returns the unsafe.Pointer for n.
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
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatEntry6.
func (*NatEntry6) DeepCopyInto ¶ added in v1.5.1
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
DeepCopyMapValue is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapValue.
func (*NatEntry6) GetValuePtr ¶ added in v1.5.0
GetValuePtr returns the unsafe.Pointer for n.
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 sb. Returns true if successful. Dump(sb *strings.Builder, reverse bool) bool // GetFlags flags containing the direction of the TupleKey. GetFlags() uint8 // GetNextHeader returns the proto of the NatKey GetNextHeader() u8proto.U8proto }
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
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatKey4.
func (*NatKey4) DeepCopyInto ¶ added in v1.6.0
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
DeepCopyMapKey is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapKey.
func (*NatKey4) GetNextHeader ¶
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
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NatKey6.
func (*NatKey6) DeepCopyInto ¶ added in v1.6.0
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
DeepCopyMapKey is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapKey.
func (*NatKey6) GetNextHeader ¶
type NatMap ¶
type NatMap interface { Open() error Close() error Path() (string, error) DumpEntries() (string, error) DumpWithCallback(bpf.DumpCallback) error }
NatMap interface represents a NAT map, and can be reused to implement mock maps for unit tests.
type NatMapRecord ¶
A "Record" designates a map entry (key + value), but avoid "entry" because of possible confusion with "NatEntry" (actually the value part). This type is used for JSON dump and mock maps.
type PerClusterNATMap ¶ added in v1.14.0
A map-in-map that holds per-cluster NAT maps.
type PerClusterNATMapKey ¶
type PerClusterNATMapKey struct {
ClusterID uint32
}
+k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapKey
func (*PerClusterNATMapKey) DeepCopy ¶
func (in *PerClusterNATMapKey) DeepCopy() *PerClusterNATMapKey
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PerClusterNATMapKey.
func (*PerClusterNATMapKey) DeepCopyInto ¶
func (in *PerClusterNATMapKey) DeepCopyInto(out *PerClusterNATMapKey)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*PerClusterNATMapKey) DeepCopyMapKey ¶
func (in *PerClusterNATMapKey) DeepCopyMapKey() bpf.MapKey
DeepCopyMapKey is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapKey.
func (*PerClusterNATMapKey) GetKeyPtr ¶
func (k *PerClusterNATMapKey) GetKeyPtr() unsafe.Pointer
func (*PerClusterNATMapKey) NewValue ¶
func (k *PerClusterNATMapKey) NewValue() bpf.MapValue
func (*PerClusterNATMapKey) String ¶
func (k *PerClusterNATMapKey) String() string
type PerClusterNATMapVal ¶
type PerClusterNATMapVal struct {
Fd uint32
}
+k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapValue
func (*PerClusterNATMapVal) DeepCopy ¶
func (in *PerClusterNATMapVal) DeepCopy() *PerClusterNATMapVal
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PerClusterNATMapVal.
func (*PerClusterNATMapVal) DeepCopyInto ¶
func (in *PerClusterNATMapVal) DeepCopyInto(out *PerClusterNATMapVal)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*PerClusterNATMapVal) DeepCopyMapValue ¶
func (in *PerClusterNATMapVal) DeepCopyMapValue() bpf.MapValue
DeepCopyMapValue is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapValue.
func (*PerClusterNATMapVal) GetValuePtr ¶
func (v *PerClusterNATMapVal) GetValuePtr() unsafe.Pointer
func (*PerClusterNATMapVal) String ¶
func (v *PerClusterNATMapVal) String() string
type PerClusterNATMapper ¶
type PerClusterNATMapper interface { UpdateClusterNATMaps(clusterID uint32) error DeleteClusterNATMaps(clusterID uint32) error GetClusterNATMap(clusterID uint32, v4 bool) (*Map, error) Cleanup() }
An interface to interact with the global map.
var PerClusterNATMaps PerClusterNATMapper
Global interface to interact with IPv4 and v6 NAT maps. We can choose the implementation of this at startup time by choosing InitPerClusterNATMaps or InitDummyPerClusterNATMaps for initialization.