]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc-user-nic: enable uid-marked veth devices for uids with 5 digits
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 21 Mar 2020 10:52:15 +0000 (11:52 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 21 Mar 2020 10:52:15 +0000 (11:52 +0100)
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: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cmd/lxc_user_nic.c

index cd9c1ef2f4850089c606815ac3d44d0250ac6c6d..fd345590310e8e93af1bdda9fce126b3120d9412 100644 (file)
@@ -727,9 +727,15 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid,
                return NULL;
 
         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)
-               ret = snprintf(nicname, sizeof(nicname), "veth%d_XXXXX", uid);
+               ret = snprintf(nicname, sizeof(nicname), "veth%d_XXXX", uid);
        else
                ret = snprintf(nicname, sizeof(nicname), "vethXXXXXX");
        if (ret < 0 || (size_t)ret >= sizeof(nicname))