vrrpServer

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: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VRRP_REDDIS_DB_PORT = ":6379"
	VRRP_INTF_DB        = "VrrpIntf"

	// Error Message
	VRRP_INVALID_VRID                   = "VRID is invalid"
	VRRP_CLIENT_CONNECTION_NOT_REQUIRED = "Connection to Client is not required"
	VRRP_INCORRECT_VERSION              = "Version is not correct for received VRRP Packet"
	VRRP_INCORRECT_FIELDS               = "Field like type/count ip addr/Advertisement Interval are not valid"
	VRRP_SAME_OWNER                     = "Local Router should not be same as the VRRP Ip Address"
	VRRP_MISSING_VRID_CONFIG            = "VRID is not configured on interface"
	VRRP_CHECKSUM_ERR                   = "VRRP checksum failure"
	VRRP_INVALID_PCAP                   = "Invalid Pcap Handler"
	VRRP_VLAN_NOT_CREATED               = "Create Vlan before configuring VRRP"
	VRRP_IPV4_INTF_NOT_CREATED          = "Create IPv4 interface before configuring VRRP"
	VRRP_DATABASE_LOCKED                = "database is locked"

	// VRRP multicast ip address for join
	VRRP_GROUP_IP     = "224.0.0.18"
	VRRP_BPF_FILTER   = "ip host " + VRRP_GROUP_IP
	VRRP_PROTOCOL_MAC = "01:00:5e:00:00:12"
	VRRP_MAC_MASK     = "ff:ff:ff:ff:ff:ff"
	VRRP_PROTO_ID     = 112

	// Default Size
	VRRP_GLOBAL_INFO_DEFAULT_SIZE         = 50
	VRRP_VLAN_MAPPING_DEFAULT_SIZE        = 5
	VRRP_INTF_STATE_SLICE_DEFAULT_SIZE    = 5
	VRRP_LINUX_INTF_MAPPING_DEFAULT_SIZE  = 5
	VRRP_INTF_IPADDR_MAPPING_DEFAULT_SIZE = 5
	VRRP_RX_BUF_CHANNEL_SIZE              = 100
	VRRP_TX_BUF_CHANNEL_SIZE              = 1
	VRRP_FSM_CHANNEL_SIZE                 = 1
	VRRP_INTF_CONFIG_CH_SIZE              = 1
	VRRP_TOTAL_INTF_CONFIG_ELEMENTS       = 7

	// ip/vrrp header Check Defines
	VRRP_TTL                        = 255
	VRRP_VERSION2                   = 2
	VRRP_VERSION3                   = 3
	VRRP_PKT_TYPE_ADVERTISEMENT     = 1 // Only one type is supported which is advertisement
	VRRP_RSVD                       = 0
	VRRP_HDR_CREATE_CHECKSUM        = 0
	VRRP_HEADER_SIZE_EXCLUDING_IPVX = 8 // 8 bytes...
	VRRP_IPV4_HEADER_MIN_SIZE       = 20
	VRRP_HEADER_MIN_SIZE            = 20
	VRRP_MASTER_PRIORITY            = 255
	VRRP_IGNORE_PRIORITY            = 65535
	VRRP_MASTER_DOWN_PRIORITY       = 0

	// vrrp default configs
	VRRP_DEFAULT_PRIORITY = 100
	VRRP_IEEE_MAC_ADDR    = "00-00-5E-00-01-"

	// vrrp state names
	VRRP_UNINTIALIZE_STATE = "Un-Initialize"
	VRRP_INITIALIZE_STATE  = "Initialize"
	VRRP_BACKUP_STATE      = "Backup"
	VRRP_MASTER_STATE      = "Master"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type VrrpAsicdClient

type VrrpAsicdClient struct {
	VrrpClientBase
	ClientHdl *asicdServices.ASICDServicesClient
}

type VrrpClientBase

type VrrpClientBase struct {
	Address            string
	Transport          thrift.TTransport
	PtrProtocolFactory *thrift.TBinaryProtocolFactory
	IsConnected        bool
}

type VrrpClientJson

type VrrpClientJson struct {
	Name string `json:Name`
	Port int    `json:Port`
}

type VrrpFsm

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

type VrrpFsmIntf

type VrrpFsmIntf interface {
	VrrpFsmStart(fsmObj VrrpFsm)
	VrrpCreateObject(gblInfo VrrpGlobalInfo) (fsmObj VrrpFsm)
	VrrpInitState(key string)
	VrrpBackupState(inPkt gopacket.Packet, vrrpHdr *VrrpPktHeader, key string)
	VrrpMasterState(inPkt gopacket.Packet, vrrpHdr *VrrpPktHeader, key string)
	VrrpTransitionToMaster(key string, reason string)
	VrrpTransitionToBackup(key string, AdvertisementInterval int32, reason string)
	VrrpHandleIntfUpEvent(IfIndex int32)
	VrrpHandleIntfShutdownEvent(IfIndex int32)
}

type VrrpGlobalInfo

type VrrpGlobalInfo struct {
	IntfConfig vrrpd.VrrpIntf
	// VRRP MAC aka VMAC
	VirtualRouterMACAddress string
	// The initial value is the same as Advertisement_Interval.
	MasterAdverInterval int32
	// (((256 - priority) * Master_Adver_Interval) / 256)
	SkewTime int32
	// (3 * Master_Adver_Interval) + Skew_time
	MasterDownValue int32
	MasterDownTimer *time.Timer
	MasterDownLock  *sync.RWMutex
	// Advertisement Timer
	AdverTimer *time.Timer
	// IfIndex IpAddr which needs to be used if no Virtual Ip is specified
	IpAddr string
	// cached info for IfName is required in future
	IfName string

	// Pcap Handler lock to write data one routine at a time
	PcapHdlLock *sync.RWMutex
	// State Name
	StateName string
	// Lock to read current state of vrrp object
	StateNameLock *sync.RWMutex
	// Vrrp State Lock for each IfIndex + VRID
	StateInfo     VrrpGlobalStateInfo
	StateInfoLock *sync.RWMutex
	// contains filtered or unexported fields
}

type VrrpGlobalStateInfo

type VrrpGlobalStateInfo struct {
	AdverRx             uint32 // Total advertisement received
	AdverTx             uint32 // Total advertisement send out
	MasterIp            string // Remote Master Ip Address
	LastAdverRx         string // Last advertisement received
	LastAdverTx         string // Last advertisment send out
	PreviousFsmState    string // previous fsm state
	CurrentFsmState     string // current fsm state
	ReasonForTransition string // why did we transition to current state?
}

type VrrpPktChannelInfo

type VrrpPktChannelInfo struct {
	IfIndex int32
	// contains filtered or unexported fields
}

type VrrpPktHeader

type VrrpPktHeader struct {
	Version       uint8
	Type          uint8
	VirtualRtrId  uint8
	Priority      uint8
	CountIPv4Addr uint8
	Rsvd          uint8
	MaxAdverInt   uint16
	CheckSum      uint16
	IPv4Addr      []net.IP
}

type VrrpServer

type VrrpServer struct {
	VrrpCreateIntfConfigCh chan vrrpd.VrrpIntf
	VrrpDeleteIntfConfigCh chan vrrpd.VrrpIntf
	VrrpUpdateIntfConfigCh chan VrrpUpdateConfig
	// contains filtered or unexported fields
}

func VrrpNewServer

func VrrpNewServer(log *logging.Writer) *VrrpServer

func (*VrrpServer) VrrpAsicdSubscriber

func (svr *VrrpServer) VrrpAsicdSubscriber()

func (*VrrpServer) VrrpBackupState

func (svr *VrrpServer) VrrpBackupState(inPkt gopacket.Packet, vrrpHdr *VrrpPktHeader,
	key string)

func (*VrrpServer) VrrpCalculateDownValue

func (svr *VrrpServer) VrrpCalculateDownValue(AdvertisementInterval int32,
	gblInfo *VrrpGlobalInfo)

