netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Serhey Popovych <serhe.popovych@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH iproute2-next v2 1/4] utils: Introduce and use inet_prefix_reset_flags()
Date: Mon, 12 Feb 2018 13:08:13 -0700	[thread overview]
Message-ID: <82f92e8f-3316-f15f-002e-81ff97857b1e@gmail.com> (raw)
In-Reply-To: <1518379353-31995-2-git-send-email-serhe.popovych@gmail.com>

On 2/11/18 1:02 PM, Serhey Popovych wrote:
> Initializing @inet_prefix using C initializers or memset() seems
> inefficient and unnecessary: only small part of ->data[] field will be
> used to store address corresponding to ->family.
> 
> Instead initialize ->flags with zero and assume no other fields accessed
> before checking corresponding bits in ->flags. For example special
> helpers (e.g. is_addrtype_*()) can be used to ensure that @inet_prefix
> contains valid ip or ipv6 address.
> 
> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
> ---
>  include/utils.h    |    5 +++++
>  ip/iplink_geneve.c |    2 +-
>  ip/iplink_vxlan.c  |    7 ++++---
>  3 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/include/utils.h b/include/utils.h
> index 4dc514d..ccbf353 100644
> --- a/include/utils.h
> +++ b/include/utils.h
> @@ -65,6 +65,11 @@ enum {
>  	ADDRTYPE_INET_MULTI	= ADDRTYPE_INET | ADDRTYPE_MULTI
>  };
>  
> +static inline void inet_prefix_reset_flags(inet_prefix *p)
> +{
> +	p->flags = 0;
> +}
> +

I think inet_prefix_reset is sufficient; flags is an implementation detail.

  parent reply	other threads:[~2018-02-12 20:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-11 20:02 [PATCH iproute2-next v2 0/4] ip/tunnel: Unify local/remote endpoint address parsing Serhey Popovych
2018-02-11 20:02 ` [PATCH iproute2-next v2 1/4] utils: Introduce and use inet_prefix_reset_flags() Serhey Popovych
2018-02-11 23:48   ` Stephen Hemminger
2018-02-12  1:15     ` David Ahern
2018-02-12 20:08   ` David Ahern [this message]
2018-02-11 20:02 ` [PATCH iproute2-next v2 2/4] vti/vti6: Unify local/remote endpoint address parsing Serhey Popovych
2018-02-11 20:02 ` [PATCH iproute2-next v2 3/4] gre/gre6: " Serhey Popovych
2018-02-11 20:02 ` [PATCH iproute2-next v2 4/4] iptnl/ip6tnl: Unify local/remote endpoint and 6rd " Serhey Popovych

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=82f92e8f-3316-f15f-002e-81ff97857b1e@gmail.com \
    --to=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=serhe.popovych@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).