Message ID | CAON-bUVx1KHkdDN_+7ZUKW=qV8SCpn+7BnLsL0yxc0nsT2s2SA@mail.gmail.com |
---|---|
State | Not Applicable |
Headers | show |
I was not able to apply this patch - can you fix this Also, can you make sure the OVN vtep GW test passes (using make check) with the patch submitted 2043: ovn.at:1029 ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS vtep The changes to vtep.xml are hard to follow; also I am not sure they are required as there is already documentation for Per Logical_Switch+Physical_Locator pair tunnel keys. On Tue, Jun 7, 2016 at 1:19 AM, Itamar Ofek <itamar.ofeq@gmail.com> wrote: > This patch adds support for handeling a per-tunnel tunnel key in the > ovs-vtep and vtep-ctl to support the usage of neutron L2GW as an > inter-cloud > gateway. > > The Neutron spec is available here: > https://review.openstack.org/#/c/270786/ > > Requested-by: "Ofer Ben-Yacov" <ofer.benyacov@gmail.com> > Signed-off-by: "Itamar Ofek" <itamar.ofeq@gmail.com> > --- > tests/vtep-ctl.at | 132 > +++++++++++++++++++++++++-------------------------- > vtep/ovs-vtep | 52 +++++++++++++------- > vtep/vtep-ctl.c | 138 > +++++++++++++++++++++++++++++++++++------------------- > vtep/vtep.xml | 10 +++- > 4 files changed, 200 insertions(+), 132 deletions(-) > > diff --git a/tests/vtep-ctl.at b/tests/vtep-ctl.at > index f0511ad..b7803c3 100644 > --- a/tests/vtep-ctl.at > +++ b/tests/vtep-ctl.at > @@ -437,8 +437,8 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-local > > @@ -464,7 +464,7 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-local > > @@ -484,8 +484,8 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-local > > @@ -495,7 +495,7 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-local > > @@ -515,8 +515,8 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-remote > > @@ -542,7 +542,7 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-remote > > @@ -562,8 +562,8 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-remote > > @@ -573,7 +573,7 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-remote > > @@ -595,16 +595,16 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-local > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > - 02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > mcast-mac-remote > > @@ -627,9 +627,9 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > > mcast-mac-local > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > @@ -657,10 +657,10 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > > mcast-mac-local > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL( > @@ -670,9 +670,9 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > > mcast-mac-local > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > VTEP_CTL_CLEANUP > @@ -693,9 +693,9 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > > mcast-mac-remote > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > @@ -723,10 +723,10 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > > mcast-mac-remote > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL( > @@ -736,9 +736,9 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > > mcast-mac-remote > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > VTEP_CTL_CLEANUP > @@ -762,18 +762,18 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > > mcast-mac-local > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > > mcast-mac-remote > - 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 03:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 03:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > VTEP_CTL_CLEANUP > @@ -797,22 +797,22 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > > mcast-mac-local > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > > mcast-mac-remote > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL( > @@ -825,12 +825,12 @@ mcast-mac-local > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > > mcast-mac-remote > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > VTEP_CTL_CLEANUP > @@ -854,34 +854,34 @@ AT_CHECK([RUN_VTEP_CTL( > ], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > > mcast-mac-local > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > [ucast-mac-remote > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > > mcast-mac-remote > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL( > [clear-remote-macs ls1])], [0], [], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], > [ucast-mac-local > - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > > mcast-mac-local > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 > - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 > - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] > + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] > + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] > > ], [], [VTEP_CTL_CLEANUP]) > AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], > diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep > index e52c66f..59b76db 100755 > --- a/vtep/ovs-vtep > +++ b/vtep/ovs-vtep > @@ -175,11 +175,25 @@ class Logical_Switch(object): > del self.ports[lbinding] > self.update_flood() > > + def tunnel_dict(self,entry): > + return { > + 'tunnel_type': entry[2], > + 'dest_ip': entry[3], > + 'tunnel_key': entry[4], > + } > + > def add_tunnel(self, tunnel): > global tun_id > - vlog.info("adding tunnel %s" % tunnel) > - encap, ip = tunnel.split("/") > - > + use_self_key = False > + tunnel_key = tunnel['tunnel_key'] > + if not tunnel_key: > + use_self_key = True > + tunnel_key = self.tunnel_key > + vlog.info("adding tunnel %s key %s" % (tunnel['dest_ip'], > + tunnel_key)) > + > + encap = tunnel['tunnel_type'] > + ip = tunnel['dest_ip'] > if encap != "vxlan_over_ipv4": > vlog.warn("unsupported tunnel format %s" % encap) > return > @@ -189,7 +203,7 @@ class Logical_Switch(object): > > ovs_vsctl("add-port %s %s -- set Interface %s type=vxlan " > "options:key=%s options:remote_ip=%s" > - % (self.short_name, tun_name, tun_name, self.tunnel_key, > ip)) > + % (self.short_name, tun_name, tun_name, tunnel_key, ip)) > > for i in range(10): > port_no = ovs_vsctl("get Interface %s ofport" % tun_name) > @@ -203,10 +217,13 @@ class Logical_Switch(object): > # Give the system a moment to allocate the port number > time.sleep(0.5) > > - self.tunnels[tunnel] = (port_no, tun_name, ip) > + self.tunnels[ip] = (port_no, > + tun_name, > + ip, > + tunnel['tunnel_key']) > > add_bfd(ip) > - > + > ovs_ofctl("add-flow %s table=0,priority=1000,in_port=%s," > "actions=resubmit(,1)" > % (self.short_name, port_no)) > @@ -256,7 +273,7 @@ class Logical_Switch(object): > def update_remote_macs(self): > remote_macs = {} > unknown_dsts = set() > - tunnels = set() > + tunnels = {} > parse_ucast = True > > mac_list = vtep_ctl("list-remote-macs %s" % self.name > ).splitlines() > @@ -264,32 +281,31 @@ class Logical_Switch(object): > if (line.find("mcast-mac-remote") != -1): > parse_ucast = False > continue > - > - entry = re.split(r' (.*) -> (.*)', line) > - if len(entry) != 4: > + entry = re.split(r' (.*) -> (.*)/(.*) \[(.*)\]', line) > + if len(entry) != 6: > continue > > if parse_ucast: > - remote_macs[entry[1]] = entry[2] > + remote_macs[entry[1]] = self.tunnel_dict(entry) > else: > if entry[1] != "unknown-dst": > continue > > - unknown_dsts.add(entry[2]) > + unknown_dsts.add(entry[3]) > > - tunnels.add(entry[2]) > + tunnels[entry[3]]= self.tunnel_dict(entry) > > old_tunnels = set(self.tunnels.keys()) > + tunnels_keys = set(tunnels.keys()) > + for tunnel in tunnels_keys.difference(old_tunnels): > + self.add_tunnel(tunnels[tunnel]) > > - for tunnel in tunnels.difference(old_tunnels): > - self.add_tunnel(tunnel) > - > - for tunnel in old_tunnels.difference(tunnels): > + for tunnel in old_tunnels.difference(tunnels_keys): > self.del_tunnel(tunnel) > > for mac in six.iterkeys(remote_macs): > if (self.remote_macs.get(mac) != remote_macs[mac]): > - self.add_remote_mac(mac, remote_macs[mac]) > + self.add_remote_mac(mac, remote_macs[mac]['dest_ip']) > > for mac in six.iterkeys(self.remote_macs): > if mac not in remote_macs: > diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c > index 5c18971..e09425c 100644 > --- a/vtep/vtep-ctl.c > +++ b/vtep/vtep-ctl.c > @@ -345,18 +345,18 @@ Logical Router commands:\n\ > lr-exists LR exit 2 if LR does not exist\n\ > \n\ > MAC binding commands:\n\ > - add-ucast-local LS MAC [ENCAP] IP add ucast local entry in LS\n\ > - del-ucast-local LS MAC del ucast local entry from LS\n\ > - add-mcast-local LS MAC [ENCAP] IP add mcast local entry in LS\n\ > - del-mcast-local LS MAC [ENCAP] IP del mcast local entry from LS\n\ > - clear-local-macs LS clear local mac entries\n\ > - list-local-macs LS list local mac entries\n\ > - add-ucast-remote LS MAC [ENCAP] IP add ucast remote entry in LS\n\ > - del-ucast-remote LS MAC del ucast remote entry from LS\n\ > - add-mcast-remote LS MAC [ENCAP] IP add mcast remote entry in LS\n\ > - del-mcast-remote LS MAC [ENCAP] IP del mcast remote entry from LS\n\ > - clear-remote-macs LS clear remote mac entries\n\ > - list-remote-macs LS list remote mac entries\n\ > + add-ucast-local LS MAC [ENCAP] IP [KEY] add ucast local entry in LS\n\ > + del-ucast-local LS MAC del ucast local entry > from LS\n\ > + add-mcast-local LS MAC [ENCAP] IP [KEY] add mcast local entry in LS\n\ > + del-mcast-local LS MAC [ENCAP] IP del mcast local entry > from LS\n\ > + clear-local-macs LS clear local mac > entries\n\ > + list-local-macs LS list local mac > entries\n\ > + add-ucast-remote LS MAC [ENCAP] IP [KEY] add ucast remote entry in > LS\n\ > + del-ucast-remote LS MAC del ucast remote entry > from LS\n\ > + add-mcast-remote LS MAC [ENCAP] IP [KEY] add mcast remote entry in > LS\n\ > + del-mcast-remote LS MAC [ENCAP] IP del mcast remote entry > from LS\n\ > + clear-remote-macs LS clear remote mac > entries\n\ > + list-remote-macs LS list remote mac > entries\n\ > \n\ > %s\ > \n\ > @@ -451,6 +451,11 @@ struct vtep_ctl_context { > * struct vtep_ctl_lrouter. */ > }; > > +static bool is_valid_ip(const char* address) > +{ > + struct sockaddr_in sa; > + return inet_pton(AF_INET, address, &(sa.sin_addr)); > +} > /* Casts 'base' into 'struct vtep_ctl_context'. */ > static struct vtep_ctl_context * > vtep_ctl_context_cast(struct ctl_context *base) > @@ -887,7 +892,8 @@ pre_get_info(struct ctl_context *ctx) > &vteprec_physical_locator_col_dst_ip); > ovsdb_idl_add_column(ctx->idl, > > &vteprec_physical_locator_col_encapsulation_type); > - > + ovsdb_idl_add_column(ctx->idl, > + &vteprec_physical_locator_col_tunnel_key); > ovsdb_idl_add_column(ctx->idl, &vteprec_tunnel_col_local); > ovsdb_idl_add_column(ctx->idl, &vteprec_tunnel_col_remote); > } > @@ -1653,27 +1659,43 @@ add_ucast_entry(struct ctl_context *ctx, bool > local) > { > struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); > struct vtep_ctl_lswitch *ls; > - const char *mac; > - const char *encap; > - const char *dst_ip; > + const char *mac = 0; > + const char *encap = 0; > + const char *dst_ip = 0; > + const char *tunnel_key = 0; > struct vteprec_physical_locator *ploc_cfg; > > vtep_ctl_context_populate_cache(ctx); > > ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); > mac = ctx->argv[2]; > - > - if (ctx->argc == 4) { > - encap = "vxlan_over_ipv4"; > - dst_ip = ctx->argv[3]; > - } else { > - encap = ctx->argv[3]; > - dst_ip = ctx->argv[4]; > + switch (ctx->argc) > + { > + case 6: > + tunnel_key = ctx->argv[5]; > + case 5: > + if (is_valid_ip(ctx->argv[4])){ > + dst_ip = ctx->argv[4]; > + encap = ctx->argv[3]; > + break; > + } > + tunnel_key = ctx->argv[4]; > + case 4: > + dst_ip = ctx->argv[3]; > + encap = "vxlan_over_ipv4"; > + break; > + default: > + break; > } > > ploc_cfg = find_ploc(vtepctl_ctx, encap, dst_ip); > if (!ploc_cfg) { > ploc_cfg = vteprec_physical_locator_insert(ctx->txn); > + if (tunnel_key) { > + int64_t segement_value = 0; > + sscanf(tunnel_key,"%ld",&segement_value); > + > vteprec_physical_locator_set_tunnel_key(ploc_cfg,&segement_value,1); > + } > vteprec_physical_locator_set_dst_ip(ploc_cfg, dst_ip); > vteprec_physical_locator_set_encapsulation_type(ploc_cfg, encap); > > @@ -1790,7 +1812,7 @@ commit_mcast_entries(struct vtep_ctl_mcast_mac > *mcast_mac) > static void > add_mcast_entry(struct ctl_context *ctx, > struct vtep_ctl_lswitch *ls, const char *mac, > - const char *encap, const char *dst_ip, bool local) > + const char *encap, const char *dst_ip, const char* > tunnel_key,bool local) > { > struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); > struct shash *mcast_shash; > @@ -1839,6 +1861,11 @@ add_mcast_entry(struct ctl_context *ctx, > ploc_cfg = find_ploc(vtepctl_ctx, encap, dst_ip); > if (!ploc_cfg) { > ploc_cfg = vteprec_physical_locator_insert(ctx->txn); > + if (tunnel_key) { > + int64_t tunnel_id = 0; > + sscanf(tunnel_key,"%ld",&tunnel_id); > + > vteprec_physical_locator_set_tunnel_key(ploc_cfg,&tunnel_id,1); > + } > vteprec_physical_locator_set_dst_ip(ploc_cfg, dst_ip); > vteprec_physical_locator_set_encapsulation_type(ploc_cfg, encap); > > @@ -1908,25 +1935,35 @@ add_del_mcast_entry(struct ctl_context *ctx, bool > add, bool local) > { > struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); > struct vtep_ctl_lswitch *ls; > - const char *mac; > - const char *encap; > - const char *dst_ip; > - > + const char *mac = 0; > + const char *encap = 0; > + const char *dst_ip = 0; > + const char *tunnel_key = 0; > vtep_ctl_context_populate_cache(ctx); > > ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); > mac = ctx->argv[2]; > > - if (ctx->argc == 4) { > - encap = "vxlan_over_ipv4"; > - dst_ip = ctx->argv[3]; > - } else { > - encap = ctx->argv[3]; > - dst_ip = ctx->argv[4]; > + switch (ctx->argc) > + { > + case 6: > + tunnel_key = ctx->argv[5]; > + case 5: > + if (is_valid_ip(ctx->argv[4])){ > + dst_ip = ctx->argv[4]; > + encap = ctx->argv[3]; > + break; > + } > + tunnel_key = ctx->argv[4]; > + case 4: > + dst_ip = ctx->argv[3]; > + encap = "vxlan_over_ipv4"; > + break; > + default: > + break; > } > - > if (add) { > - add_mcast_entry(ctx, ls, mac, encap, dst_ip, local); > + add_mcast_entry(ctx, ls, mac, encap, dst_ip, tunnel_key, local); > } else { > del_mcast_entry(ctx, ls, mac, encap, dst_ip, local); > } > @@ -2017,7 +2054,7 @@ list_macs(struct ctl_context *ctx, bool local) > struct svec ucast_macs; > struct shash *mcast_shash; > struct svec mcast_macs; > - > + char tunnel_key[6]; > vtep_ctl_context_populate_cache(ctx); > ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); > > @@ -2032,9 +2069,13 @@ list_macs(struct ctl_context *ctx, bool local) > char *entry; > > ploc_cfg = local ? ucast_local->locator : ucast_remote->locator; > - > - entry = xasprintf(" %s -> %s/%s", node->name, > - ploc_cfg->encapsulation_type, ploc_cfg->dst_ip); > + tunnel_key[0] = 0; > + if (ploc_cfg->tunnel_key) > + > snprintf(&tunnel_key[0],5,"%d",(uint32_t)*ploc_cfg->tunnel_key); > + entry = xasprintf(" %s -> %s/%s [%s]", node->name, > + ploc_cfg->encapsulation_type, > + ploc_cfg->dst_ip, > + tunnel_key ); > svec_add_nocopy(&ucast_macs, entry); > } > ds_put_format(&ctx->output, "ucast-mac-%s\n", local ? "local" : > "remote"); > @@ -2047,11 +2088,14 @@ list_macs(struct ctl_context *ctx, bool local) > struct vtep_ctl_mcast_mac *mcast_mac = node->data; > struct vtep_ctl_ploc *ploc; > char *entry; > - > LIST_FOR_EACH (ploc, locators_node, &mcast_mac->locators) { > - entry = xasprintf(" %s -> %s/%s", node->name, > + tunnel_key[0] = 0; > + if (ploc->ploc_cfg->tunnel_key) > + > snprintf(tunnel_key,5,"%d",(uint32_t)*ploc->ploc_cfg->tunnel_key); > + entry = xasprintf(" %s -> %s/%s [%s]", node->name, > ploc->ploc_cfg->encapsulation_type, > - ploc->ploc_cfg->dst_ip); > + ploc->ploc_cfg->dst_ip, > + tunnel_key); > svec_add_nocopy(&mcast_macs, entry); > } > } > @@ -2508,11 +2552,11 @@ static const struct ctl_command_syntax > vtep_commands[] = { > {"lr-exists", 1, 1, NULL, pre_get_info, cmd_lr_exists, NULL, "", RO}, > > /* MAC binding commands. */ > - {"add-ucast-local", 3, 4, NULL, pre_get_info, cmd_add_ucast_local, > NULL, > + {"add-ucast-local", 3, 5, NULL, pre_get_info, cmd_add_ucast_local, > NULL, > "", RW}, > {"del-ucast-local", 2, 2, NULL, pre_get_info, cmd_del_ucast_local, > NULL, > "", RW}, > - {"add-mcast-local", 3, 4, NULL, pre_get_info, cmd_add_mcast_local, > NULL, > + {"add-mcast-local", 3, 5, NULL, pre_get_info, cmd_add_mcast_local, > NULL, > "", RW}, > {"del-mcast-local", 3, 4, NULL, pre_get_info, cmd_del_mcast_local, > NULL, > "", RW}, > @@ -2520,11 +2564,11 @@ static const struct ctl_command_syntax > vtep_commands[] = { > "", RO}, > {"list-local-macs", 1, 1, NULL, pre_get_info, cmd_list_local_macs, > NULL, > "", RO}, > - {"add-ucast-remote", 3, 4, NULL, pre_get_info, cmd_add_ucast_remote, > NULL, > + {"add-ucast-remote", 3, 5, NULL, pre_get_info, cmd_add_ucast_remote, > NULL, > "", RW}, > {"del-ucast-remote", 2, 2, NULL, pre_get_info, cmd_del_ucast_remote, > NULL, > "", RW}, > - {"add-mcast-remote", 3, 4, NULL, pre_get_info, cmd_add_mcast_remote, > NULL, > + {"add-mcast-remote", 3, 5, NULL, pre_get_info, cmd_add_mcast_remote, > NULL, > "", RW}, > {"del-mcast-remote", 3, 4, NULL, pre_get_info, cmd_del_mcast_remote, > NULL, > "", RW}, > diff --git a/vtep/vtep.xml b/vtep/vtep.xml > index 62075ca..cbef24b 100644 > --- a/vtep/vtep.xml > +++ b/vtep/vtep.xml > @@ -1173,7 +1173,15 @@ > 16,777,215. > </p> > </column> > - > + <column name="tunnel_key"> > + <p> > + For <code>vxlan_over_ipv4</code> encapsulation to support vni > mapping, the vni tage of the mapped > + VXLAN tunnel. > + </p> > + <p> > + Futer implementation will support other then VXLAN tunnels. > + </p> > + </column> > </table> > <table name="ACL_entry"> > <p> > -- > 1.9.1 > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev >
Hi Darrel, The problem with applying the patch may be caused by gmail. Patch will be resubmitted again. I have run make check, and it passed. Itamar On Mon, Jun 13, 2016 at 7:30 PM, Darrell Ball <dlu998@gmail.com> wrote: > I was not able to apply this patch - can you fix this > > Also, can you make sure the OVN vtep GW test passes (using make check) with > the patch submitted > > 2043: ovn.at:1029 ovn -- vtep: 3 HVs, 1 VIFs/HV, 1 GW, 1 LS > vtep > > The changes to vtep.xml are hard to follow; also I am not sure > they are required as there is already documentation for > Per Logical_Switch+Physical_Locator pair tunnel keys. > > > > > > > On Tue, Jun 7, 2016 at 1:19 AM, Itamar Ofek <itamar.ofeq@gmail.com> wrote: > >> This patch adds support for handeling a per-tunnel tunnel key in the >> ovs-vtep and vtep-ctl to support the usage of neutron L2GW as an >> inter-cloud >> gateway. >> >> The Neutron spec is available here: >> https://review.openstack.org/#/c/270786/ >> >> Requested-by: "Ofer Ben-Yacov" <ofer.benyacov@gmail.com> >> Signed-off-by: "Itamar Ofek" <itamar.ofeq@gmail.com> >> --- >> tests/vtep-ctl.at | 132 >> +++++++++++++++++++++++++-------------------------- >> vtep/ovs-vtep | 52 +++++++++++++------- >> vtep/vtep-ctl.c | 138 >> +++++++++++++++++++++++++++++++++++------------------- >> vtep/vtep.xml | 10 +++- >> 4 files changed, 200 insertions(+), 132 deletions(-) >> >> diff --git a/tests/vtep-ctl.at b/tests/vtep-ctl.at >> index f0511ad..b7803c3 100644 >> --- a/tests/vtep-ctl.at >> +++ b/tests/vtep-ctl.at >> @@ -437,8 +437,8 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-local >> >> @@ -464,7 +464,7 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-local >> >> @@ -484,8 +484,8 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-local >> >> @@ -495,7 +495,7 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-local >> >> @@ -515,8 +515,8 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-remote >> >> @@ -542,7 +542,7 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-remote >> >> @@ -562,8 +562,8 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-remote >> >> @@ -573,7 +573,7 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-remote >> >> @@ -595,16 +595,16 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-local >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> - 02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> mcast-mac-remote >> >> @@ -627,9 +627,9 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> >> mcast-mac-local >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> @@ -657,10 +657,10 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> >> mcast-mac-local >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL( >> @@ -670,9 +670,9 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> >> mcast-mac-local >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> VTEP_CTL_CLEANUP >> @@ -693,9 +693,9 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> >> mcast-mac-remote >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> @@ -723,10 +723,10 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], >> [0], >> [ucast-mac-remote >> >> mcast-mac-remote >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL( >> @@ -736,9 +736,9 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> >> mcast-mac-remote >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> VTEP_CTL_CLEANUP >> @@ -762,18 +762,18 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> >> mcast-mac-local >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> >> mcast-mac-remote >> - 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 03:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 03:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> VTEP_CTL_CLEANUP >> @@ -797,22 +797,22 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> >> mcast-mac-local >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> >> mcast-mac-remote >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL( >> @@ -825,12 +825,12 @@ mcast-mac-local >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> >> mcast-mac-remote >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> VTEP_CTL_CLEANUP >> @@ -854,34 +854,34 @@ AT_CHECK([RUN_VTEP_CTL( >> ], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> >> mcast-mac-local >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> [ucast-mac-remote >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> >> mcast-mac-remote >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL( >> [clear-remote-macs ls1])], [0], [], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], >> [ucast-mac-local >> - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> >> mcast-mac-local >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 >> - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 >> - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] >> + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] >> + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] >> >> ], [], [VTEP_CTL_CLEANUP]) >> AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], >> diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep >> index e52c66f..59b76db 100755 >> --- a/vtep/ovs-vtep >> +++ b/vtep/ovs-vtep >> @@ -175,11 +175,25 @@ class Logical_Switch(object): >> del self.ports[lbinding] >> self.update_flood() >> >> + def tunnel_dict(self,entry): >> + return { >> + 'tunnel_type': entry[2], >> + 'dest_ip': entry[3], >> + 'tunnel_key': entry[4], >> + } >> + >> def add_tunnel(self, tunnel): >> global tun_id >> - vlog.info("adding tunnel %s" % tunnel) >> - encap, ip = tunnel.split("/") >> - >> + use_self_key = False >> + tunnel_key = tunnel['tunnel_key'] >> + if not tunnel_key: >> + use_self_key = True >> + tunnel_key = self.tunnel_key >> + vlog.info("adding tunnel %s key %s" % (tunnel['dest_ip'], >> + tunnel_key)) >> + >> + encap = tunnel['tunnel_type'] >> + ip = tunnel['dest_ip'] >> if encap != "vxlan_over_ipv4": >> vlog.warn("unsupported tunnel format %s" % encap) >> return >> @@ -189,7 +203,7 @@ class Logical_Switch(object): >> >> ovs_vsctl("add-port %s %s -- set Interface %s type=vxlan " >> "options:key=%s options:remote_ip=%s" >> - % (self.short_name, tun_name, tun_name, >> self.tunnel_key, >> ip)) >> + % (self.short_name, tun_name, tun_name, tunnel_key, >> ip)) >> >> for i in range(10): >> port_no = ovs_vsctl("get Interface %s ofport" % tun_name) >> @@ -203,10 +217,13 @@ class Logical_Switch(object): >> # Give the system a moment to allocate the port number >> time.sleep(0.5) >> >> - self.tunnels[tunnel] = (port_no, tun_name, ip) >> + self.tunnels[ip] = (port_no, >> + tun_name, >> + ip, >> + tunnel['tunnel_key']) >> >> add_bfd(ip) >> - >> + >> ovs_ofctl("add-flow %s table=0,priority=1000,in_port=%s," >> "actions=resubmit(,1)" >> % (self.short_name, port_no)) >> @@ -256,7 +273,7 @@ class Logical_Switch(object): >> def update_remote_macs(self): >> remote_macs = {} >> unknown_dsts = set() >> - tunnels = set() >> + tunnels = {} >> parse_ucast = True >> >> mac_list = vtep_ctl("list-remote-macs %s" % self.name >> ).splitlines() >> @@ -264,32 +281,31 @@ class Logical_Switch(object): >> if (line.find("mcast-mac-remote") != -1): >> parse_ucast = False >> continue >> - >> - entry = re.split(r' (.*) -> (.*)', line) >> - if len(entry) != 4: >> + entry = re.split(r' (.*) -> (.*)/(.*) \[(.*)\]', line) >> + if len(entry) != 6: >> continue >> >> if parse_ucast: >> - remote_macs[entry[1]] = entry[2] >> + remote_macs[entry[1]] = self.tunnel_dict(entry) >> else: >> if entry[1] != "unknown-dst": >> continue >> >> - unknown_dsts.add(entry[2]) >> + unknown_dsts.add(entry[3]) >> >> - tunnels.add(entry[2]) >> + tunnels[entry[3]]= self.tunnel_dict(entry) >> >> old_tunnels = set(self.tunnels.keys()) >> + tunnels_keys = set(tunnels.keys()) >> + for tunnel in tunnels_keys.difference(old_tunnels): >> + self.add_tunnel(tunnels[tunnel]) >> >> - for tunnel in tunnels.difference(old_tunnels): >> - self.add_tunnel(tunnel) >> - >> - for tunnel in old_tunnels.difference(tunnels): >> + for tunnel in old_tunnels.difference(tunnels_keys): >> self.del_tunnel(tunnel) >> >> for mac in six.iterkeys(remote_macs): >> if (self.remote_macs.get(mac) != remote_macs[mac]): >> - self.add_remote_mac(mac, remote_macs[mac]) >> + self.add_remote_mac(mac, remote_macs[mac]['dest_ip']) >> >> for mac in six.iterkeys(self.remote_macs): >> if mac not in remote_macs: >> diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c >> index 5c18971..e09425c 100644 >> --- a/vtep/vtep-ctl.c >> +++ b/vtep/vtep-ctl.c >> @@ -345,18 +345,18 @@ Logical Router commands:\n\ >> lr-exists LR exit 2 if LR does not exist\n\ >> \n\ >> MAC binding commands:\n\ >> - add-ucast-local LS MAC [ENCAP] IP add ucast local entry in LS\n\ >> - del-ucast-local LS MAC del ucast local entry from LS\n\ >> - add-mcast-local LS MAC [ENCAP] IP add mcast local entry in LS\n\ >> - del-mcast-local LS MAC [ENCAP] IP del mcast local entry from LS\n\ >> - clear-local-macs LS clear local mac entries\n\ >> - list-local-macs LS list local mac entries\n\ >> - add-ucast-remote LS MAC [ENCAP] IP add ucast remote entry in LS\n\ >> - del-ucast-remote LS MAC del ucast remote entry from LS\n\ >> - add-mcast-remote LS MAC [ENCAP] IP add mcast remote entry in LS\n\ >> - del-mcast-remote LS MAC [ENCAP] IP del mcast remote entry from LS\n\ >> - clear-remote-macs LS clear remote mac entries\n\ >> - list-remote-macs LS list remote mac entries\n\ >> + add-ucast-local LS MAC [ENCAP] IP [KEY] add ucast local entry in >> LS\n\ >> + del-ucast-local LS MAC del ucast local entry >> from LS\n\ >> + add-mcast-local LS MAC [ENCAP] IP [KEY] add mcast local entry in >> LS\n\ >> + del-mcast-local LS MAC [ENCAP] IP del mcast local entry >> from LS\n\ >> + clear-local-macs LS clear local mac >> entries\n\ >> + list-local-macs LS list local mac >> entries\n\ >> + add-ucast-remote LS MAC [ENCAP] IP [KEY] add ucast remote entry in >> LS\n\ >> + del-ucast-remote LS MAC del ucast remote entry >> from LS\n\ >> + add-mcast-remote LS MAC [ENCAP] IP [KEY] add mcast remote entry in >> LS\n\ >> + del-mcast-remote LS MAC [ENCAP] IP del mcast remote entry >> from LS\n\ >> + clear-remote-macs LS clear remote mac >> entries\n\ >> + list-remote-macs LS list remote mac >> entries\n\ >> \n\ >> %s\ >> \n\ >> @@ -451,6 +451,11 @@ struct vtep_ctl_context { >> * struct vtep_ctl_lrouter. */ >> }; >> >> +static bool is_valid_ip(const char* address) >> +{ >> + struct sockaddr_in sa; >> + return inet_pton(AF_INET, address, &(sa.sin_addr)); >> +} >> /* Casts 'base' into 'struct vtep_ctl_context'. */ >> static struct vtep_ctl_context * >> vtep_ctl_context_cast(struct ctl_context *base) >> @@ -887,7 +892,8 @@ pre_get_info(struct ctl_context *ctx) >> &vteprec_physical_locator_col_dst_ip); >> ovsdb_idl_add_column(ctx->idl, >> >> &vteprec_physical_locator_col_encapsulation_type); >> - >> + ovsdb_idl_add_column(ctx->idl, >> + &vteprec_physical_locator_col_tunnel_key); >> ovsdb_idl_add_column(ctx->idl, &vteprec_tunnel_col_local); >> ovsdb_idl_add_column(ctx->idl, &vteprec_tunnel_col_remote); >> } >> @@ -1653,27 +1659,43 @@ add_ucast_entry(struct ctl_context *ctx, bool >> local) >> { >> struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); >> struct vtep_ctl_lswitch *ls; >> - const char *mac; >> - const char *encap; >> - const char *dst_ip; >> + const char *mac = 0; >> + const char *encap = 0; >> + const char *dst_ip = 0; >> + const char *tunnel_key = 0; >> struct vteprec_physical_locator *ploc_cfg; >> >> vtep_ctl_context_populate_cache(ctx); >> >> ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); >> mac = ctx->argv[2]; >> - >> - if (ctx->argc == 4) { >> - encap = "vxlan_over_ipv4"; >> - dst_ip = ctx->argv[3]; >> - } else { >> - encap = ctx->argv[3]; >> - dst_ip = ctx->argv[4]; >> + switch (ctx->argc) >> + { >> + case 6: >> + tunnel_key = ctx->argv[5]; >> + case 5: >> + if (is_valid_ip(ctx->argv[4])){ >> + dst_ip = ctx->argv[4]; >> + encap = ctx->argv[3]; >> + break; >> + } >> + tunnel_key = ctx->argv[4]; >> + case 4: >> + dst_ip = ctx->argv[3]; >> + encap = "vxlan_over_ipv4"; >> + break; >> + default: >> + break; >> } >> >> ploc_cfg = find_ploc(vtepctl_ctx, encap, dst_ip); >> if (!ploc_cfg) { >> ploc_cfg = vteprec_physical_locator_insert(ctx->txn); >> + if (tunnel_key) { >> + int64_t segement_value = 0; >> + sscanf(tunnel_key,"%ld",&segement_value); >> + >> vteprec_physical_locator_set_tunnel_key(ploc_cfg,&segement_value,1); >> + } >> vteprec_physical_locator_set_dst_ip(ploc_cfg, dst_ip); >> vteprec_physical_locator_set_encapsulation_type(ploc_cfg, encap); >> >> @@ -1790,7 +1812,7 @@ commit_mcast_entries(struct vtep_ctl_mcast_mac >> *mcast_mac) >> static void >> add_mcast_entry(struct ctl_context *ctx, >> struct vtep_ctl_lswitch *ls, const char *mac, >> - const char *encap, const char *dst_ip, bool local) >> + const char *encap, const char *dst_ip, const char* >> tunnel_key,bool local) >> { >> struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); >> struct shash *mcast_shash; >> @@ -1839,6 +1861,11 @@ add_mcast_entry(struct ctl_context *ctx, >> ploc_cfg = find_ploc(vtepctl_ctx, encap, dst_ip); >> if (!ploc_cfg) { >> ploc_cfg = vteprec_physical_locator_insert(ctx->txn); >> + if (tunnel_key) { >> + int64_t tunnel_id = 0; >> + sscanf(tunnel_key,"%ld",&tunnel_id); >> + >> vteprec_physical_locator_set_tunnel_key(ploc_cfg,&tunnel_id,1); >> + } >> vteprec_physical_locator_set_dst_ip(ploc_cfg, dst_ip); >> vteprec_physical_locator_set_encapsulation_type(ploc_cfg, encap); >> >> @@ -1908,25 +1935,35 @@ add_del_mcast_entry(struct ctl_context *ctx, bool >> add, bool local) >> { >> struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); >> struct vtep_ctl_lswitch *ls; >> - const char *mac; >> - const char *encap; >> - const char *dst_ip; >> - >> + const char *mac = 0; >> + const char *encap = 0; >> + const char *dst_ip = 0; >> + const char *tunnel_key = 0; >> vtep_ctl_context_populate_cache(ctx); >> >> ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); >> mac = ctx->argv[2]; >> >> - if (ctx->argc == 4) { >> - encap = "vxlan_over_ipv4"; >> - dst_ip = ctx->argv[3]; >> - } else { >> - encap = ctx->argv[3]; >> - dst_ip = ctx->argv[4]; >> + switch (ctx->argc) >> + { >> + case 6: >> + tunnel_key = ctx->argv[5]; >> + case 5: >> + if (is_valid_ip(ctx->argv[4])){ >> + dst_ip = ctx->argv[4]; >> + encap = ctx->argv[3]; >> + break; >> + } >> + tunnel_key = ctx->argv[4]; >> + case 4: >> + dst_ip = ctx->argv[3]; >> + encap = "vxlan_over_ipv4"; >> + break; >> + default: >> + break; >> } >> - >> if (add) { >> - add_mcast_entry(ctx, ls, mac, encap, dst_ip, local); >> + add_mcast_entry(ctx, ls, mac, encap, dst_ip, tunnel_key, local); >> } else { >> del_mcast_entry(ctx, ls, mac, encap, dst_ip, local); >> } >> @@ -2017,7 +2054,7 @@ list_macs(struct ctl_context *ctx, bool local) >> struct svec ucast_macs; >> struct shash *mcast_shash; >> struct svec mcast_macs; >> - >> + char tunnel_key[6]; >> vtep_ctl_context_populate_cache(ctx); >> ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); >> >> @@ -2032,9 +2069,13 @@ list_macs(struct ctl_context *ctx, bool local) >> char *entry; >> >> ploc_cfg = local ? ucast_local->locator : ucast_remote->locator; >> - >> - entry = xasprintf(" %s -> %s/%s", node->name, >> - ploc_cfg->encapsulation_type, >> ploc_cfg->dst_ip); >> + tunnel_key[0] = 0; >> + if (ploc_cfg->tunnel_key) >> + >> snprintf(&tunnel_key[0],5,"%d",(uint32_t)*ploc_cfg->tunnel_key); >> + entry = xasprintf(" %s -> %s/%s [%s]", node->name, >> + ploc_cfg->encapsulation_type, >> + ploc_cfg->dst_ip, >> + tunnel_key ); >> svec_add_nocopy(&ucast_macs, entry); >> } >> ds_put_format(&ctx->output, "ucast-mac-%s\n", local ? "local" : >> "remote"); >> @@ -2047,11 +2088,14 @@ list_macs(struct ctl_context *ctx, bool local) >> struct vtep_ctl_mcast_mac *mcast_mac = node->data; >> struct vtep_ctl_ploc *ploc; >> char *entry; >> - >> LIST_FOR_EACH (ploc, locators_node, &mcast_mac->locators) { >> - entry = xasprintf(" %s -> %s/%s", node->name, >> + tunnel_key[0] = 0; >> + if (ploc->ploc_cfg->tunnel_key) >> + >> snprintf(tunnel_key,5,"%d",(uint32_t)*ploc->ploc_cfg->tunnel_key); >> + entry = xasprintf(" %s -> %s/%s [%s]", node->name, >> ploc->ploc_cfg->encapsulation_type, >> - ploc->ploc_cfg->dst_ip); >> + ploc->ploc_cfg->dst_ip, >> + tunnel_key); >> svec_add_nocopy(&mcast_macs, entry); >> } >> } >> @@ -2508,11 +2552,11 @@ static const struct ctl_command_syntax >> vtep_commands[] = { >> {"lr-exists", 1, 1, NULL, pre_get_info, cmd_lr_exists, NULL, "", RO}, >> >> /* MAC binding commands. */ >> - {"add-ucast-local", 3, 4, NULL, pre_get_info, cmd_add_ucast_local, >> NULL, >> + {"add-ucast-local", 3, 5, NULL, pre_get_info, cmd_add_ucast_local, >> NULL, >> "", RW}, >> {"del-ucast-local", 2, 2, NULL, pre_get_info, cmd_del_ucast_local, >> NULL, >> "", RW}, >> - {"add-mcast-local", 3, 4, NULL, pre_get_info, cmd_add_mcast_local, >> NULL, >> + {"add-mcast-local", 3, 5, NULL, pre_get_info, cmd_add_mcast_local, >> NULL, >> "", RW}, >> {"del-mcast-local", 3, 4, NULL, pre_get_info, cmd_del_mcast_local, >> NULL, >> "", RW}, >> @@ -2520,11 +2564,11 @@ static const struct ctl_command_syntax >> vtep_commands[] = { >> "", RO}, >> {"list-local-macs", 1, 1, NULL, pre_get_info, cmd_list_local_macs, >> NULL, >> "", RO}, >> - {"add-ucast-remote", 3, 4, NULL, pre_get_info, cmd_add_ucast_remote, >> NULL, >> + {"add-ucast-remote", 3, 5, NULL, pre_get_info, cmd_add_ucast_remote, >> NULL, >> "", RW}, >> {"del-ucast-remote", 2, 2, NULL, pre_get_info, cmd_del_ucast_remote, >> NULL, >> "", RW}, >> - {"add-mcast-remote", 3, 4, NULL, pre_get_info, cmd_add_mcast_remote, >> NULL, >> + {"add-mcast-remote", 3, 5, NULL, pre_get_info, cmd_add_mcast_remote, >> NULL, >> "", RW}, >> {"del-mcast-remote", 3, 4, NULL, pre_get_info, cmd_del_mcast_remote, >> NULL, >> "", RW}, >> diff --git a/vtep/vtep.xml b/vtep/vtep.xml >> index 62075ca..cbef24b 100644 >> --- a/vtep/vtep.xml >> +++ b/vtep/vtep.xml >> @@ -1173,7 +1173,15 @@ >> 16,777,215. >> </p> >> </column> >> - >> + <column name="tunnel_key"> >> + <p> >> + For <code>vxlan_over_ipv4</code> encapsulation to support vni >> mapping, the vni tage of the mapped >> + VXLAN tunnel. >> + </p> >> + <p> >> + Futer implementation will support other then VXLAN tunnels. >> + </p> >> + </column> >> </table> >> <table name="ACL_entry"> >> <p> >> -- >> 1.9.1 >> _______________________________________________ >> dev mailing list >> dev@openvswitch.org >> http://openvswitch.org/mailman/listinfo/dev >> > >
diff --git a/tests/vtep-ctl.at b/tests/vtep-ctl.at index f0511ad..b7803c3 100644 --- a/tests/vtep-ctl.at +++ b/tests/vtep-ctl.at @@ -437,8 +437,8 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-local @@ -464,7 +464,7 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-local @@ -484,8 +484,8 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-local @@ -495,7 +495,7 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-local @@ -515,8 +515,8 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-remote @@ -542,7 +542,7 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-remote @@ -562,8 +562,8 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-remote @@ -573,7 +573,7 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-remote @@ -595,16 +595,16 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-local ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote - 02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] mcast-mac-remote @@ -627,9 +627,9 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local mcast-mac-local - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], @@ -657,10 +657,10 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local mcast-mac-local - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL( @@ -670,9 +670,9 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local mcast-mac-local - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) VTEP_CTL_CLEANUP @@ -693,9 +693,9 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote mcast-mac-remote - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], @@ -723,10 +723,10 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote mcast-mac-remote - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL( @@ -736,9 +736,9 @@ AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote mcast-mac-remote - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) VTEP_CTL_CLEANUP @@ -762,18 +762,18 @@ AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local mcast-mac-local - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote mcast-mac-remote - 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 03:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 03:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) VTEP_CTL_CLEANUP @@ -797,22 +797,22 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] mcast-mac-local - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] mcast-mac-remote - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL( @@ -825,12 +825,12 @@ mcast-mac-local ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] mcast-mac-remote - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) VTEP_CTL_CLEANUP @@ -854,34 +854,34 @@ AT_CHECK([RUN_VTEP_CTL( ], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] mcast-mac-local - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], [ucast-mac-remote - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] mcast-mac-remote - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL( [clear-remote-macs ls1])], [0], [], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0], [ucast-mac-local - 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 + 00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] mcast-mac-local - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 - 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 - 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10 [[]] + 01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12 [[]] + 01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11 [[]] ], [], [VTEP_CTL_CLEANUP]) AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0], diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep index e52c66f..59b76db 100755 --- a/vtep/ovs-vtep +++ b/vtep/ovs-vtep @@ -175,11 +175,25 @@ class Logical_Switch(object): del self.ports[lbinding] self.update_flood() + def tunnel_dict(self,entry): + return { + 'tunnel_type': entry[2], + 'dest_ip': entry[3], + 'tunnel_key': entry[4], + } + def add_tunnel(self, tunnel): global tun_id - vlog.info("adding tunnel %s" % tunnel) - encap, ip = tunnel.split("/") - + use_self_key = False + tunnel_key = tunnel['tunnel_key'] + if not tunnel_key: + use_self_key = True + tunnel_key = self.tunnel_key + vlog.info("adding tunnel %s key %s" % (tunnel['dest_ip'], + tunnel_key)) + + encap = tunnel['tunnel_type'] + ip = tunnel['dest_ip'] if encap != "vxlan_over_ipv4": vlog.warn("unsupported tunnel format %s" % encap) return @@ -189,7 +203,7 @@ class Logical_Switch(object): ovs_vsctl("add-port %s %s -- set Interface %s type=vxlan " "options:key=%s options:remote_ip=%s" - % (self.short_name, tun_name, tun_name, self.tunnel_key, ip)) + % (self.short_name, tun_name, tun_name, tunnel_key, ip)) for i in range(10): port_no = ovs_vsctl("get Interface %s ofport" % tun_name) @@ -203,10 +217,13 @@ class Logical_Switch(object): # Give the system a moment to allocate the port number time.sleep(0.5) - self.tunnels[tunnel] = (port_no, tun_name, ip) + self.tunnels[ip] = (port_no, + tun_name, + ip, + tunnel['tunnel_key']) add_bfd(ip) - + ovs_ofctl("add-flow %s table=0,priority=1000,in_port=%s," "actions=resubmit(,1)" % (self.short_name, port_no)) @@ -256,7 +273,7 @@ class Logical_Switch(object): def update_remote_macs(self): remote_macs = {} unknown_dsts = set() - tunnels = set() + tunnels = {} parse_ucast = True mac_list = vtep_ctl("list-remote-macs %s" % self.name).splitlines() @@ -264,32 +281,31 @@ class Logical_Switch(object): if (line.find("mcast-mac-remote") != -1): parse_ucast = False continue - - entry = re.split(r' (.*) -> (.*)', line) - if len(entry) != 4: + entry = re.split(r' (.*) -> (.*)/(.*) \[(.*)\]', line) + if len(entry) != 6: continue if parse_ucast: - remote_macs[entry[1]] = entry[2] + remote_macs[entry[1]] = self.tunnel_dict(entry) else: if entry[1] != "unknown-dst": continue - unknown_dsts.add(entry[2]) + unknown_dsts.add(entry[3]) - tunnels.add(entry[2]) + tunnels[entry[3]]= self.tunnel_dict(entry) old_tunnels = set(self.tunnels.keys()) + tunnels_keys = set(tunnels.keys()) + for tunnel in tunnels_keys.difference(old_tunnels): + self.add_tunnel(tunnels[tunnel]) - for tunnel in tunnels.difference(old_tunnels): - self.add_tunnel(tunnel) - - for tunnel in old_tunnels.difference(tunnels): + for tunnel in old_tunnels.difference(tunnels_keys): self.del_tunnel(tunnel) for mac in six.iterkeys(remote_macs): if (self.remote_macs.get(mac) != remote_macs[mac]): - self.add_remote_mac(mac, remote_macs[mac]) + self.add_remote_mac(mac, remote_macs[mac]['dest_ip']) for mac in six.iterkeys(self.remote_macs): if mac not in remote_macs: diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index 5c18971..e09425c 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -345,18 +345,18 @@ Logical Router commands:\n\ lr-exists LR exit 2 if LR does not exist\n\ \n\ MAC binding commands:\n\ - add-ucast-local LS MAC [ENCAP] IP add ucast local entry in LS\n\ - del-ucast-local LS MAC del ucast local entry from LS\n\ - add-mcast-local LS MAC [ENCAP] IP add mcast local entry in LS\n\ - del-mcast-local LS MAC [ENCAP] IP del mcast local entry from LS\n\ - clear-local-macs LS clear local mac entries\n\ - list-local-macs LS list local mac entries\n\ - add-ucast-remote LS MAC [ENCAP] IP add ucast remote entry in LS\n\ - del-ucast-remote LS MAC del ucast remote entry from LS\n\ - add-mcast-remote LS MAC [ENCAP] IP add mcast remote entry in LS\n\ - del-mcast-remote LS MAC [ENCAP] IP del mcast remote entry from LS\n\ - clear-remote-macs LS clear remote mac entries\n\ - list-remote-macs LS list remote mac entries\n\ + add-ucast-local LS MAC [ENCAP] IP [KEY] add ucast local entry in LS\n\ + del-ucast-local LS MAC del ucast local entry from LS\n\ + add-mcast-local LS MAC [ENCAP] IP [KEY] add mcast local entry in LS\n\ + del-mcast-local LS MAC [ENCAP] IP del mcast local entry from LS\n\ + clear-local-macs LS clear local mac entries\n\ + list-local-macs LS list local mac entries\n\ + add-ucast-remote LS MAC [ENCAP] IP [KEY] add ucast remote entry in LS\n\ + del-ucast-remote LS MAC del ucast remote entry from LS\n\ + add-mcast-remote LS MAC [ENCAP] IP [KEY] add mcast remote entry in LS\n\ + del-mcast-remote LS MAC [ENCAP] IP del mcast remote entry from LS\n\ + clear-remote-macs LS clear remote mac entries\n\ + list-remote-macs LS list remote mac entries\n\ \n\ %s\ \n\ @@ -451,6 +451,11 @@ struct vtep_ctl_context { * struct vtep_ctl_lrouter. */ }; +static bool is_valid_ip(const char* address) +{ + struct sockaddr_in sa; + return inet_pton(AF_INET, address, &(sa.sin_addr)); +} /* Casts 'base' into 'struct vtep_ctl_context'. */ static struct vtep_ctl_context * vtep_ctl_context_cast(struct ctl_context *base) @@ -887,7 +892,8 @@ pre_get_info(struct ctl_context *ctx) &vteprec_physical_locator_col_dst_ip); ovsdb_idl_add_column(ctx->idl, &vteprec_physical_locator_col_encapsulation_type); - + ovsdb_idl_add_column(ctx->idl, + &vteprec_physical_locator_col_tunnel_key); ovsdb_idl_add_column(ctx->idl, &vteprec_tunnel_col_local); ovsdb_idl_add_column(ctx->idl, &vteprec_tunnel_col_remote); } @@ -1653,27 +1659,43 @@ add_ucast_entry(struct ctl_context *ctx, bool local) { struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); struct vtep_ctl_lswitch *ls; - const char *mac; - const char *encap; - const char *dst_ip; + const char *mac = 0; + const char *encap = 0; + const char *dst_ip = 0; + const char *tunnel_key = 0; struct vteprec_physical_locator *ploc_cfg; vtep_ctl_context_populate_cache(ctx); ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); mac = ctx->argv[2]; - - if (ctx->argc == 4) { - encap = "vxlan_over_ipv4"; - dst_ip = ctx->argv[3]; - } else { - encap = ctx->argv[3]; - dst_ip = ctx->argv[4]; + switch (ctx->argc) + { + case 6: + tunnel_key = ctx->argv[5]; + case 5: + if (is_valid_ip(ctx->argv[4])){ + dst_ip = ctx->argv[4]; + encap = ctx->argv[3]; + break; + } + tunnel_key = ctx->argv[4]; + case 4: + dst_ip = ctx->argv[3]; + encap = "vxlan_over_ipv4"; + break; + default: + break; } ploc_cfg = find_ploc(vtepctl_ctx, encap, dst_ip); if (!ploc_cfg) { ploc_cfg = vteprec_physical_locator_insert(ctx->txn); + if (tunnel_key) { + int64_t segement_value = 0; + sscanf(tunnel_key,"%ld",&segement_value); + vteprec_physical_locator_set_tunnel_key(ploc_cfg,&segement_value,1); + } vteprec_physical_locator_set_dst_ip(ploc_cfg, dst_ip); vteprec_physical_locator_set_encapsulation_type(ploc_cfg, encap); @@ -1790,7 +1812,7 @@ commit_mcast_entries(struct vtep_ctl_mcast_mac *mcast_mac) static void add_mcast_entry(struct ctl_context *ctx, struct vtep_ctl_lswitch *ls, const char *mac, - const char *encap, const char *dst_ip, bool local) + const char *encap, const char *dst_ip, const char* tunnel_key,bool local) { struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); struct shash *mcast_shash; @@ -1839,6 +1861,11 @@ add_mcast_entry(struct ctl_context *ctx, ploc_cfg = find_ploc(vtepctl_ctx, encap, dst_ip); if (!ploc_cfg) { ploc_cfg = vteprec_physical_locator_insert(ctx->txn); + if (tunnel_key) { + int64_t tunnel_id = 0; + sscanf(tunnel_key,"%ld",&tunnel_id); + vteprec_physical_locator_set_tunnel_key(ploc_cfg,&tunnel_id,1); + } vteprec_physical_locator_set_dst_ip(ploc_cfg, dst_ip); vteprec_physical_locator_set_encapsulation_type(ploc_cfg, encap); @@ -1908,25 +1935,35 @@ add_del_mcast_entry(struct ctl_context *ctx, bool add, bool local) { struct vtep_ctl_context *vtepctl_ctx = vtep_ctl_context_cast(ctx); struct vtep_ctl_lswitch *ls; - const char *mac; - const char *encap; - const char *dst_ip; - + const char *mac = 0; + const char *encap = 0; + const char *dst_ip = 0; + const char *tunnel_key = 0; vtep_ctl_context_populate_cache(ctx); ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); mac = ctx->argv[2]; - if (ctx->argc == 4) { - encap = "vxlan_over_ipv4"; - dst_ip = ctx->argv[3]; - } else { - encap = ctx->argv[3]; - dst_ip = ctx->argv[4]; + switch (ctx->argc) + { + case 6: + tunnel_key = ctx->argv[5]; + case 5: + if (is_valid_ip(ctx->argv[4])){ + dst_ip = ctx->argv[4]; + encap = ctx->argv[3]; + break; + } + tunnel_key = ctx->argv[4]; + case 4: + dst_ip = ctx->argv[3]; + encap = "vxlan_over_ipv4"; + break; + default: + break; } - if (add) { - add_mcast_entry(ctx, ls, mac, encap, dst_ip, local); + add_mcast_entry(ctx, ls, mac, encap, dst_ip, tunnel_key, local); } else { del_mcast_entry(ctx, ls, mac, encap, dst_ip, local); } @@ -2017,7 +2054,7 @@ list_macs(struct ctl_context *ctx, bool local) struct svec ucast_macs; struct shash *mcast_shash; struct svec mcast_macs; - + char tunnel_key[6]; vtep_ctl_context_populate_cache(ctx); ls = find_lswitch(vtepctl_ctx, ctx->argv[1], true); @@ -2032,9 +2069,13 @@ list_macs(struct ctl_context *ctx, bool local) char *entry; ploc_cfg = local ? ucast_local->locator : ucast_remote->locator; - - entry = xasprintf(" %s -> %s/%s", node->name, - ploc_cfg->encapsulation_type, ploc_cfg->dst_ip); + tunnel_key[0] = 0; + if (ploc_cfg->tunnel_key) + snprintf(&tunnel_key[0],5,"%d",(uint32_t)*ploc_cfg->tunnel_key); + entry = xasprintf(" %s -> %s/%s [%s]", node->name, + ploc_cfg->encapsulation_type, + ploc_cfg->dst_ip, + tunnel_key ); svec_add_nocopy(&ucast_macs, entry); } ds_put_format(&ctx->output, "ucast-mac-%s\n", local ? "local" : "remote"); @@ -2047,11 +2088,14 @@ list_macs(struct ctl_context *ctx, bool local) struct vtep_ctl_mcast_mac *mcast_mac = node->data; struct vtep_ctl_ploc *ploc; char *entry; - LIST_FOR_EACH (ploc, locators_node, &mcast_mac->locators) { - entry = xasprintf(" %s -> %s/%s", node->name, + tunnel_key[0] = 0; + if (ploc->ploc_cfg->tunnel_key) + snprintf(tunnel_key,5,"%d",(uint32_t)*ploc->ploc_cfg->tunnel_key); + entry = xasprintf(" %s -> %s/%s [%s]", node->name, ploc->ploc_cfg->encapsulation_type, - ploc->ploc_cfg->dst_ip); + ploc->ploc_cfg->dst_ip, + tunnel_key); svec_add_nocopy(&mcast_macs, entry); } } @@ -2508,11 +2552,11 @@ static const struct ctl_command_syntax vtep_commands[] = { {"lr-exists", 1, 1, NULL, pre_get_info, cmd_lr_exists, NULL, "", RO}, /* MAC binding commands. */ - {"add-ucast-local", 3, 4, NULL, pre_get_info, cmd_add_ucast_local, NULL, + {"add-ucast-local", 3, 5, NULL, pre_get_info, cmd_add_ucast_local, NULL, "", RW}, {"del-ucast-local", 2, 2, NULL, pre_get_info, cmd_del_ucast_local, NULL, "", RW}, - {"add-mcast-local", 3, 4, NULL, pre_get_info, cmd_add_mcast_local, NULL, + {"add-mcast-local", 3, 5, NULL, pre_get_info, cmd_add_mcast_local, NULL, "", RW}, {"del-mcast-local", 3, 4, NULL, pre_get_info, cmd_del_mcast_local, NULL, "", RW}, @@ -2520,11 +2564,11 @@ static const struct ctl_command_syntax vtep_commands[] = { "", RO}, {"list-local-macs", 1, 1, NULL, pre_get_info, cmd_list_local_macs, NULL, "", RO}, - {"add-ucast-remote", 3, 4, NULL, pre_get_info, cmd_add_ucast_remote, NULL, + {"add-ucast-remote", 3, 5, NULL, pre_get_info, cmd_add_ucast_remote, NULL, "", RW}, {"del-ucast-remote", 2, 2, NULL, pre_get_info, cmd_del_ucast_remote, NULL, "", RW}, - {"add-mcast-remote", 3, 4, NULL, pre_get_info, cmd_add_mcast_remote, NULL, + {"add-mcast-remote", 3, 5, NULL, pre_get_info, cmd_add_mcast_remote, NULL, "", RW}, {"del-mcast-remote", 3, 4, NULL, pre_get_info, cmd_del_mcast_remote, NULL, "", RW}, diff --git a/vtep/vtep.xml b/vtep/vtep.xml index 62075ca..cbef24b 100644 --- a/vtep/vtep.xml +++ b/vtep/vtep.xml @@ -1173,7 +1173,15 @@ 16,777,215. </p> </column> - + <column name="tunnel_key"> + <p> + For <code>vxlan_over_ipv4</code> encapsulation to support vni mapping, the vni tage of the mapped + VXLAN tunnel. + </p> + <p> + Futer implementation will support other then VXLAN tunnels. + </p> + </column> </table> <table name="ACL_entry">
This patch adds support for handeling a per-tunnel tunnel key in the ovs-vtep and vtep-ctl to support the usage of neutron L2GW as an inter-cloud gateway. The Neutron spec is available here: https://review.openstack.org/#/c/270786/ Requested-by: "Ofer Ben-Yacov" <ofer.benyacov@gmail.com> Signed-off-by: "Itamar Ofek" <itamar.ofeq@gmail.com> --- tests/vtep-ctl.at | 132 +++++++++++++++++++++++++-------------------------- vtep/ovs-vtep | 52 +++++++++++++------- vtep/vtep-ctl.c | 138 +++++++++++++++++++++++++++++++++++------------------- vtep/vtep.xml | 10 +++- 4 files changed, 200 insertions(+), 132 deletions(-) <p>