func (*VrrpServer) VrrpChannelHanlder

func (svr *VrrpServer) VrrpChannelHanlder()

func (*VrrpServer) VrrpCheckHeader

func (svr *VrrpServer) VrrpCheckHeader(hdr *VrrpPktHeader, layerContent []byte, key string) error

func (*VrrpServer) VrrpCheckRcvdPkt

func (svr *VrrpServer) VrrpCheckRcvdPkt(packet gopacket.Packet, key string,
	IfIndex int32)

func (*VrrpServer) VrrpChecknUpdateGblInfo

func (svr *VrrpServer) VrrpChecknUpdateGblInfo(IfIndex int32, IpAddr string)

func (*VrrpServer) VrrpCloseAllPcapHandlers

func (svr *VrrpServer) VrrpCloseAllPcapHandlers()

func (*VrrpServer) VrrpCloseDB

func (svr *VrrpServer) VrrpCloseDB()

func (*VrrpServer) VrrpComputeChecksum

func (svr *VrrpServer) VrrpComputeChecksum(version uint8, content []byte) uint16

func (*VrrpServer) VrrpConnectAndInitPortVlan

func (svr *VrrpServer) VrrpConnectAndInitPortVlan() error

func (*VrrpServer) VrrpConnectToAsicd

func (svr *VrrpServer) VrrpConnectToAsicd(client VrrpClientJson) error

func (*VrrpServer) VrrpConnectToUnConnectedClient

func (svr *VrrpServer) VrrpConnectToUnConnectedClient(client VrrpClientJson) error

func (*VrrpServer) VrrpCreateGblInfo

func (svr *VrrpServer) VrrpCreateGblInfo(config vrrpd.VrrpIntf)

func (*VrrpServer) VrrpCreateIfIndexEntry

func (svr *VrrpServer) VrrpCreateIfIndexEntry(IfIndex int32, IpAddr string)

func (*VrrpServer) VrrpCreateObject

func (svr *VrrpServer) VrrpCreateObject(gblInfo VrrpGlobalInfo) (fsmObj VrrpFsm)

func (*VrrpServer) VrrpCreateSendPkt

func (svr *VrrpServer) VrrpCreateSendPkt(gblInfo VrrpGlobalInfo, vrrpEncHdr []byte, hdrLen uint16) []byte

func (*VrrpServer) VrrpCreateVlanEntry

func (svr *VrrpServer) VrrpCreateVlanEntry(vlanId int, vlanName string)

func (*VrrpServer) VrrpCreateVrrpHeader

func (svr *VrrpServer) VrrpCreateVrrpHeader(gblInfo VrrpGlobalInfo) ([]byte, uint16)

func (*VrrpServer) VrrpCreateWriteBuf

func (svr *VrrpServer) VrrpCreateWriteBuf(eth *layers.Ethernet,
	arp *layers.ARP, ipv4 *layers.IPv4, payload []byte) []byte

func (*VrrpServer) VrrpDeAllocateMemoryToGlobalDS

func (svr *VrrpServer) VrrpDeAllocateMemoryToGlobalDS()

func (*VrrpServer) VrrpDecodeHeader

func (svr *VrrpServer) VrrpDecodeHeader(data []byte) *VrrpPktHeader

Octet Offset--> 0 1 2 3

 |		0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 |		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 V		|                    IPv4 Fields or IPv6 Fields                 |
		...                                                             ...
		|                                                               |
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 0		|Version| Type  | Virtual Rtr ID|   Priority    |Count IPvX Addr|
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 4		|(rsvd) |     Max Adver Int     |          Checksum             |
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 8		|                                                               |
		+                                                               +

12 | IPvX Address(es) |

  • +

.. + +

  • +
  • + | |
  • + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*VrrpServer) VrrpDeleteGblInfo

func (svr *VrrpServer) VrrpDeleteGblInfo(config vrrpd.VrrpIntf)

func (*VrrpServer) VrrpEncodeHeader

func (svr *VrrpServer) VrrpEncodeHeader(hdr VrrpPktHeader) ([]byte, uint16)

