ip

package
v1.2.0-rc.1.0...-65ced95 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: GPL-2.0, GPL-2.0-or-later Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const IfAddrNil = ^IfAddr(0)

Variables

View Source
var (
	ErrNotRewrite = errors.New("replacment adjacenty is not rewrite")
	ErrNotFound   = errors.New("adjacency not found")
)

Functions

This section is empty.

Types

type Address

type Address [16]uint8

Generic ip4/ip6 address: big enough for either.

func AddressUint32

func AddressUint32(x uint32) (a Address)

func AddressUint64

func AddressUint64(x uint64) (a Address)

func (*Address) Add

func (a *Address) Add(x uint64)

func (*Address) AsUint32

func (a *Address) AsUint32(i uint) vnet.Uint32

Address 32-bit chunk in network byte order.

func (*Address) String

func (a *Address) String() string

func (*Address) ToNetIP

func (a *Address) ToNetIP() (ip net.IP)

type AddressStringer

type AddressStringer func(a *Address) string

type Adj

type Adj uint32

Index into adjacency table.

const (
	AdjMiss Adj = 0
	AdjDrop Adj = 1
	AdjPunt Adj = 2
	AdjNil  Adj = (^Adj(0) - 1) // so AdjNil + 1 is non-zero for remaps.
)

Miss adjacency is always first in adjacency table.

func (Adj) IsConnectedRoute

func (ai Adj) IsConnectedRoute(m *Main) (conn bool, si vnet.Si)

func (Adj) IsGlean

func (ai Adj) IsGlean(m *Main) bool

func (Adj) IsLocal

func (ai Adj) IsLocal(m *Main) bool

func (Adj) IsViaRoute

func (ai Adj) IsViaRoute(m *Main) bool

func (Adj) String

func (a Adj) String() string

type AdjGetCounterHandler

type AdjGetCounterHandler func(tag string, v vnet.CombinedCounter)

type Adjacency

type Adjacency struct {
	// Next hop after ip4-lookup.
	LookupNextIndex LookupNext

	// Number of adjecencies in block.  Greater than 1 means multipath; otherwise equal to 1.
	NAdj uint16

	// not used for Local and Glean
	// Destination index for rewrite.
	Index uint32

	vnet.Rewrite
}

func (*Adjacency) AdjLines

func (a *Adjacency) AdjLines(m *Main) (lines []string)

func (*Adjacency) IsGlean

func (a *Adjacency) IsGlean() bool

func (*Adjacency) IsLocal

func (a *Adjacency) IsLocal() bool

func (*Adjacency) IsRewrite

func (a *Adjacency) IsRewrite() bool

func (*Adjacency) ParseWithArgs

func (a *Adjacency) ParseWithArgs(in *parse.Input, args *parse.Args)

type AdjacencyFinalizer

type AdjacencyFinalizer interface {
	FinalizeAdjacency(a *Adjacency)
}

type Checksum

type Checksum uint64

Incremental checksum update.

func (Checksum) AddBytes

func (c Checksum) AddBytes(b []byte) (d Checksum)

func (Checksum) AddEven

func (c Checksum) AddEven(x Checksum) (d Checksum)

Update checksum changing field at even byte offset from 0 to x.

func (Checksum) AddRef

func (c Checksum) AddRef(first *vnet.Ref, o_first uint) (d Checksum)

func (Checksum) AddWithCarry

func (sum Checksum) AddWithCarry(x Checksum) (t Checksum)

func (Checksum) Fold

func (c Checksum) Fold() vnet.Uint16

Reduce to 16 bits.

func (Checksum) SubEven

func (c Checksum) SubEven(x Checksum) Checksum

type Family

type Family uint8
const (
	Ip4 Family = iota
	Ip6
	NFamily
)

func (Family) String

func (x Family) String() string

type FamilyConfig

