/usr/share/gocode/src/github.com/docker/libnetwork/drivers/windows/overlay/peerdb_windows.go is in golang-github-docker-libnetwork-dev 0.8.0-dev.2+git20170202.599.45b4086-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | package overlay
import (
"fmt"
"net"
"encoding/json"
"github.com/Sirupsen/logrus"
"github.com/Microsoft/hcsshim"
"github.com/docker/libnetwork/types"
)
const ovPeerTable = "overlay_peer_table"
func (d *driver) pushLocalDb() {
if !d.isSerfAlive() {
return
}
d.Lock()
networks := d.networks
d.Unlock()
for _, n := range networks {
n.Lock()
endpoints := n.endpoints
n.Unlock()
for _, ep := range endpoints {
if !ep.remote {
d.notifyCh <- ovNotify{
action: "join",
nw: n,
ep: ep,
}
}
}
}
}
func (d *driver) peerAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error {
logrus.Debugf("WINOVERLAY: Enter peerAdd for ca ip %s with ca mac %s", peerIP.String(), peerMac.String())
if err := validateID(nid, eid); err != nil {
return err
}
n := d.network(nid)
if n == nil {
return nil
}
if updateDb {
logrus.Info("WINOVERLAY: peerAdd: notifying HNS of the REMOTE endpoint")
hnsEndpoint := &hcsshim.HNSEndpoint{
VirtualNetwork: n.hnsId,
MacAddress: peerMac.String(),
IPAddress: peerIP,
IsRemoteEndpoint: true,
}
paPolicy, err := json.Marshal(hcsshim.PaPolicy{
Type: "PA",
PA: vtep.String(),
})
if err != nil {
return err
}
hnsEndpoint.Policies = append(hnsEndpoint.Policies, paPolicy)
configurationb, err := json.Marshal(hnsEndpoint)
if err != nil {
return err
}
// Temp: We have to create a endpoint object to keep track of the HNS ID for
// this endpoint so that we can retrieve it later when the endpoint is deleted.
// This seems unnecessary when we already have dockers EID. See if we can pass
// the global EID to HNS to use as it's ID, rather than having each HNS assign
// it's own local ID for the endpoint
addr, err := types.ParseCIDR(peerIP.String() + "/32")
if err != nil {
return err
}
n.removeEndpointWithAddress(addr)
hnsresponse, err := hcsshim.HNSEndpointRequest("POST", "", string(configurationb))
if err != nil {
return err
}
ep := &endpoint{
id: eid,
nid: nid,
addr: addr,
mac: peerMac,
profileId: hnsresponse.Id,
remote: true,
}
n.addEndpoint(ep)
if err := d.writeEndpointToStore(ep); err != nil {
return fmt.Errorf("failed to update overlay endpoint %s to local store: %v", ep.id[0:7], err)
}
}
return nil
}
func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask,
peerMac net.HardwareAddr, vtep net.IP, updateDb bool) error {
logrus.Infof("WINOVERLAY: Enter peerDelete for endpoint %s and peer ip %s", eid, peerIP.String())
if err := validateID(nid, eid); err != nil {
return err
}
n := d.network(nid)
if n == nil {
return nil
}
ep := n.endpoint(eid)
if ep == nil {
return fmt.Errorf("could not find endpoint with id %s", eid)
}
if updateDb {
_, err := hcsshim.HNSEndpointRequest("DELETE", ep.profileId, "")
if err != nil {
return err
}
n.deleteEndpoint(eid)
if err := d.deleteEndpointFromStore(ep); err != nil {
logrus.Debugf("Failed to delete stale overlay endpoint (%s) from store", ep.id[0:7])
}
}
return nil
}
|