Octet Offset--> 0 1 2 3

 |		0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 |		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 V		|                    IPv4 Fields or IPv6 Fields                 |
		...                                                             ...
		|                                                               |
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 0		|Version| Type  | Virtual Rtr ID|   Priority    |Count IPvX Addr|
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 4		|(rsvd) |     Max Adver Int     |          Checksum             |
		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 8		|                                                               |
		+                                                               +

12 | IPvX Address(es) |

  • +

.. + +

  • +
  • + | |
  • + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*VrrpServer) VrrpFsmStart

func (svr *VrrpServer) VrrpFsmStart(fsmObj VrrpFsm)

func (*VrrpServer) VrrpGetBulkVrrpIntfStates

func (svr *VrrpServer) VrrpGetBulkVrrpIntfStates(idx int, cnt int) (int, int, []vrrpd.VrrpIntfState)

func (*VrrpServer) VrrpGetBulkVrrpVridStates

func (svr *VrrpServer) VrrpGetBulkVrrpVridStates(idx int, cnt int) (int, int, []vrrpd.VrrpVridState)

func (*VrrpServer) VrrpGetIPv4IntfList

func (svr *VrrpServer) VrrpGetIPv4IntfList()

func (*VrrpServer) VrrpGetInfoFromAsicd

func (svr *VrrpServer) VrrpGetInfoFromAsicd() error

func (*VrrpServer) VrrpGetVlanList

func (svr *VrrpServer) VrrpGetVlanList()

func (*VrrpServer) VrrpHandleIntfShutdownEvent

func (svr *VrrpServer) VrrpHandleIntfShutdownEvent(IfIndex int32)

func (*VrrpServer) VrrpHandleIntfUpEvent

func (svr *VrrpServer) VrrpHandleIntfUpEvent(IfIndex int32)

func (*VrrpServer) VrrpHandleMasterAdverTimer

func (svr *VrrpServer) VrrpHandleMasterAdverTimer(key string)

func (*VrrpServer) VrrpHandleMasterDownTimer

func (svr *VrrpServer) VrrpHandleMasterDownTimer(key string)

func (*VrrpServer) VrrpInitDB

func (svr *VrrpServer) VrrpInitDB() error

func (*VrrpServer) VrrpInitGlobalDS

func (vrrpServer *VrrpServer) VrrpInitGlobalDS()

func (*VrrpServer) VrrpInitPacketListener

func (svr *VrrpServer) VrrpInitPacketListener(key string, IfIndex int32)

func (*VrrpServer) VrrpInitState

func (svr *VrrpServer) VrrpInitState(key string)

func (*VrrpServer) VrrpMapIfIndexToLinuxIfIndex

func (svr *VrrpServer) VrrpMapIfIndexToLinuxIfIndex(IfIndex int32)

func (*VrrpServer) VrrpMasterState

func (svr *VrrpServer) VrrpMasterState(inPkt gopacket.Packet, vrrpHdr *VrrpPktHeader,
	key string)

func (*VrrpServer) VrrpOSSignalHandle

func (svr *VrrpServer) VrrpOSSignalHandle()

func (*VrrpServer) VrrpPopulateIntfState

func (svr *VrrpServer) VrrpPopulateIntfState(key string, entry *vrrpd.VrrpIntfState) bool

func (*VrrpServer) VrrpPopulateVridState

func (svr *VrrpServer) VrrpPopulateVridState(key string, entry *vrrpd.VrrpVridState) bool

func (*VrrpServer) VrrpReadDB

func (svr *VrrpServer) VrrpReadDB() error

func (*VrrpServer) VrrpReceivePackets

func (svr *VrrpServer) VrrpReceivePackets(pHandle *pcap.Handle, key string, IfIndex int32)

func (*VrrpServer) VrrpRegisterWithAsicdUpdates

func (svr *VrrpServer) VrrpRegisterWithAsicdUpdates(address string) error

func (*VrrpServer) VrrpSendPkt

func (svr *VrrpServer) VrrpSendPkt(key string, priority uint16)

