Skip to content

Commit

Permalink
Changed ipMask to string
Browse files Browse the repository at this point in the history
Avoid error logs in case of local peer case, there is no need for deleteNeighbor
Avoid the network leave to readvertise already deleted entries to upper layer

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
  • Loading branch information
Flavio Crisciani committed Oct 3, 2017
1 parent b12d63c commit d93b9b0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
6 changes: 3 additions & 3 deletions drivers/overlay/ov_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
continue
}
n.driver.peerAdd(n.id, "dummy", ip, IPmask, mac, vtep, l2Miss, l3Miss, false)
} else if l3Miss && time.Since(t) > 500*time.Millisecond {
} else if l3Miss && time.Since(t) > time.Second {
// All the local peers will trigger a miss notification but this one is expected and the local container will reply
// autonomously to the ARP request
// In case the gc_thresh3 values is low kernel might reject new entries during peerAdd. This will trigger the following
Expand All @@ -778,9 +778,9 @@ func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
// Entries which are marked as permanent are never deleted by the garbage-collector.
// The time limit here is to guarantee that the dbSearch is not
// done too frequently causing a stall of the peerDB operations.
t = time.Now()
pKey, pEntry, err := n.driver.peerDbSearch(n.id, ip)
if !pEntry.isLocal {
if err == nil && !pEntry.isLocal {
t = time.Now()
logrus.Warnf("miss notification for peer:%+v l3Miss:%t l2Miss:%t, if the problem persist check the gc_thresh on the host pKey:%+v pEntry:%+v err:%v",
neigh, l3Miss, l2Miss, *pKey, *pEntry, err)
}
Expand Down
46 changes: 23 additions & 23 deletions drivers/overlay/peerdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,29 @@ type peerEntry struct {
}

func (p *peerEntry) MarshalDB() peerEntryDB {
ones, bits := p.peerIPMask.Size()
return peerEntryDB{
eid: p.eid,
vtep: p.vtep.String(),
isLocal: p.isLocal,
peerIPMaskOnes: ones,
peerIPMaskBits: bits,
eid: p.eid,
vtep: p.vtep.String(),
peerIPMask: p.peerIPMask.String(),
isLocal: p.isLocal,
}
}

// This the structure saved into the set (SetMatrix), due to the implementation of it
// the value inserted in the set has to be Hashable so the []byte had to be converted into
// strings
type peerEntryDB struct {
eid string
vtep string
peerIPMaskOnes int
peerIPMaskBits int
isLocal bool
eid string
vtep string
peerIPMask string
isLocal bool
}

func (p *peerEntryDB) UnMarshalDB() peerEntry {
return peerEntry{
eid: p.eid,
vtep: net.ParseIP(p.vtep),
peerIPMask: net.CIDRMask(p.peerIPMaskOnes, p.peerIPMaskBits),
peerIPMask: net.IPMask(net.ParseIP(p.peerIPMask)),
isLocal: p.isLocal,
}
}
Expand Down Expand Up @@ -454,19 +451,22 @@ func (d *driver) peerDeleteOp(nid, eid string, peerIP net.IP, peerIPMask net.IPM
logrus.Warn(err)
}

// Remove fdb entry to the bridge for the peer mac
if err := sbox.DeleteNeighbor(vtep, peerMac, true); err != nil {
if _, ok := err.(osl.NeighborSearchError); ok && dbEntries > 0 {
// We fall in here if there is a transient state and if the neighbor that is being deleted
// was never been configured into the kernel (we allow only 1 configuration at the time per <ip,mac> mapping)
return nil
// Local peers do not have any local configuration to delete
if !localPeer {
// Remove fdb entry to the bridge for the peer mac
if err := sbox.DeleteNeighbor(vtep, peerMac, true); err != nil {
if _, ok := err.(osl.NeighborSearchError); ok && dbEntries > 0 {
// We fall in here if there is a transient state and if the neighbor that is being deleted
// was never been configured into the kernel (we allow only 1 configuration at the time per <ip,mac> mapping)
return nil
}
return fmt.Errorf("could not delete fdb entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
}
return fmt.Errorf("could not delete fdb entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
}

// Delete neighbor entry for the peer IP
if err := sbox.DeleteNeighbor(peerIP, peerMac, true); err != nil {
return fmt.Errorf("could not delete neighbor entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
// Delete neighbor entry for the peer IP
if err := sbox.DeleteNeighbor(peerIP, peerMac, true); err != nil {
return fmt.Errorf("could not delete neighbor entry for nid:%s eid:%s into the sandbox:%v", nid, eid, err)
}
}

if dbEntries == 0 {
Expand Down
5 changes: 4 additions & 1 deletion networkdb/networkdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,10 @@ func (nDB *NetworkDB) deleteNodeNetworkEntries(nid, node string) {
nDB.deleteEntry(nid, tname, key)
}

nDB.broadcaster.Write(makeEvent(opDelete, tname, nid, key, entry.value))
// Notify to the upper layer only entries not already marked for deletion
if !oldEntry.deleting {
nDB.broadcaster.Write(makeEvent(opDelete, tname, nid, key, entry.value))
}
return false
})
}
Expand Down

0 comments on commit d93b9b0

Please sign in to comment.