id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c26400
b[:]) *(*uint32)(unsafe.Pointer(&b)) = ^uint32(0) copy(x[4:], b[:]) return x }
c26401
[4]byte copy(b[:], x) *f = ServiceFlags(*(*uint32)(unsafe.Pointer(&b))) }
c26402
svc.FirewallMark == other.FirewallMark && svc.Scheduler == other.Scheduler && svc.Flags == other.Flags && svc.Timeout == other.Timeout && svc.PersistenceEngine == other.PersistenceEngine }
c26403
svc.Protocol, svc.Address, svc.Port, svc.Scheduler) default: return fmt.Sprintf("%v %v:%d (%s)", svc.Protocol, svc.Address, svc.Port, svc.Scheduler) } }
c26404
dest.Weight == other.Weight && dest.Flags == other.Flags && dest.LowerThreshold == other.LowerThreshold && dest.UpperThreshold == other.UpperThreshold }
c26405
addr) } return fmt.Sprintf("%s:%d", addr, dest.Port) }
c26406
if err != nil { return err } return netlink.SendMessageUnmarshal(C.IPVS_CMD_GET_INFO, family, 0, &info) }
c26407
Minor: (v >> 8) & 0xff, Patch: v & 0xff, } }
c26408
range svc.Destinations { if err := AddDestination(svc, *dst); err != nil { return err } } return nil }
c26409
newIPVSService(&svc)} return netlink.SendMessageMarshalled(C.IPVS_CMD_SET_SERVICE, family, 0, ic) }
c26410
newIPVSService(&svc)} return netlink.SendMessageMarshalled(C.IPVS_CMD_DEL_SERVICE, family, 0, ic) }
c26411
Destination: newIPVSDestination(&dst), } return netlink.SendMessageMarshalled(C.IPVS_CMD_NEW_DEST, family, 0, ic) }
c26412
return netlink.SendMessageMarshalled(C.IPVS_CMD_SET_DEST, family, 0, ic) }
c26413
return netlink.SendMessageMarshalled(C.IPVS_CMD_DEL_DEST, family, 0, ic) }
c26414
} if ic.Destination == nil { return errors.New("no destination in unmarshalled message") } dsts = append(dsts, ic.Destination.toDestination()) return nil } if err := msg.SendCallback(cb, nil); err != nil { return nil, err } return dsts, nil }
c26415
} if ic.Service == nil { return errors.New("no service in unmarshalled message") } svcs = append(svcs, ic.Service.toService()) return nil } if err := msg.SendCallback(cb, nil); err != nil { return nil, err } for _, svc := range svcs { dsts, err := destinations(svc) if err != nil { return nil,...
c26416
return nil, errors.New("no service found") } return svcs[0], nil }
c26417
c.client.Call("SeesawEngine.HAStatus", c.ctx, &ha); err != nil { return nil, err } return &ha, nil }
c26418
:= c.client.Call("SeesawEngine.ConfigSource", cs, &source); err != nil { return "", err } return source, nil }
c26419
c.client.Call("SeesawEngine.BGPNeighbors", c.ctx, &bn); err != nil { return nil, err } return bn.Neighbors, nil }
c26420
c.ctx, &v); err != nil { return nil, err } return &v, nil }
c26421
c.client.Call("SeesawEngine.Vservers", c.ctx, &vm); err != nil { return nil, err } return vm.Vservers, nil }
c26422
:= &ipc.Override{Ctx: c.ctx, Vserver: vserver} return c.client.Call("SeesawEngine.OverrideVserver", override, nil) }
c26423
err := engine.Call("SeesawEngine.HAConfig", ctx, &config); err != nil { return nil, fmt.Errorf("HAConfig: SeesawEngine.HAConfig failed: %v", err) } return &config, nil }
c26424
err := engine.Call("SeesawEngine.HAUpdate", &ipc.HAStatus{ctx, status}, &failover); err != nil { return false, fmt.Errorf("HAUpdate: SeesawEngine.HAUpdate failed: %v", err) } return failover, nil }
c26425
error) { return false, nil }
c26426
ok := signalNames[s]; ok { return name } return fmt.Sprintf("SIG %d", s) }
c26427
for s := range sigc { name := s.String() if sig, ok := s.(syscall.Signal); ok { name = signalName(sig) } log.Infof("Received %v, initiating shutdown...", name) server.Shutdown() } }() }
c26428
is in use", socket) } log.Infof("Removing stale socket %v", socket) return os.Remove(socket) } return nil }
c26429
!= nil { return fmt.Errorf("Failed to make run directory: %v", err) } if err := os.Chown(serverRunDir, owner, group); err != nil { return fmt.Errorf("Failed to change ownership on run directory: %v", err) } if err := os.Chmod(serverRunDir, 0770); err != nil { return fmt.Errorf("Failed to change permissions o...
c26430
== errClosing.Error() { log.Infoln("RPC accept connection closed") return nil } log.Errorf("RPC accept error: %v", err) return err } go server.ServeConn(conn) } }
c26431
} return -1, fmt.Errorf("unknown source %q", name) }
c26432
ok := sourceNames[s]; ok { return name } return "(unknown)" }
c26433
} c, err := protoToCluster(p, clusterName) if err != nil { return nil, err } return &Notification{c, false, p, SourceDisk, filename, time.Now()}, nil }
c26434
cfg.ClusterName = cluster n := &Notifier{engineCfg: &cfg} return n.configFromServer() }
c26435
if curr.count > max.count || curr.bytes > max.bytes || curr.age > max.age { seen.filesRemoved, seen.filesErrored = removeFiles(archiveDir, files[i:]) return &seen, nil } seen = curr } return &seen, nil }
c26436
socket, shutdown: make(chan bool), } }
c26437
defer os.Remove(n.nccSocket) seesawNCC := rpc.NewServer() seesawNCC.Register(&SeesawNCC{}) go server.RPCAccept(ln, seesawNCC) <-n.shutdown }
c26438
make(chan seesaw.HAState), shutdownChannel: make(chan bool), } n.setState(seesaw.HABackup) n.resetMasterDownInterval(cfg.MasterAdvertInterval) return n }
c26439
{ n.masterDownInterval = masterDownInterval log.Infof("resetMasterDownInterval: skewTime=%v, masterDownInterval=%v", skewTime, masterDownInterval) } }
c26440
n.statusLock.RUnlock() return n.haStatus.State }
c26441
= s n.haStatus.Since = time.Now() n.haStatus.Transitions++ } }
c26442
atomic.LoadUint64(&n.receiveCount) n.haStatus.ReceivedQueued = uint64(len(n.recvChannel)) return n.haStatus }
c26443
AdvertInt: uint16(n.MasterAdvertInterval / time.Millisecond / 10), // AdvertInt is in centiseconds } }
c26444
if err := n.runOnce(); err != nil { return err } } return nil }
c26445
{ panic(fmt.Sprintf("Callback ID %d already in use", cbArg.id)) } callbacks[cbArg.id] = cbArg return cbArg.id }
c26446
panic(fmt.Sprintf("Callback ID %d not registered", cbArg.id)) } delete(callbacks, cbArg.id) }
c26447
cbMsg := &Message{nlm: nlm} if err := cbArg.fn(cbMsg, cbArg.arg); err != nil { cbArg.err = err return C.NL_STOP } return C.NL_OK }
c26448
C.NL_AUTO_SEQ, C.int(family), 0, C.int(flags), C.uint8_t(command), genlVersion) return &Message{nlm: nlm}, nil }
c26449
return nil, errors.New("failed to create netlink message") } nlh := C.nlmsg_hdr(nlm) copy((*[1 << 20]byte)(unsafe.Pointer(nlh))[:len(nlb)], nlb) return &Message{nlm: nlm}, nil }
c26450
C.nlmsg_free(m.nlm) m.nlm = nil }
c26451
make([]byte, nlh.nlmsg_len) copy(nlb, (*[1 << 20]byte)(unsafe.Pointer(nlh))[:nlh.nlmsg_len]) return nlb, nil }
c26452
!= nil { return err } attrs, err := parseMessage(m.nlm, maxAttrID) if err != nil { return err } return unmarshal(val, "", nil, attrs) }
c26453
if errno := C._nl_socket_modify_cb(s.nls, C.NL_CB_VALID, C.NL_CB_CUSTOM, (C.nl_recvmsg_msg_cb_t)(unsafe.Pointer(C.callbackGateway)), C.uintptr_t(cbID)); errno != 0 { return &Error{errno, "failed to modify callback"} } // nl_send_auto_complete returns number of bytes sent or a negative // errno on failure. if err...
c26454
return SendMessageCallback(command, family, flags, callbackDefault, nil) }
c26455
msg, err := NewMessage(command, family, flags) if err != nil { return err } defer msg.Free() return msg.SendCallback(cb, arg) }
c26456
if err := msg.Marshal(v); err != nil { return err } return msg.Send() }
c26457
SendMessageCallback(command, family, flags, callbackUnmarshal, v) }
c26458
retrieve HAConfig: %v", err) case !c.Enabled: log.Infof("config: HA peering is currently disabled for this node") default: return c } time.Sleep(*initConfigRetryDelay) } }
c26459
&bgpManager{engine: engine, updateInterval: interval} }
c26460
for { log.V(1).Infof("Updating BGP state and statistics...") b.update() <-ticker.C } }
c26461
!= nil { log.Warningf("Failed to get BGP neighbors: %v", err) return } b.lock.Lock() b.neighbors = neighbors b.lock.Unlock() }
c26462
Proto: seesaw.IPProtoTCP, }, Secure: false, TLSVerify: true, Method: "GET", Proxy: false, Request: "/", Response: "", ResponseCode: 200, } }
c26463
attr = append(attr, "verify") } } s := strings.Join(attr, "; ") return fmt.Sprintf("HTTP %s %s [%s] %s", hc.Method, hc.Request, s, hc.Target) }
c26464
Target: Target{ IP: ip, Port: port, Proto: seesaw.IPProtoTCP, }, } }
c26465
if len(attr) > 0 { s = fmt.Sprintf(" [%s]", strings.Join(attr, "; ")) } return fmt.Sprintf("TCP%s %s", s, hc.Target) }
c26466
tlsConfig := &tls.Config{ InsecureSkipVerify: !hc.TLSVerify, ServerName: host, } tlsConn := tls.Client(conn, tlsConfig) if err := tlsConn.Handshake(); err != nil { return complete(start, msg, false, err) } conn = tlsConn } if hc.Send == "" && hc.Receive == "" { return complete(start, ms...
c26467
if err != nil { return nil, err } return iface, nil }
c26468
if pad < 0 { pad = 0 } return fmt.Sprintf("%s%s%s", strings.Repeat(" ", indent), l, strings.Repeat(" ", pad)) }
c26469
subIndent, valIndent) fmt.Printf("%s %s\n", l, fmt.Sprintf(v, args...)) }
c26470
printFmt(l, "%s", f) default: printFmt(l, "%v", f) } }
c26471
ok { return name } return fmt.Sprintf("(Unknown %d)", snt) }
c26472
session.Lock() session.expiryTime = time.Now().Add(sessionDeadtime) session.Unlock() *id = session.id log.Infof("Synchronisation session %d registered by %v", *id, node) return nil }
c26473
{ log.Infof("Synchronisation session %d deregistered with %v", id, session.node) } return nil }
c26474
our poll expires. select { case note := <-session.notes: sn.Notes = append(sn.Notes, *note) case <-time.After(syncPollTimeout): return errors.New("poll timeout") } pollLoop: for i := 0; i < syncPollMsgLimit; i++ { select { case note := <-session.notes: sn.Notes = append(sn.Notes, *note) default: b...
c26475
error { return errors.New("unimplemented") }
c26476
s.sync.engine.haManager.requestFailover(true) }
c26477
return errors.New("unimplemented") }
c26478
time.Now(), expiryTime: time.Now().Add(sessionDeadtime), notes: make(chan *SyncNote, sessionNotesQueueSize), } }
c26479
ss.Lock() if !ss.desync { log.Warningf("Sync session with %v is desynchronised", ss.node) ss.desync = true } ss.Unlock() } }
c26480
heartbeatInterval: syncHeartbeatInterval, sessions: make(map[SyncSessionID]*syncSession), } }
c26481
} rip := net.ParseIP(host) if rip == nil || (!rip.IsLoopback() && !rip.Equal(s.engine.config.Peer.IPv4Addr) && !rip.Equal(s.engine.config.Peer.IPv6Addr)) { log.Warningf("Rejecting connection from non-peer (%s)...", rip) c.Close() continue } log.Infof("Sync connection established from %s", rip) go s....
c26482
s.sessionLock.RUnlock() for _, ss := range sessions { ss.addNote(sn) } }
c26483
expired", id, ss.node) delete(s.sessions, id) continue } ss.addNote(&SyncNote{Type: SNTHeartbeat}) } s.sessionLock.Unlock() } } }
c26484
stopped: make(chan bool, 1), } sc.dispatch = sc.handleNote sc.stopped <- true return sc }
c26485
IP: sc.engine.config.Node.IPv4Addr, } conn, err := net.DialTCP("tcp", self, peer) if err != nil { return fmt.Errorf("failed to connect: %v", err) } sc.client = rpc.NewClient(conn) sc.refs = 1 return nil }
c26486
!= nil { sc.client = nil return fmt.Errorf("client close failed: %v", err) } sc.client = nil return nil }
c26487
:= sc.client.Call("SeesawSync.Failover", 0, nil); err != nil { return err } return nil }
c26488
err != nil { log.Warningf("Sync registration failed: %v", err) return } log.Infof("Registered for synchronisation notifications (ID %d)", sid) // TODO(jsing): Export synchronisation data to ECU/CLI. sc.poll(sid) // Attempt to deregister for notifications. // TODO(jsing): Implement timeout on RPC? if err ...
c26489
<-sc.quit: sc.stopped <- true return case <-time.After(syncPollTimeout): log.Warningf("Synchronisation polling timed out after %s", syncPollTimeout) return } } }
c26490
case SNTConfigUpdate: sc.handleConfigUpdate(note) case SNTHealthcheck: sc.handleHealthcheck(note) case SNTOverride: sc.handleOverride(note) default: log.Errorf("Unable to handle sync notification type %s (%d)", note.Type, note.Type) } }
c26491
sc.engine.queueOverride(o) } if o := sn.BackendOverride; o != nil { sc.engine.queueOverride(o) } }
c26492
<-time.After(5 * time.Second): case <-sc.quit: sc.stopped <- true } } } }
c26493
true sc.lock.Unlock() if start { sc.start <- true } }
c26494
false sc.lock.Unlock() if quit { sc.quit <- true } }
c26495
ok := componentNames[sc]; ok { return name } return "(unknown)" }
c26496
"RADIUS" case HCTypeTCP: return "TCP" // TODO(angusc): Drop TCPTLS as a separate type. case HCTypeTCPTLS: return "TCP" // NB: Not TCPTLS case HCTypeUDP: return "UDP" } return "(unknown)" }
c26497
fmt.Sprintf("%v (%v)", v.IP, v.Type) }
c26498
vipSubnets): vipType = DedicatedVIP } return &VIP{ IP: NewIP(ip), Type: vipType, } }
c26499
nip.To16()) return ip }