Hi Martin,
Since we are going to assume lapb->state would remain in LAPB_STATE_0 when
the carrier is down (as understood by me. Right?), could we add a check in
lapb_connect_request to reject the upper layer's "connect" instruction when
the carrier is down? Like this:
diff --git a/include/linux/lapb.h b/include/linux/lapb.h
index eb56472f23b2..7923b1c6fc6a 100644
--- a/include/linux/lapb.h
+++ b/include/linux/lapb.h
@@ -14,6 +14,7 @@
#define LAPB_REFUSED 5
#define LAPB_TIMEDOUT 6
#define LAPB_NOMEM 7
+#define LAPB_NOCARRIER 8
#define LAPB_STANDARD 0x00
#define LAPB_EXTENDED 0x01
diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c
index 3c03f6512c5f..c909d8db1bef 100644
--- a/net/lapb/lapb_iface.c
+++ b/net/lapb/lapb_iface.c
@@ -270,6 +270,10 @@ int lapb_connect_request(struct net_device *dev)
if (!lapb)
goto out;
+ rc = LAPB_NOCARRIER;
+ if (!netif_carrier_ok(dev))
+ goto out_put;
+
rc = LAPB_OK;
if (lapb->state == LAPB_STATE_1)
goto out_put;
Also, since we are going to assume the lapb->state would remain in
LAPB_STATE_0 when the carrier is down, are the
"lapb->state == LAPB_STATE_0" checks in carrier-up/device-up event
handling necessary? If they are not necessary, it might be better to
remove them because it may confuse people reading the code.