server

package
v0.0.0-...-ac9ef1f Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2017 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Copyright [2016] [SnapRoute Inc]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

	 Unless required by applicable law or agreed to in writing, software
	 distributed under the License is distributed on an "AS IS" BASIS,
	 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 See the License for the specific language governing permissions and
	 limitations under the License.

_______ __ __________ ___ _______.____ __ ____ __ .___________. ______ __ __ | ____|| | | ____\ \ / / / |\ \ / \ / / | | | | / || | | | | |__ | | | |__ \ V / | (----` \ \/ \/ / | | `---| |----`| ,----'| |__| | | __| | | | __| > < \ \ \ / | | | | | | | __ | | | | `----.| |____ / . \ .----) | \ /\ / | | | | | `----.| | | | |__| |_______||_______/__/ \__\ |_______/ \__/ \__/ |__| |__| \______||__| |__|

Index

Constants

View Source
const (
	NDP_CPU_PROFILE_FILE                  = "/var/log/ndpd.prof"
	NDP_SERVER_MAP_INITIAL_CAP            = 30
	NDP_SERVER_ASICD_NOTIFICATION_CH_SIZE = 1
	NDP_SERVER_INITIAL_CHANNEL_SIZE       = 1
	INTF_REF_NOT_FOUND                    = "Not Found"
)
View Source
const (
	NDP_PCAP_FILTER                              = "(ip6[6] == 0x3a) and (ip6[40] >= 133 && ip6[40] <= 136)"
	NDP_PCAP_TIMEOUT                             = 1 * time.Second
	NDP_PCAP_SNAPSHOTlEN                         = 1024
	NDP_PCAP_PROMISCUOUS                         = false
	MIN_DELAY_BETWEEN_RAS                  uint8 = 3 // RFC: 4861
	MAX_INITIAL_RTR_ADVERTISEMENTS         uint8 = 3
	MAX_INITIAL_RTR_ADVERT_INTERVAL        uint8 = 16
	ALL_NODES_MULTICAST_IPV6_ADDRESS             = "ff02::1"
	ALL_NODES_MULTICAST_LINK_LAYER_ADDRESS       = "33:33:00:00:00:01"

	NDP_DEFAULT_RTR_ADVERTISEMENT_INTERVAL uint8  = 5
	NDP_DEFAULT_RETRANSMIT_INTERVAL        uint32 = 1
	NDP_DEFAULT_REACHABLE_INTERVAL         uint32 = 30000
)
View Source
const (
	MAX_UNICAST_SOLICIT            uint8 = 3
	MAX_MULTICAST_SOLICIT                = 3
	MAX_ANYCAST_DELAY_TIMER              = 1
	MAX_NEIGHBOR_ADVERTISEMENT           = 3
	DELAY_FIRST_PROBE_TIME               = 5 // this is in seconds
	MIN_RANDOM_FACTOR                    = 0.5
	MAX_RANDOM_FACTOR                    = 1.5
	RECOMPUTE_BASE_REACHABLE_TIMER       = 1 // this is in hour
)
View Source
const (
	INCOMPLETE
	REACHABLE
	STALE
	DELAY
	PROBE
)

Variables

View Source
var IPV6_MULTICAST_PREFIXES = []string{"ff00", "ff01", "ff02", "ff03", "ff04", "ff05", "ff06", "ff07",
	"ff08", "ff09", "ff0a", "ff0b", "ff0c", "ff0d", "ff0e", "ff0f"}

https://tools.ietf.org/html/rfc7346

+------+--------------------------+-------------------------+
| scop | NAME                     | REFERENCE               |
+------+--------------------------+-------------------------+
|  0   | Reserved                 | [RFC4291], RFC 7346     |
|  1   | Interface-Local scope    | [RFC4291], RFC 7346     |
|  2   | Link-Local scope         | [RFC4291], RFC 7346     |
|  3   | Realm-Local scope        | [RFC4291], RFC 7346     |
|  4   | Admin-Local scope        | [RFC4291], RFC 7346     |
|  5   | Site-Local scope         | [RFC4291], RFC 7346     |
|  6   | Unassigned               |                         |
|  7   | Unassigned               |                         |
|  8   | Organization-Local scope | [RFC4291], RFC 7346     |
|  9   | Unassigned               |                         |
|  A   | Unassigned               |                         |
|  B   | Unassigned               |                         |
|  C   | Unassigned               |                         |
|  D   | Unassigned               |                         |
|  E   | Global scope             | [RFC4291], RFC 7346     |
|  F   | Reserved                 | [RFC4291], RFC 7346     |
+------+--------------------------+-------------------------+

Functions

This section is empty.

Types

type Interface

type Interface struct {
	PcapBase
	IntfRef     string
	IfIndex     int32
	IfType      int    // IfTypePort, IfTypeVlan
	IpAddr      string // CIDR Format
	LinkLocalIp string // CIDR format

	MsgType   string
	OperState string

	Neighbor  map[string]NeighborInfo // key is NbrIp_NbrMac to handle move scenario's
	PktDataCh chan config.PacketData
	// contains filtered or unexported fields
}

func (*Interface) CreateIntf

func (intf *Interface) CreateIntf(obj *config.IPIntfNotification, pktCh chan config.PacketData, gCfg NdpConfig)

* CreateIntf is called during CreateIPInterface notification

func (*Interface) CreatePcap

func (intf *Interface) CreatePcap() (err error)

* API: will create pcap handler for each port * 1) check if pcap users are > 0.. if so then just add pcap user and move on * 2) if no pcap users then check for PcapHandler and then create a new pcap handler * 3) Check if PcapCtrl is created or not..

func (*Interface) CreateTXPcap

func (intf *Interface) CreateTXPcap() (err error)

* Create a TX pcap handler for sending packets on timer expiry

func (*Interface) DeInitIntf

func (intf *Interface) DeInitIntf() []string

* De-Init Interface will be called during delete ip interface

func (*Interface) DeleteAll

func (intf *Interface) DeleteAll() ([]string, error)

* Delete All will delete ip address and then remove entire pcap

func (*Interface) DeleteIntf

func (intf *Interface) DeleteIntf(ipAddr string) ([]string, error)

* DeleteIntf will kill pcap, flush neighbors and then stop all timers

func (*Interface) DeleteNeighbor

func (intf *Interface) DeleteNeighbor(nbrEntry config.NeighborConfig) ([]string, error)

* Api to delete one neighbor entry request by the action

func (*Interface) DeletePcap

func (intf *Interface) DeletePcap()

* DeletePcap Handler * 1) fpPort1 has one ip address, bypass the check and delete pcap * 2) fpPort1 has two ip address * a) 2003::2/64 - Global Scope * b) fe80::123/64 - Link Scope * In this case we will get two Notification for port down from the chip, one is for * Global Scope Ip and second is for Link Scope.. * On first Notification NDP will update pcap users and move on. Only when second delete * notification comes then NDP will delete pcap

func (*Interface) DeleteTXPcap

func (intf *Interface) DeleteTXPcap()

func (*Interface) FlushNeighborPerIp

func (intf *Interface) FlushNeighborPerIp(nbrKey, ipAddr string) ([]string, error)

* flush neighbors per ip address

func (*Interface) FlushNeighbors

func (intf *Interface) FlushNeighbors() ([]string, error)

* On physical link down.. server will request to delete all the neighbors from the cache.. * We will iterate over all the neighbors, stop its timer and delete the neighbor cache * @NOTE: Always start from the bottom most layer as we never know when golang will run its garbage collector

func (*Interface) InitIntf

func (intf *Interface) InitIntf(obj *commonDefs.IPv6IntfState, pktCh chan config.PacketData, gCfg NdpConfig)

* Init Interface will be called during bootup when we do Get ALL ipv6 intfs

func (*Interface) PopulateNeighborInfo

func (intf *Interface) PopulateNeighborInfo(nbr NeighborInfo, nbrState *config.NeighborEntry)

* Get Neighbor Information

func (*Interface) ProcessND

func (intf *Interface) ProcessND(ndInfo *packet.NDInfo) (*config.NeighborConfig, NDP_OPERATION)

* process nd will be called during received message

func (*Interface) RAResTransmitTimer

func (intf *Interface) RAResTransmitTimer()

* Router Advertisment Timer: Only timer owned by Interface Object

func (*Interface) ReceiveNdpPkts

func (intf *Interface) ReceiveNdpPkts(pktCh chan *RxPktInfo) error

* Receive Ndp Packet and push it on the pktCh

func (*Interface) RefreshAllNeighbors

func (intf *Interface) RefreshAllNeighbors(mac string)

* Api to Send Unicast Solicitation Message for all neighbor entries to do refresh before the expiry * Time

func (*Interface) SendND

func (intf *Interface) SendND(pktData config.PacketData, mac string) NDP_OPERATION

* send neighbor discover messages on timer expiry

func (*Interface) SendNS

func (intf *Interface) SendNS(myMac, nbrMac, nbrIp string, isFastProbe bool) NDP_OPERATION

func (*Interface) SendRA

func (intf *Interface) SendRA(srcMac string)

* Router Advertisement Packet is send out for both link scope ip and global scope ip on timer expiry & port * up notification

func (*Interface) SetIfType

func (intf *Interface) SetIfType(ifType int)

set if type for the l3 port

func (*Interface) StopRATimer

func (intf *Interface) StopRATimer()

* stop Router Advertisement Timer

func (*Interface) UpdateIntf

func (intf *Interface) UpdateIntf(ipAddr string)

* If Entry Already exists during CreateIPInterface then Update Interface will be called

func (*Interface) UpdateTimer

func (intf *Interface) UpdateTimer(gCfg NdpConfig)

* Update timer values

type L3Info

type L3Info struct {
	Name     string
	IfIndex  int32
	PortType string // tag or untag
}

type NDPServer

type NDPServer struct {
	NdpConfig // base config

	SwitchPlugin asicdClient.AsicdClientIntf // asicd plugin

	// System Ports information, key is IntfRef
	L2Port              map[int32]PhyPort                //config.PortInfo        // key is l2 ifIndex
	L3Port              map[int32]Interface              // key is l3 ifIndex
	VlanInfo            map[int32]config.VlanInfo        // key is vlanId
	VlanIfIdxVlanIdMap  map[string]int32                 //reverse map for vlanName ----> vlanId, used during ipv6 neig create
	SwitchMacMapEntries map[string]struct{}              // cache entry for all mac addresses on a switch
	NeighborInfo        map[string]config.NeighborConfig // neighbor created by NDP used for STATE

	PhyPortToL3PortMap map[int32]int32 // reverse map for l2IfIndex ----> l3IfIndex, used during vlan RX Pcap

	//Configuration Channels
	GlobalCfg chan NdpConfig
	// Lock for reading/writing NeighorInfo
	// We need this lock because getbulk/getentry is not requested on the main entry point channel, rather it's a
	// direct call to server. So to avoid updating the Neighbor Runtime Info during read
	// it's better to use lock
	NeigborEntryLock *sync.RWMutex

	//IPV6 Create/Delete State Up/Down Notification Channel
	IpIntfCh chan *config.IPIntfNotification
	// Vlan Create/Delete/Update Notification Channel
	VlanCh chan *config.VlanNotification
	// Mac Move Notification Channel
	MacMoveCh chan *config.MacMoveNotification
	//Received Pkt Channel
	RxPktCh chan *RxPktInfo
	//Package packet informs server over PktDataCh saying that send this packet..
	PktDataCh chan config.PacketData
	//Action Channel for NDP
	ActionCh chan *config.ActionData

	L3IfIntfRefToIfIndex map[string]int32

	//Pcap Default config values
	SnapShotLen int32
	Promiscuous bool
	Timeout     time.Duration

	// Neighbor Cache Information
	Packet *packet.Packet

	// @HACK: Need to find better way of getting Switch Mac Address
	SwitchMac string
	// contains filtered or unexported fields
}

func NDPNewServer

func NDPNewServer(sPlugin asicdClient.AsicdClientIntf, dmnBase *dmnBase.FSBaseDmn) *NDPServer

func (*NDPServer) ActionDeleteByIntf

func (svr *NDPServer) ActionDeleteByIntf(intfRef string)

* Utility Action function to delete ndp entries by L3 Port interface name

func (*NDPServer) ActionDeleteByNbrIp

func (svr *NDPServer) ActionDeleteByNbrIp(ipAddr string)

* Utility Action function to delete ndp entries by Neighbor Ip Address

func (*NDPServer) ActionRefreshByIntf

func (svr *NDPServer) ActionRefreshByIntf(intfRef string)

* Utility Action function to refreshndp entries by L3 Port interface name

func (*NDPServer) ActionRefreshByNbrIp

func (svr *NDPServer) ActionRefreshByNbrIp(ipAddr string)

* Utility Action function to refresh ndp entries by Neighbor Ip Address

func (*NDPServer) CheckSrcMac

func (svr *NDPServer) CheckSrcMac(macAddr string) bool

* CheckSrcMac * a) Check for packet src mac and validate it against ifIndex mac addr * if it is same then discard the packet

func (*NDPServer) CreateNeighborInfo

func (svr *NDPServer) CreateNeighborInfo(nbrInfo *config.NeighborConfig)

* CreateNeighborInfo * a) It will first check whether a neighbor exists in the neighbor cache * b) If it doesn't exists then we create neighbor in the platform * a) It will update ndp server neighbor info cache with the latest information

func (*NDPServer) CreatePcap

func (svr *NDPServer) CreatePcap(ifIndex int32) error

* Creating Pcap handlers for l2 port which are marked as tag/untag for l3 vlan port and are in UP state * only l3 CreatePcap should update l2Port.L3 information

func (*NDPServer) DeInitGlobalDS

func (svr *NDPServer) DeInitGlobalDS()

func (*NDPServer) DeleteL3IntfFromUpState

func (svr *NDPServer) DeleteL3IntfFromUpState(ifIndex int32)

* API: It will remove any deleted ip port from the up state slice list

func (*NDPServer) DeleteNeighborInfo

func (svr *NDPServer) DeleteNeighborInfo(deleteEntries []string, ifIndex int32)

* DeleteNeighborInfo * a) It will first check whether a neighbor exists in the neighbor cache * b) If it doesn't exists then we will move on to next neighbor * c) If exists then we will call DeleteIPV6Neighbor for that entry and remove * the entry from our runtime information

func (*NDPServer) DeletePcap

func (svr *NDPServer) DeletePcap(ifIndex int32)

* Deleting Pcap handlers for l2 port which are marked as tag/untag for l3 vlan port and are in UP state * only l3 CreatePcap should update l2Port.L3 information

func (*NDPServer) EventsListener

func (svr *NDPServer) EventsListener()

func (*NDPServer) GetGlobalState

func (svr *NDPServer) GetGlobalState(vrf string) *config.GlobalState

func (*NDPServer) GetIPIntf

func (svr *NDPServer) GetIPIntf()

* API: will return all system L3 interfaces information

func (*NDPServer) GetIfType

func (svr *NDPServer) GetIfType(ifIndex int32) int

func (*NDPServer) GetInterfaceNeighborEntries

func (svr *NDPServer) GetInterfaceNeighborEntries(idx, cnt int) (int, int, []config.InterfaceEntries)

func (*NDPServer) GetInterfaceNeighborEntry

func (svr *NDPServer) GetInterfaceNeighborEntry(intfRef string) *config.InterfaceEntries

func (*NDPServer) GetNeighborEntries

func (svr *NDPServer) GetNeighborEntries(idx, cnt int) (int, int, []config.NeighborConfig)

func (*NDPServer) GetNeighborEntry

func (svr *NDPServer) GetNeighborEntry(ipAddr string) *config.NeighborConfig

func (*NDPServer) GetPorts

func (svr *NDPServer) GetPorts()

* API: will return all system port information

func (*NDPServer) GetVlans

func (svr *NDPServer) GetVlans()

* API: will return all system vlan information

func (*NDPServer) HandleAction

func (svr *NDPServer) HandleAction(action *config.ActionData)

* API: handle action request coming from the user

func (*NDPServer) HandleIPIntfCreateDelete

func (svr *NDPServer) HandleIPIntfCreateDelete(obj *config.IPIntfNotification)
API: will handle IPv6 notifications received from switch/asicd

* Msg types * 1) Create: * Create an entry in the map * 2) Delete: * delete an entry from the map

func (*NDPServer) HandlePhyPortStateNotification

func (svr *NDPServer) HandlePhyPortStateNotification(msg *config.PortState)
API: will handle l2/physical notifications received from switch/asicd

* Update map entry and then call state notification *

func (*NDPServer) HandleStateNotification

func (svr *NDPServer) HandleStateNotification(msg *config.IPIntfNotification)
API: will handle IPv6 notifications received from switch/asicd

* Msg types * 1) Create: * Start Rx/Tx in this case * 2) Delete: * Stop Rx/Tx in this case

func (*NDPServer) HandleVlanNotification

func (svr *NDPServer) HandleVlanNotification(msg *config.VlanNotification)

API: will handle Vlan Create/Delete/Update notifications received from switch/asicd

func (*NDPServer) InitGlobalDS

func (svr *NDPServer) InitGlobalDS()

func (*NDPServer) InitSystem

func (svr *NDPServer) InitSystem()

* API: it will collect all ipv6 interface ports from the system... If needed we can collect port information * also from the system. * After the information is collected, if the oper state is up then we will start rx/tx

func (*NDPServer) IsIPv6Addr

func (svr *NDPServer) IsIPv6Addr(ipAddr string) bool

func (*NDPServer) NDPStartServer

func (svr *NDPServer) NDPStartServer()

func (*NDPServer) OSSignalHandle

func (svr *NDPServer) OSSignalHandle()

Create os signal handler channel and initiate go routine for that

func (*NDPServer) PopulateInterfaceInfo

func (svr *NDPServer) PopulateInterfaceInfo(ifIndex int32, entry *config.InterfaceEntries)

func (*NDPServer) PopulateVlanInfo

func (svr *NDPServer) PopulateVlanInfo(nbrInfo *config.NeighborConfig, intfRef string)

* API: It will populate correct vlan information which will be used for ipv6 neighbor create

func (*NDPServer) ProcessRxPkt

func (svr *NDPServer) ProcessRxPkt(ifIndex int32, pkt gopacket.Packet) error

* ProcessRxPkt * a) Check for runtime information * b) Validate & Parse Pkt, which gives ipAddr, MacAddr * c) PopulateVlanInfo will check if the port is untagged port or not and based of that * vlan id will be selected * c) CreateIPv6 Neighbor entry

func (*NDPServer) ProcessTimerExpiry

func (svr *NDPServer) ProcessTimerExpiry(pktData config.PacketData) error

func (*NDPServer) ReadDB

func (svr *NDPServer) ReadDB()

func (*NDPServer) SendIPv6CreateNotification

func (svr *NDPServer) SendIPv6CreateNotification(ipAddr string, ifIndex int32)

* API: send ipv6 neighbor create notification

func (*NDPServer) SendIPv6DeleteNotification

func (svr *NDPServer) SendIPv6DeleteNotification(ipAddr string, ifIndex int32)

* API: send ipv6 neighbor delete notification

func (*NDPServer) SignalHandler

func (svr *NDPServer) SignalHandler(sigChannel <-chan os.Signal)

OS signal handler. * If the process get a sighup signal then close all the pcap handlers. * After that delete all the memory which was used during init process

func (*NDPServer) SoftwareUpdateNbrEntry

func (svr *NDPServer) SoftwareUpdateNbrEntry(msg *config.MacMoveNotification)

* API: helper function to update ifIndex & port information for software. Hardware is already taken care * off * NOTE: * Below Scenario will only happen when mac move happens between a physical port.. L3 port remains * the same and hence do not need to update clients

func (*NDPServer) StartRxTx

func (svr *NDPServer) StartRxTx(ifIndex int32)

* StartRxTx a) Check if entry is present in the map * b) If no entry create one do the initialization for the entry * c) Create Pcap Handler & add the entry to up interface slice * d) Start receiving Packets

func (*NDPServer) StopRxTx

func (svr *NDPServer) StopRxTx(ifIndex int32, ipAddr string)

* StopRxTx a) Check if entry is present in the map * b) If present then send a ctrl signal to stop receiving packets * c) block until cleanup is going on * c) delete the entry from up interface slice * delete interface will delete pcap if needed and return the deleteEntries * The below check is based on following assumptions: * 1) fpPort1 has one ip address, bypass the check and delete pcap * 2) fpPort1 has two ip address * a) 2003::2/64 - Global Scope * b) fe80::123/64 - Link Scope * In this case we will get two Notification for port down from the chip, one is for * Global Scope Ip and second is for Link Scope.. * On first Notification NDP will update pcap users and move on. Only when second delete * notification comes then NDP will delete pcap

func (*NDPServer) UpdateInterfaceTimers

func (svr *NDPServer) UpdateInterfaceTimers()

func (*NDPServer) UpdateNeighborInfo

func (svr *NDPServer) UpdateNeighborInfo(nbrInfo *config.NeighborConfig, oldNbrEntry config.NeighborConfig)

type NDP_OPERATION

type NDP_OPERATION byte
const (
	IGNORE NDP_OPERATION = 1
	CREATE NDP_OPERATION = 2
	DELETE NDP_OPERATION = 3
	UPDATE NDP_OPERATION = 4
)

type NdpConfig

type NdpConfig struct {
	Vrf               string
	ReachableTime     uint32
	RetransTime       uint32
	RaRestransmitTime uint8
}

func (*NdpConfig) Create

func (cfg *NdpConfig) Create(gCfg NdpConfig) bool

func (*NdpConfig) Validate

func (cfg *NdpConfig) Validate(vrf string, retransmit uint32, reachableTime uint32, raTime uint8) (bool, error)

type NeighborInfo

type NeighborInfo struct {
	BaseReachableTimer   float32
	RetransTimerConfig   uint32
	ReachableTimeConfig  uint32
	RecomputeBaseTimer   *time.Timer
	ReachableTimer       *time.Timer
	RetransTimer         *time.Timer
	DelayFirstProbeTimer *time.Timer
	InvalidationTimer    *time.Timer
	FastProbeTimer       *time.Timer
	ProbesSent           uint8
	FastProbesMultiplier uint8
	StopFastProbe        bool
	State                int
	LinkLayerAddress     string // this is our neighbor port mac address
	IpAddr               string
	ReturnCh             chan config.PacketData // NDP Server communicator
	IfIndex              int32                  // Physical Port where to send the packet on timer expiry
	// contains filtered or unexported fields
}

func (*NeighborInfo) DeInit

func (c *NeighborInfo) DeInit()

* Delete Cache completely

func (*NeighborInfo) DelayProbe

func (c *NeighborInfo) DelayProbe()

* Delay first probe timer handler

func (*NeighborInfo) FastProbe

func (c *NeighborInfo) FastProbe()

* Start Fast Probe Timer

func (*NeighborInfo) InValidTimer

func (c *NeighborInfo) InValidTimer(lifetime uint16)

* invalidation timer received during RA

func (*NeighborInfo) InitCache

func (c *NeighborInfo) InitCache(reachableTime, retransTime uint32, nbrKey string, pktCh chan config.PacketData, ifIndex int32)

* Initialize cache with default values..

func (*NeighborInfo) RchTimer

func (c *NeighborInfo) RchTimer()

* Start Reachable Timer

func (*NeighborInfo) ReComputeBaseReachableTimer

func (c *NeighborInfo) ReComputeBaseReachableTimer()

* Re-computing base reachable timer

func (*NeighborInfo) StopDelayProbeTimer

func (c *NeighborInfo) StopDelayProbeTimer()

* stop delay probe Timer

func (*NeighborInfo) StopFastProbeTimer

func (c *NeighborInfo) StopFastProbeTimer()

* stop fast probe Timer

func (*NeighborInfo) StopInvalidTimer

func (c *NeighborInfo) StopInvalidTimer()

* stop Invalid Timer

func (*NeighborInfo) StopReComputeBaseTimer

func (c *NeighborInfo) StopReComputeBaseTimer()

* Stop Reachable Timer

func (*NeighborInfo) StopReTransmitTimer

func (c *NeighborInfo) StopReTransmitTimer()

* Stop ReTransmit Timer

func (*NeighborInfo) StopReachableTimer

func (c *NeighborInfo) StopReachableTimer()

* Stop Reachable Timer

func (*NeighborInfo) Timer

func (c *NeighborInfo) Timer()

* Re-Transmit Timer

func (*NeighborInfo) UpdateProbe

func (c *NeighborInfo) UpdateProbe()

* Update Probe Information * 1) Stop Delay Timer if running * 2) Stop Re-Transmit Timer if running * 3) Update Probes Sent counter to 0

type PcapBase

type PcapBase struct {
	// TX Pcap handler
	Tx *pcap.Handle
	// RX Pcap Handler for Each Port
	PcapHandle *pcap.Handle
	// at any give time there can be two users for Pcap..
	// if 0 then only start rx/tx
	// if 1 then only stop rx/tx
	PcapUsers uint8
}

type PhyPort

type PhyPort struct {
	RX   *pcap.Handle
	Info config.PortInfo
	L3   L3Info
}

func (*PhyPort) L2ReceiveNdpPkts

func (intf *PhyPort) L2ReceiveNdpPkts(pktCh chan *RxPktInfo) error

* Receive Ndp Packet and push it on the pktCh

type PktCounter

type PktCounter struct {
	Send int64
	Rcvd int64
}

type RxPktInfo

type RxPktInfo struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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