]> Git Repo - J-linux.git/blobdiff - drivers/net/wireguard/netlink.c
ASoC: Merge v6.5-rc2
[J-linux.git] / drivers / net / wireguard / netlink.c
index 43c8c84e7ea82377c4d2a532380fcc5c4554fab2..6d1bd9f52d02a07498ce5217348de1ee8f4bc03d 100644 (file)
@@ -546,6 +546,7 @@ static int wg_set_device(struct sk_buff *skb, struct genl_info *info)
                u8 *private_key = nla_data(info->attrs[WGDEVICE_A_PRIVATE_KEY]);
                u8 public_key[NOISE_PUBLIC_KEY_LEN];
                struct wg_peer *peer, *temp;
+               bool send_staged_packets;
 
                if (!crypto_memneq(wg->static_identity.static_private,
                                   private_key, NOISE_PUBLIC_KEY_LEN))
@@ -564,14 +565,17 @@ static int wg_set_device(struct sk_buff *skb, struct genl_info *info)
                }
 
                down_write(&wg->static_identity.lock);
-               wg_noise_set_static_identity_private_key(&wg->static_identity,
-                                                        private_key);
-               list_for_each_entry_safe(peer, temp, &wg->peer_list,
-                                        peer_list) {
+               send_staged_packets = !wg->static_identity.has_identity && netif_running(wg->dev);
+               wg_noise_set_static_identity_private_key(&wg->static_identity, private_key);
+               send_staged_packets = send_staged_packets && wg->static_identity.has_identity;
+
+               wg_cookie_checker_precompute_device_keys(&wg->cookie_checker);
+               list_for_each_entry_safe(peer, temp, &wg->peer_list, peer_list) {
                        wg_noise_precompute_static_static(peer);
                        wg_noise_expire_current_peer_keypairs(peer);
+                       if (send_staged_packets)
+                               wg_packet_send_staged_packets(peer);
                }
-               wg_cookie_checker_precompute_device_keys(&wg->cookie_checker);
                up_write(&wg->static_identity.lock);
        }
 skip_set_private_key:
This page took 0.027314 seconds and 4 git commands to generate.