Skip to content

Commit

Permalink
Pass in buf value
Browse files Browse the repository at this point in the history
  • Loading branch information
cYKatherine committed Dec 5, 2024
1 parent eaf7274 commit 15a4f10
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions vsock-bridge/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ namespace vsockproxy
ServiceType _type = ServiceType::UNKNOWN;
EndpointConfig _listenEndpoint;
EndpointConfig _connectEndpoint;
int _acceptRcvBuf;
int _acceptSndBuf;
int _peerRcvBuf;
int _peerSndBuf;
};

std::vector<ServiceDescription> loadConfig(const std::string& filepath);
Expand Down
6 changes: 5 additions & 1 deletion vsock-bridge/include/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ namespace vsockio
const int MAX_POLLER_EVENTS = 256;
const int SO_BACKLOG = 64;

Listener(std::unique_ptr<Endpoint>&& listenEndpoint, std::unique_ptr<Endpoint>&& connectEndpoint, Dispatcher& dispatcher)
Listener(std::unique_ptr<Endpoint>&& listenEndpoint, std::unique_ptr<Endpoint>&& connectEndpoint, Dispatcher& dispatcher, int acceptRcvBuf, int acceptSndBuf, int peerRcvBuf, int peerSndBuf)
: _fd(-1)
, _acceptRcvBuf(acceptRcvBuf)
, _acceptSndBuf(acceptSndBuf)
, _peerRcvBuf(peerRcvBuf)
, _peerSndBuf(peerSndBuf)
, _listenEp(std::move(listenEndpoint))
, _connectEp(std::move(connectEndpoint))
, _events(new VsbEvent[MAX_POLLER_EVENTS])
Expand Down
16 changes: 16 additions & 0 deletions vsock-bridge/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,22 @@ namespace vsockproxy
}
cs._connectEndpoint = *endpoint;
}
else if (line._key == "acceptRcvBuf")
{
cs._acceptRcvBuf = std::stoi(line._value);
}
else if (line._key == "acceptSndBuf")
{
cs._acceptSndBuf = std::stoi(line._value);
}
else if (line._key == "peerRcvBuf")
{
cs._peerRcvBuf = std::stoi(line._value);
}
else if (line._key == "peerSndBuf")
{
cs._peerSndBuf = std::stoi(line._value);
}
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions vsock-bridge/src/vsock-bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static std::unique_ptr<Endpoint> createEndpoint(EndpointScheme scheme, const std
}
}

static std::unique_ptr<Listener> createListener(Dispatcher& dispatcher, EndpointScheme inScheme, const std::string& inAddress, uint16_t inPort, EndpointScheme outScheme, const std::string& outAddress, uint16_t outPort)
static std::unique_ptr<Listener> createListener(Dispatcher& dispatcher, EndpointScheme inScheme, const std::string& inAddress, uint16_t inPort, EndpointScheme outScheme, const std::string& outAddress, uint16_t outPort, int acceptRcvBuf, int acceptSndBuf, int peerRcvBuf, int peerSndBuf)
{
auto listenEp { createEndpoint(inScheme, inAddress, inPort) };
auto connectEp{ createEndpoint(outScheme, outAddress, outPort) };
Expand All @@ -44,7 +44,7 @@ static std::unique_ptr<Listener> createListener(Dispatcher& dispatcher, Endpoint
}
else
{
return std::make_unique<Listener>(std::move(listenEp), std::move(connectEp), dispatcher);
return std::make_unique<Listener>(std::move(listenEp), std::move(connectEp), dispatcher, acceptRcvBuf, acceptSndBuf, peerRcvBuf, peerSndBuf);
}
}

Expand All @@ -68,7 +68,10 @@ static void startServices(const std::vector<ServiceDescription>& services, int n
/*inPort:*/ sd._listenEndpoint._port,
/*outScheme:*/ sd._connectEndpoint._scheme,
/*outAddress:*/ sd._connectEndpoint._address,
/*outPort:*/ sd._connectEndpoint._port
_acceptRcvBuf,
_acceptSndBuf,
_peerRcvBuf,
_peerSndBuf,
);

if (!listener)
Expand Down

0 comments on commit 15a4f10

Please sign in to comment.