aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2020-12-22 15:42:01 +0100
committerlaforge <laforge@osmocom.org>2020-12-27 19:59:52 +0000
commit8c33d4a485f1f5742211b7c1b4ea188949b4ed06 (patch)
tree95f3c05f6dcc236786a0668afc924b145a6c306b
parent8a2a1a4959a2d51c74e87c8329d3dd35792f6ef5 (diff)
gprs_ns2_fr: setup_device: allow to setup a new dahdi device
When a dahdi device hasn't been set up yet, ioctl IF_GET_PROTO fails with invalid argument. Also fix the device check to skip ioctl's if the device is also in the correct state. Change-Id: I398d056546e35465a2944e1b4a86a8c93b3e5f7a
-rw-r--r--src/gb/gprs_ns2_fr.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 1a6b92f7..1b0ec003 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -476,23 +476,24 @@ static int setup_device(const char *netif)
req.ifr_settings.size = sizeof(buffer);
req.ifr_settings.type = IF_GET_PROTO;
+ /* EINVAL is returned when no protocol has been set */
rc = ioctl(sock, SIOCWANDEV, &req);
- if (rc < 0) {
+ if (rc < 0 && errno != EINVAL) {
LOGP(DLNS, LOGL_ERROR, "%s: Unable to get FR protocol information: %s\n",
netif, strerror(errno));
goto err;
}
/* check if the device is good */
- if (req.ifr_settings.type != IF_PROTO_FR && fr->lmi != LMI_NONE) {
- LOGP(DLNS, LOGL_INFO, "%s: has correct frame relay mode and lmi\n", netif);
+ if (rc == 0 && req.ifr_settings.type == IF_PROTO_FR && fr->lmi == LMI_NONE) {
+ LOGP(DLNS, LOGL_NOTICE, "%s: has correct frame relay mode and lmi\n", netif);
goto ifup;
}
/* modify the device to match */
rc = set_ifupdown(netif, false);
if (rc) {
- LOGP(DLNS, LOGL_ERROR, "Unable to bring up the device %s: %s\n",
+ LOGP(DLNS, LOGL_ERROR, "Unable to bring down the device %s: %s\n",
netif, strerror(errno));
goto err;
}
@@ -516,6 +517,7 @@ static int setup_device(const char *netif)
/* monitored events count */
fr->n393 = 4;
+ LOGP(DLNS, LOGL_INFO, "%s: Setting frame relay related parameters\n", netif);
rc = ioctl(sock, SIOCWANDEV, &req);
if (rc) {
LOGP(DLNS, LOGL_ERROR, "%s: Unable to set FR protocol on information: %s\n",