1
0
Fork 0

gtp: avoid zero size hashtable

GTP default hashtable size is 1024 and userspace could set specific
hashtable size with IFLA_GTP_PDP_HASHSIZE. If hashtable size is set to 0
from userspace,  hashtable will not work and panic will occur.

Fixes: 459aa660eb ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
alistair/sunxi64-5.5-dsi
Taehee Yoo 2019-12-11 08:23:48 +00:00 committed by Jakub Kicinski
parent 94dc550a50
commit 6a902c0f31
1 changed files with 5 additions and 2 deletions

View File

@ -667,10 +667,13 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
if (err < 0)
return err;
if (!data[IFLA_GTP_PDP_HASHSIZE])
if (!data[IFLA_GTP_PDP_HASHSIZE]) {
hashsize = 1024;
else
} else {
hashsize = nla_get_u32(data[IFLA_GTP_PDP_HASHSIZE]);
if (!hashsize)
hashsize = 1024;
}
err = gtp_hashtable_new(gtp, hashsize);
if (err < 0)