func (c *controller) agentDriverNotify(d driverapi.Driver) { if c.agent == nil { return } d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{ Address: c.agent.advertiseAddr, BindAddress: c.agent.bindAddr, Self: true, }) drvEnc := discoverapi.DriverEncryptionConfig{} keys, tags := c.getKeys(subsysIPSec) drvEnc.Keys = keys drvEnc.Tags = tags c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool { err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc) if err != nil { logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err) } return false }) }
func (c *controller) agentDriverNotify(d driverapi.Driver) { if c.agent == nil { return } d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{ Address: c.agent.bindAddr, Self: true, }) drvEnc := discoverapi.DriverEncryptionConfig{} for _, key := range c.keys { if key.Subsystem == "networking:gossip" /*"networking:ipsec"*/ { drvEnc.Keys = append(drvEnc.Keys, hex.EncodeToString(key.Key)) drvEnc.Tags = append(drvEnc.Tags, strconv.FormatUint(key.LamportTime, 10)) } } c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool { err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc) if err != nil { logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err) } return false }) }
func (c *controller) agentInit(bindAddrOrInterface string) error { if !c.isAgent() { return nil } drvEnc := discoverapi.DriverEncryptionConfig{} // sort the keys by lamport time sort.Sort(ByTime(c.keys)) gossipkey := [][]byte{} for _, key := range c.keys { if key.Subsystem == "networking:gossip" { gossipkey = append(gossipkey, key.Key) } if key.Subsystem == "networking:gossip" /*"networking:ipsec"*/ { drvEnc.Keys = append(drvEnc.Keys, hex.EncodeToString(key.Key)) drvEnc.Tags = append(drvEnc.Tags, strconv.FormatUint(key.LamportTime, 10)) } } bindAddr, err := resolveAddr(bindAddrOrInterface) if err != nil { return err } hostname, _ := os.Hostname() nDB, err := networkdb.New(&networkdb.Config{ BindAddr: bindAddr, NodeName: hostname, Keys: gossipkey, }) if err != nil { return err } ch, cancel := nDB.Watch("endpoint_table", "", "") c.agent = &agent{ networkDB: nDB, bindAddr: bindAddr, epTblCancel: cancel, driverCancelFuncs: make(map[string][]func()), } go c.handleTableEvents(ch, c.handleEpTableEvent) c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool { err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc) if err != nil { logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err) } return false }) return nil }
func (c *controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr string) error { if !c.isAgent() { return nil } bindAddr, err := resolveAddr(bindAddrOrInterface) if err != nil { return err } keys, tags := c.getKeys(subsysGossip) hostname, _ := os.Hostname() nodeName := hostname + "-" + stringid.TruncateID(stringid.GenerateRandomID()) logrus.Info("Gossip cluster hostname ", nodeName) nDB, err := networkdb.New(&networkdb.Config{ BindAddr: listenAddr, AdvertiseAddr: advertiseAddr, NodeName: nodeName, Keys: keys, }) if err != nil { return err } ch, cancel := nDB.Watch("endpoint_table", "", "") c.Lock() c.agent = &agent{ networkDB: nDB, bindAddr: bindAddr, advertiseAddr: advertiseAddr, epTblCancel: cancel, driverCancelFuncs: make(map[string][]func()), } c.Unlock() go c.handleTableEvents(ch, c.handleEpTableEvent) drvEnc := discoverapi.DriverEncryptionConfig{} keys, tags = c.getKeys(subsysIPSec) drvEnc.Keys = keys drvEnc.Tags = tags c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool { err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc) if err != nil { logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err) } return false }) c.WalkNetworks(joinCluster) return nil }
func (c *controller) agentInit(bindAddrOrInterface string) error { if !c.isAgent() { return nil } drvEnc := discoverapi.DriverEncryptionConfig{} keys, tags := c.getKeys(subsysGossip) // getKeys(subsysIPSec) drvEnc.Keys = keys drvEnc.Tags = tags bindAddr, err := resolveAddr(bindAddrOrInterface) if err != nil { return err } hostname, _ := os.Hostname() nDB, err := networkdb.New(&networkdb.Config{ BindAddr: bindAddr, NodeName: hostname, Keys: keys, }) if err != nil { return err } ch, cancel := nDB.Watch("endpoint_table", "", "") c.agent = &agent{ networkDB: nDB, bindAddr: bindAddr, epTblCancel: cancel, driverCancelFuncs: make(map[string][]func()), } go c.handleTableEvents(ch, c.handleEpTableEvent) c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool { err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc) if err != nil { logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err) } return false }) return nil }