Skip to content

Commit

Permalink
add tunneling functionality to sai and controller
Browse files Browse the repository at this point in the history
this adds the ofdpa-grpc client to communicate with the switch for
of-dpa api calls that are not available via ofagent
  • Loading branch information
Tobias Jungel committed Jan 22, 2019
1 parent 8ca9293 commit 88510c7
Show file tree
Hide file tree
Showing 8 changed files with 787 additions and 6 deletions.
10 changes: 8 additions & 2 deletions meson.build
Expand Up @@ -41,6 +41,8 @@ sources = files('''
src/netlink/tap_manager.hpp
src/of-dpa/controller.cpp
src/of-dpa/controller.hpp
src/of-dpa/ofdpa_client.cpp
src/of-dpa/ofdpa_client.hpp
src/of-dpa/ofdpa_datatypes.h
src/sai.hpp
src/utils/rofl-utils.hpp
Expand Down Expand Up @@ -128,12 +130,16 @@ grpc_gen = generator(protoc,
'@INPUT@'])

# generate sources and files
src_pb = protoc_gen.process('src/grpc/proto/common/empty.proto',
src_pb = protoc_gen.process(
'src/grpc/proto/api/ofdpa.proto',
'src/grpc/proto/common/empty.proto',
'src/grpc/proto/common/openconfig-interfaces.proto',
'src/grpc/proto/statistics/statistics-service.proto',
preserve_path_from : meson.current_source_dir()+'/src/grpc/proto')

src_grpc = grpc_gen.process('src/grpc/proto/statistics/statistics-service.proto',
src_grpc = grpc_gen.process(
'src/grpc/proto/api/ofdpa.proto',
'src/grpc/proto/statistics/statistics-service.proto',
preserve_path_from : meson.current_source_dir()+'/src/grpc/proto')

version_h = vcs_tag(input: 'src/version.h.in',
Expand Down
3 changes: 3 additions & 0 deletions pkg/systemd/sysconfig.template
Expand Up @@ -2,6 +2,9 @@
#
# Listening port:
# FLAGS_port=6653
#
# gRPC listening port:
# FLAGS_ofdpa_grpc_port=50051

### glog
#
Expand Down
10 changes: 8 additions & 2 deletions src/baseboxd.cpp
Expand Up @@ -14,6 +14,7 @@

DECLARE_string(tryfromenv); // from gflags
DEFINE_int32(port, 6653, "Listening port");
DEFINE_int32(ofdpa_grpc_port, 50051, "Listening port of ofdpa gRPC server");

static bool validate_port(const char *flagname, gflags::int32 value) {
VLOG(3) << __FUNCTION__ << ": flagname=" << flagname << ", value=" << value;
Expand All @@ -33,8 +34,13 @@ int main(int argc, char **argv) {
exit(1);
}

if (!gflags::RegisterFlagValidator(&FLAGS_ofdpa_grpc_port, &validate_port)) {
std::cerr << "Failed to register port validator 2" << std::endl;
exit(1);
}

// all variables can be set from env
FLAGS_tryfromenv = std::string("port");
FLAGS_tryfromenv = std::string("port,ofdpa_grpc_port");
gflags::SetUsageMessage("");
gflags::SetVersionString(PROJECT_VERSION);

Expand All @@ -51,7 +57,7 @@ int main(int argc, char **argv) {
std::shared_ptr<tap_manager> tap_man(new tap_manager(nl));
std::unique_ptr<nbi_impl> nbi(new nbi_impl(nl, tap_man));
std::shared_ptr<controller> box(
new controller(std::move(nbi), versionbitmap));
new controller(std::move(nbi), versionbitmap, FLAGS_ofdpa_grpc_port));

rofl::csockaddr baddr(AF_INET, std::string("0.0.0.0"), FLAGS_port);
box->dpt_sock_listen(baddr);
Expand Down

0 comments on commit 88510c7

Please sign in to comment.