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

Method SetPortConf

core/bessctl.cc:1033–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1031 }
1032
1033 Status SetPortConf(ServerContext*, const SetPortConfRequest* request,
1034 EmptyResponse* response) override {
1035 std::lock_guard<std::recursive_mutex> lock(mutex_);
1036
1037 if (!request->name().length()) {
1038 return return_with_error(response, EINVAL, "Port name is not given");
1039 }
1040
1041 const char* port_name = request->name().c_str();
1042 const auto& it = PortBuilder::all_ports().find(port_name);
1043 if (it == PortBuilder::all_ports().end()) {
1044 return return_with_error(response, ENOENT, "No port `%s' found",
1045 port_name);
1046 }
1047
1048 const bess::pb::PortConf& pb_conf = request->conf();
1049 Port::Conf conf;
1050
1051 conf.mtu = pb_conf.mtu();
1052 conf.admin_up = pb_conf.admin_up();
1053
1054 if (!conf.mac_addr.FromString(pb_conf.mac_addr())) {
1055 return return_with_error(
1056 response, EINVAL,
1057 "MAC address should be formatted xx:xx:xx:xx:xx:xx");
1058 }
1059
1060 WorkerPauser wp;
1061 it->second->UpdateConf(conf);
1062 return Status::OK;
1063 }
1064
1065 Status GetPortConf(ServerContext*, const GetPortConfRequest* request,
1066 GetPortConfResponse* response) override {

Callers

nothing calls this directly

Calls 4

return_with_errorFunction · 0.85
FromStringMethod · 0.80
endMethod · 0.45
UpdateConfMethod · 0.45

Tested by

no test coverage detected