Disable piscsi_bridge creation

This commit is contained in:
Daniel Markstedt 2024-02-17 19:57:01 +09:00
parent a307a85d2f
commit 806fa25609
1 changed files with 9 additions and 2 deletions

View File

@ -29,9 +29,10 @@ using namespace std;
using namespace piscsi_util; using namespace piscsi_util;
using namespace network_util; using namespace network_util;
const string CTapDriver::BRIDGE_NAME = "piscsi_bridge"; // const string CTapDriver::BRIDGE_NAME = "piscsi_bridge";
static string br_setif(int br_socket_fd, const string& bridgename, const string& ifname, bool add) { //static string br_setif(int br_socket_fd, const string& bridgename, const string& ifname, bool add) {
static string br_setif(int br_socket_fd, const string& ifname, bool add) {
#ifndef __linux__ #ifndef __linux__
return "if_nametoindex: Linux is required"; return "if_nametoindex: Linux is required";
#else #else
@ -40,10 +41,12 @@ static string br_setif(int br_socket_fd, const string& bridgename, const string&
if (ifr.ifr_ifindex == 0) { if (ifr.ifr_ifindex == 0) {
return "Can't if_nametoindex " + ifname; return "Can't if_nametoindex " + ifname;
} }
#if 0
strncpy(ifr.ifr_name, bridgename.c_str(), IFNAMSIZ - 1); //NOSONAR Using strncpy is safe strncpy(ifr.ifr_name, bridgename.c_str(), IFNAMSIZ - 1); //NOSONAR Using strncpy is safe
if (ioctl(br_socket_fd, add ? SIOCBRADDIF : SIOCBRDELIF, &ifr) < 0) { if (ioctl(br_socket_fd, add ? SIOCBRADDIF : SIOCBRDELIF, &ifr) < 0) {
return "Can't ioctl " + string(add ? "SIOCBRADDIF" : "SIOCBRDELIF"); return "Can't ioctl " + string(add ? "SIOCBRADDIF" : "SIOCBRDELIF");
} }
#endif
return ""; return "";
#endif #endif
} }
@ -173,11 +176,13 @@ bool CTapDriver::Init(const param_map& const_params)
return cleanUp(error); return cleanUp(error);
} }
#if 0
spdlog::trace(">brctl addif " + BRIDGE_NAME + " piscsi0"); spdlog::trace(">brctl addif " + BRIDGE_NAME + " piscsi0");
if (const string error = br_setif(br_socket_fd, BRIDGE_NAME, "piscsi0", true); !error.empty()) { if (const string error = br_setif(br_socket_fd, BRIDGE_NAME, "piscsi0", true); !error.empty()) {
return cleanUp(error); return cleanUp(error);
} }
#endif
spdlog::trace("Getting the MAC address"); spdlog::trace("Getting the MAC address");
@ -251,6 +256,7 @@ pair<string, string> CTapDriver::ExtractAddressAndMask(const string& s)
string CTapDriver::SetUpEth0(int socket_fd, const string& bridge_interface) string CTapDriver::SetUpEth0(int socket_fd, const string& bridge_interface)
{ {
#if 0
#ifdef __linux__ #ifdef __linux__
spdlog::trace(">brctl addbr " + BRIDGE_NAME); spdlog::trace(">brctl addbr " + BRIDGE_NAME);
@ -263,6 +269,7 @@ string CTapDriver::SetUpEth0(int socket_fd, const string& bridge_interface)
if (const string error = br_setif(socket_fd, BRIDGE_NAME, bridge_interface, true); !error.empty()) { if (const string error = br_setif(socket_fd, BRIDGE_NAME, bridge_interface, true); !error.empty()) {
return error; return error;
} }
#endif
#endif #endif
return ""; return "";