Until we do not implemented a proper method to add/remove interfaces
under sys/class/net, replace hardcoded list of interfaces by a simple
algorithm.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 50553 Build 47444: arc lint + arc unit
Event Timeline
fix +linsysfs_net_delnic, use sx instead of pair lock/counter
tested by:
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define CT 10
static void
worker(void)
{
char cmd[64];
int i, r;
for (;;) {
for (i = 1; i < CT; i++) { snprintf(cmd, sizeof(cmd), "ifconfig lo%d create", i); r = system(cmd); if (r == 0) continue; snprintf(cmd, sizeof(cmd), "ifconfig lo%d destroy", i); system(cmd); usleep(50); }
}
}
int
main(void)
{
char cmd[64];
int error, i, ncpu, status;
pid_t pid;
ncpu = sysconf(_SC_NPROCESSORS_ONLN);
ncpu *= 2;
pid_t pt[ncpu];
for (i = 0; i < ncpu; i++) {
pid = fork(); if (pid == 0) worker(); else pt[i] = pid;
}
usleep(50000000);
for (i = 0; i < ncpu; i++) {
kill(pt[i], SIGKILL); waitpid(pt[i], &status, WEXITED);
}
for (i = 1; i < CT; i++) {
snprintf(cmd, sizeof(cmd), "ifconfig lo%d destroy", i); system(cmd);
}
}
ugh, back to handmade latch instead of sx, sx is not good due to priority propagation
This change has been blamed to cause kernel panics on the FreeBSD current mailing list: https://lists.freebsd.org/archives/freebsd-current/2023-March/003381.html. It's been reported that reverting commit 0b56641cfcda30d06243223f37781ccc18455bef allows starting jails without triggering the observed kernel panic.