* [PATCH net-next] net: lapbether: Consider it successful if (dis)connecting when already (dis)connected
@ 2020-12-08 22:50 Xie He
2020-12-10 6:41 ` Martin Schiller
2020-12-10 21:19 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Xie He @ 2020-12-08 22:50 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, linux-x25, netdev, linux-kernel,
Martin Schiller
Cc: Xie He
When the upper layer instruct us to connect (or disconnect), but we have
already connected (or disconnected), consider this operation successful
rather than failed.
This can help the upper layer to correct its record about whether we are
connected or not here in layer 2.
The upper layer may not have the correct information about whether we are
connected or not. This can happen if this driver has already been running
for some time when the "x25" module gets loaded.
Another X.25 driver (hdlc_x25) is already doing this, so we make this
driver do this, too.
Cc: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
---
drivers/net/wan/lapbether.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index b6be2454b8bd..605fe555e157 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -55,6 +55,9 @@ struct lapbethdev {
static LIST_HEAD(lapbeth_devices);
+static void lapbeth_connected(struct net_device *dev, int reason);
+static void lapbeth_disconnected(struct net_device *dev, int reason);
+
/* ------------------------------------------------------------------------ */
/*
@@ -167,11 +170,17 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
case X25_IFACE_DATA:
break;
case X25_IFACE_CONNECT:
- if ((err = lapb_connect_request(dev)) != LAPB_OK)
+ err = lapb_connect_request(dev);
+ if (err == LAPB_CONNECTED)
+ lapbeth_connected(dev, LAPB_OK);
+ else if (err != LAPB_OK)
pr_err("lapb_connect_request error: %d\n", err);
goto drop;
case X25_IFACE_DISCONNECT:
- if ((err = lapb_disconnect_request(dev)) != LAPB_OK)
+ err = lapb_disconnect_request(dev);
+ if (err == LAPB_NOTCONNECTED)
+ lapbeth_disconnected(dev, LAPB_OK);
+ else if (err != LAPB_OK)
pr_err("lapb_disconnect_request err: %d\n", err);
fallthrough;
default:
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: lapbether: Consider it successful if (dis)connecting when already (dis)connected
2020-12-08 22:50 [PATCH net-next] net: lapbether: Consider it successful if (dis)connecting when already (dis)connected Xie He
@ 2020-12-10 6:41 ` Martin Schiller
2020-12-10 21:19 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Martin Schiller @ 2020-12-10 6:41 UTC (permalink / raw)
To: Xie He; +Cc: David S. Miller, Jakub Kicinski, linux-x25, netdev, linux-kernel
On 2020-12-08 23:50, Xie He wrote:
> When the upper layer instruct us to connect (or disconnect), but we
> have
> already connected (or disconnected), consider this operation successful
> rather than failed.
>
> This can help the upper layer to correct its record about whether we
> are
> connected or not here in layer 2.
>
> The upper layer may not have the correct information about whether we
> are
> connected or not. This can happen if this driver has already been
> running
> for some time when the "x25" module gets loaded.
>
> Another X.25 driver (hdlc_x25) is already doing this, so we make this
> driver do this, too.
Looks good to me.
Acked-by: Martin Schiller <ms@dev.tdt.de>
>
> Cc: Martin Schiller <ms@dev.tdt.de>
> Signed-off-by: Xie He <xie.he.0141@gmail.com>
> ---
> drivers/net/wan/lapbether.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
> index b6be2454b8bd..605fe555e157 100644
> --- a/drivers/net/wan/lapbether.c
> +++ b/drivers/net/wan/lapbether.c
> @@ -55,6 +55,9 @@ struct lapbethdev {
>
> static LIST_HEAD(lapbeth_devices);
>
> +static void lapbeth_connected(struct net_device *dev, int reason);
> +static void lapbeth_disconnected(struct net_device *dev, int reason);
> +
> /*
> ------------------------------------------------------------------------
> */
>
> /*
> @@ -167,11 +170,17 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff
> *skb,
> case X25_IFACE_DATA:
> break;
> case X25_IFACE_CONNECT:
> - if ((err = lapb_connect_request(dev)) != LAPB_OK)
> + err = lapb_connect_request(dev);
> + if (err == LAPB_CONNECTED)
> + lapbeth_connected(dev, LAPB_OK);
> + else if (err != LAPB_OK)
> pr_err("lapb_connect_request error: %d\n", err);
> goto drop;
> case X25_IFACE_DISCONNECT:
> - if ((err = lapb_disconnect_request(dev)) != LAPB_OK)
> + err = lapb_disconnect_request(dev);
> + if (err == LAPB_NOTCONNECTED)
> + lapbeth_disconnected(dev, LAPB_OK);
> + else if (err != LAPB_OK)
> pr_err("lapb_disconnect_request err: %d\n", err);
> fallthrough;
> default:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: lapbether: Consider it successful if (dis)connecting when already (dis)connected
2020-12-08 22:50 [PATCH net-next] net: lapbether: Consider it successful if (dis)connecting when already (dis)connected Xie He
2020-12-10 6:41 ` Martin Schiller
@ 2020-12-10 21:19 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-12-10 21:19 UTC (permalink / raw)
To: xie.he.0141; +Cc: kuba, linux-x25, netdev, linux-kernel, ms
From: Xie He <xie.he.0141@gmail.com>
Date: Tue, 8 Dec 2020 14:50:44 -0800
> When the upper layer instruct us to connect (or disconnect), but we have
> already connected (or disconnected), consider this operation successful
> rather than failed.
>
> This can help the upper layer to correct its record about whether we are
> connected or not here in layer 2.
>
> The upper layer may not have the correct information about whether we are
> connected or not. This can happen if this driver has already been running
> for some time when the "x25" module gets loaded.
>
> Another X.25 driver (hdlc_x25) is already doing this, so we make this
> driver do this, too.
>
> Cc: Martin Schiller <ms@dev.tdt.de>
> Signed-off-by: Xie He <xie.he.0141@gmail.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-10 21:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-08 22:50 [PATCH net-next] net: lapbether: Consider it successful if (dis)connecting when already (dis)connected Xie He
2020-12-10 6:41 ` Martin Schiller
2020-12-10 21:19 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).