File: 0002-Fixing-issue-Authentication-requests-from-the-same-I.patch

package info (click to toggle)
ocserv 1.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,484 kB
  • sloc: ansic: 44,469; sh: 11,205; makefile: 371; xml: 29
file content (35 lines) | stat: -rw-r--r-- 1,512 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From: Feng Xie <fengx@microsoft.com>
Date: Mon, 28 Feb 2022 16:00:13 +0000
Subject: Fixing issue: Authentication requests from the same IP address are
 not load balanced among security modules

---
 src/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c
index d99095b..b772292 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1079,6 +1079,7 @@ static void listen_watcher_cb (EV_P_ ev_io *w, int revents)
 		pid = fork();
 		if (pid == 0) {	/* child */
 			unsigned int sec_mod_instance_index;
+			char buf[MAX_IP_STR]; // buffer holding human readable sockaddr
 			/* close any open descriptors, and erase
 			 * sensitive data before running the worker
 			 */
@@ -1096,9 +1097,10 @@ static void listen_watcher_cb (EV_P_ ev_io *w, int revents)
 
 			set_self_oom_score_adj(s);
 
-			sec_mod_instance_index = hash_any(
-				SA_IN_P_GENERIC(&ws->remote_addr, ws->remote_addr_len),
-				SA_IN_SIZE(ws->remote_addr_len), 0) % s->sec_mod_instance_count;
+			sec_mod_instance_index = hash_any(&ws->remote_addr, ws->remote_addr_len, 0) % s->sec_mod_instance_count;
+			mslog(s, NULL, LOG_DEBUG, "map worker serving remote address %s to secmod instance %u",
+				human_addr((struct sockaddr*)&ws->remote_addr, ws->remote_addr_len, buf, sizeof(buf)),
+				sec_mod_instance_index);
 
 			/* write sec-mod's address */
 			memcpy(&ws->secmod_addr, &s->sec_mod_instances[sec_mod_instance_index].secmod_addr, s->sec_mod_instances[sec_mod_instance_index].secmod_addr_len);