lkml.org 
[lkml]   [2020]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH net-next v3 3/6] net/lapb: handle carrier loss correctly
Date
In case of carrier loss, clear all queues, enter state LABB_STATE_0 and
stop all timers.

By setting rc = LAPB_NOTCONNECTED, the upper layer is informed about the
disconnect.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
net/lapb/lapb_iface.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
index 8dd7c420ae93..017bc169c334 100644
--- a/net/lapb/lapb_iface.c
+++ b/net/lapb/lapb_iface.c
@@ -303,6 +303,18 @@ int lapb_disconnect_request(struct net_device *dev)
if (!lapb)
goto out;

+ if (!netif_carrier_ok(dev)) {
+ lapb_dbg(0, "(%p) Carrier lost!\n", lapb->dev);
+ lapb_dbg(0, "(%p) S%d -> S0\n", lapb->dev, lapb->state);
+ lapb_clear_queues(lapb);
+ lapb->state = LAPB_STATE_0;
+ lapb->n2count = 0;
+ lapb_stop_t1timer(lapb);
+ lapb_stop_t2timer(lapb);
+ rc = LAPB_NOTCONNECTED;
+ goto out_put;
+ }
+
switch (lapb->state) {
case LAPB_STATE_0:
rc = LAPB_NOTCONNECTED;
--
2.20.1
\
 
 \ /
  Last update: 2020-11-18 15:11    [W:0.068 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site