From: Jukka Rissanen <jukka.rissanen@linux.intel.com>
To: Alexander Aring <alex.aring@gmail.com>
Cc: linux-wpan@vger.kernel.org, kernel@pengutronix.de,
linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH bluetooth-next 4/6] 6lowpan: cleanup lowpan_header_compress
Date: Fri, 16 Oct 2015 15:41:51 +0300 [thread overview]
Message-ID: <1444999311.3652.11.camel@linux.intel.com> (raw)
In-Reply-To: <1444736579-27826-4-git-send-email-alex.aring@gmail.com>
Hi Alex,
Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
On ti, 2015-10-13 at 13:42 +0200, Alexander Aring wrote:
> This patch changes the lowpan_header_compress function by removing
> unused parameters like "len" and drop static value parameters of
> protocol type. Instead we really check the protocol type inside inside
> the skb structure. Also we drop the use of IEEE802154_ADDR_LEN which is
> link-layer specific. Instead we using EUI64_ADDR_LEN which should always
> the default case for now.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> include/net/6lowpan.h | 30 +++++++++++++++++++++++-------
> net/6lowpan/iphc.c | 17 +++++++----------
> net/bluetooth/6lowpan.c | 3 +--
> net/ieee802154/6lowpan/tx.c | 2 +-
> 4 files changed, 32 insertions(+), 20 deletions(-)
>
> diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
> index aa5a823..6f1e0bd 100644
> --- a/include/net/6lowpan.h
> +++ b/include/net/6lowpan.h
> @@ -258,7 +258,7 @@ struct lowpan_802154_cb *lowpan_802154_cb(const struct sk_buff *skb)
> #ifdef DEBUG
> /* print data in line */
> static inline void raw_dump_inline(const char *caller, char *msg,
> - unsigned char *buf, int len)
> + const unsigned char *buf, int len)
> {
> if (msg)
> pr_debug("%s():%s: ", caller, msg);
> @@ -273,7 +273,7 @@ static inline void raw_dump_inline(const char *caller, char *msg,
> * ...
> */
> static inline void raw_dump_table(const char *caller, char *msg,
> - unsigned char *buf, int len)
> + const unsigned char *buf, int len)
> {
> if (msg)
> pr_debug("%s():%s:\n", caller, msg);
> @@ -282,9 +282,9 @@ static inline void raw_dump_table(const char *caller, char *msg,
> }
> #else
> static inline void raw_dump_table(const char *caller, char *msg,
> - unsigned char *buf, int len) { }
> + const unsigned char *buf, int len) { }
> static inline void raw_dump_inline(const char *caller, char *msg,
> - unsigned char *buf, int len) { }
> + const unsigned char *buf, int len) { }
> #endif
>
> static inline int lowpan_fetch_skb_u8(struct sk_buff *skb, u8 *val)
> @@ -325,8 +325,24 @@ lowpan_header_decompress(struct sk_buff *skb, struct net_device *dev,
> const u8 saddr_len, const u8 *daddr,
> const u8 daddr_type, const u8 daddr_len,
> u8 iphc0, u8 iphc1);
> -int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
> - unsigned short type, const void *_daddr,
> - const void *_saddr, unsigned int len);
> +
> +/**
> + * lowpan_header_compress - replace IPv6 header with 6LoWPAN header
> + *
> + * This function replaces the IPv6 header which should be pointed at
> + * skb->data and skb_network_header, with the IPHC 6LoWPAN header.
> + * The caller need to be sure that the sk buffer is not shared and at have
> + * at least a headroom which is smaller or equal LOWPAN_IPHC_MAX_HEADER_LEN,
> + * which is the IPHC "more bytes than IPv6 header" at worst case.
> + *
> + * @skb: the buffer which should be manipulate.
> + * @dev: the lowpan net device pointer.
> + * @daddr: destination lladdr of mac header which is used for compression
> + * methods.
> + * @saddr: source lladdr of mac header which is used for compression
> + * methods.
> + */
> +int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
> + const void *daddr, const void *saddr);
>
> #endif /* __6LOWPAN_H__ */
> diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
> index dd5f27d..4e4af8c 100644
> --- a/net/6lowpan/iphc.c
> +++ b/net/6lowpan/iphc.c
> @@ -423,16 +423,15 @@ static u8 lowpan_compress_addr_64(u8 **hc_ptr, u8 shift,
> return rol8(val, shift);
> }
>
> -int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
> - unsigned short type, const void *_daddr,
> - const void *_saddr, unsigned int len)
> +int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
> + const void *daddr, const void *saddr)
> {
> u8 tmp, iphc0, iphc1, *hc_ptr;
> struct ipv6hdr *hdr;
> u8 head[LOWPAN_IPHC_MAX_HC_BUF_LEN] = {};
> int ret, addr_type;
>
> - if (type != ETH_P_IPV6)
> + if (skb->protocol != htons(ETH_P_IPV6))
> return -EINVAL;
>
> hdr = ipv6_hdr(skb);
> @@ -456,10 +455,8 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
>
> /* TODO: context lookup */
>
> - raw_dump_inline(__func__, "saddr",
> - (unsigned char *)_saddr, IEEE802154_ADDR_LEN);
> - raw_dump_inline(__func__, "daddr",
> - (unsigned char *)_daddr, IEEE802154_ADDR_LEN);
> + raw_dump_inline(__func__, "saddr", saddr, EUI64_ADDR_LEN);
> + raw_dump_inline(__func__, "daddr", daddr, EUI64_ADDR_LEN);
>
> raw_dump_table(__func__, "sending raw skb network uncompressed packet",
> skb->data, skb->len);
> @@ -544,7 +541,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
> if (addr_type & IPV6_ADDR_LINKLOCAL) {
> iphc1 |= lowpan_compress_addr_64(&hc_ptr,
> LOWPAN_IPHC_SAM_BIT,
> - &hdr->saddr, _saddr);
> + &hdr->saddr, saddr);
> pr_debug("source address unicast link-local %pI6c iphc1 0x%02x\n",
> &hdr->saddr, iphc1);
> } else {
> @@ -589,7 +586,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
> if (addr_type & IPV6_ADDR_LINKLOCAL) {
> /* TODO: context lookup */
> iphc1 |= lowpan_compress_addr_64(&hc_ptr,
> - LOWPAN_IPHC_DAM_BIT, &hdr->daddr, _daddr);
> + LOWPAN_IPHC_DAM_BIT, &hdr->daddr, daddr);
> pr_debug("dest address unicast link-local %pI6c "
> "iphc1 0x%02x\n", &hdr->daddr, iphc1);
> } else {
> diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
> index 665bf38..e2b66f3 100644
> --- a/net/bluetooth/6lowpan.c
> +++ b/net/bluetooth/6lowpan.c
> @@ -489,8 +489,7 @@ static int setup_header(struct sk_buff *skb, struct net_device *netdev,
> status = 1;
> }
>
> - lowpan_header_compress(skb, netdev, ETH_P_IPV6, daddr,
> - dev->netdev->dev_addr, skb->len);
> + lowpan_header_compress(skb, netdev, daddr, dev->netdev->dev_addr);
>
> err = dev_hard_header(skb, netdev, ETH_P_IPV6, NULL, NULL, 0);
> if (err < 0)
> diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
> index 62a21f6..2a5b2c2 100644
> --- a/net/ieee802154/6lowpan/tx.c
> +++ b/net/ieee802154/6lowpan/tx.c
> @@ -218,7 +218,7 @@ static int lowpan_header(struct sk_buff *skb, struct net_device *ldev,
> saddr = &info.saddr.u.extended_addr;
>
> *dgram_size = skb->len;
> - lowpan_header_compress(skb, ldev, ETH_P_IPV6, daddr, saddr, skb->len);
> + lowpan_header_compress(skb, ldev, daddr, saddr);
> /* dgram_offset = (saved bytes after compression) + lowpan header len */
> *dgram_offset = (*dgram_size - skb->len) + skb_network_header_len(skb);
>
Cheers,
Jukka
next prev parent reply other threads:[~2015-10-16 12:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-13 11:42 [PATCH bluetooth-next 1/6] mac802154: llsec: use kzfree Alexander Aring
2015-10-13 11:42 ` [PATCH bluetooth-next 2/6] bluetooth: 6lowpan: use lowpan dispatch helpers Alexander Aring
2015-10-13 13:02 ` Jukka Rissanen
2015-10-16 12:38 ` Jukka Rissanen
2015-10-13 11:42 ` [PATCH bluetooth-next 3/6] 6lowpan: introduce LOWPAN_IPHC_MAX_HC_BUF_LEN Alexander Aring
2015-10-16 12:40 ` Jukka Rissanen
2015-10-13 11:42 ` [PATCH bluetooth-next 4/6] 6lowpan: cleanup lowpan_header_compress Alexander Aring
2015-10-16 12:41 ` Jukka Rissanen [this message]
2015-10-13 11:42 ` [PATCH bluetooth-next 5/6] 6lowpan: cleanup lowpan_header_decompress Alexander Aring
2015-10-16 12:43 ` Jukka Rissanen
2015-10-13 11:42 ` [PATCH bluetooth-next 6/6] 6lowpan: remove lowpan_fetch_skb_u8 Alexander Aring
2015-10-16 12:44 ` Jukka Rissanen
2015-10-20 8:04 ` [PATCH bluetooth-next 1/6] mac802154: llsec: use kzfree Marcel Holtmann
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=1444999311.3652.11.camel@linux.intel.com \
--to=jukka.rissanen@linux.intel.com \
--cc=alex.aring@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-bluetooth@vger.kernel.org \
--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 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).