type FamilyConfig struct {
	AddressStringer  AddressStringer
	Family           Family
	RewriteNode      vnet.Noder
	PacketType       vnet.PacketType
	GetRoute         func(p *net.IPNet, si vnet.Si) (ai Adj, as []Adjacency, ok bool)
	GetReachable     func(p *net.IPNet, si vnet.Si) (ai Adj, as []Adjacency, ok bool)
	GetRouteFibIndex func(p *net.IPNet, fi FibIndex) (ai Adj, ok bool)
	AddDelRoute      func(p *net.IPNet, fi FibIndex, newAdj Adj, isDel bool) (oldAdj Adj, err error)
}

type FibId

type FibId uint32

Sparse 32 bit id for route table.

type FibIndex

type FibIndex uint32

Dense index into fib vector.

type FibIndexVec

type FibIndexVec []FibIndex

func (FibIndexVec) Len

func (p FibIndexVec) Len() uint

func (*FibIndexVec) ResetLen

func (p *FibIndexVec) ResetLen()

func (*FibIndexVec) Resize

func (p *FibIndexVec) Resize(n uint)

func (*FibIndexVec) Validate

func (p *FibIndexVec) Validate(i uint) *FibIndex

func (*FibIndexVec) ValidateInit

func (p *FibIndexVec) ValidateInit(i uint, zero FibIndex) *FibIndex

func (*FibIndexVec) ValidateLen

func (p *FibIndexVec) ValidateLen(l uint) (v *FibIndex)

func (*FibIndexVec) ValidateLenInit

func (p *FibIndexVec) ValidateLenInit(l uint, zero FibIndex) (v *FibIndex)

type FibName

type FibName struct {
	M *Main
	I FibIndex
}

func (FibName) String

func (n FibName) String() string

type IfAddr

type IfAddr uint32

type IfAddrVec

type IfAddrVec []IfAddr

func (IfAddrVec) Len

func (p IfAddrVec) Len() uint

func (*IfAddrVec) ResetLen

func (p *IfAddrVec) ResetLen()

func (*IfAddrVec) Resize

func (p *IfAddrVec) Resize(n uint)

func (*IfAddrVec) Validate

func (p *IfAddrVec) Validate(i uint) *IfAddr

func (*IfAddrVec) ValidateInit

func (p *IfAddrVec) ValidateInit(i uint, zero IfAddr) *IfAddr

func (*IfAddrVec) ValidateLen

func (p *IfAddrVec) ValidateLen(l uint) (v *IfAddr)

func (*IfAddrVec) ValidateLenInit

func (p *IfAddrVec) ValidateLenInit(l uint, zero IfAddr) (v *IfAddr)

type IfAddress

type IfAddress struct {
	// ip4/ip6 address and map key plus length.
	Prefix net.IPNet

	// Interface which has this address.
	Si vnet.Si

	NeighborProbeAdj Adj
	// contains filtered or unexported fields
}

type LookupNext

type LookupNext uint16

Next node index stored in ip adjacencies.

const (
	// Packet does not match any route in table.
	LookupNextMiss LookupNext = iota

	// Adjacency says to drop or punt this packet.
	LookupNextDrop
	LookupNextPunt

	// This packet matches an IP address of one of our interfaces.
	LookupNextLocal

	// Glean node.
	// This packet matches an "interface route" and packets need to be passed to ip4 ARP (or ip6 neighbor discovery)
	// to find rewrite string for this destination.
	LookupNextGlean

	// This packet is to be rewritten and forwarded to the next
	// processing node.  This is typically the output interface but
	// might be another node for further output processing.
	LookupNextRewrite

	LookupNNext
)

func (*LookupNext) Parse

func (n *LookupNext) Parse(in *parse.Input)

func (LookupNext) String

func (n LookupNext) String() string

type Main

type Main struct {
	FamilyConfig
	// contains filtered or unexported fields
}

func (*Main) AddDelInterfaceAddress

func (m *Main) AddDelInterfaceAddress(si vnet.Si, p *net.IPNet, isDel bool) (ai IfAddr, exists bool, err error)

func (*Main) AddDelNextHop

func (m *Main) AddDelNextHop(oldAdj Adj, nextHopAdj Adj, nextHopWeight NextHopWeight, af AdjacencyFinalizer, isDel bool) (newAdj Adj, ok bool)

func (*Main) AddNextHopsAdj

func (m *Main) AddNextHopsAdj(nhs NextHopVec) (newAdj Adj, ok bool)

