Thread (71 messages) 71 messages, 4 authors, 2024-07-19

Re: [PATCH net-next v5 15/25] ovpn: implement multi-peer support

From: Sabrina Dubroca <sd@queasysnail.net>
Date: 2024-07-15 10:40:44

2024-06-27, 15:08:33 +0200, Antonio Quartulli wrote:
quoted hunk ↗ jump to hunk
@@ -46,6 +46,17 @@ static int ovpn_struct_init(struct net_device *dev, enum ovpn_mode mode)
 	ovpn->mode = mode;
 	spin_lock_init(&ovpn->lock);
 
+	if (mode == OVPN_MODE_MP) {
+		/* the peer container is fairly large, therefore we dynamically
+		 * allocate it only when needed
+		 */
+		ovpn->peers = kzalloc(sizeof(*ovpn->peers), GFP_KERNEL);
+		if (!ovpn->peers)
+			return -ENOMEM;
As we discussed in v3 (it was about the workqueue), I don't think this
will get freed correctly in some of the failure cases. This should go
in ovpn_net_init.
+
+		spin_lock_init(&ovpn->peers->lock);
+	}
+
 	return 0;
 }
-- 
Sabrina
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help