| .. | .. |
|---|
| 546 | 546 | u8 *private_key = nla_data(info->attrs[WGDEVICE_A_PRIVATE_KEY]); |
|---|
| 547 | 547 | u8 public_key[NOISE_PUBLIC_KEY_LEN]; |
|---|
| 548 | 548 | struct wg_peer *peer, *temp; |
|---|
| 549 | + bool send_staged_packets; |
|---|
| 549 | 550 | |
|---|
| 550 | 551 | if (!crypto_memneq(wg->static_identity.static_private, |
|---|
| 551 | 552 | private_key, NOISE_PUBLIC_KEY_LEN)) |
|---|
| .. | .. |
|---|
| 564 | 565 | } |
|---|
| 565 | 566 | |
|---|
| 566 | 567 | down_write(&wg->static_identity.lock); |
|---|
| 567 | | - wg_noise_set_static_identity_private_key(&wg->static_identity, |
|---|
| 568 | | - private_key); |
|---|
| 569 | | - list_for_each_entry_safe(peer, temp, &wg->peer_list, |
|---|
| 570 | | - peer_list) { |
|---|
| 568 | + send_staged_packets = !wg->static_identity.has_identity && netif_running(wg->dev); |
|---|
| 569 | + wg_noise_set_static_identity_private_key(&wg->static_identity, private_key); |
|---|
| 570 | + send_staged_packets = send_staged_packets && wg->static_identity.has_identity; |
|---|
| 571 | + |
|---|
| 572 | + wg_cookie_checker_precompute_device_keys(&wg->cookie_checker); |
|---|
| 573 | + list_for_each_entry_safe(peer, temp, &wg->peer_list, peer_list) { |
|---|
| 571 | 574 | wg_noise_precompute_static_static(peer); |
|---|
| 572 | 575 | wg_noise_expire_current_peer_keypairs(peer); |
|---|
| 576 | + if (send_staged_packets) |
|---|
| 577 | + wg_packet_send_staged_packets(peer); |
|---|
| 573 | 578 | } |
|---|
| 574 | | - wg_cookie_checker_precompute_device_keys(&wg->cookie_checker); |
|---|
| 575 | 579 | up_write(&wg->static_identity.lock); |
|---|
| 576 | 580 | } |
|---|
| 577 | 581 | skip_set_private_key: |
|---|