func (*Main) CallAdjAddHooks

func (m *Main) CallAdjAddHooks(a Adj)

func (*Main) CallAdjDelHooks

func (m *Main) CallAdjDelHooks(a Adj)

func (*Main) CallAdjGetCounterHooks

func (m *Main) CallAdjGetCounterHooks(adj Adj, f AdjGetCounterHandler, clear bool)

func (*Main) CallAdjSyncCounterHooks

func (m *Main) CallAdjSyncCounterHooks()

func (*Main) ClearAdjCounters

func (m *Main) ClearAdjCounters()

func (*Main) DelAdj

func (m *Main) DelAdj(a Adj)

func (*Main) DelNextHopsAdj

func (m *Main) DelNextHopsAdj(oldAdj Adj) (ok bool)

func (*Main) EqualAdj

func (m *Main) EqualAdj(ai0, ai1 Adj) (same bool)

func (*Main) FibIndexForId

func (f *Main) FibIndexForId(id FibId) (i FibIndex, ok bool)

func (*Main) FibIndexForSi

func (f *Main) FibIndexForSi(si vnet.Si) FibIndex

func (*Main) FibNameForIndex

func (f *Main) FibNameForIndex(i FibIndex) string

func (*Main) ForeachAdjCounter

func (m *Main) ForeachAdjCounter(a Adj, f AdjGetCounterHandler)

func (*Main) ForeachIfAddress

func (m *Main) ForeachIfAddress(si vnet.Si, f func(ia IfAddr, i *IfAddress) error) error

func (*Main) FreeAdj

func (m *Main) FreeAdj(a Adj) bool

func (*Main) GetAdj

func (m *Main) GetAdj(a Adj) (as []Adjacency)

func (*Main) GetAdjRewriteSi

func (m *Main) GetAdjRewriteSi(a Adj) (si vnet.Si, ok bool)

func (*Main) GetAdjacencyUsage

func (m *Main) GetAdjacencyUsage() elib.HeapUsage

func (*Main) GetIfAddr

func (m *Main) GetIfAddr(i IfAddr) *IfAddress

func (*Main) GetIfAddress

func (m *Main) GetIfAddress(a net.IP, i FibIndex) (ia *IfAddress)

func (*Main) GetLayer

func (m *Main) GetLayer(t Protocol) (l vnet.Layer, ok bool)

func (*Main) IfAddrForPrefix

func (m *Main) IfAddrForPrefix(p *net.IPNet, si vnet.Si) (ai IfAddr, exists bool)

func (*Main) IfFirstAddr

func (m *Main) IfFirstAddr(i vnet.Si) IfAddr

func (*Main) IfFirstAddress

func (m *Main) IfFirstAddress(i vnet.Si) (ifa *IfAddress)

func (*Main) Init

func (m *Main) Init(v *vnet.Vnet)

func (*Main) InterfaceAddressReset

func (m *Main) InterfaceAddressReset(v *vnet.Vnet)

deletes ALL interface addresses

func (*Main) IsAdjFree

func (m *Main) IsAdjFree(a Adj) bool

func (*Main) IsMpAdj

func (m *Main) IsMpAdj(a Adj) bool

func (*Main) NewAdj

func (m *Main) NewAdj(n uint) (Adj, []Adjacency)

func (*Main) NewAdjWithTemplate

func (m *Main) NewAdjWithTemplate(n uint, template *Adjacency) (ai Adj, as []Adjacency)

func (*Main) NextHopsForAdj

func (m *Main) NextHopsForAdj(a Adj) (nhs nextHopVec)

func (*Main) PackageInit

func (m *Main) PackageInit(v *vnet.Vnet, c FamilyConfig)

func (*Main) PoisonAdj

func (m *Main) PoisonAdj(a Adj)

func (*Main) RegisterAdjAddDelHook

func (m *Main) RegisterAdjAddDelHook(f adjAddDelHook, dep ...*dep.Dep)

func (*Main) RegisterAdjGetCounterHook

func (m *Main) RegisterAdjGetCounterHook(f adjGetCounterHook, dep ...*dep.Dep)