func (*VrrpServer) VrrpSignalHandler

func (svr *VrrpServer) VrrpSignalHandler(sigChannel <-chan os.Signal)

func (*VrrpServer) VrrpStartServer

func (svr *VrrpServer) VrrpStartServer(paramsDir string)

func (*VrrpServer) VrrpStopTimers

func (svr *VrrpServer) VrrpStopTimers(IfIndex int32)

* During a shutdown event stop timers will be called and we will cancel master * down timer and transition to initialize state

func (*VrrpServer) VrrpTransitionToBackup

func (svr *VrrpServer) VrrpTransitionToBackup(key string, AdvertisementInterval int32,
	reason string)

func (*VrrpServer) VrrpTransitionToMaster

func (svr *VrrpServer) VrrpTransitionToMaster(key string, reason string)

func (*VrrpServer) VrrpUpdateIPv4GblInfo

func (svr *VrrpServer) VrrpUpdateIPv4GblInfo(msg asicdCommonDefs.IPv4IntfNotifyMsg, msgType uint8)

func (*VrrpServer) VrrpUpdateIntf

func (svr *VrrpServer) VrrpUpdateIntf(origconfig vrrpd.VrrpIntf,
	newconfig vrrpd.VrrpIntf, attrset []bool)

func (*VrrpServer) VrrpUpdateIntfIpAddr

func (svr *VrrpServer) VrrpUpdateIntfIpAddr(gblInfo *VrrpGlobalInfo) bool

func (*VrrpServer) VrrpUpdateL3IntfStateChange

func (svr *VrrpServer) VrrpUpdateL3IntfStateChange(msg asicdCommonDefs.IPv4L3IntfStateNotifyMsg)

func (*VrrpServer) VrrpUpdateMasterTimerStateInfo

func (svr *VrrpServer) VrrpUpdateMasterTimerStateInfo(gblInfo *VrrpGlobalInfo)

func (*VrrpServer) VrrpUpdateProtocolMacEntry

func (svr *VrrpServer) VrrpUpdateProtocolMacEntry(add bool)

func (*VrrpServer) VrrpUpdateStateInfo

func (svr *VrrpServer) VrrpUpdateStateInfo(key string, reason string,
	currentSt string)

func (*VrrpServer) VrrpUpdateSubIntf

func (svr *VrrpServer) VrrpUpdateSubIntf(gblInfo VrrpGlobalInfo, configure bool)

* This API will create config object with MacAddr and configure.... * Configure will enable/disable the link...

func (*VrrpServer) VrrpUpdateVlanGblInfo

func (svr *VrrpServer) VrrpUpdateVlanGblInfo(vlanNotifyMsg asicdCommonDefs.VlanNotifyMsg, msgType uint8)

func (*VrrpServer) VrrpValidateIntfConfig

func (svr *VrrpServer) VrrpValidateIntfConfig(IfIndex int32) error

func (*VrrpServer) VrrpWritePacket

func (svr *VrrpServer) VrrpWritePacket(gblInfo VrrpGlobalInfo, vrrpTxPkt []byte)

type VrrpTxChannelInfo

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

type VrrpTxIntf

type VrrpTxIntf interface {
	VrrpSendPkt(key string, priority uint16)
	VrrpEncodeHeader(hdr VrrpPktHeader) ([]byte, uint16)
	VrrpCreateVrrpHeader(gblInfo VrrpGlobalInfo) ([]byte, uint16)
	VrrpCreateSendPkt(gblInfo VrrpGlobalInfo, vrrpEncHdr []byte, hdrLen uint16) []byte
	VrrpCreateWriteBuf(eth *layers.Ethernet, arp *layers.ARP, ipv4 *layers.IPv4, payload []byte) []byte
}

* VRRP TX INTERFACE

type VrrpUpdateConfig

type VrrpUpdateConfig struct {
	OldConfig vrrpd.VrrpIntf
	NewConfig vrrpd.VrrpIntf
	AttrSet   []bool
}

Jump to

Keyboard shortcuts

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