Beispiel #1
0
func updateDefaultGw(odb ovsdb.Ovsdb) {
	currMac, err := getMac("", quiltBridge)
	if err != nil {
		log.WithError(err).Errorf("failed to get MAC for %s", quiltBridge)
		return
	}

	if currMac != gatewayMAC {
		if err := odb.SetBridgeMac(quiltBridge, gatewayMAC); err != nil {
			log.WithError(err).Error("failed to set MAC for default gateway")
		}
	}

	if err := upLink("", quiltBridge); err != nil {
		log.WithError(err).Error("failed to up default gateway")
	}

	currIPs, err := listIP("", quiltBridge)
	if err != nil {
		log.WithError(err).Errorf("failed to list IPs")
		return
	}

	targetIPs := []string{gatewayIP + "/8"}
	if err := updateIPs("", quiltBridge, currIPs, targetIPs); err != nil {
		log.WithError(err).Errorf("failed to update IPs")
	}
}