func (*Main) RegisterAdjSyncCounterHook

func (m *Main) RegisterAdjSyncCounterHook(f adjSyncCounterHook, dep ...*dep.Dep)

func (*Main) RegisterLayer

func (m *Main) RegisterLayer(v *vnet.Vnet, t Protocol, l vnet.Layer)

func (*Main) ReplaceNextHop

func (m *Main) ReplaceNextHop(ai, fromNextHopAdj, toNextHopAdj Adj, af AdjacencyFinalizer) (newAdj Adj, err error)

func (*Main) SetFibIndexForId

func (f *Main) SetFibIndexForId(id FibId, i FibIndex)

func (*Main) SetFibIndexForSi

func (m *Main) SetFibIndexForSi(si vnet.Si, fi FibIndex)

func (*Main) SetFibNameForIndex

func (f *Main) SetFibNameForIndex(name string, i FibIndex)

func (*Main) UnregisterLayer

func (m *Main) UnregisterLayer(v *vnet.Vnet, t Protocol) (ok bool)

func (*Main) ValidateFibIndexForSi

func (f *Main) ValidateFibIndexForSi(si vnet.Si) FibIndex

type NextHop

type NextHop struct {
	Address net.IP
	Si      vnet.Si
	// contains filtered or unexported fields
}

func (*NextHop) FinalizeAdjacency

func (n *NextHop) FinalizeAdjacency(a *Adjacency)

func (*NextHop) NextHopFibIndex

func (n *NextHop) NextHopFibIndex(m *Main) FibIndex

func (*NextHop) NextHopWeight

func (n *NextHop) NextHopWeight() NextHopWeight

type NextHopVec

type NextHopVec []NextHop

func (NextHopVec) ListNhs

func (nhs NextHopVec) ListNhs(m *Main) string

func (NextHopVec) Match

func (nhs NextHopVec) Match(nhs2 []NextHop) bool

type NextHopWeight

type NextHopWeight uint32

type Prefix

type Prefix struct {
	Address
	Len uint32
}

func NewPrefix

func NewPrefix(l uint32, a []byte) (p Prefix)

NewPrefix returns prefix with given length and address. Address will be masked so that only length bits may be non-zero.

func (*Prefix) IsMoreSpecific

func (p *Prefix) IsMoreSpecific(q *Prefix) (ok bool)

Returns whether p matches q and is more specific.

func (*Prefix) IsMoreSpecificMatch

func (p *Prefix) IsMoreSpecificMatch(q *Prefix) (more, match bool)

Like IsMoreSpecific but qualify by returning if prefix matches

func (*Prefix) String

func (p *Prefix) String(m *Main) string

type Protocol

type Protocol uint8

8-bit protocol field from IP 4/6 headers.

