<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/21845">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gprs_ns2_fr: setup_device: allow to setup a new dahdi device<br><br>When a dahdi device hasn't been set up yet, ioctl IF_GET_PROTO fails<br>with invalid argument.<br>Also fix the device check to skip ioctl's if the device is also in the<br>correct state.<br><br>Change-Id: I398d056546e35465a2944e1b4a86a8c93b3e5f7a<br>---<br>M src/gb/gprs_ns2_fr.c<br>1 file changed, 6 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c</span><br><span>index 1a6b92f..1b0ec00 100644</span><br><span>--- a/src/gb/gprs_ns2_fr.c</span><br><span>+++ b/src/gb/gprs_ns2_fr.c</span><br><span>@@ -476,23 +476,24 @@</span><br><span>     req.ifr_settings.size = sizeof(buffer);</span><br><span>      req.ifr_settings.type = IF_GET_PROTO;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+     /* EINVAL is returned when no protocol has been set */</span><br><span>       rc = ioctl(sock, SIOCWANDEV, &req);</span><br><span style="color: hsl(0, 100%, 40%);">- if (rc < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+      if (rc < 0 && errno != EINVAL) {</span><br><span>          LOGP(DLNS, LOGL_ERROR, "%s: Unable to get FR protocol information: %s\n",</span><br><span>               netif, strerror(errno));</span><br><span>                goto err;</span><br><span>    }</span><br><span> </span><br><span>        /* check if the device is good */</span><br><span style="color: hsl(0, 100%, 40%);">-       if (req.ifr_settings.type != IF_PROTO_FR && fr->lmi != LMI_NONE) {</span><br><span style="color: hsl(0, 100%, 40%);">-           LOGP(DLNS, LOGL_INFO, "%s: has correct frame relay mode and lmi\n", netif);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc == 0 && req.ifr_settings.type == IF_PROTO_FR && fr->lmi == LMI_NONE) {</span><br><span style="color: hsl(120, 100%, 40%);">+              LOGP(DLNS, LOGL_NOTICE, "%s: has correct frame relay mode and lmi\n", netif);</span><br><span>              goto ifup;</span><br><span>   }</span><br><span> </span><br><span>        /* modify the device to match */</span><br><span>     rc = set_ifupdown(netif, false);</span><br><span>     if (rc) {</span><br><span style="color: hsl(0, 100%, 40%);">-               LOGP(DLNS, LOGL_ERROR, "Unable to bring up the device %s: %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+            LOGP(DLNS, LOGL_ERROR, "Unable to bring down the device %s: %s\n",</span><br><span>                       netif, strerror(errno));</span><br><span>               goto err;</span><br><span>    }</span><br><span>@@ -516,6 +517,7 @@</span><br><span>      /* monitored events count */</span><br><span>         fr->n393 = 4;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+  LOGP(DLNS, LOGL_INFO, "%s: Setting frame relay related parameters\n", netif);</span><br><span>      rc = ioctl(sock, SIOCWANDEV, &req);</span><br><span>      if (rc) {</span><br><span>            LOGP(DLNS, LOGL_ERROR, "%s: Unable to set FR protocol on information: %s\n",</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/21845">change 21845</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/21845"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I398d056546e35465a2944e1b4a86a8c93b3e5f7a </div>
<div style="display:none"> Gerrit-Change-Number: 21845 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: lynxis lazus <lynxis@fe80.eu> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-CC: daniel <dwillmann@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>