On 5/29/2015 10:18 AM, Sridhar Samudrala wrote:
Trying to create a team device with name > 15 char results in a
failure, but
a netdev with truncated name is created.
git commit removed the lines with #. The
missing lines are
# teamd -t 0123456789abcdef
Netdevice "0123456789abcdef" not found.
teamd_init() failed.
Failed: No such device
# ip link show
114: 0123456789abcde@NONE: <BROADCAST,MULTICAST> mtu 1500 qdisc
noop state DOWN mode DEFAULT group default
link/ether 42:21:52:eb:37:a0 brd ff:ff:ff:ff:ff:ff
This patch fixes this issue by failing before a netdev with truncated name
is created.
# ./teamd -t 0123456789abcdef
Failed to create team device.
teamd_init() failed.
Failed: File name too long
Signed-off-by: Sridhar Samudrala <sridhar.samudrala(a)intel.com>
---
libteam/libteam.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libteam/libteam.c b/libteam/libteam.c
index 4595081..ac187aa 100644
--- a/libteam/libteam.c
+++ b/libteam/libteam.c
@@ -458,6 +458,9 @@ static int do_create(struct team_handle *th, const char *team_name,
bool recreat
return -ENOMEM;
if (team_name) {
+ if (strlen(team_name) >= IFNAMSIZ)
+ return -ENAMETOOLONG;
+
rtnl_link_set_name(link, team_name);
if (recreate && team_ifname2ifindex(th, team_name)) {