const (
	IP6_HOP_BY_HOP_OPTIONS Protocol = 0
	ICMP                   Protocol = 1
	IGMP                   Protocol = 2
	GGP                    Protocol = 3
	IP_IN_IP               Protocol = 4
	ST                     Protocol = 5
	TCP                    Protocol = 6
	CBT                    Protocol = 7
	EGP                    Protocol = 8
	IGP                    Protocol = 9
	BBN_RCC_MON            Protocol = 10
	NVP2                   Protocol = 11
	PUP                    Protocol = 12
	ARGUS                  Protocol = 13
	EMCON                  Protocol = 14
	XNET                   Protocol = 15
	CHAOS                  Protocol = 16
	UDP                    Protocol = 17
	MUX                    Protocol = 18
	DCN_MEAS               Protocol = 19
	HMP                    Protocol = 20
	PRM                    Protocol = 21
	XNS_IDP                Protocol = 22
	TRUNK1                 Protocol = 23
	TRUNK2                 Protocol = 24
	LEAF1                  Protocol = 25
	LEAF2                  Protocol = 26
	RDP                    Protocol = 27
	IRTP                   Protocol = 28
	ISO_TP4                Protocol = 29
	NETBLT                 Protocol = 30
	MFE_NSP                Protocol = 31
	MERIT_INP              Protocol = 32
	SEP                    Protocol = 33
	THREE_PC               Protocol = 34
	IDPR                   Protocol = 35
	XTP                    Protocol = 36
	DDP                    Protocol = 37
	IDPR_CMTP              Protocol = 38
	TP                     Protocol = 39
	IL                     Protocol = 40
	IP6_IN_IP              Protocol = 41
	SDRP                   Protocol = 42
	IP6_ROUTE              Protocol = 43
	IP6_FRAG               Protocol = 44
	IDRP                   Protocol = 45
	RSVP                   Protocol = 46
	GRE                    Protocol = 47
	MHRP                   Protocol = 48
	BNA                    Protocol = 49
	IPSEC_ESP              Protocol = 50
	IPSEC_AH               Protocol = 51
	I_NLSP                 Protocol = 52
	SWIPE                  Protocol = 53
	NARP                   Protocol = 54
	MOBILE                 Protocol = 55
	TLSP                   Protocol = 56
	SKIP                   Protocol = 57
	ICMP6                  Protocol = 58
	IP6_NONXT              Protocol = 59
	IP6_DST_OPTIONS        Protocol = 60
	CFTP                   Protocol = 62
	SAT_EXPAK              Protocol = 64
	KRYPTOLAN              Protocol = 65
	RVD                    Protocol = 66
	IPPC                   Protocol = 67
	SAT_MON                Protocol = 69
	VISA                   Protocol = 70
	IPCV                   Protocol = 71
	CPNX                   Protocol = 72
	CPHB                   Protocol = 73
	WSN                    Protocol = 74
	PVP                    Protocol = 75
	BR_SAT_MON             Protocol = 76
	SUN_ND                 Protocol = 77
	WB_MON                 Protocol = 78
	WB_EXPAK               Protocol = 79
	ISO_IP                 Protocol = 80
	VMTP                   Protocol = 81
	SECURE_VMTP            Protocol = 82
	VINES                  Protocol = 83
	TTP                    Protocol = 84
	NSFNET_IGP             Protocol = 85
	DGP                    Protocol = 86
	TCF                    Protocol = 87
	EIGRP                  Protocol = 88
	OSPF                   Protocol = 89
	SPRITE_RPC             Protocol = 90
	LARP                   Protocol = 91
	MTP                    Protocol = 92
	AX                     Protocol = 93
	IPIP                   Protocol = 94
	MICP                   Protocol = 95
	SCC_SP                 Protocol = 96
	ETHERIP                Protocol = 97
	ENCAP                  Protocol = 98
	GMTP                   Protocol = 100
	IFMP                   Protocol = 101
	PNNI                   Protocol = 102
	PIM                    Protocol = 103
	ARIS                   Protocol = 104
	SCPS                   Protocol = 105
	QNX                    Protocol = 106
	A                      Protocol = 107
	IPCOMP                 Protocol = 108
	SNP                    Protocol = 109
	COMPAQ_PEER            Protocol = 110
	IPX_IN_IP              Protocol = 111
	VRRP                   Protocol = 112
	PGM                    Protocol = 113
	L2TP                   Protocol = 115
	DDX                    Protocol = 116
	IATP                   Protocol = 117
	STP                    Protocol = 118
	SRP                    Protocol = 119
	UTI                    Protocol = 120
	SMP                    Protocol = 121
	SM                     Protocol = 122
	PTP                    Protocol = 123
	ISIS                   Protocol = 124
	FIRE                   Protocol = 125
	CRTP                   Protocol = 126
	CRUDP                  Protocol = 127
	SSCOPMCE               Protocol = 128
	IPLT                   Protocol = 129
	SPS                    Protocol = 130
	PIPE                   Protocol = 131
	SCTP                   Protocol = 132
	FC                     Protocol = 133
	RSVP_E2E_IGNORE        Protocol = 134
	MOBILITY               Protocol = 135
	UDP_LITE               Protocol = 136
	MPLS_IN_IP             Protocol = 137
	RESERVED               Protocol = 255
)

func (Protocol) MaskedString

func (v Protocol) MaskedString(r vnet.MaskedStringer) (s string)

func (*Protocol) Parse

func (p *Protocol) Parse(in *parse.Input)

func (Protocol) String

func (p Protocol) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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