Re: [PATCH net-next 2/3] vxlan: extack support for some changelink cases
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-randconfig-x006-201847 (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: In function 'vxlan_nl2conf': >> drivers//net/vxlan.c:3527:3: error: expected '}' before 'else' else { ^~~~ vim +3527 drivers//net/vxlan.c 3376 3377 static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], 3378 struct net_device *dev, struct vxlan_config *conf, 3379 bool changelink, struct netlink_ext_ack *extack) 3380 { 3381 struct vxlan_dev *vxlan = netdev_priv(dev); 3382 3383 memset(conf, 0, sizeof(*conf)); 3384 3385 /* if changelink operation, start with old existing cfg */ 3386 if (changelink) 3387 memcpy(conf, &vxlan->cfg, sizeof(*conf)); 3388 3389 if (data[IFLA_VXLAN_ID]) { 3390 __be32 vni = cpu_to_be32(nla_get_u32(data[IFLA_VXLAN_ID])); 3391 3392 if (changelink && (vni != conf->vni)) { 3393 NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_ID], 3394 "Cannot change vni"); 3395 return -EOPNOTSUPP; 3396 } 3397 conf->vni = cpu_to_be32(nla_get_u32(data[IFLA_VXLAN_ID])); 3398 } 3399 3400 if (data[IFLA_VXLAN_GROUP]) { 3401 if (changelink && (conf->remote_ip.sa.sa_family != AF_INET)) { 3402 NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_GROUP], 3403 "New group addr family does not match old group"); 3404 return -EOPNOTSUPP; 3405 } 3406 conf->remote_ip.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_GROUP]); 3407 conf->remote_ip.sa.sa_family = AF_INET; 3408 } else if (data[IFLA_VXLAN_GROUP6]) { 3409 if (!IS_ENABLED(CONFIG_IPV6)) { 3410 NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_GROUP6], 3411 "IPv6 support not enabled in the kernel"); 3412 return -EPFNOSUPPORT; 3413 } 3414 3415 if (changelink && (conf->remote_ip.sa.sa_family != AF_INET6)) { 3416 NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_GROUP6], 3417 "New group addr family does not match old group"); 3418 return -EOPNOTSUPP; 3419 } 3420 3421 conf->remote_ip.sin6.sin6_addr = nla_get_in6_addr(data[IFLA_VXLAN_GROUP6]); 3422 conf->remote_ip.sa.sa_family = AF_INET6; 3423 } 3424 3425 if (data[IFLA_VXLAN_LOCAL]) { 3426 if (changelink && (conf->saddr.sa.sa_family != AF_INET)) { 3427 NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LOCAL], 3428 "New local addr family does not match old"); 3429 return -EOPNOTSUPP; 3430 } 3431 3432 conf->saddr.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_LOCAL]); 3433 conf->saddr.sa.sa_family = AF_INET; 3434 } else if (data[IFLA_VXLAN_LOCAL6]) { 3435 if (!IS_ENABLED(CONFIG_IPV6)) { 3436 NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LOCAL6], 3437 "IPv6 support not enabled in the kernel"); 3438 return -EPFNOSUPPORT; 3439 } 3440 3441 if (changelink && (conf->saddr.sa.sa_family != AF_INET6)) { 3442 NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LOCAL6], 3443 "New local6 addr family does not match old"); 3444 return -EOPNOTSUPP; 3445 } 3446 3447 /* TODO: respect scope id */ 3448 conf->saddr.sin6.sin6_addr = nla_get_in6_addr(data[IFLA_VXLAN_LOCAL6]); 3449 conf->saddr.sa.sa_family = AF_INET6; 3450 } 3451 3452 if (data[IFLA_VXLAN_LINK]) 3453 conf->remote_ifindex = nla_get_u32(data[IFLA_VXLAN_LINK]); 3454 3455 if (data[IFLA_VXLAN_TOS]) 3456 conf->tos
[PATCH net-next 2/3] vxlan: extack support for some changelink cases
From: Roopa Prabhu Signed-off-by: Roopa Prabhu --- drivers/net/vxlan.c | 76 + 1 file changed, 59 insertions(+), 17 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 73caa65..4cb6b50 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -3376,7 +3376,7 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev, static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], struct net_device *dev, struct vxlan_config *conf, -bool changelink) +bool changelink, struct netlink_ext_ack *extack) { struct vxlan_dev *vxlan = netdev_priv(dev); @@ -3389,40 +3389,60 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], if (data[IFLA_VXLAN_ID]) { __be32 vni = cpu_to_be32(nla_get_u32(data[IFLA_VXLAN_ID])); - if (changelink && (vni != conf->vni)) + if (changelink && (vni != conf->vni)) { + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_ID], + "Cannot change vni"); return -EOPNOTSUPP; + } conf->vni = cpu_to_be32(nla_get_u32(data[IFLA_VXLAN_ID])); } if (data[IFLA_VXLAN_GROUP]) { - if (changelink && (conf->remote_ip.sa.sa_family != AF_INET)) + if (changelink && (conf->remote_ip.sa.sa_family != AF_INET)) { + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_GROUP], + "New group addr family does not match old group"); return -EOPNOTSUPP; - + } conf->remote_ip.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_GROUP]); conf->remote_ip.sa.sa_family = AF_INET; } else if (data[IFLA_VXLAN_GROUP6]) { - if (!IS_ENABLED(CONFIG_IPV6)) + if (!IS_ENABLED(CONFIG_IPV6)) { + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_GROUP6], + "IPv6 support not enabled in the kernel"); return -EPFNOSUPPORT; + } - if (changelink && (conf->remote_ip.sa.sa_family != AF_INET6)) + if (changelink && (conf->remote_ip.sa.sa_family != AF_INET6)) { + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_GROUP6], + "New group addr family does not match old group"); return -EOPNOTSUPP; + } conf->remote_ip.sin6.sin6_addr = nla_get_in6_addr(data[IFLA_VXLAN_GROUP6]); conf->remote_ip.sa.sa_family = AF_INET6; } if (data[IFLA_VXLAN_LOCAL]) { - if (changelink && (conf->saddr.sa.sa_family != AF_INET)) + if (changelink && (conf->saddr.sa.sa_family != AF_INET)) { + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LOCAL], + "New local addr family does not match old"); return -EOPNOTSUPP; + } conf->saddr.sin.sin_addr.s_addr = nla_get_in_addr(data[IFLA_VXLAN_LOCAL]); conf->saddr.sa.sa_family = AF_INET; } else if (data[IFLA_VXLAN_LOCAL6]) { - if (!IS_ENABLED(CONFIG_IPV6)) + if (!IS_ENABLED(CONFIG_IPV6)) { + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LOCAL6], + "IPv6 support not enabled in the kernel"); return -EPFNOSUPPORT; + } - if (changelink && (conf->saddr.sa.sa_family != AF_INET6)) + if (changelink && (conf->saddr.sa.sa_family != AF_INET6)) { + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LOCAL6], + "New local6 addr family does not match old"); return -EOPNOTSUPP; + } /* TODO: respect scope id */ conf->saddr.sin6.sin6_addr = nla_get_in6_addr(data[IFLA_VXLAN_LOCAL6]); @@ -3479,14 +3499,21 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], } if (data[IFLA_VXLAN_LIMIT]) { - if (changelink) + if (changelink) { + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LIMIT], + "Cannot change limit"); return -EOPNOTSUPP; + } conf->addrmax = nla_get_u32(data[IFLA_VXLAN_LIMIT]); } if (data[IFLA_VXLAN_COLLECT_METADATA]) { - if (changelink) + if (changelink) { + NL_SET_ERR_MSG_ATTR(extack, + tb[IFLA