aboutsummaryrefslogtreecommitdiffstats
path: root/gtp/gtp.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-05-16 17:03:02 +0200
committerHarald Welte <laforge@gnumonks.org>2017-06-09 08:53:10 +0000
commit283188790bb1b3af673d4edbd56ff649b7464e1e (patch)
tree60e6a597d32a8086c1831aa00ab6a874995c9cd1 /gtp/gtp.c
parent3142d8d30ba0056f405d1d9aed83d7b62e9464d4 (diff)
libgtp: improve error logging and propagation
* propagate error code from gtp_new() to caller instead of always returning -1 * on socket-related failures log explicitly which kind of socket caused error * log expected GTP version for unexpected packets Change-Id: Ie07f1e4246eb178838b7df21946a08a1f60f2084 related: SYS#3610
Diffstat (limited to 'gtp/gtp.c')
-rw-r--r--gtp/gtp.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/gtp/gtp.c b/gtp/gtp.c
index ade746a..801664d 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -730,9 +730,9 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
if (((*gsn)->fd0 = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
(*gsn)->err_socket++;
LOGP(DLGTP, LOGL_ERROR,
- "socket(domain=%d, type=%d, protocol=%d) failed: Error = %s\n",
+ "GTPv0 socket(domain=%d, type=%d, protocol=%d) failed: Error = %s\n",
AF_INET, SOCK_DGRAM, 0, strerror(errno));
- return -1;
+ return -errno;
}
memset(&addr, 0, sizeof(addr));
@@ -748,16 +748,16 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
LOGP_WITH_ADDR(DLGTP, LOGL_ERROR, addr,
"bind(fd0=%d) failed: Error = %s\n",
(*gsn)->fd0, strerror(errno));
- return -1;
+ return -errno;
}
/* Create GTP version 1 control plane socket */
if (((*gsn)->fd1c = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
(*gsn)->err_socket++;
LOGP(DLGTP, LOGL_ERROR,
- "socket(domain=%d, type=%d, protocol=%d) failed: Error = %s\n",
+ "GTPv1 control plane socket(domain=%d, type=%d, protocol=%d) failed: Error = %s\n",
AF_INET, SOCK_DGRAM, 0, strerror(errno));
- return -1;
+ return -errno;
}
memset(&addr, 0, sizeof(addr));
@@ -773,16 +773,16 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
LOGP_WITH_ADDR(DLGTP, LOGL_ERROR, addr,
"bind(fd1c=%d) failed: Error = %s\n",
(*gsn)->fd1c, strerror(errno));
- return -1;
+ return -errno;
}
/* Create GTP version 1 user plane socket */
if (((*gsn)->fd1u = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
(*gsn)->err_socket++;
LOGP(DLGTP, LOGL_ERROR,
- "socket(domain=%d, type=%d, protocol=%d) failed: Error = %s\n",
+ "GTPv1 user plane socket(domain=%d, type=%d, protocol=%d) failed: Error = %s\n",
AF_INET, SOCK_DGRAM, 0, strerror(errno));
- return -1;
+ return -errno;
}
memset(&addr, 0, sizeof(addr));
@@ -798,7 +798,7 @@ int gtp_new(struct gsn_t **gsn, char *statedir, struct in_addr *listen,
LOGP_WITH_ADDR(DLGTP, LOGL_ERROR, addr,
"bind(fd1u=%d) failed: Error = %s\n",
(*gsn)->fd1u, strerror(errno));
- return -1;
+ return -errno;
}
return 0;
@@ -2730,7 +2730,7 @@ int gtp_decaps0(struct gsn_t *gsn)
gsn->unexpect++;
GTP_LOGPKG(LOGL_ERROR, &peer, buffer,
status,
- "Unexpected GTP Signalling Message\n");
+ "Unexpected GTPv0 Signalling Message\n");
continue; /* Silently discard 29.60: 11.1.4 */
}
@@ -2741,7 +2741,7 @@ int gtp_decaps0(struct gsn_t *gsn)
gsn->unexpect++;
GTP_LOGPKG(LOGL_ERROR, &peer, buffer,
status,
- "Unexpected GTP Signalling Message\n");
+ "Unexpected GTPv0 Signalling Message\n");
continue; /* Silently discard 29.60: 11.1.4 */
}
@@ -2905,7 +2905,7 @@ int gtp_decaps1c(struct gsn_t *gsn)
gsn->unexpect++;
GTP_LOGPKG(LOGL_ERROR, &peer, buffer,
status,
- "Unexpected GTP Signalling Message\n");
+ "Unexpected GTPv1 Signalling Message\n");
continue; /* Silently discard 29.60: 11.1.4 */
}
@@ -2916,7 +2916,7 @@ int gtp_decaps1c(struct gsn_t *gsn)
gsn->unexpect++;
GTP_LOGPKG(LOGL_ERROR, &peer, buffer,
status,
- "Unexpected GTP Signalling Message\n");
+ "Unexpected GTPv1 Signalling Message\n");
continue; /* Silently discard 29.60: 11.1.4 */
}