Signed-off-by: Andreas Schultz <aschultz(a)tpip.net>
---
gtp.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/gtp.c b/gtp.c
index 11f8fad..4f5729e 100644
--- a/gtp.c
+++ b/gtp.c
@@ -756,8 +756,12 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
if (!tb[IFLA_MTU])
dev->mtu = real_dev->mtu;
- else if (dev->mtu > real_dev->mtu)
- return -EINVAL;
+ else if (dev->mtu > real_dev->mtu) {
+ netdev_dbg(dev, "GTP mtu greater that transport MTU (%d > %d)\n",
+ dev->mtu, real_dev->mtu);
+ err = -EINVAL;
+ goto out_err;
+ }
gti = netdev_priv(dev);
gti->real_dev = real_dev;
@@ -765,7 +769,9 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
fd0 = nla_get_u32(data[IFLA_GTP_FD0]);
fd1 = nla_get_u32(data[IFLA_GTP_FD1]);
- gtp_encap_enable(dev, gti, fd0, fd1);
+ err = gtp_encap_enable(dev, gti, fd0, fd1);
+ if (err < 0)
+ goto out_err;
if (!data[IFLA_GTP_HASHSIZE])
hashsize = 1024;
@@ -774,21 +780,29 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
err = gtp_hashtable_new(gti, hashsize);
if (err < 0)
- return err;
+ goto out_encap;
err = register_netdevice(dev);
- if (err < 0)
- goto err1;
+ if (err < 0) {
+ netdev_dbg(dev, "failed to register new netdev %d\n", err);
+ goto out_hashtable;
+ }
gn = net_generic(dev_net(dev), gtp_net_id);
list_add_rcu(>i->list, &gn->gtp_instance_list);
- netdev_dbg(dev, "registered new interface\n");
+ netdev_dbg(dev, "registered new GTP interface\n");
return 0;
-err1:
- netdev_dbg(dev, "failed to register new netdev %d\n", err);
+
+out_hashtable:
gtp_hashtable_free(gti);
+
+out_encap:
+ gtp_encap_disable(gti);
+
+out_err:
+ dev_put(real_dev);
return err;
}
--
2.5.0