Re: [PATCH 5/7 net-next] vxlan: add VXLAN_NL2FLAG macro

From: Michal Kubecek
Date: Thu Aug 27 2020 - 05:50:29 EST


On Thu, Aug 27, 2020 at 08:50:19AM +0200, Fabian Frederick wrote:
> Replace common flag assignment with a macro.
> This could yet be simplified with changelink/supported but it would
> remove clarity
>
> Signed-off-by: Fabian Frederick <fabf@xxxxxxxxx>
> ---
[...]
> diff --git a/include/net/vxlan.h b/include/net/vxlan.h
> index 3a41627cbdfe5..8a56b7a0f75f9 100644
> --- a/include/net/vxlan.h
> +++ b/include/net/vxlan.h
> @@ -290,6 +290,16 @@ struct vxlan_dev {
> VXLAN_F_UDP_ZERO_CSUM6_RX | \
> VXLAN_F_COLLECT_METADATA)
>
> +
> +#define VXLAN_NL2FLAG(iflag, flag, changelink, changelink_supported) { \
> + if (data[iflag]) { \
> + err = vxlan_nl2flag(conf, data, iflag, flag, changelink, \
> + changelink_supported, extack); \
> + if (err) \
> + return err; \
> + } \
> +}
> +

Hiding a goto or return in a macro is generally discouraged as it may
confuse people reading or updating the code. See e.g. commit
94f826b8076e ("net: fix a potential rcu_read_lock() imbalance in
rt6_fill_node()") for an example of such problem - which was likely the
trigger for removal of NLA_PUT() and related macros shortly after.

Michal

> struct net_device *vxlan_dev_create(struct net *net, const char *name,
> u8 name_assign_type, struct vxlan_config *conf);
>
> --
> 2.27.0
>