Change in libosmocore[master]: gprs_ns2_fr: setup_device: allow to setup a new dahdi device

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Dec 27 19:59:52 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/21845 )

Change subject: gprs_ns2_fr: setup_device: allow to setup a new dahdi device
......................................................................

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
---
M src/gb/gprs_ns2_fr.c
1 file changed, 6 insertions(+), 4 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 1a6b92f..1b0ec00 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -476,23 +476,24 @@
 	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 @@
 	/* 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",

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21845
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I398d056546e35465a2944e1b4a86a8c93b3e5f7a
Gerrit-Change-Number: 21845
Gerrit-PatchSet: 6
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-CC: daniel <dwillmann at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201227/efb49b51/attachment.htm>


More information about the gerrit-log mailing list