On 07/21/2015 03:51 PM, Russell Bryant wrote: > On 07/16/2015 03:56 AM, Alex Wang wrote: >> This commit adds the gateway module to ovn-controller-vtep. The >> module will register the physical switches to ovnsb as chassis and >> constantly update the "vtep_logical_switches" column in Chassis table. >> >> Limitation: >> >> - Do not support reading multiple tunnel ips of physical switch. >> > > It's probably worth noting in the TODO file, unless we have a better way > to track it. > >> Signed-off-by: Alex Wang <al...@nicira.com> >> >> --- >> V3->V4: >> - rebase to master. >> >> V2->V3: >> - since ovn-sb schema changes (removal of Gateway table), the gateway >> module code needs to be adapted. >> - rebase to master. >> >> PATCH->V2: >> - split into separate commit. >> - can register all physical switches controlled by vtep database. >> --- >> ovn/controller-vtep/automake.mk | 2 + >> ovn/controller-vtep/gateway.c | 281 >> ++++++++++++++++++++ >> .../{ovn-controller-vtep.h => gateway.h} | 15 +- >> ovn/controller-vtep/ovn-controller-vtep.c | 3 + >> ovn/controller-vtep/ovn-controller-vtep.h | 18 ++ >> tests/ovn-controller-vtep.at | 151 +++++++++++ >> 6 files changed, 461 insertions(+), 9 deletions(-) >> create mode 100644 ovn/controller-vtep/gateway.c >> copy ovn/controller-vtep/{ovn-controller-vtep.h => gateway.h} (72%) >> >> diff --git a/ovn/controller-vtep/automake.mk >> b/ovn/controller-vtep/automake.mk >> index 7adda15..514cafa 100644 >> --- a/ovn/controller-vtep/automake.mk >> +++ b/ovn/controller-vtep/automake.mk >> @@ -1,5 +1,7 @@ >> bin_PROGRAMS += ovn/controller-vtep/ovn-controller-vtep >> ovn_controller_vtep_ovn_controller_vtep_SOURCES = \ >> + ovn/controller-vtep/gateway.c \ >> + ovn/controller-vtep/gateway.h \ >> ovn/controller-vtep/ovn-controller-vtep.c \ >> ovn/controller-vtep/ovn-controller-vtep.h >> ovn_controller_vtep_ovn_controller_vtep_LDADD = ovn/lib/libovn.la >> lib/libopenvswitch.la vtep/libvtep.la >> diff --git a/ovn/controller-vtep/gateway.c b/ovn/controller-vtep/gateway.c >> new file mode 100644 >> index 0000000..c2c1a3f >> --- /dev/null >> +++ b/ovn/controller-vtep/gateway.c >> @@ -0,0 +1,281 @@ >> +/* Copyright (c) 2015 Nicira, Inc. >> + * >> + * Licensed under the Apache License, Version 2.0 (the "License"); >> + * you may not use this file except in compliance with the License. >> + * You may obtain a copy of the License at: >> + * >> + * http://www.apache.org/licenses/LICENSE-2.0 >> + * >> + * Unless required by applicable law or agreed to in writing, software >> + * distributed under the License is distributed on an "AS IS" BASIS, >> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >> + * See the License for the specific language governing permissions and >> + * limitations under the License. >> + */ >> + >> +#include <config.h> >> +#include "gateway.h" >> + >> +#include "lib/hash.h" >> +#include "lib/hmap.h" >> +#include "lib/poll-loop.h" >> +#include "lib/sset.h" >> +#include "lib/util.h" >> +#include "openvswitch/vlog.h" >> +#include "ovn/lib/ovn-sb-idl.h" >> +#include "vtep/vtep-idl.h" >> +#include "ovn-controller-vtep.h" >> + >> +VLOG_DEFINE_THIS_MODULE(gateway); >> + >> +/* >> + * Registers the physical switches in vtep to ovnsb as chassis. For each >> + * physical switch in the vtep database, finds all vtep logical switches >> that >> + * are associated with the physical switch, and updates the corresponding >> + * chassis's 'vtep_logical_switches' column. >> + * >> + */ >> + >> +/* Global revalidation sequence number, incremented at each call to >> + * 'revalidate_gateway()'. */ >> +static uint64_t gw_reval_seq; >> + >> +/* Represents a chassis added by the gateway module. The 'reval_seq' >> + * is increment each time a chassis is revalidated. Chassis whose >> 'reval_seq' >> + * not equal to 'gw_reval_seq' will be removed. */ >> +struct gw_chassis { >> + struct hmap_node hmap_node; /* In 'gw_chassis'. */ >> + char *name; /* Name of the Chassis. */ >> + uint64_t reval_seq; /* Chassis revalidation sequence number. */ >> +}; >> + >> +/* Contains all chassis created by the gateway module. */ >> +static struct hmap gw_chassis_map = HMAP_INITIALIZER(&gw_chassis_map); > > I think the shash API is a slightly more convenient way to implement > what you have here. It wraps hmap for the common case of a string hash > key + custom data.
Actually, simap is even closer to what's being done here. The only difference is that it uses "unsigned int" instead of "uint64_t". -- Russell Bryant _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev