From: Alexander Aring <alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Stefan Schmidt <stefan-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
Cc: linux-wpan-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
mcr-SWp7JaYWvAQV+D8aMU/kSg@public.gmane.org,
lukasz.duda-hR+23Fw+YnFSHonuZl5R5Q@public.gmane.org,
martin.gergeleit-6wGqcYweBVc@public.gmane.org,
"David S . Miller"
<davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Alexey Kuznetsov <kuznet-v/Mj1YrvjDBInbfyfbPRSQ@public.gmane.org>,
James Morris <jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org>,
Hideaki YOSHIFUJI
<yoshfuji-VfPWfsRibaP+Ru+s062T9g@public.gmane.org>,
Patrick McHardy <kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org>
Subject: Re: [RFCv2 bluetooth-next 2/3] ipv6: add ipv6_addr_prefix_cpy
Date: Wed, 25 Nov 2015 19:17:17 +0100 [thread overview]
Message-ID: <20151125181713.GC4652@omega> (raw)
In-Reply-To: <5655E50C.5090906-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
On Wed, Nov 25, 2015 at 05:42:52PM +0100, Stefan Schmidt wrote:
> Hello.
>
> On 17/11/15 23:33, Alexander Aring wrote:
> >This patch adds a static inline function ipv6_addr_prefix_cpy which
> >copies a ipv6 address prefix(argument pfx) into the ipv6 address prefix.
> >The prefix len is given by plen as bits. This function mainly based on
> >ipv6_addr_prefix which copies one address prefix from address into a new
> >ipv6 address destination and zero all other address bits.
> >
> >The difference is that ipv6_addr_prefix_cpy don't get a prefix from an
> >ipv6 address, it sets a prefix to an ipv6 address with keeping other
> >address bits. The use case is for context based address compression
> >inside 6LoWPAN IPHC header which keeping ipv6 prefixes inside a context
> >table to lookup address-bits without sending them.
> >
> >Cc: David S. Miller<davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
> >Cc: Alexey Kuznetsov<kuznet-v/Mj1YrvjDBInbfyfbPRSQ@public.gmane.org>
> >Cc: James Morris<jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org>
> >Cc: Hideaki YOSHIFUJI<yoshfuji-VfPWfsRibaP+Ru+s062T9g@public.gmane.org>
> >Cc: Patrick McHardy<kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org>
> >Signed-off-by: Alexander Aring<alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> >---
> > include/net/ipv6.h | 15 +++++++++++++++
> > 1 file changed, 15 insertions(+)
> >
> >diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> >index e1a10b0..9d38fc2 100644
> >--- a/include/net/ipv6.h
> >+++ b/include/net/ipv6.h
> >@@ -382,6 +382,21 @@ static inline void ipv6_addr_prefix(struct in6_addr *pfx,
> > pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b);
> > }
> >+static inline void ipv6_addr_prefix_cpy(struct in6_addr *addr,
> >+ const struct in6_addr *pfx,
> >+ int plen)
> >+{
>
> Naming it ipv6_addr_prefix_cop, as Sergei suggested, would be easier to
> read.
ok.
> >+ /* caller must guarantee 0 <= plen <= 128 */
> >+ int o = plen >> 3,
> >+ b = plen & 0x7;
> >+
>
> Any reason you are not doing the memset here before memcpy like it is done
> in ipv6_addr_prefi()?
ipv6_addr_prefix is more a "getter" for a prefix from an address. The
destination address (which should be the result) will memset the whole
address before copy the prefix from address to it.
THe ipv6_addr_prefix_copy will set a prefix given by second parameter
pfx and set the prefix to the address (given by first parameter).
Maybe the ipv6_addr_prefix could call:
1. memset(pfx, sizeof...)
2. ipv6_addr_prefix_copy(pfx, addr, plen);
but ipv6_addr_prefix_copy need to care about other bits which are set at
destination address, if (plen/8 != 0). I don't want to touch
ipv6_addr_prefix function and slow-down some mechanism.
- Alex
next prev parent reply other threads:[~2015-11-25 18:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 22:33 [RFCv2 bluetooth-next 0/3] 6lowpan: debugfs and stateful compression support Alexander Aring
2015-11-17 22:33 ` [RFCv2 bluetooth-next 1/3] 6lowpan: add debugfs support Alexander Aring
2015-11-25 16:42 ` Stefan Schmidt
2015-11-25 18:00 ` Alexander Aring
2015-11-26 11:07 ` Stefan Schmidt
[not found] ` <1447799594-6050-1-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-17 22:33 ` [RFCv2 bluetooth-next 2/3] ipv6: add ipv6_addr_prefix_cpy Alexander Aring
[not found] ` <1447799594-6050-3-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-18 13:55 ` Sergei Shtylyov
2015-11-25 16:42 ` Stefan Schmidt
2015-11-25 16:42 ` Stefan Schmidt
[not found] ` <5655E50C.5090906-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
2015-11-25 18:17 ` Alexander Aring [this message]
2015-11-26 11:11 ` Stefan Schmidt
2015-11-17 22:33 ` [RFCv2 bluetooth-next 3/3] 6lowpan: iphc: add support for stateful compression Alexander Aring
[not found] ` <1447799594-6050-4-git-send-email-alex.aring-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-25 17:12 ` Stefan Schmidt
[not found] ` <5655EBF9.7060102-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
2015-11-25 18:07 ` Alexander Aring
2015-11-26 11:19 ` 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=20151125181713.GC4652@omega \
--to=alex.aring-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org \
--cc=kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org \
--cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=kuznet-v/Mj1YrvjDBInbfyfbPRSQ@public.gmane.org \
--cc=linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-wpan-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lukasz.duda-hR+23Fw+YnFSHonuZl5R5Q@public.gmane.org \
--cc=martin.gergeleit-6wGqcYweBVc@public.gmane.org \
--cc=mcr-SWp7JaYWvAQV+D8aMU/kSg@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=stefan-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org \
--cc=yoshfuji-VfPWfsRibaP+Ru+s062T9g@public.gmane.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).