Re: [PATCH net-next 3/3] vxlan: move flag sets to use a helper func vxlan_nl2conf

2018-11-30 Thread kbuild test robot
Hi Roopa,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Roopa-Prabhu/vxlan-support-changelink-for-a-few-more-attributes/20181130-030315
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers/net/vxlan.c:3526:22: error: Expected ; at end of statement
>> drivers/net/vxlan.c:3526:22: error: got {
>> drivers/net/vxlan.c:3534:17: error: Expected ) in function declarator
   drivers/net/vxlan.c:3534:17: error: got [
>> drivers/net/vxlan.c:3534:9: error: Trying to use reserved word 'if' as 
>> identifier
   drivers/net/vxlan.c:3536:25: error: Trying to use reserved word 'if' as 
identifier
>> drivers/net/vxlan.c:3536:25: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3536:25: error: got }
>> drivers/net/vxlan.c:3539:25: error: Trying to use reserved word 'return' as 
>> identifier
>> drivers/net/vxlan.c:3539:32: error: Expected ; at end of declaration
   drivers/net/vxlan.c:3539:32: error: got -
   drivers/net/vxlan.c:3540:17: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3540:17: error: got }
   drivers/net/vxlan.c:3542:9: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3542:9: error: got }
   drivers/net/vxlan.c:3546:25: error: Trying to use reserved word 'if' as 
identifier
   drivers/net/vxlan.c:3546:25: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3546:25: error: got }
   drivers/net/vxlan.c:3549:25: error: Trying to use reserved word 'return' as 
identifier
   drivers/net/vxlan.c:3549:32: error: Expected ; at end of declaration
   drivers/net/vxlan.c:3549:32: error: got -
   drivers/net/vxlan.c:3550:17: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3550:17: error: got }
   drivers/net/vxlan.c:3553:9: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3553:9: error: got }
   drivers/net/vxlan.c:3558:63: error: Expected ) in function declarator
   drivers/net/vxlan.c:3558:63: error: got ,
   drivers/net/vxlan.c:3561:56: error: Expected ) in function declarator
   drivers/net/vxlan.c:3561:56: error: got ,
   drivers/net/vxlan.c:3564:56: error: Expected ) in function declarator
   drivers/net/vxlan.c:3564:56: error: got ,
   drivers/net/vxlan.c:3567:49: error: Expected ) in function declarator
   drivers/net/vxlan.c:3567:49: error: got ,
   drivers/net/vxlan.c:3570:49: error: Expected ) in function declarator
   drivers/net/vxlan.c:3570:49: error: got ,
   drivers/net/vxlan.c:3573:63: error: Expected ) in function declarator
   drivers/net/vxlan.c:3573:63: error: got ,
   drivers/net/vxlan.c:3576:15: error: Expected ) in function declarator
   drivers/net/vxlan.c:3576:15: error: got [
   drivers/net/vxlan.c:3576:9: error: Trying to use reserved word 'if' as 
identifier
   drivers/net/vxlan.c:3578:25: error: Trying to use reserved word 'if' as 
identifier
   drivers/net/vxlan.c:3578:25: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3578:25: error: got }
   drivers/net/vxlan.c:3581:25: error: Trying to use reserved word 'return' as 
identifier
   drivers/net/vxlan.c:3581:32: error: Expected ; at end of declaration
   drivers/net/vxlan.c:3581:32: error: got -
   drivers/net/vxlan.c:3582:17: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3582:17: error: got }
   drivers/net/vxlan.c:3584:9: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3584:9: error: got }
   drivers/net/vxlan.c:3589:9: error: Trying to use reserved word 'return' as 
identifier
   drivers/net/vxlan.c:3589:16: error: Expected ; at end of declaration
   drivers/net/vxlan.c:3589:16: error: got 0
   drivers/net/vxlan.c:3590:1: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3590:1: error: got }
   drivers/net/vxlan.c:3600:9: error: Trying to use reserved word 'if' as 
identifier
   drivers/net/vxlan.c:3601:17: error: Expected ; at end of declaration
>> drivers/net/vxlan.c:3601:17: error: got return
   drivers/net/vxlan.c:3603:9: error: Trying to use reserved word 'return' as 
identifier
   drivers/net/vxlan.c:3603:16: error: Expected ; at end of declaration
>> drivers/net/vxlan.c:3603:16: error: got __vxlan_dev_create
   drivers/net/vxlan.c:3604:1: error: Expected ; at the end of type declaration
   drivers/net/vxlan.c:3604:1: error: got }
   drivers/net/vxlan.c:3620:9: error: Trying to use reserved word 'if' as 
identifier
   drivers/net/vxlan.c:3621:17: error: Expected ; at end of declaration
   drivers/net/vxlan.c:3621:17: error: got return
   drivers/net/vxlan.c:3624:9: error: Expected ) in function declarator
   drivers/net/vxlan.c:3624:9: error: got &
   drivers/net/vxlan.c:3627:9: error: Trying to use reserved word 'if' as 

Re: [PATCH net-next 3/3] vxlan: move flag sets to use a helper func vxlan_nl2conf

2018-11-28 Thread Roopa Prabhu
On Wed, Nov 28, 2018 at 2:10 PM Roopa Prabhu  wrote:
>
> From: Roopa Prabhu 
>
> Signed-off-by: Roopa Prabhu 
> ---

just noticed a typo in the title, spinning v2.


>  drivers/net/vxlan.c | 95 
> -
>  1 file changed, 43 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
> index 4cb6b50..47671fd 100644
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -3374,6 +3374,23 @@ static int __vxlan_dev_create(struct net *net, struct 
> net_device *dev,
> return err;
>  }
>
> +/* Set/clear flags based on attribute */
> +static void vxlan_nl2flag(struct vxlan_config *conf, struct nlattr *tb[],
> + int attrtype, unsigned long mask)
> +{
> +   unsigned long flags;
> +
> +   if (!tb[attrtype])
> +   return;
> +
> +   if (nla_get_u8(tb[attrtype]))
> +   flags = conf->flags | mask;
> +   else
> +   flags = conf->flags & ~mask;
> +
> +   conf->flags = flags;
> +}
> +
>  static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[],
>  struct net_device *dev, struct vxlan_config *conf,
>  bool changelink, struct netlink_ext_ack *extack)
> @@ -3458,45 +3475,27 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct 
> nlattr *data[],
> if (data[IFLA_VXLAN_TTL])
> conf->ttl = nla_get_u8(data[IFLA_VXLAN_TTL]);
>
> -   if (data[IFLA_VXLAN_TTL_INHERIT])
> -   conf->flags |= VXLAN_F_TTL_INHERIT;
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_TTL_INHERIT,
> + VXLAN_F_TTL_INHERIT);
>
> if (data[IFLA_VXLAN_LABEL])
> conf->label = nla_get_be32(data[IFLA_VXLAN_LABEL]) &
>  IPV6_FLOWLABEL_MASK;
>
> -   if (data[IFLA_VXLAN_LEARNING]) {
> -   if (nla_get_u8(data[IFLA_VXLAN_LEARNING]))
> -   conf->flags |= VXLAN_F_LEARN;
> -   else
> -   conf->flags &= ~VXLAN_F_LEARN;
> -   } else if (!changelink) {
> +   if (data[IFLA_VXLAN_LEARNING])
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_LEARNING,
> + VXLAN_F_LEARN);
> +   else if (!changelink)
> /* default to learn on a new device */
> conf->flags |= VXLAN_F_LEARN;
> -   }
>
> if (data[IFLA_VXLAN_AGEING])
> conf->age_interval = nla_get_u32(data[IFLA_VXLAN_AGEING]);
>
> -   if (data[IFLA_VXLAN_PROXY]) {
> -   if (nla_get_u8(data[IFLA_VXLAN_PROXY]))
> -   conf->flags |= VXLAN_F_PROXY;
> -   }
> -
> -   if (data[IFLA_VXLAN_RSC]) {
> -   if (nla_get_u8(data[IFLA_VXLAN_RSC]))
> -   conf->flags |= VXLAN_F_RSC;
> -   }
> -
> -   if (data[IFLA_VXLAN_L2MISS]) {
> -   if (nla_get_u8(data[IFLA_VXLAN_L2MISS]))
> -   conf->flags |= VXLAN_F_L2MISS;
> -   }
> -
> -   if (data[IFLA_VXLAN_L3MISS]) {
> -   if (nla_get_u8(data[IFLA_VXLAN_L3MISS]))
> -   conf->flags |= VXLAN_F_L3MISS;
> -   }
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_PROXY, VXLAN_F_PROXY);
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_RSC, VXLAN_F_RSC);
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_L2MISS, VXLAN_F_L2MISS);
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_L3MISS, VXLAN_F_L3MISS);
>
> if (data[IFLA_VXLAN_LIMIT]) {
> if (changelink) {
> @@ -3514,8 +3513,8 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct 
> nlattr *data[],
> "Cannot change metadata flag");
> return -EOPNOTSUPP;
> }
> -   if (nla_get_u8(data[IFLA_VXLAN_COLLECT_METADATA]))
> -   conf->flags |= VXLAN_F_COLLECT_METADATA;
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_COLLECT_METADATA,
> + VXLAN_F_COLLECT_METADATA);
> }
>
> if (data[IFLA_VXLAN_PORT_RANGE]) {
> @@ -3553,34 +3552,26 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct 
> nlattr *data[],
> conf->flags |= VXLAN_F_UDP_ZERO_CSUM_TX;
> }
>
> -   if (data[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]) {
> -   if (nla_get_u8(data[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]))
> -   conf->flags |= VXLAN_F_UDP_ZERO_CSUM6_TX;
> -   }
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_UDP_ZERO_CSUM6_TX,
> + VXLAN_F_UDP_ZERO_CSUM6_TX);
>
> -   if (data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) {
> -   if (nla_get_u8(data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]))
> -   conf->flags |= VXLAN_F_UDP_ZERO_CSUM6_RX;
> -   }
> +   vxlan_nl2flag(conf, data, IFLA_VXLAN_UDP_ZERO_CSUM6_RX,
> + VXLAN_F_UDP_ZERO_CSUM6_RX);
>
> -   if