[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <82f92e8f-3316-f15f-002e-81ff97857b1e@gmail.com>
Date: Mon, 12 Feb 2018 13:08:13 -0700
From: David Ahern <dsahern@...il.com>
To: Serhey Popovych <serhe.popovych@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH iproute2-next v2 1/4] utils: Introduce and use
inet_prefix_reset_flags()
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@...il.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.
Powered by blists - more mailing lists