Commit 9b3ab10c authored by Robert Schmidt's avatar Robert Schmidt

Make failed TUN socket operation non-fatal

It might be desirable to run the UE without superuser rights. More
concretely, it might run without NET_ADMIN. In this case, various
corresponding operations on the TUN socket fd might fail. In this
commit,

- improve error reports to make them more clear
- do not automatically exit(1), but return from the function to ensure
  continuity of the softmodem
parent 8dc29be0
...@@ -144,7 +144,7 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, . ...@@ -144,7 +144,7 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, .
if (nas_sock_fd[i] == -1) { if (nas_sock_fd[i] == -1) {
LOG_E(PDCP, "TUN: Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno)); LOG_E(PDCP, "TUN: Error opening socket %s (%d:%s)\n",ifname,errno, strerror(errno));
exit(1); return 0;
} }
LOG_I(PDCP, "TUN: Opened socket %s with fd nas_sock_fd[%d]=%d\n", LOG_I(PDCP, "TUN: Opened socket %s with fd nas_sock_fd[%d]=%d\n",
......
...@@ -406,8 +406,7 @@ static void reblock_tun_socket(void) ...@@ -406,8 +406,7 @@ static void reblock_tun_socket(void)
f = fcntl(nas_sock_fd[0], F_GETFL, 0); f = fcntl(nas_sock_fd[0], F_GETFL, 0);
f &= ~(O_NONBLOCK); f &= ~(O_NONBLOCK);
if (fcntl(nas_sock_fd[0], F_SETFL, f) == -1) { if (fcntl(nas_sock_fd[0], F_SETFL, f) == -1) {
LOG_E(PDCP, "reblock_tun_socket failed\n"); LOG_E(PDCP, "fcntl(F_SETFL) failed on fd %d: errno %d, %s\n", nas_sock_fd[0], errno, strerror(errno));
exit(1);
} }
} }
...@@ -425,8 +424,8 @@ static void *enb_tun_read_thread(void *_) ...@@ -425,8 +424,8 @@ static void *enb_tun_read_thread(void *_)
while (1) { while (1) {
len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD); len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD);
if (len == -1) { if (len == -1) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(PDCP, "could not read(): errno %d %s\n", errno, strerror(errno));
exit(1); return NULL;
} }
LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len); LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len);
...@@ -483,8 +482,8 @@ static void *ue_tun_read_thread(void *_) ...@@ -483,8 +482,8 @@ static void *ue_tun_read_thread(void *_)
while (1) { while (1) {
len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD); len = read(nas_sock_fd[0], &rx_buf, NL_MAX_PAYLOAD);
if (len == -1) { if (len == -1) {
LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); LOG_E(PDCP, "error: cannot read() from fd %d: errno %d, %s\n", nas_sock_fd[0], errno, strerror(errno));
exit(1); return NULL; /* exit thread */
} }
LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len); LOG_D(PDCP, "%s(): nas_sock_fd read returns len %d\n", __func__, len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment