From: Alexander Aring <alex.aring@gmail.com>
To: Martin Townsend <mtownsend1973@gmail.com>
Cc: linux-zigbee-devel@lists.sourceforge.net,
linux-bluetooth@vger.kernel.org, linux-wpan@vger.kernel.org,
marcel@holtmann.org, Martin Townsend <martin.townsend@xsilon.com>
Subject: Re: [PATCH v4 bluetooth] 6lowpan: fix incorrect return values in lowpan_rcv
Date: Tue, 16 Sep 2014 13:36:16 +0200 [thread overview]
Message-ID: <20140916113614.GC4969@omega> (raw)
In-Reply-To: <1410865319-16310-2-git-send-email-martin.townsend@xsilon.com>
On Tue, Sep 16, 2014 at 12:01:59PM +0100, Martin Townsend wrote:
> Currently there are a number of error paths in the lowpan_rcv function that
> free the skb before returning, the patch simplifies the receive path by
> ensuring that the skb is only freed from this function.
>
> Passing the skb from 6lowpan up to the higher layers is not a
> function of IPHC. By moving it out of IPHC we also remove the
> need to support error code returns with NET_RX codes.
> It also makes the lowpan_rcv function more extendable as we
> can support more compression schemes.
>
> With the above 2 lowpan_rcv is refacored so eliminate incorrect return values.
>
> Signed-off-by: Martin Townsend <martin.townsend@xsilon.com>
> ---
> include/net/6lowpan.h | 9 +++--
> net/6lowpan/iphc.c | 88 +++++++++++++++++--------------------------
> net/bluetooth/6lowpan.c | 38 ++++++++++---------
> net/ieee802154/6lowpan_rtnl.c | 61 ++++++++++++++++--------------
> 4 files changed, 94 insertions(+), 102 deletions(-)
>
> diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
> index d184df1..c28fadb 100644
> --- a/include/net/6lowpan.h
> +++ b/include/net/6lowpan.h
...
> -static int process_data(struct sk_buff *skb, struct net_device *netdev,
> - struct l2cap_chan *chan)
> +static struct sk_buff *
> +process_data(struct sk_buff *skb, struct net_device *netdev,
> + struct l2cap_chan *chan)
> {
> const u8 *saddr, *daddr;
> u8 iphc0, iphc1;
> @@ -230,36 +231,31 @@ static int process_data(struct sk_buff *skb, struct net_device *netdev,
> peer = peer_lookup_chan(dev, chan);
> read_unlock_irqrestore(&devices_lock, flags);
> if (!peer)
> - goto drop;
> + return ERR_PTR(-EINVAL);
>
> saddr = peer->eui64_addr;
> daddr = dev->netdev->dev_addr;
>
> /* at least two bytes will be used for the encoding */
> if (skb->len < 2)
> - goto drop;
> + return ERR_PTR(-EINVAL);
>
> if (lowpan_fetch_skb_u8(skb, &iphc0))
> - goto drop;
> + return ERR_PTR(-EINVAL);
>
> if (lowpan_fetch_skb_u8(skb, &iphc1))
> - goto drop;
> + return ERR_PTR(-EINVAL);
>
> return lowpan_process_data(skb, netdev,
> saddr, IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
> daddr, IEEE802154_ADDR_LONG, EUI64_ADDR_LEN,
> - iphc0, iphc1, give_skb_to_upper);
> -
> -drop:
> - kfree_skb(skb);
> - return -EINVAL;
> + iphc0, iphc1);
> }
>
> static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
> struct l2cap_chan *chan)
> {
> struct sk_buff *local_skb;
> - int ret;
>
> if (!netif_running(dev))
> goto drop;
> @@ -280,9 +276,6 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
> local_skb->protocol = htons(ETH_P_IPV6);
> local_skb->pkt_type = PACKET_HOST;
>
> - skb_reset_network_header(local_skb);
> - skb_set_transport_header(local_skb, sizeof(struct ipv6hdr));
> -
> if (give_skb_to_upper(local_skb, dev) != NET_RX_SUCCESS) {
> kfree_skb(local_skb);
> goto drop;
> @@ -300,9 +293,20 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
> if (!local_skb)
> goto drop;
>
> - ret = process_data(local_skb, dev, chan);
> - if (ret != NET_RX_SUCCESS)
> + skb = process_data(local_skb, dev, chan);
> + if (IS_ERR(skb)) {
> + kfree_skb(local_skb);
> goto drop;
> + }
> +
> + local_skb->protocol = htons(ETH_P_IPV6);
> + local_skb->pkt_type = PACKET_HOST;
this is the wrong skb here, the new one is skb. I don't know maybe there
is some optimization to call skb = process_data(skb, ...);
> +
> + if (give_skb_to_upper(local_skb, dev)
also here local_skb should be skb, or?
- Alex
next prev parent reply other threads:[~2014-09-16 11:36 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 11:01 [PATCH v4 bluetooth] Fix lowpan_rcv Martin Townsend
2014-09-16 11:01 ` [PATCH v4 bluetooth] 6lowpan: fix incorrect return values in lowpan_rcv Martin Townsend
2014-09-16 11:09 ` Martin Townsend
2014-09-16 11:36 ` Alexander Aring [this message]
2014-09-16 11:39 ` Martin Townsend
2014-09-16 11:48 ` Alexander Aring
2014-09-16 11:53 ` Alexander Aring
2014-09-16 12:02 ` Alexander Aring
2014-09-16 12:18 ` Alexander Aring
2014-09-16 12:26 ` Martin Townsend
2014-09-16 12:34 ` Alexander Aring
2014-09-16 12:40 ` Martin Townsend
2014-09-16 12:48 ` Alexander Aring
2014-09-16 13:20 ` Jukka Rissanen
2014-09-16 13:32 ` Alexander Aring
2014-09-16 13:52 ` Jukka Rissanen
2014-09-16 14:05 ` Alexander Aring
2014-09-16 14:44 ` Martin Townsend
2014-09-16 17:38 ` Alexander Aring
2014-09-16 18:57 ` Martin Townsend
2014-09-16 19:37 ` Alexander Aring
2014-09-16 19:53 ` Martin Townsend
2014-09-16 20:07 ` Alexander Aring
2014-09-16 20:19 ` Martin Townsend
2014-09-16 20:30 ` Alexander Aring
2014-09-25 5:55 ` Alexander Aring
2014-09-25 7:25 ` Martin Townsend
2014-09-25 7:31 ` Alexander Aring
2014-09-25 7:39 ` Alexander Aring
2014-09-16 19:38 ` Martin Townsend
-- strict thread matches above, loose matches on Subject: below --
2014-10-01 12:10 [PATCH v4 bluetooth] Fix lowpan_rcv Martin Townsend
2014-10-01 12:10 ` [PATCH v4 bluetooth] 6lowpan: fix incorrect return values in lowpan_rcv Martin Townsend
2014-10-01 12:42 ` Alexander Aring
2014-10-02 12:43 ` Alexander Aring
2014-10-05 17:50 ` Alexander Aring
2014-10-05 17:58 ` Alexander Aring
2014-10-05 18:03 ` Alexander Aring
2014-10-05 21:00 ` Martin Townsend
2014-10-06 7:12 ` Alexander Aring
2014-10-06 8:27 ` Martin Townsend
2014-10-06 8:50 ` Marcel Holtmann
2014-10-06 8:35 ` Martin Townsend
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=20140916113614.GC4969@omega \
--to=alex.aring@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=linux-zigbee-devel@lists.sourceforge.net \
--cc=marcel@holtmann.org \
--cc=martin.townsend@xsilon.com \
--cc=mtownsend1973@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).