MCPcopy Create free account
hub / github.com/NetSys/bess / GateHookCommand

Method GateHookCommand

core/bessctl.cc:1576–1611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1574 }
1575
1576 Status GateHookCommand(ServerContext*, const GateHookCommandRequest* request,
1577 CommandResponse* response) override {
1578 std::lock_guard<std::recursive_mutex> lock(mutex_);
1579
1580 // No need to look up the hook builder: the gate either
1581 // has a hook instance with the right name, or doesn't.
1582 const bess::pb::GateHookInfo& rh = request->hook();
1583 const auto& it = ModuleGraph::GetAllModules().find(rh.module_name());
1584 if (it == ModuleGraph::GetAllModules().end()) {
1585 return return_with_error(response, ENOENT, "No module '%s' found",
1586 rh.module_name().c_str());
1587 }
1588 Module* m = it->second;
1589 bool is_igate = rh.gate_case() == bess::pb::GateHookInfo::kIgate;
1590 gate_idx_t gate_idx = is_igate ? rh.igate() : rh.ogate();
1591 bess::Gate* g = module_gate(m, is_igate, gate_idx);
1592 if (g == nullptr) {
1593 return return_with_error(
1594 response, EINVAL, "%s: %cgate '%hu' does not exist",
1595 m->name().c_str(), is_igate ? 'i' : 'o', gate_idx);
1596 }
1597
1598 bess::GateHook* hook = g->FindHook(rh.hook_name());
1599 if (hook == nullptr) {
1600 return return_with_error(response, ENOENT,
1601 "%s: %cgate '%hu' has no hook named '%s'",
1602 m->name().c_str(), is_igate ? 'i' : 'o',
1603 gate_idx, rh.hook_name().c_str());
1604 }
1605
1606 // DPDK functions may be called, so be prepared
1607 current_worker.SetNonWorker();
1608
1609 *response = hook->RunCommand(request->cmd(), rh.arg());
1610 return Status::OK;
1611 }
1612
1613 Status ConfigureResumeHook(ServerContext*,
1614 const ConfigureResumeHookRequest* request,

Callers

nothing calls this directly

Calls 8

return_with_errorFunction · 0.85
module_gateFunction · 0.85
igateMethod · 0.80
FindHookMethod · 0.80
SetNonWorkerMethod · 0.80
cmdMethod · 0.80
endMethod · 0.45
RunCommandMethod · 0.45

Tested by

no test coverage detected