contrail
| /trunk/resource/vin/interface-configs/iproute2-host/remove-iproute2-host-route.conf |
|---|
| 6,15 → 6,16 |
| # network, <remote-ip> is a remote VM IP address and <tunnel> is a name |
| # of an interface through which traffic has been routed. |
| parameters BR_NAME LOC_IP_ADDR LOC_NETMASK REM_IP_ADDR TUNNEL |
| parameters BR_NAME LOC_IP_ADDR NETMASKBITS REM_IP_ADDR TUNNEL |
| #parameter sanity checks |
| assertmatch [[:alnum:]_-]+ $(BR_NAME) |
| assertmatch [[:xdigit:]:.]+ $(LOC_IP_ADDR) |
| assertmatch [[:xdigit:]:.]+ $(LOC_NETMASK) |
| assertmatch [[:xdigit:]:.]+ $(REM_IP_ADDR) |
| assertmatch [[:alnum:]]+ $(TUNNEL) |
| assertmatch [[:digit:]][[:digit:]]? $(NETMASKBITS) |
| #remove routing entry |
| run /bin/ip route del $(REM_IP_ADDR) dev $(TUNNEL) |
| run /bin/ip address del $(LOC_IP_ADDR) dev $(TUNNEL) |
| 22,8 → 23,8 |
| run /bin/ip tunnel del name $(BR_NAME) |
| #remove iptable rules |
| run /sbin/iptables -D FORWARD -s $(LOC_IP_ADDR)/$(LOC_NETMASK) -d $(REM_IP_ADDR)/32) -i $(BR_NAME) -o $(TUNNEL) -j ACCEPT |
| run /sbin/iptables -D FORWARD -s $(REM_IP_ADDR)/32 -d $(LOC_IP_ADDR)/$(LOC_NETMASK) -i $(TUNNEL) -o $(BR_NAME) -j ACCEPT |
| run /sbin/iptables -D FORWARD -s $(LOC_IP_ADDR)/$(NETMASKBITS) -d $(REM_IP_ADDR)/32 -i $(BR_NAME) -o $(TUNNEL) -j ACCEPT |
| run /sbin/iptables -D FORWARD -s $(REM_IP_ADDR)/32 -d $(LOC_IP_ADDR)/$(NETMASKBITS) -i $(TUNNEL) -o $(BR_NAME) -j ACCEPT |
| debugrun /bin/ip tunnel show |
| debugprint |
| /trunk/resource/vin/interface-configs/iproute2-host/add-iproute2-host-route.conf |
|---|
| 8,10 → 8,10 |
| # MODE: The tunneling mode to use |
| # REMOTE: The address of the remote host |
| # LOCAL: The address of the local VIN address |
| # NETMASK: The netmask of the VIN network |
| # NETMASKBITS: The netmask bits of the VIN network |
| # DESTINATION: The address of the remote VIN address |
| # BR_NAME: Name of the bridge device |
| parameters TUNNEL MODE REMOTE LOCAL NETMASK DESTINATION BR_NAME |
| parameters TUNNEL MODE REMOTE LOCAL NETMASKBITS DESTINATION BR_NAME |
| # Do a sanity check on the parameters to make sure no nasty |
| # games are played, for example by adding a space and an |
| 30,22 → 30,28 |
| assertmatch [[:xdigit:]:.]+ $(REMOTE) |
| assertmatch [[:xdigit:]:.]+ $(LOCAL) |
| assertmatch [[:xdigit:]:.]+ $(DESTINATION) |
| assertmatch [[:xdigit:]:.]+ $(NETMASK) |
| # Netmaskbits is an integer with one or two digits |
| assertmatch [[:digit:]][[:digit:]]? $(NETMASKBITS) |
| assertmatch [[:alnum:]_-]+ $(BR_NAME) |
| debugprint "TUNNEL=$(TUNNEL) MODE=$(MODE) REMOTE=$(REMOTE) LOCAL=$(LOCAL) NETMASK=$(NETMASK) DESTINATION=$(DESTINATION) BR_NAME=$(BR_NAME)" |
| debugprint "TUNNEL=$(TUNNEL) MODE=$(MODE) REMOTE=$(REMOTE) LOCAL=$(LOCAL) NETMASKBITS=$(NETMASKBITS) DESTINATION=$(DESTINATION) BR_NAME=$(BR_NAME)" |
| run /bin/ip tunnel add name $(TUNNEL) remote $(REMOTE) mode $(MODE) |
| debugprint Created tunnel '$(TUNNEL)': |
| debugrun /bin/ip tunnel show |
| run /bin/ip address add $(LOCAL) dev $(TUNNEL) |
| debugprint Assigned address '$(LOCAL)' to tunnel '$(TUNNEL)': |
| run /bin/ip link set $(TUNNEL) up |
| debugprint Started tunnel $(TUNNEL) |
| #add routing entry |
| run /bin/ip route add $(REMOTE) dev $(TUNNEL) |
| #add iptable rules |
| run /sbin/iptables -I FORWARD 1 -s $(LOCAL)/$(NETMASK) -d $(REMOTE)/32 -i $(BR_NAME) -o $(TUNNEL) -j ACCEPT |
| run /sbin/iptables -I FORWARD 1 -s $(REMOTE)/32 -d $(LOCAL)/$(NETMASK) -i $(TUNNEL) -o $(BR_NAME) -j ACCEPT |
| run /sbin/iptables -I FORWARD 1 -s $(LOCAL)/$(NETMASKBITS) -d $(REMOTE)/32 -i $(BR_NAME) -o $(TUNNEL) -j ACCEPT |
| run /sbin/iptables -I FORWARD 1 -s $(REMOTE)/32 -d $(LOCAL)/$(NETMASKBITS) -i $(TUNNEL) -o $(BR_NAME) -j ACCEPT |
| debugrun /bin/ip tunnel show |
| debugrun /bin/ip address show |
| /trunk/resource/vin/src/org/ow2/contrail/resource/vin/common/Inet4Subnet.java |
|---|
| 104,4 → 104,8 |
| // FIXME: more accurate implementation |
| return 1L << maskBits; |
| } |
| public String getNetmaskBitsString() { |
| return Integer.toString(maskBits); |
| } |
| } |
| /trunk/resource/vin/src/org/ow2/contrail/resource/vin/agent/Iproute2HostNetworkHandler.java |
|---|
| 148,7 → 148,7 |
| Utils.cleanlyRunConfig(safeconfigPath, debug, configDir, |
| CREATE_CONNECTION_CONFIG_NAME, tunnelName, tunnelMode, |
| remote.getHostAddressString(), local.getVINAddressString(), |
| local.network.subnet.getNetmaskString(), |
| local.network.subnet.getNetmaskBitsString(), |
| remote.getVINAddressString(), bridgeName); |
| logger.trace("connection created: local=" + local + " remote=" + remote); |
| } |
| 165,7 → 165,7 |
| Utils.cleanlyRunConfig(safeconfigPath, debug, configDir, |
| REMOVE_CONNECTION_CONFIG_NAME, bridgeName, |
| local.getVINAddressString(), |
| local.network.subnet.getNetmaskString(), |
| local.network.subnet.getNetmaskBitsString(), |
| remote.getVINAddressString(), tunnelName); |
| logger.trace("connection removed: local=" + local + " remote=" + remote); |
| } |