Lines Matching full:namespace

46 	/* Open initial network namespace */  in TEST()
50 /* Get file handle for initial namespace */ in TEST()
59 /* Close the namespace fd */ in TEST()
70 /* Verify we opened the same namespace */ in TEST()
83 * Test namespace lifecycle: create a namespace in a child process,
85 * the process exits (namespace becomes inactive).
108 /* Create new network namespace */ in TEST()
115 /* Open our new namespace */ in TEST()
122 /* Get file handle for the namespace */ in TEST()
137 /* Exit - namespace should become inactive */ in TEST()
156 /* Try to reopen namespace - should fail with ENOENT since it's inactive */ in TEST()
159 /* Should fail with ENOENT (namespace inactive) or ESTALE */ in TEST()
164 * Test that a namespace remains active while a process is using it,
188 /* First child - creates namespace */ in TEST()
192 /* Create new network namespace */ in TEST()
237 /* Create second child that will keep namespace active */ in TEST()
242 /* Second child - reopens the namespace */ in TEST()
246 /* Open the namespace via handle */ in TEST()
252 /* Join the namespace */ in TEST()
259 /* Sleep to keep namespace active */ in TEST()
264 /* Let second child enter the namespace */ in TEST()
277 /* Namespace should still be active because second child is using it */ in TEST()
288 * Test user namespace active ref tracking via credential lifecycle
310 /* Create new user namespace */ in TEST()
371 /* Namespace should be inactive after all tasks exit */ in TEST()
378 * Test PID namespace active ref tracking
400 /* Create new PID namespace */ in TEST()
407 /* Fork to actually enter the PID namespace */ in TEST()
415 /* Grandchild - in new PID namespace */ in TEST()
453 /* Namespace should be inactive after all processes exit */ in TEST()
460 * Test that an open file descriptor keeps a namespace active.
461 * Even after the creating process exits, the namespace should remain
489 TH_LOG("Child: creating new network namespace"); in TEST()
491 /* Create new network namespace */ in TEST()
500 TH_LOG("Child: network namespace created successfully"); in TEST()
502 /* Get file handle for the namespace */ in TEST()
511 TH_LOG("Child: opened namespace fd %d", nsfd); in TEST()
538 /* Exit - namespace should stay active because parent holds fd */ in TEST()
556 /* Open the child's namespace while it's still alive */ in TEST()
558 TH_LOG("Parent: opening child's namespace at %s", proc_path); in TEST()
565 SKIP(return, "Failed to open child's namespace"); in TEST()
568 TH_LOG("Parent: opened child's namespace, got fd %d", nsfd); in TEST()
581 TH_LOG("Child exited, parent holds fd %d to namespace", nsfd); in TEST()
584 * Namespace should still be ACTIVE because we hold an fd. in TEST()
587 TH_LOG("Attempting to reopen namespace via file handle (should succeed - fd held)"); in TEST()
591 TH_LOG("Successfully reopened namespace via file handle, got fd %d", fd2); in TEST()
593 /* Verify it's the same namespace */ in TEST()
597 TH_LOG("Namespace inodes: nsfd=%lu, fd2=%lu", st1.st_ino, st2.st_ino); in TEST()
601 /* Now close the fd - namespace should become inactive */ in TEST()
602 TH_LOG("Closing fd %d - namespace should become inactive", nsfd); in TEST()
605 /* Now reopening should fail - namespace is inactive */ in TEST()
606 TH_LOG("Attempting to reopen namespace via file handle (should fail - inactive)"); in TEST()
616 * When a child namespace is active, its owning user namespace should also
641 TH_LOG("Child: creating parent user namespace and setting up mappings"); in TEST()
643 /* Create parent user namespace with mappings */ in TEST()
651 TH_LOG("Child: parent user namespace created, now uid=%d gid=%d", getuid(), getgid()); in TEST()
653 /* Get namespace ID for parent user namespace */ in TEST()
671 TH_LOG("Child: got parent namespace ID %llu", (unsigned long long)parent_id); in TEST()
673 /* Create child user namespace within parent */ in TEST()
674 TH_LOG("Child: creating nested child user namespace"); in TEST()
682 TH_LOG("Child: nested child user namespace created, uid=%d gid=%d", getuid(), getgid()); in TEST()
684 /* Get namespace ID for child user namespace */ in TEST()
702 TH_LOG("Child: got child namespace ID %llu", (unsigned long long)child_id); in TEST()
704 /* Send both namespace IDs to parent */ in TEST()
705 TH_LOG("Child: sending both namespace IDs to parent"); in TEST()
711 /* Exit - parent user namespace should become inactive */ in TEST()
718 TH_LOG("Parent: reading both namespace IDs from child"); in TEST()
720 /* Read both namespace IDs - fixed size, no parsing needed */ in TEST()
725 SKIP(return, "Failed to read parent namespace ID from child"); in TEST()
732 SKIP(return, "Failed to read child namespace ID from child"); in TEST()
738 /* Construct file handles from namespace IDs */ in TEST()
755 TH_LOG("Parent: opening child namespace BEFORE child exits"); in TEST()
757 /* Open child namespace while child is still alive to keep it active */ in TEST()
760 TH_LOG("Failed to open child namespace: %s (errno=%d)", strerror(errno), errno); in TEST()
762 SKIP(return, "Failed to open child namespace"); in TEST()
765 TH_LOG("Opened child namespace fd %d", child_nsfd); in TEST()
773 TH_LOG("Child process exited, parent holds fd to child namespace"); in TEST()
777 * Since the child namespace is active (parent process holds fd), in TEST()
778 * the parent user namespace should ALSO be active automatically. in TEST()
780 * it propagated up to the owning user namespace. in TEST()
782 TH_LOG("Attempting to reopen parent namespace (should SUCCEED - hierarchical propagation)"); in TEST()
786 TH_LOG("SUCCESS: Parent namespace is active (fd=%d) due to active child", parent_fd); in TEST()
800 /* Verify both methods give us the same namespace */ in TEST()
804 TH_LOG("Parent namespace inodes: parent_fd=%lu, parent_fd2=%lu", st1.st_ino, st2.st_ino); in TEST()
820 TH_LOG("Closing all fds to parent namespace"); in TEST()
864 /* Unshare mount namespace and make mounts private to avoid propagation */ in TEST()
878 /* Create new network namespace */ in TEST()
886 /* Bind mount the namespace */ in TEST()
934 * Namespace should be inactive but still in tree due to bind mount. in TEST()
972 /* Create grandparent user namespace */ in TEST()
990 /* Create parent user namespace */ in TEST()
1008 /* Create child user namespace */ in TEST()
1026 /* Send all three namespace IDs */ in TEST()
1036 /* Read all three namespace IDs - fixed size, no parsing needed */ in TEST()
1041 SKIP(return, "Failed to read grandparent namespace ID from child"); in TEST()
1048 SKIP(return, "Failed to read parent namespace ID from child"); in TEST()
1055 SKIP(return, "Failed to read child namespace ID from child"); in TEST()
1058 /* Construct file handles from namespace IDs */ in TEST()
1087 SKIP(return, "Failed to open child namespace"); in TEST()
1135 /* Create parent user namespace */ in TEST()
1153 /* Create first child user namespace */ in TEST()
1171 /* Return to parent user namespace and create second child */ in TEST()
1172 /* We can't actually do this easily, so let's create a sibling namespace in TEST()
1173 * by creating a network namespace instead */ in TEST()
1191 /* Send all namespace IDs */ in TEST()
1201 /* Read all three namespace IDs - fixed size, no parsing needed */ in TEST()
1206 SKIP(return, "Failed to read parent namespace ID"); in TEST()
1213 SKIP(return, "Failed to read first child namespace ID"); in TEST()
1220 SKIP(return, "Failed to read second child namespace ID"); in TEST()
1223 /* Construct file handles from namespace IDs */ in TEST()
1284 * Test that different namespace types with same owner all contribute
1285 * active references to the owning user namespace.
1305 /* Create user namespace */ in TEST()
1323 /* Create network namespace (owned by user namespace) */ in TEST()
1341 /* Create UTS namespace (also owned by user namespace) */ in TEST()
1359 /* Send all namespace IDs */ in TEST()
1369 /* Read all three namespace IDs - fixed size, no parsing needed */ in TEST()
1374 SKIP(return, "Failed to read user namespace ID"); in TEST()
1381 SKIP(return, "Failed to read network namespace ID"); in TEST()
1388 SKIP(return, "Failed to read UTS namespace ID"); in TEST()
1391 /* Construct file handles from namespace IDs */ in TEST()
1433 * User namespace should be active (gets 2 active refs). in TEST()
1435 TH_LOG("Both net and uts active - user namespace should be active"); in TEST()
1440 /* Close network namespace - user namespace should STILL be active */ in TEST()
1447 /* Close UTS namespace - user namespace should become inactive */ in TEST()
1455 * Test hierarchical propagation with deep namespace hierarchy.
1530 /* Send all three namespace IDs */ in TEST()
1540 /* Read all three namespace IDs - fixed size, no parsing needed */ in TEST()
1545 SKIP(return, "Failed to read user_A namespace ID"); in TEST()
1552 SKIP(return, "Failed to read user_B namespace ID"); in TEST()
1559 SKIP(return, "Failed to read network namespace ID"); in TEST()
1562 /* Construct file handles from namespace IDs */ in TEST()
1591 SKIP(return, "Failed to open network namespace"); in TEST()
1632 * Create parent user namespace with two child net namespaces.
1656 /* Create parent user namespace */ in TEST()
1674 /* Create first network namespace */ in TEST()
1693 /* Keep n1_fd open so first namespace stays active */ in TEST()
1695 /* Create second network namespace */ in TEST()
1719 /* Send all namespace IDs */ in TEST()
1734 /* Read all three namespace IDs - fixed size, no parsing needed */ in TEST()
1739 SKIP(return, "Failed to read parent namespace ID"); in TEST()
1746 SKIP(return, "Failed to read first network namespace ID"); in TEST()
1753 SKIP(return, "Failed to read second network namespace ID"); in TEST()
1756 /* Construct file handles from namespace IDs */ in TEST()
1810 /* Close first net namespace - parent should STILL be active */ in TEST()
1817 /* Close second net namespace - parent should become inactive */ in TEST()
1825 * Test that user namespace as a child also propagates correctly.
1827 * is also active. This is different from non-user namespace children.
1882 /* Send both namespace IDs */ in TEST()
1891 /* Read both namespace IDs - fixed size, no parsing needed */ in TEST()
1896 SKIP(return, "Failed to read user_A namespace ID"); in TEST()
1903 SKIP(return, "Failed to read user_B namespace ID"); in TEST()
1906 /* Construct file handles from namespace IDs */ in TEST()
1957 * Test different namespace types (net, uts, ipc) all contributing
1958 * active references to the same owning user namespace.
2029 /* Send all namespace IDs */ in TEST()
2039 /* Read all three namespace IDs - fixed size, no parsing needed */ in TEST()
2044 SKIP(return, "Failed to read user namespace ID"); in TEST()
2051 SKIP(return, "Failed to read network namespace ID"); in TEST()
2058 SKIP(return, "Failed to read UTS namespace ID"); in TEST()
2061 /* Construct file handles from namespace IDs */ in TEST()
2100 /* User namespace should be active (2 active children) */ in TEST()
2134 /* Create new network namespace */ in thread_create_namespace()
2141 /* Get namespace ID */ in thread_create_namespace()
2155 /* Send namespace ID to main thread */ in thread_create_namespace()
2173 * Test that namespace becomes inactive after thread exits.
2195 /* Create thread that will create a namespace */ in TEST()
2199 /* Read namespace ID from thread */ in TEST()
2210 SKIP(return, "Failed to read namespace ID from thread"); in TEST()
2213 TH_LOG("Thread created namespace with ID %llu", (unsigned long long)ns_id); in TEST()
2224 /* Namespace should be active while thread is alive */ in TEST()
2225 TH_LOG("Attempting to open namespace while thread is alive (should succeed)"); in TEST()
2243 SKIP(return, "Thread failed to create namespace"); in TEST()
2245 TH_LOG("Thread exited, namespace should be inactive"); in TEST()
2247 /* Namespace should now be inactive */ in TEST()
2251 TH_LOG("Namespace inactive as expected: %s (errno=%d)", strerror(errno), errno); in TEST()
2256 * Test that a namespace remains active while a thread holds an fd to it.
2257 * Even after the thread exits, the namespace should remain active as long as
2279 /* Create thread that will create a namespace */ in TEST()
2283 /* Read namespace ID from thread */ in TEST()
2294 SKIP(return, "Failed to read namespace ID from thread"); in TEST()
2297 TH_LOG("Thread created namespace with ID %llu", (unsigned long long)ns_id); in TEST()
2308 /* Open namespace while thread is alive */ in TEST()
2309 TH_LOG("Opening namespace while thread is alive"); in TEST()
2327 SKIP(return, "Thread failed to create namespace"); in TEST()
2330 TH_LOG("Thread exited, but main thread holds fd - namespace should remain active"); in TEST()
2332 /* Namespace should still be active because we hold an fd */ in TEST()
2336 /* Verify it's the same namespace */ in TEST()
2343 TH_LOG("Closing fd - namespace should become inactive"); in TEST()
2346 /* Now namespace should be inactive */ in TEST()
2350 TH_LOG("Namespace inactive as expected: %s (errno=%d)", strerror(errno), errno); in TEST()
2400 /* Create user namespace with mappings */ in TEST()
2409 /* Get user namespace ID */ in TEST()
2428 /* Unshare network namespace */ in TEST()
2437 /* Get network namespace ID */ in TEST()
2456 /* Send namespace IDs to parent */ in TEST()
2466 fprintf(stderr, "Child: sent namespace IDs to parent\n"); in TEST()
2508 TH_LOG("Parent: waiting to read namespace IDs from child"); in TEST()
2510 /* Read namespace IDs from child */ in TEST()
2519 SKIP(return, "Failed to read user namespace ID from child"); in TEST()
2530 SKIP(return, "Failed to read network namespace ID from child"); in TEST()
2588 TH_LOG("User namespace found in listns() as expected"); in TEST()
2590 /* Check network namespace */ in TEST()
2602 TH_LOG("Network namespace found in listns() as expected"); in TEST()
2628 TH_LOG("User namespace inactive as expected: %s (errno=%d)", in TEST()
2634 TH_LOG("Network namespace inactive as expected: %s (errno=%d)", in TEST()
2653 TH_LOG("User namespace correctly not listed in listns()"); in TEST()
2655 /* Check network namespace */ in TEST()
2667 TH_LOG("Network namespace correctly not listed in listns()"); in TEST()