Page MenuHomeFreeBSD

linsysfs(4): Make listnics use new if_foreach_sleep method
ClosedPublic

Authored by dchagin on Mar 3 2023, 10:11 PM.
Referenced Files
F102911821: D38901.diff
Mon, Nov 18, 4:02 PM
Unknown Object (File)
Wed, Nov 13, 4:30 AM
Unknown Object (File)
Sun, Nov 3, 11:29 AM
Unknown Object (File)
Sun, Nov 3, 11:29 AM
Unknown Object (File)
Sun, Nov 3, 11:29 AM
Unknown Object (File)
Sun, Nov 3, 11:29 AM
Unknown Object (File)
Sun, Nov 3, 11:29 AM
Unknown Object (File)
Sun, Nov 3, 11:29 AM

Details

Summary

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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 50720
Build 47611: arc lint + arc unit

Event Timeline

Make listnics use new if_foreach_sleep method,
excelent to me

dchagin retitled this revision from linsysfs(4): Temporarily fix the listnics() facility to linsysfs(4): Make listnics use new if_foreach_sleep method.Mar 4 2023, 2:33 PM

add arrival/departure handlers, and move to a separate files

This revision is now accepted and ready to land.Mar 6 2023, 4:21 PM

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);

}
}

This revision now requires review to proceed.Mar 23 2023, 10:19 PM

ugh, back to handmade latch instead of sx, sx is not good due to priority propagation

This revision was not accepted when it landed; it landed in state Needs Review.Mar 25 2023, 10:46 AM
This revision was automatically updated to reflect the committed changes.

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.

fix linsysfs_if_visible, initialize visible

This revision was not accepted when it landed; it landed in state Needs Review.Apr 3 2023, 8:23 AM
This revision was automatically updated to reflect the committed changes.