Exemplo n.º 1
0
func main() {
	flag.Parse()

	// Connect to the NCC component.
	ncc := client.NewNCC(*nccSocket)
	if err := ncc.Dial(); err != nil {
		log.Fatalf("Failed to connect to NCC: %v", err)
	}

	switch strings.ToLower(*testClass) {
	case "arp":
		log.Print("Starting ARP tests...")
		arpTests(ncc)
	case "bgp":
		log.Print("Starting BGP tests...")
		bgpTests(ncc)
	case "interface":
		log.Print("Starting interface tests...")
		interfaceTests(ncc)
	case "ipvs":
		log.Print("Starting IPVS tests...")
		ipvsTests(ncc)
	case "route":
		log.Print("Starting route tests...")
		routeTests(ncc)
	case "vserver":
		log.Print("Starting vserver tests...")
		vserverTests(ncc)
	default:
		log.Fatal("Test class must be one of arp, bgp, interface, ipvs, route or vserver")
	}

	ncc.Close()
	log.Print("Done!")
}
Exemplo n.º 2
0
func ipvsAddService(done chan bool, service, dests int) {
	ncc := client.NewNCC(*nccSocket)
	if err := ncc.Dial(); err != nil {
		log.Fatalf("Failed to connect to NCC: %v", err)
	}
	defer ncc.Close()

	svc := &ipvs.Service{
		Address:   net.IPv4(1, 1, 1, 1),
		Protocol:  syscall.IPPROTO_TCP,
		Port:      uint16(10000 + service),
		Scheduler: "wlc",
	}
	if err := ncc.IPVSAddService(svc); err != nil {
		log.Fatalf("Failed to add IPVS service: %v", err)
	}

	for i := 0; i < dests; i++ {
		dst := &ipvs.Destination{
			Address: net.IPv4(1, 1, 1, byte(i+2)),
			Port:    uint16(10000 + service),
			Flags:   ipvs.DFForwardRoute,
			Weight:  1,
		}
		if err := ncc.IPVSAddDestination(svc, dst); err != nil {
			log.Fatalf("Failed to add IPVS destination: %v", err)
		}
	}

	done <- true
}
Exemplo n.º 3
0
// NewEngine returns an initialised Engine struct.
func NewEngine(cfg *config.EngineConfig) *Engine {
	if cfg == nil {
		defaultCfg := config.DefaultEngineConfig()
		cfg = &defaultCfg
	}
	// TODO(jsing): Validate node, peer and cluster IP configuration.
	engine := &Engine{
		config:   cfg,
		fwmAlloc: newMarkAllocator(fwmAllocBase, fwmAllocSize),
		ncc:      ncclient.NewNCC(cfg.NCCSocket),

		overrides:    make(map[string]seesaw.Override),
		overrideChan: make(chan seesaw.Override),

		vlans:    make(map[uint16]*seesaw.VLAN),
		vservers: make(map[string]*vserver),

		shutdown:    make(chan bool),
		shutdownARP: make(chan bool),
		shutdownIPC: make(chan bool),
		shutdownRPC: make(chan bool),

		vserverSnapshots: make(map[string]*seesaw.Vserver),
		vserverChan:      make(chan *seesaw.Vserver, 1000),
	}
	engine.bgpManager = newBGPManager(engine, cfg.BGPUpdateInterval)
	engine.haManager = newHAManager(engine, cfg.HAStateTimeout)
	engine.hcManager = newHealthcheckManager(engine)
	engine.syncClient = newSyncClient(engine)
	engine.syncServer = newSyncServer(engine)
	return engine
}
Exemplo n.º 4
0
// newHealthcheckManager creates a new healthcheckManager.
func newHealthcheckManager(e *Engine) *healthcheckManager {
	return &healthcheckManager{
		engine:        e,
		marks:         make(map[seesaw.IP]uint32),
		markAlloc:     newMarkAllocator(dsrMarkBase, dsrMarkSize),
		ncc:           ncclient.NewNCC(e.config.NCCSocket),
		next:          healthcheck.Id((uint64(os.Getpid()) & 0xFFFF) << 48),
		vserverChecks: make(map[string]map[checkKey]*check),
		quit:          make(chan bool),
		stopped:       make(chan bool),
		vcc:           make(chan vserverChecks, 100),
	}
}
Exemplo n.º 5
0
// newVserver returns an initialised vserver struct.
func newVserver(e *Engine) *vserver {
	return &vserver{
		engine: e,
		ncc:    ncclient.NewNCC(e.config.NCCSocket),

		fwm:        make(map[seesaw.AF]uint32),
		active:     make(map[seesaw.IP]bool),
		lbVservers: make(map[seesaw.IP]*seesaw.Vserver),
		vips:       make(map[seesaw.VIP]bool),

		overrideChan: make(chan seesaw.Override, 5),

		notify:  make(chan *checkNotification, 20),
		update:  make(chan *config.Vserver, 1),
		quit:    make(chan bool, 1),
		stopped: make(chan bool, 1),
	}
}
Exemplo n.º 6
0
func ipvsGetServices(quit chan bool, count chan int) {
	ncc := client.NewNCC(*nccSocket)
	if err := ncc.Dial(); err != nil {
		log.Fatalf("Failed to connect to NCC: %v", err)
	}
	defer ncc.Close()

	i := 0
	for {
		select {
		case <-quit:
			count <- i
			return
		default:
		}
		if _, err := ncc.IPVSGetServices(); err != nil {
			log.Fatalf("Failed to get IPVS services: %v", err)
		}
		i++
	}
}