public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Karsten Keil <keil@b1-systems.de>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	David Miller <davem@davemloft.net>,
	i4ldeveloper@listserv.isdn4linux.de
Subject: Re: [mISDN PATCH v2 09/19] Fix TEI and SAPI handling
Date: Fri, 22 May 2009 23:53:14 +0200	[thread overview]
Message-ID: <20090522215314.GA4592@uranus.ravnborg.org> (raw)
In-Reply-To: <cbbb2723784ecf04bcec253c547a9464a2e722c7.1243024967.git.kkeil@pingi.linux-pingi.de>

Hi Karsten.

Flash from the past looking at some ISDN layer2.
Some comments below.

	Sam

>  struct layer2 *
> -create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, u_long arg)
> +create_l2(struct mISDNchannel *ch, u_int protocol, u_long options, u_int tei,
> +		u_int sapi)

Unrealted to this specific patch...
Are there any specific reason why mISDN prefer bsd style (u_int)
rather then linux style (u32)?

>  
>  static struct layer2 *
> -create_new_tei(struct manager *mgr, int tei)
> +create_new_tei(struct manager *mgr, int tei, int sapi)
>  {

Here tei and sapi are passed as signed.
But valid sapi range is [0..63] and tei [0..127].
And create_l2 above uses unsigned.

This looks confusing.

>  	u_long		opt = 0;
>  	u_long		flags;
> @@ -791,7 +791,7 @@ create_new_tei(struct manager *mgr, int tei)
>  	if (mgr->ch.st->dev->Dprotocols
>  	  & ((1 << ISDN_P_TE_E1) | (1 << ISDN_P_NT_E1)))
>  		test_and_set_bit(OPTION_L2_PMX, &opt);
> -	l2 = create_l2(mgr->up, ISDN_P_LAPD_NT, (u_int)opt, (u_long)tei);
> +	l2 = create_l2(mgr->up, ISDN_P_LAPD_NT, (u_int)opt, tei, sapi);
>  	if (!l2) {
>  		printk(KERN_WARNING "%s:no memory for layer2\n", __func__);
>  		return NULL;
> @@ -839,12 +839,15 @@ new_tei_req(struct manager *mgr, u_char *dp)
>  	ri += dp[1];
>  	if (!mgr->up)
>  		goto denied;
> -	tei = get_free_tei(mgr);
> +	if (dp[3] != 0xff)
> +		tei = dp[3] >> 1; /* 3GPP TS 08.56 6.1.11.2 */
> +	else
> +		tei = get_free_tei(mgr);

You should check EA0 here before assuming that any values except
EA=1, tei=127 equals ptmp.


>  	if (tei < 0) {
>  		printk(KERN_WARNING "%s:No free tei\n", __func__);
>  		goto denied;
>  	}

So get_free_tei() may return a negative value indicating no free tei.
So that make my comment above void - but is this really the best way
to return an error. Possibly it is..


> -	l2 = create_new_tei(mgr, tei);
> +	l2 = create_new_tei(mgr, tei, 0);

In general I would prefer to read: SAPI_CALLCONTROL rahter than a hardcoded 0.

>  	if (!l2)
>  		goto denied;
>  	else
> @@ -976,8 +979,6 @@ create_teimgr(struct manager *mgr, struct channel_req *crq)
>  			__func__, dev_name(&mgr->ch.st->dev->dev),
>  			crq->protocol, crq->adr.dev, crq->adr.channel,
>  			crq->adr.sapi, crq->adr.tei);
> -	if (crq->adr.sapi != 0) /* not supported yet */
> -		return -EINVAL;
>  	if (crq->adr.tei > GROUP_TEI)
>  		return -EINVAL;
>  	if (crq->adr.tei < 64)
> @@ -1025,7 +1026,7 @@ create_teimgr(struct manager *mgr, struct channel_req *crq)
>  		return 0;
>  	}
>  	l2 = create_l2(crq->ch, crq->protocol, (u_int)opt,
> -		(u_long)crq->adr.tei);
> +		crq->adr.tei, crq->adr.sapi);
>  	if (!l2)
>  		return -ENOMEM;
>  	l2->tm = kzalloc(sizeof(struct teimgr), GFP_KERNEL);
> @@ -1166,7 +1167,7 @@ static int
>  check_data(struct manager *mgr, struct sk_buff *skb)
>  {
>  	struct mISDNhead	*hh =  mISDN_HEAD_P(skb);
> -	int			ret, tei;
> +	int			ret, tei, sapi;
>  	struct layer2		*l2;
>  
>  	if (*debug & DEBUG_L2_CTRL)
> @@ -1178,18 +1179,16 @@ check_data(struct manager *mgr, struct sk_buff *skb)
>  		return -ENOTCONN;
>  	if (skb->len != 3)
>  		return -ENOTCONN;
> -	if (skb->data[0] != 0)
> -		/* only SAPI 0 command */
> -		return -ENOTCONN;
> +	sapi = skb->data[0] >> 2;

PReviously there was an implicit check of EA0.
This is missed not that you read sapi and discard the two lower bits.

I also wonder if you remeber to check the command/response bit.
That was implicitly tested to be 0 before and also ignored now.


>  	if (!(skb->data[1] & 1)) /* invalid EA1 */
>  		return -EINVAL;
> -	tei = skb->data[1] >> 0;
> +	tei = skb->data[1] >> 1;

This looks like a bug-fix...

>  	if (tei > 63) /* not a fixed tei */
>  		return -ENOTCONN;
>  	if ((skb->data[2] & ~0x10) != SABME)
>  		return -ENOTCONN;
>  	/* We got a SABME for a fixed TEI */
> -	l2 = create_new_tei(mgr, tei);
> +	l2 = create_new_tei(mgr, tei, sapi);
>  	if (!l2)
>  		return -ENOMEM;
>  	ret = l2->ch.send(&l2->ch, skb);


  reply	other threads:[~2009-05-22 21:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-22 20:42 [mISDN PATCH v2 00/19] mISDN patchset for next Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 01/19] Add watchdog functionality to hfcmulti driver Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 02/19] DSP now uses ring buffer for echo canceler Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 03/19] Echo canceler now gets delay information from hardware Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 05/19] Reduce stack size in dsp_cmx_send() Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 04/19] Fixed missing spin lock on pipeline process Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 07/19] Fix DTMF locking bug issue Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 06/19] Added layer-1-hold feature Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 08/19] Hardware acceleration is now possible in conjunction with audio recording Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 09/19] Fix TEI and SAPI handling Karsten Keil
2009-05-22 21:53   ` Sam Ravnborg [this message]
2009-05-23 13:00     ` Karsten Keil
2009-05-23 23:10       ` Sam Ravnborg
2009-05-24 15:39         ` Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 11/19] Add allocation of recvbuf[1500] at run time to reduce stack size Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 10/19] Add "sapi" information to debug messages Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 12/19] Fix skb leak in error cases Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 13/19] isdn: get_free_devid() failure ignored Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 14/19] Add XHFC support for embedded Speech-Design board to hfcmulti Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 16/19] Added PCI ID for new Junghanns.net Single E1 cards Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 15/19] Add PCI ID for Junghanns 8S card Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 17/19] Cleanup debug messages Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 18/19] Use kernel_{send,recv}msg instead of open coding Karsten Keil
2009-05-22 21:04 ` [mISDN PATCH v2 19/19] Fix DTMF detection enable/disable Karsten Keil
2009-05-25  7:53 ` [mISDN PATCH v2 00/19] mISDN patchset for next David Miller

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=20090522215314.GA4592@uranus.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=davem@davemloft.net \
    --cc=i4ldeveloper@listserv.isdn4linux.de \
    --cc=keil@b1-systems.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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