mirror of https://github.com/wolfSSL/wolfssl.git
Update ssl_RemoveSession to use SessionHash for direct row calculation
Co-Authored-By: lealem@wolfssl.com <lealem@wolfssl.com>devin/1747238512-add-ssl-remove-session
parent
8de9b9e69e
commit
e0216d3ea5
|
@ -7630,9 +7630,11 @@ int ssl_RemoveSession(const char* clientIp, int clientPort,
|
||||||
{
|
{
|
||||||
IpAddrInfo clientAddr = {0};
|
IpAddrInfo clientAddr = {0};
|
||||||
IpAddrInfo serverAddr = {0};
|
IpAddrInfo serverAddr = {0};
|
||||||
|
IpInfo ipInfo;
|
||||||
|
TcpInfo tcpInfo;
|
||||||
SnifferSession* session;
|
SnifferSession* session;
|
||||||
int ret = -1; /* Default to not found */
|
int ret = -1; /* Default to not found */
|
||||||
word32 i;
|
word32 row;
|
||||||
|
|
||||||
if (clientIp == NULL || serverIp == NULL) {
|
if (clientIp == NULL || serverIp == NULL) {
|
||||||
SetError(BAD_IPVER_STR, error, NULL, 0);
|
SetError(BAD_IPVER_STR, error, NULL, 0);
|
||||||
|
@ -7679,11 +7681,23 @@ int ssl_RemoveSession(const char* clientIp, int clientPort,
|
||||||
|
|
||||||
/* No need to ensure IP versions match - client could use IPv4 while server uses IPv6 */
|
/* No need to ensure IP versions match - client could use IPv4 while server uses IPv6 */
|
||||||
|
|
||||||
|
/* Set up IpInfo and TcpInfo for SessionHash */
|
||||||
|
XMEMSET(&ipInfo, 0, sizeof(ipInfo));
|
||||||
|
XMEMSET(&tcpInfo, 0, sizeof(tcpInfo));
|
||||||
|
|
||||||
|
/* Set up client->server direction */
|
||||||
|
ipInfo.src = clientAddr;
|
||||||
|
ipInfo.dst = serverAddr;
|
||||||
|
tcpInfo.srcPort = clientPort;
|
||||||
|
tcpInfo.dstPort = serverPort;
|
||||||
|
|
||||||
|
/* Calculate the hash row for this session */
|
||||||
|
row = SessionHash(&ipInfo, &tcpInfo);
|
||||||
|
|
||||||
LOCK_SESSION();
|
LOCK_SESSION();
|
||||||
|
|
||||||
/* Search through all rows in the session table */
|
/* Search only the specific row in the session table */
|
||||||
for (i = 0; i < HASH_SIZE; i++) {
|
session = SessionTable[row];
|
||||||
session = SessionTable[i];
|
|
||||||
|
|
||||||
while (session) {
|
while (session) {
|
||||||
SnifferSession* next = session->next;
|
SnifferSession* next = session->next;
|
||||||
|
@ -7695,7 +7709,7 @@ int ssl_RemoveSession(const char* clientIp, int clientPort,
|
||||||
session->srvPort == serverPort) {
|
session->srvPort == serverPort) {
|
||||||
|
|
||||||
/* Use RemoveSession to remove and free the session */
|
/* Use RemoveSession to remove and free the session */
|
||||||
RemoveSession(session, NULL, NULL, i);
|
RemoveSession(session, NULL, NULL, row);
|
||||||
ret = 0; /* Session found and freed */
|
ret = 0; /* Session found and freed */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -7703,11 +7717,6 @@ int ssl_RemoveSession(const char* clientIp, int clientPort,
|
||||||
session = next;
|
session = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == 0) {
|
|
||||||
break; /* Session found and freed, exit the loop */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UNLOCK_SESSION();
|
UNLOCK_SESSION();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue