lxc-user-nic: enable uid-marked veth devices for uids with 5 digits

With the newly extended lxc_ifname_alnum_case_sensitive() we'll have 62^4 unique network device names per user. Closes #3176. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 3646ffd9
...@@ -727,9 +727,15 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid, ...@@ -727,9 +727,15 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid,
return NULL; return NULL;
uid = getuid(); uid = getuid();
/* for POSIX integer uids the network device name schema is vethUID_XXXXX */ /*
* For POSIX integer uids the network device name schema is
* vethUID_XXXX.
* With four random characters passed to
* lxc_ifname_alnum_case_sensitive() we get 62^4 = 14776336
* combinations per uid. That's plenty of network devices for now.
*/
if (uid > 0 && uid <= 65536) if (uid > 0 && uid <= 65536)
ret = snprintf(nicname, sizeof(nicname), "veth%d_XXXXX", uid); ret = snprintf(nicname, sizeof(nicname), "veth%d_XXXX", uid);
else else
ret = snprintf(nicname, sizeof(nicname), "vethXXXXXX"); ret = snprintf(nicname, sizeof(nicname), "vethXXXXXX");
if (ret < 0 || (size_t)ret >= sizeof(nicname)) if (ret < 0 || (size_t)ret >= sizeof(nicname))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment