axsh / openvnet

Data Center Level Virtual Network Toolkit based on Edge Overlaid Network using OpenFlow 1.3.
http://openvnet.org
GNU Lesser General Public License v3.0
74 stars 18 forks source link

New interface for static address translation #460

Open akry opened 8 years ago

akry commented 8 years ago

Current implementation requires users a bit cumbersome operations for NAT through wanedge. When the users create a NAT rule they need to know the mac_lease_uuid of a specific simulated interface and the route_link_uuid that links a virtual network and a physical network.

What I did is the following:

1) initial db setup (these are passed to vnctl)

datapaths add --uuid dp-1 --dpid 0x0000aaaaaaaaaaaa --node-id vna --display-name vna
datapaths add --uuid dp-2 --dpid 0x0000bbbbbbbbbbbb --node-id wanedge --display-name wanedge

mac_range_groups            add --uuid mrg-dpg
mac_range_groups mac_ranges add mrg-dpg --begin-mac-address 52:56:01:00:00:00 --end-mac-address 52:56:01:ff:ff:ff

networks add --uuid nw-vnet   --display-name vnet   --ipv4-network 10.100.0.0   --ipv4-prefix 24 --network-mode virtual
networks add --uuid nw-public   --display-name public   --ipv4-network 192.168.1.0   --ipv4-prefix 24 --network-mode physical
networks add --uuid nw-global   --display-name global   --ipv4-network 192.168.2.0   --ipv4-prefix 24 --network-mode physical

interfaces add --uuid if-dp1eth0 --port-name eth0 --network-uuid nw-public --mac-address 10:AA:00:00:00:01 --ipv4-address 192.168.1.2      --mode host --owner-datapath-uuid dp-1
interfaces add --uuid if-dp2eth0 --port-name eth0 --network-uuid nw-public --mac-address 10:AA:00:00:01:01 --ipv4-address 192.168.1.3      --mode host --owner-datapath-uuid dp-2
interfaces add --uuid if-dp2eth2 --port-name eth2 --network-uuid nw-global --mac-address 10:AA:00:00:01:02 --ipv4-address 192.168.2.3      --mode host --owner-datapath-uuid dp-2

datapaths networks add dp-1     nw-vnet     --interface-uuid if-dp1eth0
datapaths networks add dp-1     nw-public   --interface-uuid if-dp1eth0
datapaths networks add dp-2     nw-vnet     --interface-uuid if-dp2eth0
datapaths networks add dp-2     nw-public   --interface-uuid if-dp2eth0
datapaths networks add dp-2     nw-global   --interface-uuid if-dp2eth2

interfaces add --uuid if-v1 --port-name if-v1 --network-uuid nw-vnet --mac-address 02:00:00:00:00:01 --ipv4-address 10.100.0.10 --mode vif
interfaces add --uuid if-v2 --port-name if-v2 --network-uuid nw-vnet --mac-address 02:00:00:00:00:02 --ipv4-address 10.100.0.20 --mode vif

interfaces add --uuid if-vnetgw     --network-uuid nw-vnet   --mac-address 10:FE:00:00:00:00 --mode simulated --enable-routing true                                 --ipv4-address 10.100.0.1
interfaces add --uuid if-glo2vnetgw --network-uuid nw-global --mac-address 10:FE:00:00:00:01 --mode simulated --enable-routing true --enable-route-translation true --owner-datapath-uuid dp-2

route_links add --uuid rl-vnet1link1

datapaths route_links add dp-1 rl-vnet1link1 --interface-uuid if-dp1eth0
datapaths route_links add dp-2 rl-vnet1link1 --interface-uuid if-dp2eth0

routes add --uuid r-vnet1    --interface-uuid if-vnetgw     --route-link-uuid rl-vnet1link1 --network-uuid nw-vnet   --ipv4-network 10.100.0.0 --ipv4-prefix 24
routes add --uuid r-glo2vnet --interface-uuid if-glo2vnetgw --route-link-uuid rl-vnet1link1 --network-uuid nw-global --ipv4-network 0.0.0.0    --ipv4-prefix 0

translations add --uuid tr-saddr --interface-uuid if-glo2vnetgw --mode static_address  --passthrough true

translations static_address add tr-saddr --ingress-ipv4-address 192.168.2.4 --egress-ipv4-address 10.100.0.10 --route-link-uuid rl-vnet1link1

memorize route_link_uuid : rl-vnet1link1

2) lookup mac_lease_uuid of if-glo2vnetgw with either vnctl or mysql

$ vnctl mac_leases show
- :id: 7
  :uuid: ml-ecil1m8s
  :interface_id: 7
  :mac_address_id: 12
  :created_at: 2016-03-28 09:49:54.000000000 Z
  :updated_at: 2016-03-28 09:49:54.000000000 Z
  :deleted_at:
  :is_deleted: 0
  :mac_address: 10:fe:00:00:00:01
  :interface:
    :id: 7
    :uuid: if-glo2vnetgw
    :mode: simulated
    :display_name:
    :ingress_filtering_enabled: false
    :enable_routing: true
    :enable_route_translation: true
    :created_at: 2016-03-28 09:49:54.000000000 Z
    :updated_at: 2016-03-28 09:49:54.000000000 Z
    :deleted_at:
    :is_deleted: 0
    :enable_filtering: false
    :enable_legacy_filtering: false
  :interface_uuid: if-glo2vnetgw

or

$ mysql vnet -e "select * from mac_leases where is_deleted=0"
+----+----------+--------------+----------------+---------------------+---------------------+------------+------------+
| id | uuid     | interface_id | mac_address_id | created_at          | updated_at          | deleted_at | is_deleted |
+----+----------+--------------+----------------+---------------------+---------------------+------------+------------+
|  1 | mpyxvoeb |            1 |              1 | 2016-03-28 09:49:50 | 2016-03-28 09:49:50 | NULL       |          0 |
|  2 | 3px2qqkx |            2 |              2 | 2016-03-28 09:49:50 | 2016-03-28 09:49:50 | NULL       |          0 |
|  3 | j5m8zgft |            3 |              3 | 2016-03-28 09:49:51 | 2016-03-28 09:49:51 | NULL       |          0 |
|  4 | 4tx5hdmf |            4 |              9 | 2016-03-28 09:49:53 | 2016-03-28 09:49:53 | NULL       |          0 |
|  5 | 9nhtusqd |            5 |             10 | 2016-03-28 09:49:53 | 2016-03-28 09:49:53 | NULL       |          0 |
|  6 | 7fm7xv8c |            6 |             11 | 2016-03-28 09:49:53 | 2016-03-28 09:49:53 | NULL       |          0 |
|  7 | ecil1m8s |            7 |             12 | 2016-03-28 09:49:54 | 2016-03-28 09:49:54 | NULL       |          0 |
+----+----------+--------------+----------------+---------------------+---------------------+------------+------------+

memorize mac_lease_uuid : ml-ecil1m8s

3) create a nat rule with route_link_uuid and mac_lease_uuid

$ vnctl ip_leases add --uuid il-nat2 --mac-lease-uuid ml-ecil1m8s --ipv4-address 192.168.2.5 --network-uuid nw-global --enable-routing true
$ vnctl translations static_address add tr-saddr --ingress-ipv4-address 192.168.2.5 --egress-ipv4-address 10.100.0.20 --route-link-uuid rl-vnet1link1

We need a sort of interface with which the users specify only ingress_ipv4_address and egress_ipv4_address like the following

$ vnctl translations static_address add tr-saddr --ingress-ipv4-address 192.168.2.5 --egress-ipv4-address 10.100.0.20

Here vnmgr selects the proper uuid of route_link and create ip_lease for if-glo2vnet based on the parameters passed to vnctl. We might need more information otherwise it's very hard to guess.

akry commented 8 years ago
$ vnctl translations static_address add tr-saddr \
       --ingress-ipv4-address 192.168.2.5 \
       --egress-ipv4-address 10.100.0.20 \
       --ingress-network-uuid nw-global \
       --egress-network-uuid nw-vnet
---
:id: 3
:translation_id: 1
:route_link_id: 1
:ingress_ipv4_address: 192.168.2.5
:egress_ipv4_address: 10.100.0.20
:ingress_port_number:
:egress_port_number:
:created_at: 2016-xx-yy 00:16:55.000000000 Z
:updated_at: 2016-xx-yy 00:16:55.000000000 Z
:deleted_at:
:is_deleted: 0