diff options
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 50 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 30 | ||||
-rw-r--r-- | include/uapi/linux/if_link.h | 3 |
3 files changed, 74 insertions, 9 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index 7b1124366011..f7015eb4f8db 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -94,6 +94,10 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { | |||
94 | [IFLA_BOND_AD_LACP_RATE] = { .type = NLA_U8 }, | 94 | [IFLA_BOND_AD_LACP_RATE] = { .type = NLA_U8 }, |
95 | [IFLA_BOND_AD_SELECT] = { .type = NLA_U8 }, | 95 | [IFLA_BOND_AD_SELECT] = { .type = NLA_U8 }, |
96 | [IFLA_BOND_AD_INFO] = { .type = NLA_NESTED }, | 96 | [IFLA_BOND_AD_INFO] = { .type = NLA_NESTED }, |
97 | [IFLA_BOND_AD_ACTOR_SYS_PRIO] = { .type = NLA_U16 }, | ||
98 | [IFLA_BOND_AD_USER_PORT_KEY] = { .type = NLA_U16 }, | ||
99 | [IFLA_BOND_AD_ACTOR_SYSTEM] = { .type = NLA_BINARY, | ||
100 | .len = ETH_ALEN }, | ||
97 | }; | 101 | }; |
98 | 102 | ||
99 | static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX + 1] = { | 103 | static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX + 1] = { |
@@ -379,6 +383,36 @@ static int bond_changelink(struct net_device *bond_dev, | |||
379 | if (err) | 383 | if (err) |
380 | return err; | 384 | return err; |
381 | } | 385 | } |
386 | if (data[IFLA_BOND_AD_ACTOR_SYS_PRIO]) { | ||
387 | int actor_sys_prio = | ||
388 | nla_get_u16(data[IFLA_BOND_AD_ACTOR_SYS_PRIO]); | ||
389 | |||
390 | bond_opt_initval(&newval, actor_sys_prio); | ||
391 | err = __bond_opt_set(bond, BOND_OPT_AD_ACTOR_SYS_PRIO, &newval); | ||
392 | if (err) | ||
393 | return err; | ||
394 | } | ||
395 | |||
396 | if (data[IFLA_BOND_AD_USER_PORT_KEY]) { | ||
397 | int port_key = | ||
398 | nla_get_u16(data[IFLA_BOND_AD_USER_PORT_KEY]); | ||
399 | |||
400 | bond_opt_initval(&newval, port_key); | ||
401 | err = __bond_opt_set(bond, BOND_OPT_AD_USER_PORT_KEY, &newval); | ||
402 | if (err) | ||
403 | return err; | ||
404 | } | ||
405 | |||
406 | if (data[IFLA_BOND_AD_ACTOR_SYSTEM]) { | ||
407 | if (nla_len(data[IFLA_BOND_AD_ACTOR_SYSTEM]) != ETH_ALEN) | ||
408 | return -EINVAL; | ||
409 | |||
410 | bond_opt_initval(&newval, | ||
411 | nla_get_be64(data[IFLA_BOND_AD_ACTOR_SYSTEM])); | ||
412 | err = __bond_opt_set(bond, BOND_OPT_AD_ACTOR_SYSTEM, &newval); | ||
413 | if (err) | ||
414 | return err; | ||
415 | } | ||
382 | return 0; | 416 | return 0; |
383 | } | 417 | } |
384 | 418 | ||
@@ -426,6 +460,9 @@ static size_t bond_get_size(const struct net_device *bond_dev) | |||
426 | nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_INFO_ACTOR_KEY */ | 460 | nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_INFO_ACTOR_KEY */ |
427 | nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_INFO_PARTNER_KEY*/ | 461 | nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_INFO_PARTNER_KEY*/ |
428 | nla_total_size(ETH_ALEN) + /* IFLA_BOND_AD_INFO_PARTNER_MAC*/ | 462 | nla_total_size(ETH_ALEN) + /* IFLA_BOND_AD_INFO_PARTNER_MAC*/ |
463 | nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_ACTOR_SYS_PRIO */ | ||
464 | nla_total_size(sizeof(u16)) + /* IFLA_BOND_AD_USER_PORT_KEY */ | ||
465 | nla_total_size(ETH_ALEN) + /* IFLA_BOND_AD_ACTOR_SYSTEM */ | ||
429 | 0; | 466 | 0; |
430 | } | 467 | } |
431 | 468 | ||
@@ -551,6 +588,19 @@ static int bond_fill_info(struct sk_buff *skb, | |||
551 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { | 588 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
552 | struct ad_info info; | 589 | struct ad_info info; |
553 | 590 | ||
591 | if (nla_put_u16(skb, IFLA_BOND_AD_ACTOR_SYS_PRIO, | ||
592 | bond->params.ad_actor_sys_prio)) | ||
593 | goto nla_put_failure; | ||
594 | |||
595 | if (nla_put_u16(skb, IFLA_BOND_AD_USER_PORT_KEY, | ||
596 | bond->params.ad_user_port_key)) | ||
597 | goto nla_put_failure; | ||
598 | |||
599 | if (nla_put(skb, IFLA_BOND_AD_ACTOR_SYSTEM, | ||
600 | sizeof(bond->params.ad_actor_system), | ||
601 | &bond->params.ad_actor_system)) | ||
602 | goto nla_put_failure; | ||
603 | |||
554 | if (!bond_3ad_get_active_agg_info(bond, &info)) { | 604 | if (!bond_3ad_get_active_agg_info(bond, &info)) { |
555 | struct nlattr *nest; | 605 | struct nlattr *nest; |
556 | 606 | ||
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index c85da05721e6..9a32bbd7724e 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -1394,7 +1394,7 @@ static int bond_option_tlb_dynamic_lb_set(struct bonding *bond, | |||
1394 | static int bond_option_ad_actor_sys_prio_set(struct bonding *bond, | 1394 | static int bond_option_ad_actor_sys_prio_set(struct bonding *bond, |
1395 | const struct bond_opt_value *newval) | 1395 | const struct bond_opt_value *newval) |
1396 | { | 1396 | { |
1397 | netdev_info(bond->dev, "Setting ad_actor_sys_prio to (%llu)\n", | 1397 | netdev_info(bond->dev, "Setting ad_actor_sys_prio to %llu\n", |
1398 | newval->value); | 1398 | newval->value); |
1399 | 1399 | ||
1400 | bond->params.ad_actor_sys_prio = newval->value; | 1400 | bond->params.ad_actor_sys_prio = newval->value; |
@@ -1405,24 +1405,36 @@ static int bond_option_ad_actor_system_set(struct bonding *bond, | |||
1405 | const struct bond_opt_value *newval) | 1405 | const struct bond_opt_value *newval) |
1406 | { | 1406 | { |
1407 | u8 macaddr[ETH_ALEN]; | 1407 | u8 macaddr[ETH_ALEN]; |
1408 | u8 *mac; | ||
1408 | int i; | 1409 | int i; |
1409 | 1410 | ||
1410 | i = sscanf(newval->string, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", | 1411 | if (newval->string) { |
1411 | &macaddr[0], &macaddr[1], &macaddr[2], | 1412 | i = sscanf(newval->string, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", |
1412 | &macaddr[3], &macaddr[4], &macaddr[5]); | 1413 | &macaddr[0], &macaddr[1], &macaddr[2], |
1413 | if (i != ETH_ALEN || !is_valid_ether_addr(macaddr)) { | 1414 | &macaddr[3], &macaddr[4], &macaddr[5]); |
1414 | netdev_err(bond->dev, "Invalid MAC address.\n"); | 1415 | if (i != ETH_ALEN) |
1415 | return -EINVAL; | 1416 | goto err; |
1417 | mac = macaddr; | ||
1418 | } else { | ||
1419 | mac = (u8 *)&newval->value; | ||
1416 | } | 1420 | } |
1417 | 1421 | ||
1418 | ether_addr_copy(bond->params.ad_actor_system, macaddr); | 1422 | if (!is_valid_ether_addr(mac)) |
1423 | goto err; | ||
1424 | |||
1425 | netdev_info(bond->dev, "Setting ad_actor_system to %pM\n", mac); | ||
1426 | ether_addr_copy(bond->params.ad_actor_system, mac); | ||
1419 | return 0; | 1427 | return 0; |
1428 | |||
1429 | err: | ||
1430 | netdev_err(bond->dev, "Invalid MAC address.\n"); | ||
1431 | return -EINVAL; | ||
1420 | } | 1432 | } |
1421 | 1433 | ||
1422 | static int bond_option_ad_user_port_key_set(struct bonding *bond, | 1434 | static int bond_option_ad_user_port_key_set(struct bonding *bond, |
1423 | const struct bond_opt_value *newval) | 1435 | const struct bond_opt_value *newval) |
1424 | { | 1436 | { |
1425 | netdev_info(bond->dev, "Setting ad_user_port_key to (%llu)\n", | 1437 | netdev_info(bond->dev, "Setting ad_user_port_key to %llu\n", |
1426 | newval->value); | 1438 | newval->value); |
1427 | 1439 | ||
1428 | bond->params.ad_user_port_key = newval->value; | 1440 | bond->params.ad_user_port_key = newval->value; |
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index d9cd19214b98..6d6e502e1051 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h | |||
@@ -417,6 +417,9 @@ enum { | |||
417 | IFLA_BOND_AD_LACP_RATE, | 417 | IFLA_BOND_AD_LACP_RATE, |
418 | IFLA_BOND_AD_SELECT, | 418 | IFLA_BOND_AD_SELECT, |
419 | IFLA_BOND_AD_INFO, | 419 | IFLA_BOND_AD_INFO, |
420 | IFLA_BOND_AD_ACTOR_SYS_PRIO, | ||
421 | IFLA_BOND_AD_USER_PORT_KEY, | ||
422 | IFLA_BOND_AD_ACTOR_SYSTEM, | ||
420 | __IFLA_BOND_MAX, | 423 | __IFLA_BOND_MAX, |
421 | }; | 424 | }; |
422 | 425 | ||