public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded•com>
To: Dean Jenkins <Dean_Jenkins@mentor•com>
Cc: davem@davemloft•net, netdev@vger•kernel.org
Subject: Re: [PATCH 2/5] SLIP: Handle error codes from the TTY layer
Date: Wed, 19 Jun 2013 22:00:37 +0400	[thread overview]
Message-ID: <51C1F1C5.6080901@cogentembedded.com> (raw)
In-Reply-To: <1371656071-27754-3-git-send-email-Dean_Jenkins@mentor.com>

Hello Dean.

On 06/19/2013 07:34 PM, Dean Jenkins wrote:

> It appears that SLIP does not handle error codes from the TTY layer.
> This will result in a malfunction because the remaining length of
> data will be corrupted by the negative error code values from the TTY
> layer.

> Therefore, add error code checks in sl_encaps() and sl_encaps_wakeup()
> to prevent the corruption of the sent data length.

> Note that SLIP is connectionless so on TTY error indicate that all data
> was sent. It seems SLIP does not return error codes to the network
> layer.

> Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor•com>
> ---
>   drivers/net/slip/slip.c | 26 ++++++++++++++++++++++----
>   1 file changed, 22 insertions(+), 4 deletions(-)

> diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
> index a34d6bf..bed819f 100644
> --- a/drivers/net/slip/slip.c
> +++ b/drivers/net/slip/slip.c
[...]
> @@ -404,7 +404,16 @@ static void sl_encaps(struct slip *sl, unsigned char *icp, int len)
>   	 *       14 Oct 1994  Dmitry Gorodchanin.
>   	 */
>   	set_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
> -	actual = sl->tty->ops->write(sl->tty, sl->xbuff, count);
> +	err = sl->tty->ops->write(sl->tty, sl->xbuff, count);
> +

    I don't think empty line is needed here.

> +	if (err < 0) {
> +		/* error case, say all was sent as connectionless */
> +		actual = count;
> +	} else {
> +		/* good case, err contains the number sent */
> +		actual = err;
> +	}
> +
>   #ifdef SL_CHECK_TRANSMIT
>   	sl->dev->trans_start = jiffies;
>   #endif
[...]
> @@ -438,7 +447,16 @@ static void slip_write_wakeup(struct tty_struct *tty)
>   		return;
>   	}
>
> -	actual = tty->ops->write(tty, sl->xhead, sl->xleft);
> +	err = tty->ops->write(tty, sl->xhead, sl->xleft);
> +

    Neither here.

> +	if (err < 0) {
> +		/* error case, say all was sent as connectionless */
> +		actual = sl->xleft;
> +	} else {
> +		/* good case, err contains the number sent */
> +		actual = err;
> +	}
> +

WBR, Sergei

  reply	other threads:[~2013-06-19 18:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19 15:34 [PATCH 0/5] SLIP SLIP-Improve robustness to crashing Dean Jenkins
2013-06-19 15:34 ` [PATCH 1/5] Bluetooth: Add RFCOMM TTY write return error codes Dean Jenkins
2013-06-19 18:01   ` Sergei Shtylyov
2013-06-19 15:34 ` [PATCH 2/5] SLIP: Handle error codes from the TTY layer Dean Jenkins
2013-06-19 18:00   ` Sergei Shtylyov [this message]
2013-06-19 15:34 ` [PATCH 3/5] SLIP: Prevent recursion stack overflow and scheduler crash Dean Jenkins
2013-06-19 15:34 ` [PATCH 4/5] SLIP: Add error message for xleft non-zero Dean Jenkins
2013-06-19 15:34 ` [PATCH 5/5] SLIP: Fix transmission segmentation mechanism Dean Jenkins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51C1F1C5.6080901@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded$(echo .)com \
    --cc=Dean_Jenkins@mentor$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox