Merge branch '1.5'

This commit is contained in:
Matthias Radestock committed 2016-05-07 14:43:04 +01:00
commit ac0f284c5f
3 files changed
+17 -11

No files matched your search

+2 -1
View File
@@ -45,6 +45,7 @@ func WithNetNS(ns netns.NsHandle, work func() error) error {
} }
type NetDev struct { type NetDev struct {
Name string
MAC net.HardwareAddr MAC net.HardwareAddr
CIDRs []*net.IPNet CIDRs []*net.IPNet
} }
@@ -97,7 +98,7 @@ func linkToNetDev(link netlink.Link) (*NetDev, error) {
return nil, err return nil, err
} }
netDev := &NetDev{MAC: link.Attrs().HardwareAddr} netDev := &NetDev{Name: link.Attrs().Name, MAC: link.Attrs().HardwareAddr}
for _, addr := range addrs { for _, addr := range addrs {
netDev.CIDRs = append(netDev.CIDRs, addr.IPNet) netDev.CIDRs = append(netDev.CIDRs, addr.IPNet)
} }
+1 -1
View File
@@ -27,7 +27,7 @@ func containerAddrs(args []string) error {
} }
for _, netDev := range netDevs { for _, netDev := range netDevs {
fmt.Printf("%12s %s", containerID, netDev.MAC.String()) fmt.Printf("%12s %s %s", containerID, netDev.Name, netDev.MAC.String())
for _, cidr := range netDev.CIDRs { for _, cidr := range netDev.CIDRs {
prefixLength, _ := cidr.Mask.Size() prefixLength, _ := cidr.Mask.Size()
fmt.Printf(" %v/%v", cidr.IP, prefixLength) fmt.Printf(" %v/%v", cidr.IP, prefixLength)
+14 -9
View File
@@ -1143,23 +1143,23 @@ with_container_addresses() {
shift 1 shift 1
CONTAINER_ADDRS=$(util_op container-addrs $BRIDGE "$@") || return 1 CONTAINER_ADDRS=$(util_op container-addrs $BRIDGE "$@") || return 1
echo "$CONTAINER_ADDRS" | while read CONTAINER_ID CONTAINER_MAC CONTAINER_IPS; do echo "$CONTAINER_ADDRS" | while read CONTAINER_ID CONTAINER_IFACE CONTAINER_MAC CONTAINER_IPS; do
$COMMAND "$CONTAINER_ID" "$CONTAINER_MAC" "$CONTAINER_IPS" $COMMAND "$CONTAINER_ID" "$CONTAINER_IFACE" "$CONTAINER_MAC" "$CONTAINER_IPS"
done done
} }
echo_addresses() { echo_addresses() {
echo $1 $2 $3 echo $1 $3 $4
} }
echo_ips() { echo_ips() {
for CIDR in $3; do for CIDR in $4; do
echo ${3%/*} echo ${CIDR%/*}
done done
} }
echo_cidrs() { echo_cidrs() {
echo $3 echo $4
} }
peer_args() { peer_args() {
@@ -1382,13 +1382,18 @@ check_overlap() {
# Claim addresses for a container in IPAM. Expects to be called from # Claim addresses for a container in IPAM. Expects to be called from
# with_container_addresses. # with_container_addresses.
ipam_reclaim() { ipam_reclaim() {
for CIDR in $3 ; do CONTAINER_ID="$1"
http_call $HTTP_ADDR PUT "/ip/$1/$CIDR?noErrorOnUnknown=true&?check-alive=true" || true # The weave IP addresses of containers attached by the plugin are
# recorded specially in IPAM, since the container id is not know
# at the time.
[ "$2" = "$CONTAINER_IFNAME" ] || CONTAINER_ID="_"
for CIDR in $4 ; do
http_call $HTTP_ADDR PUT "/ip/$CONTAINER_ID/$CIDR?noErrorOnUnknown=true&?check-alive=true" || true
done done
} }
ipam_reclaim_no_check_alive() { ipam_reclaim_no_check_alive() {
for CIDR in $3 ; do for CIDR in $4 ; do
http_call $HTTP_ADDR PUT /ip/$1/$CIDR?noErrorOnUnknown=true || true http_call $HTTP_ADDR PUT /ip/$1/$CIDR?noErrorOnUnknown=true || true
done done
} }