From: Christian Brauner Date: Sat, 21 Mar 2020 10:52:15 +0000 (+0100) Subject: lxc-user-nic: enable uid-marked veth devices for uids with 5 digits X-Git-Tag: lxc-4.0.0~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa2e1cea8de4f3e9bbb4ceccdcfd78bb64e87f58;p=thirdparty%2Flxc.git 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: Christian Brauner --- diff --git a/src/lxc/cmd/lxc_user_nic.c b/src/lxc/cmd/lxc_user_nic.c index cd9c1ef2f..fd3455903 100644 --- a/src/lxc/cmd/lxc_user_nic.c +++ b/src/lxc/cmd/lxc_user_nic.c @@ -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))