From: Stefan Schmidt <stefan@osg.samsung.com>
To: Alexander Aring <alex.aring@gmail.com>, linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de
Subject: Re: [RFC 15/16] ieee802154: 6lowpan: check on valid 802.15.4 frame
Date: Wed, 12 Aug 2015 15:37:40 +0200 [thread overview]
Message-ID: <55CB4C24.1050707@osg.samsung.com> (raw)
In-Reply-To: <1438583035-6287-16-git-send-email-alex.aring@gmail.com>
Hello.
On 03/08/15 08:23, Alexander Aring wrote:
> This patch adds frame control checks to check if the received frame is
> something which could contain a 6LoWPAN packet.
>
> Signed-off-by: Alexander Aring<alex.aring@gmail.com>
> ---
> include/linux/ieee802154.h | 48 ++++++++++++++++++++++++++++++++++++++++++++-
> net/ieee802154/6lowpan/rx.c | 9 +++++++++
> 2 files changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
> index 4f26c01..5a64fc0 100644
> --- a/include/linux/ieee802154.h
> +++ b/include/linux/ieee802154.h
> @@ -208,7 +208,24 @@ enum {
> };
>
> /* frame control handling */
> -#define IEEE802154_FCTL_ACKREQ 0x0020
> +#define IEEE802154_FCTL_FTYPE 0x0003
> +#define IEEE802154_FTYPE_DATA 0x0001
> +#define IEEE802154_FCTL_ACKREQ 0x0020
> +#define IEEE802154_FCTL_INTRA_PAN 0x0040
> +#define IEEE802154_FCTL_DADDR 0x0c00
> +#define IEEE802154_FCTL_DADDR_NONE 0x0000
> +#define IEEE802154_FCTL_SADDR 0xc000
> +#define IEEE802154_FCTL_SADDR_NONE 0x0000
> +
> +/*
> + * ieee802154_is_data - check if type is IEEE802154_FTYPE_DATA
> + * @fc: frame control bytes in little-endian byteorder
> + */
> +static inline int ieee802154_is_data(__le16 fc)
> +{
> + return (fc & cpu_to_le16(IEEE802154_FCTL_FTYPE)) ==
> + cpu_to_le16(IEEE802154_FTYPE_DATA);
> +}
>
> /**
> * ieee802154_is_ackreq - check if acknowledgment request bit is set
> @@ -220,6 +237,35 @@ static inline bool ieee802154_is_ackreq(__le16 fc)
> }
>
> /**
> + * ieee802154_is_intra_pan - check if intra pan id communication
> + * @fc: frame control bytes in little-endian byteorder
> + */
> +static inline bool ieee802154_is_intra_pan(__le16 fc)
> +{
> + return fc & cpu_to_le16(IEEE802154_FCTL_INTRA_PAN);
> +}
> +
> +/**
> + * ieee802154_is_daddr_none - check if daddr mode is none
> + * @fc: frame control bytes in little-endian byteorder
> + */
> +static inline bool ieee802154_is_daddr_none(__le16 fc)
> +{
> + return (fc & cpu_to_le16(IEEE802154_FCTL_DADDR)) ==
> + cpu_to_le16(IEEE802154_FCTL_DADDR_NONE);
> +}
> +
> +/**
> + * ieee802154_is_saddr_none - check if saddr mode is none
> + * @fc: frame control bytes in little-endian byteorder
> + */
> +static inline bool ieee802154_is_saddr_none(__le16 fc)
> +{
> + return (fc & cpu_to_le16(IEEE802154_FCTL_SADDR)) ==
> + cpu_to_le16(IEEE802154_FCTL_SADDR_NONE);
> +}
> +
> +/**
> * ieee802154_get_fc_from_skb - get the frame control field from an skb
> * @skb: skb where the frame control field will be get from
> */
> diff --git a/net/ieee802154/6lowpan/rx.c b/net/ieee802154/6lowpan/rx.c
> index 48869ac..b1a9d14 100644
> --- a/net/ieee802154/6lowpan/rx.c
> +++ b/net/ieee802154/6lowpan/rx.c
> @@ -264,6 +264,15 @@ static inline bool lowpan_is_reserved(u8 dispatch)
> */
> static bool lowpan_rx_h_check(struct sk_buff *skb)
> {
> + __le16 fc = ieee802154_get_fc_from_skb(skb);
> +
> + /* check on ieee802154 conform 6LoWPAN header */
> + if (!ieee802154_is_data(fc) ||
> + ieee802154_is_daddr_none(fc) ||
> + ieee802154_is_saddr_none(fc) ||
> + !ieee802154_is_intra_pan(fc))
Interesting, 6LoWPAN frames always have to have the intra PAN flag set?
Did not know this until now.
> + return false;
> +
> /* check for if we can evaluate the dispatch */
> if (unlikely(!skb->len))
> return false;
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
regards
Stefan Schmidt
next prev parent reply other threads:[~2015-08-12 13:37 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-03 6:23 [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Alexander Aring
2015-08-03 6:23 ` [RFC 01/16] ieee802154: 6lowpan: change dev vars to wdev and ldev Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 02/16] ieee802154: 6lowpan: remove set to zero Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 03/16] ieee802154: 6lowpan: remove EXPORT_SYMBOL Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 04/16] ieee802154: 6lowpan: remove check on wdev is running Alexander Aring
2015-08-12 8:49 ` Stefan Schmidt
2015-08-15 11:50 ` Alexander Aring
2015-08-03 6:23 ` [RFC 05/16] ieee802154: 6lowpan: cleanup pull of iphc bytes Alexander Aring
2015-08-12 9:03 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 06/16] ieee802154: 6lowpan: trivial checks at first Alexander Aring
2015-08-12 9:04 ` Stefan Schmidt
2015-08-12 9:21 ` Alexander Aring
2015-08-15 9:15 ` Alexander Aring
2015-08-03 6:23 ` [RFC 07/16] ieee802154: 6lowpan: change skb->dev earlier Alexander Aring
2015-08-12 9:13 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 08/16] ieee802154: 6lowpan: change frag return value handling Alexander Aring
2015-08-12 9:14 ` Stefan Schmidt
2015-08-12 9:26 ` Alexander Aring
2015-08-03 6:23 ` [RFC 09/16] ieee820154: 6lowpan: dispatch evaluation rework Alexander Aring
2015-08-12 12:51 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 10/16] ieee802154: 6lowpan: add dispatch evalualtion helpers Alexander Aring
2015-08-12 12:51 ` Stefan Schmidt
2015-08-12 13:20 ` Alexander Aring
2015-08-12 13:48 ` Stefan Schmidt
2015-08-12 13:55 ` Alexander Aring
2015-08-03 6:23 ` [RFC 11/16] ieee802154: 6lowpan: fix fragmentation dispatch mask Alexander Aring
2015-08-12 12:51 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 12/16] ieee802154: 6lowpan: add generic lowpan header check Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 13/16] ieee802154: 6lowpan: add handler for all dispatch values Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-03 6:23 ` [RFC 14/16] ieee802154: 6lowpan: add check for reserved dispatch Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-13 20:17 ` Alexander Aring
2015-08-03 6:23 ` [RFC 15/16] ieee802154: 6lowpan: check on valid 802.15.4 frame Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt [this message]
2015-08-12 13:54 ` Alexander Aring
2015-08-03 6:23 ` [RFC 16/16] ieee802154: 6lowpan: remove packet type to host Alexander Aring
2015-08-12 13:37 ` Stefan Schmidt
2015-08-12 8:15 ` [RFC 00/16] ieee802154: 6lowpan: cleanup and rework dispatch evaluation Stefan Schmidt
2015-08-13 9:10 ` Stefan Schmidt
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=55CB4C24.1050707@osg.samsung.com \
--to=stefan@osg.samsung.com \
--cc=alex.aring@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-wpan@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 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.