Remove some deprecated checks in bpf_module
authorBrenden Blanco <bblanco@plumgrid.com>
Sat, 8 Aug 2015 04:25:46 +0000 (21:25 -0700)
committerBrenden Blanco <bblanco@plumgrid.com>
Sat, 8 Aug 2015 04:25:46 +0000 (21:25 -0700)
Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
src/cc/bpf_module.cc
src/cc/bpf_module.h
src/cc/frontends/b/loader.cc
src/cc/frontends/b/loader.h

index 5f615b5..707e979 100644 (file)
@@ -242,9 +242,9 @@ int BPFModule::annotate() {
     }
   }
 
-  auto engine = finalize_reader(move(m));
-  if (engine)
-    engine->finalizeObject();
+  reader_engine_ = finalize_reader(move(m));
+  if (reader_engine_)
+    reader_engine_->finalizeObject();
 
   return 0;
 }
@@ -370,8 +370,6 @@ size_t BPFModule::num_tables() const {
 }
 
 int BPFModule::table_fd(const string &name) const {
-  int fd = b_loader_ ? b_loader_->get_table_fd(name) : -1;
-  if (fd >= 0) return fd;
   auto table_it = tables_->find(name);
   if (table_it == tables_->end()) return -1;
   return table_it->second.fd;
@@ -415,7 +413,6 @@ size_t BPFModule::table_key_size(size_t id) const {
   return table_key_size(table_names_[id]);
 }
 size_t BPFModule::table_key_size(const string &name) const {
-  if (b_loader_) return 0;
   auto table_it = tables_->find(name);
   if (table_it == tables_->end()) return 0;
   return table_it->second.key_size;
@@ -426,7 +423,6 @@ size_t BPFModule::table_leaf_size(size_t id) const {
   return table_leaf_size(table_names_[id]);
 }
 size_t BPFModule::table_leaf_size(const string &name) const {
-  if (b_loader_) return 0;
   auto table_it = tables_->find(name);
   if (table_it == tables_->end()) return 0;
   return table_it->second.leaf_size;
index 8f57dd0..f8d0a7a 100644 (file)
@@ -82,6 +82,7 @@ class BPFModule {
   std::string proto_filename_;
   std::unique_ptr<llvm::LLVMContext> ctx_;
   std::unique_ptr<llvm::ExecutionEngine> engine_;
+  std::unique_ptr<llvm::ExecutionEngine> reader_engine_;
   std::unique_ptr<llvm::Module> mod_;
   std::unique_ptr<BLoader> b_loader_;
   std::unique_ptr<ClangLoader> clang_loader_;
index 20840cf..cd7ea64 100644 (file)
@@ -73,9 +73,4 @@ int BLoader::parse(llvm::Module *mod, const string &filename, const string &prot
   return 0;
 }
 
-int BLoader::get_table_fd(const string &name) const {
-  if (!codegen_) return -1;
-  return codegen_->get_table_fd(name);
-}
-
 }  // namespace ebpf
index e57d266..50ef0da 100644 (file)
@@ -39,7 +39,6 @@ class BLoader {
   ~BLoader();
   int parse(llvm::Module *mod, const std::string &filename, const std::string &proto_filename,
             std::unique_ptr<std::map<std::string, TableDesc>> *tables);
-  int get_table_fd(const std::string &name) const;
  private:
   std::unique_ptr<cc::Parser> parser_;
   std::unique_ptr<cc::Parser> proto_parser_;