osmith has submitted this change. ( https://gerrit.osmocom.org/c/libgtpnl/+/39160?usp=email )
Change subject: dev_create: support returning -EEXIST ......................................................................
dev_create: support returning -EEXIST
Check if netlink has set errno to EEXIST and return -EEXIST in gtp_dev_create() and gtp_dev_create_sgsn(). Users of the function can use this to delete the GTP device and try creating it again.
Related: SYS#7240 Change-Id: Ib99bd8eed854014a5c9118c23e4058a41f3145f2 --- M src/gtp-rtnl.c 1 file changed, 10 insertions(+), 1 deletion(-)
Approvals: fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/src/gtp-rtnl.c b/src/gtp-rtnl.c index e0db921..87c7c3f 100644 --- a/src/gtp-rtnl.c +++ b/src/gtp-rtnl.c @@ -25,6 +25,7 @@ #include <unistd.h> #include <string.h> #include <time.h> +#include <errno.h>
#include <libmnl/libmnl.h> #include <net/if.h> @@ -143,7 +144,15 @@ EXPORT_SYMBOL(gtp_dev_create); int gtp_dev_create(int dest_ns, const char *gtp_ifname, int fd0, int fd1) { - return _gtp_dev_create(dest_ns, gtp_ifname, fd0, fd1, GTP_ROLE_GGSN); + int rc; + + errno = 0; + rc = _gtp_dev_create(dest_ns, gtp_ifname, fd0, fd1, GTP_ROLE_GGSN); + + if (rc < 0 && errno) + return -errno; + + return rc; }
EXPORT_SYMBOL(gtp_dev_create_sgsn);