Skip to content

Commit

Permalink
Merge pull request #546 from pwieczorkiewicz/bonding_arp
Browse files Browse the repository at this point in the history
bonding: don't insist on active-backup mode when arp_validate=none  (boo#919573)
  • Loading branch information
mtomaschewski committed Jun 12, 2015
2 parents f3e08db + 23013c6 commit ef9ded8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/wicked/bonding.h
Expand Up @@ -114,7 +114,7 @@ extern ni_bool_t ni_bonding_set_option(ni_bonding_t *, const char *, const char
extern int ni_bonding_parse_sysfs_attrs(const char *, ni_bonding_t *);
extern int ni_bonding_write_sysfs_attrs(const char *ifname,
const ni_bonding_t *cfg_bond,
const ni_bonding_t *cur_bond,
ni_bonding_t *cur_bond,
ni_bool_t is_up, ni_bool_t has_slaves);

extern ni_bool_t ni_bonding_is_valid_arp_ip_target(const char *);
Expand Down
2 changes: 1 addition & 1 deletion schema/bonding.xml
Expand Up @@ -40,7 +40,7 @@
<all value="1"/>
</validate-targets>
<!-- targets class="array" element-type="ipv4-address" minlen="1"/ -->
<targets class="array" constraint="required" minlen="1" element-type="string" />
<targets class="array" constraint="required" minlen="1" element-type="string" element-name="address" />
</arpmon>

<miimon class="dict">
Expand Down
21 changes: 16 additions & 5 deletions src/bonding.c
Expand Up @@ -241,16 +241,22 @@ ni_bonding_validate(const ni_bonding_t *bonding)
if (bonding->miimon.frequency > 0)
return "invalid arp and mii monitoring option mix";

if (bonding->mode == NI_BOND_MODE_BALANCE_TLB ||
bonding->mode == NI_BOND_MODE_BALANCE_ALB)
return "invalid arp monitoring in balance-tlb/-alb mode";
switch(bonding->mode) {
case NI_BOND_MODE_802_3AD:
case NI_BOND_MODE_BALANCE_TLB:
case NI_BOND_MODE_BALANCE_ALB:
return "invalid arp monitoring in balance-tlb/-alb or 802.3ad mode";
default:
break;
}

if (bonding->arpmon.interval == 0 ||
bonding->arpmon.interval > INT_MAX)
return "invalid arp monitoring interval";

switch (bonding->arpmon.validate) {
case NI_BOND_ARP_VALIDATE_NONE:
break;
case NI_BOND_ARP_VALIDATE_ACTIVE:
case NI_BOND_ARP_VALIDATE_BACKUP:
case NI_BOND_ARP_VALIDATE_ALL:
Expand Down Expand Up @@ -820,7 +826,7 @@ ni_bonding_parse_sysfs_attribute(ni_bonding_t *bonding, const char *attr, char *
bonding->monitoring = NI_BOND_MONITOR_ARP;
} else if (!strcmp(attr, "arp_ip_target")) {
char *s, *p = NULL;
for (s = strtok_r(value, ",", &p); s; s = strtok_r(NULL, ",", &p)) {
for (s = strtok_r(value, " \t\n", &p); s; s = strtok_r(NULL, " \t\n", &p)) {
if (ni_bonding_is_valid_arp_ip_target(s))
ni_string_array_append(&bonding->arpmon.targets, s);
}
Expand Down Expand Up @@ -1063,7 +1069,7 @@ ni_bonding_write_one_sysfs_attr(const char *ifname, const ni_bonding_t *bonding,
* as well as in dependency of the bonding up/down state and slave count.
*/
int
ni_bonding_write_sysfs_attrs(const char *ifname, const ni_bonding_t *bonding, const ni_bonding_t *current, ni_bool_t is_up, ni_bool_t has_slaves)
ni_bonding_write_sysfs_attrs(const char *ifname, const ni_bonding_t *bonding, ni_bonding_t *current, ni_bool_t is_up, ni_bool_t has_slaves)
{
/*
* option up/down slaves modes
Expand Down Expand Up @@ -1125,6 +1131,7 @@ ni_bonding_write_sysfs_attrs(const char *ifname, const ni_bonding_t *bonding, co
};
const struct attr_matrix *attrs;
unsigned int i;
char *attrval = NULL;

attrs = attr_matrix;
for (i = 0; attrs[i].name; ++i) {
Expand All @@ -1148,6 +1155,10 @@ ni_bonding_write_sysfs_attrs(const char *ifname, const ni_bonding_t *bonding, co
!attrs[i].nofail)
return -1;
}

if (!ni_sysfs_bonding_get_attr(ifname, attrs[i].name, &attrval) && attrval)
ni_bonding_parse_sysfs_attribute(current, attrs[i].name, attrval);
ni_string_free(&attrval);
}

return 0;
Expand Down
3 changes: 3 additions & 0 deletions src/ifconfig.c
Expand Up @@ -1369,6 +1369,7 @@ ni_system_bond_setup(ni_netconfig_t *nc, ni_netdev_t *dev, const ni_bonding_t *b
*/
ni_debug_ifconfig("%s: configuring bonding device (stage 0.%u.%u)",
dev->name, is_up, has_slaves);
ni_bonding_parse_sysfs_attrs(dev->name, bond);
if (ni_bonding_write_sysfs_attrs(dev->name, bond_cfg, bond,
is_up, has_slaves) < 0) {
ni_error("%s: cannot configure bonding device (stage 0.%u.%u)",
Expand Down Expand Up @@ -1442,6 +1443,7 @@ ni_system_bond_setup(ni_netconfig_t *nc, ni_netdev_t *dev, const ni_bonding_t *b
*/
ni_debug_ifconfig("%s: configuring bonding device (stage 2.%u.%u)",
dev->name, is_up, has_slaves);
ni_bonding_parse_sysfs_attrs(dev->name, bond);
if (ni_bonding_write_sysfs_attrs(dev->name, bond_cfg, bond,
is_up, has_slaves) < 0) {
ni_error("%s: cannot configure bonding device (stage 2.%u.%u)",
Expand All @@ -1453,6 +1455,7 @@ ni_system_bond_setup(ni_netconfig_t *nc, ni_netdev_t *dev, const ni_bonding_t *b
dev->name);
return -1;
}
ni_bonding_parse_sysfs_attrs(dev->name, bond);

return 0;
}
Expand Down

0 comments on commit ef9ded8

Please sign in to comment.