Skip to content

Give each network namespace its own socktab - #156

Draft
Stuartwastaken wants to merge 1 commit into
PlatformLab:mainfrom
Stuartwastaken:netns-socktab
Draft

Stuartwastaken wants to merge 1 commit into
PlatformLab:mainfrom
Stuartwastaken:netns-socktab

Conversation

@Stuartwastaken

Copy link
Copy Markdown
Contributor

This is the first step of the namespace work. Today the sockets of all network namespaces share homa->socktab, and each lookup compares hsk->hnet. This moves the socktab into struct homa_net, so each namespace has its own table and its own port space.

homa_timer still has to visit every socket, so homa->nets links the homa_nets together and homa_socktab_start_scan_all walks all of their socktabs. The timer's scan can block, so it holds homa->nets_mutex to keep a namespace from being deleted in the middle; this is the same arrangement as qshared->mutex and qshared->qdevs in homa_qdisc.c. The scans in homa_devel.c can run at SoftIRQ level, so they use RCU instead: the new pre_exit hook unlinks the homa_net, and Linux waits for a grace period between pre_exit and exit.

This also fixes homa_abort_rpcs, which scanned the shared table without checking the namespace, so an ICMP unreachable received in one namespace aborted RPCs to the same address in all of them. It now takes the hnet from the error handler and scans only that table; homa_abort_rpcs__ignore_other_hnets fails without the change. Ashish's #143 contains the same fix for homa_abort_rpcs (an hnet argument plus a check in the loop), so you can take either one; whichever goes in second needs a small rebase.

Each namespace now allocates its own socktab (1024 buckets, a little over 8 KB) while Homa is loaded.

Besides the unit tests, I ran this on 6.17.8 with the same port bound in four namespaces at once, RPCs between two namespaces over a veth pair, and 300 namespace create/delete cycles under load. That kernel has neither KASAN nor lockdep, so those have not been run.

Before this change all namespaces shared homa->socktab, with the
namespace as part of the hash key. Now each homa_net has its own
socktab, and homa->nets links the homa_nets together so that
homa_timer can scan the sockets of all namespaces.

This fixes a bug in homa_abort_rpcs: an ICMP error received in one
namespace aborted RPCs to the same address in every namespace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant