Commit 62af470
T3871: handle phase-2 rename failures in safe_bulk_rename()
The phase-2 (scratch -> final target) loop ignored rename_interface()'s
return value entirely: applied[old] was already set in phase 1 (staging
to the scratch name), so a failed final rename still got reported as a
success, and the unconditional `ip link set dev {target} up` tried to
bring up a name that was never actually assigned - the interface stays
down, stuck under its scratch (vyethN) name, with nothing tracking it
correctly. Downstream, sync_rescan_hints() would see it under that
scratch name and (since its MAC is normally a configured one, that's
the whole reason it was being renamed) skip leaving a rescan hint for
it too, since a configured MAC never gets a hint regardless of what
name it's stuck under - so the interface would just silently vanish
from the admin's view.
Track (old, target) per scratch entry instead of target alone, so a
phase-2 failure can remove the corresponding old->target entry from
applied and bring the interface back up under its actual (scratch)
name instead of the target it never reached. Successful renames are
unaffected, and one failure in a batch doesn't affect the others.
Adds TestSafeBulkRename, the first direct unit test for this function:
the success path, a phase-2 failure not being reported as applied, the
interface being brought back up under its scratch name rather than the
unassigned target, and one failure not affecting other renames in the
same batch. Verified all three failure-mode tests actually fail
against the original code before confirming they pass with the fix.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent f28df1c commit 62af470
2 files changed
Lines changed: 63 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
| 359 | + | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
363 | | - | |
364 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
365 | 370 | | |
366 | 371 | | |
367 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
332 | 386 | | |
333 | 387 | | |
334 | 388 | | |
| |||
0 commit comments