All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] tty: n_gsm: introduce macro for minimal unit size
@ 2022-10-24 13:01 D. Starke
  2022-10-24 13:01 ` [PATCH v2 2/3] tty: n_gsm: add parameters used with parameter negotiation D. Starke
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: D. Starke @ 2022-10-24 13:01 UTC (permalink / raw)
  To: linux-serial, gregkh, jirislaby, ilpo.jarvinen
  Cc: linux-kernel, Daniel Starke

From: Daniel Starke <daniel.starke@siemens.com>

n_gsm has a minimal protocol overhead of 7 bytes. The current code already
checks whether the configured MRU/MTU size is at least one byte more than
this.

Introduce the macro MIN_MTU to make this value more obvious.

Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
---
 drivers/tty/n_gsm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

v1 -> v2:
Incorporated review comments.

Link: https://lore.kernel.org/all/fe537e8-7b2-61e2-767d-787b923c7456@linux.intel.com/

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 5e516f5cac5a..570c40a3d78f 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -89,6 +89,7 @@ module_param(debug, int, 0600);
  */
 #define MAX_MRU 1500
 #define MAX_MTU 1500
+#define MIN_MTU (PROT_OVERHEAD + 1)
 /* SOF, ADDR, CTRL, LEN1, LEN2, ..., FCS, EOF */
 #define PROT_OVERHEAD 7
 #define	GSM_NET_TX_TIMEOUT (HZ*10)
@@ -2712,7 +2713,9 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
 	if ((c->adaption != 1 && c->adaption != 2) || c->k)
 		return -EOPNOTSUPP;
 	/* Check the MRU/MTU range looks sane */
-	if (c->mru > MAX_MRU || c->mtu > MAX_MTU || c->mru < 8 || c->mtu < 8)
+	if (c->mru < MIN_MTU || c->mtu < MIN_MTU)
+		return -EINVAL;
+	if (c->mru > MAX_MRU || c->mtu > MAX_MTU)
 		return -EINVAL;
 	if (c->n2 > 255)
 		return -EINVAL;
@@ -3296,7 +3299,7 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)
 		return -ENOMEM;
 	}
 	net->mtu = dlci->gsm->mtu;
-	net->min_mtu = 8;
+	net->min_mtu = MIN_MTU;
 	net->max_mtu = dlci->gsm->mtu;
 	mux_net = netdev_priv(net);
 	mux_net->dlci = dlci;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-11-01  6:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-24 13:01 [PATCH v2 1/3] tty: n_gsm: introduce macro for minimal unit size D. Starke
2022-10-24 13:01 ` [PATCH v2 2/3] tty: n_gsm: add parameters used with parameter negotiation D. Starke
2022-10-25 10:24   ` Ilpo Järvinen
2022-10-24 13:01 ` [PATCH v2 3/3] tty: n_gsm: add parameter negotiation support D. Starke
2022-10-25 11:09   ` Ilpo Järvinen
2022-10-25 11:16     ` Starke, Daniel
2022-10-25 11:50       ` Ilpo Järvinen
2022-10-25 12:25         ` Starke, Daniel
2022-10-25 12:04   ` Greg KH
2022-10-31 13:26     ` Starke, Daniel
2022-11-01  6:16       ` Greg KH
2022-10-25 10:17 ` [PATCH v2 1/3] tty: n_gsm: introduce macro for minimal unit size Ilpo Järvinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.