hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/wireguard/selftest/allowedips.c
....@@ -593,16 +593,20 @@
593593 wg_allowedips_remove_by_peer(&t, a, &mutex);
594594 test_negative(4, a, 192, 168, 0, 1);
595595
596
- /* These will hit the WARN_ON(len >= MAX_ALLOWEDIPS_BITS) in free_node
596
+ /* These will hit the WARN_ON(len >= MAX_ALLOWEDIPS_DEPTH) in free_node
597597 * if something goes wrong.
598598 */
599
- for (i = 0; i < MAX_ALLOWEDIPS_BITS; ++i) {
600
- part = cpu_to_be64(~(1LLU << (i % 64)));
601
- memset(&ip, 0xff, 16);
602
- memcpy((u8 *)&ip + (i < 64) * 8, &part, 8);
599
+ for (i = 0; i < 64; ++i) {
600
+ part = cpu_to_be64(~0LLU << i);
601
+ memset(&ip, 0xff, 8);
602
+ memcpy((u8 *)&ip + 8, &part, 8);
603
+ wg_allowedips_insert_v6(&t, &ip, 128, a, &mutex);
604
+ memcpy(&ip, &part, 8);
605
+ memset((u8 *)&ip + 8, 0, 8);
603606 wg_allowedips_insert_v6(&t, &ip, 128, a, &mutex);
604607 }
605
-
608
+ memset(&ip, 0, 16);
609
+ wg_allowedips_insert_v6(&t, &ip, 128, a, &mutex);
606610 wg_allowedips_free(&t, &mutex);
607611
608612 wg_allowedips_init(&t);