Skip to content

Commit df6b405

Browse files
committed
libnetwork/d/overlay: drop initEncryption function
The (*driver).Join function does many things to set up overlay networking. One of the first things it does is call (*network).joinSandbox, which in turn calls (*driver).initSandboxPeerDB. The initSandboxPeerDB function iterates through the peer db to add entries to the VXLAN FDB, neighbor table and IPsec security association database in the kernel for all known peers on the overlay network. One of the last things the (*driver).Join function does is call (*driver).initEncryption. The initEncryption function iterates through the peer db to add entries to the IPsec security association database in the kernel for all known peers on the overlay network. But the preceding initSandboxPeerDB call already did that! The initEncryption function is redundant and can safely be removed. Signed-off-by: Cory Snider <[email protected]>
1 parent 713f887 commit df6b405

2 files changed

Lines changed: 0 additions & 39 deletions

File tree

libnetwork/drivers/overlay/encryption.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -113,41 +113,6 @@ func (e *encrMap) String() string {
113113
return b.String()
114114
}
115115

116-
// initEncryption sets up IPsec encryption parameters for all known peers on a network.
117-
func (d *driver) initEncryption(nid string) error {
118-
log.G(context.TODO()).Debugf("initEncryption(%.7s)", nid)
119-
120-
n := d.network(nid)
121-
if n == nil || !n.secure {
122-
return nil
123-
}
124-
125-
if len(d.keys) == 0 {
126-
return types.ForbiddenErrorf("encryption key is not present")
127-
}
128-
129-
nodes := map[netip.Addr]struct{}{}
130-
131-
if err := d.peerDbNetworkWalk(nid, func(_ netip.Addr, _ net.HardwareAddr, pEntry *peerEntry) bool {
132-
if !pEntry.isLocal() {
133-
nodes[pEntry.vtep] = struct{}{}
134-
}
135-
return false
136-
}); err != nil {
137-
log.G(context.TODO()).Warnf("Failed to retrieve list of participating nodes in overlay network %.5s: %v", nid, err)
138-
}
139-
140-
log.G(context.TODO()).Debugf("List of nodes: %s", nodes)
141-
142-
for rIP := range nodes {
143-
if err := d.setupEncryption(rIP); err != nil {
144-
log.G(context.TODO()).Warnf("Failed to program network encryption to remote peer %s: %v", rIP, err)
145-
}
146-
}
147-
148-
return nil
149-
}
150-
151116
// setupEncryption programs the encryption parameters for secure communication
152117
// between the local node and a remote node.
153118
func (d *driver) setupEncryption(remoteIP netip.Addr) error {

libnetwork/drivers/overlay/joinleave.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinf
121121

122122
d.peerAdd(nid, eid, ep.addr, ep.mac, netip.Addr{})
123123

124-
if err = d.initEncryption(nid); err != nil {
125-
log.G(ctx).Warn(err)
126-
}
127-
128124
buf, err := proto.Marshal(&PeerRecord{
129125
EndpointIP: ep.addr.String(),
130126
EndpointMAC: ep.mac.String(),

0 commit comments

Comments
 (0)