예제 #1
0
int bond_option_mode_set(struct bonding *bond, int mode)
{
    if (!bond_mode_is_valid(mode)) {
        pr_err("invalid mode value %d.\n", mode);
        return -EINVAL;
    }

    if (bond->dev->flags & IFF_UP) {
        pr_err("%s: unable to update mode because interface is up.\n",
               bond->dev->name);
        return -EPERM;
    }

    if (bond_has_slaves(bond)) {
        pr_err("%s: unable to update mode because bond has slaves.\n",
               bond->dev->name);
        return -EPERM;
    }

    if (BOND_NO_USES_ARP(mode) && bond->params.arp_interval) {
        pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n",
                bond->dev->name, bond_mode_tbl[mode].modename);
        /* disable arp monitoring */
        bond->params.arp_interval = 0;
        /* set miimon to default value */
        bond->params.miimon = BOND_DEFAULT_MIIMON;
        pr_info("%s: Setting MII monitoring interval to %d.\n",
                bond->dev->name, bond->params.miimon);
    }

    /* don't cache arp_validate between modes */
    bond->params.arp_validate = BOND_ARP_VALIDATE_NONE;
    bond->params.mode = mode;
    return 0;
}
예제 #2
0
/* Check opt's dependencies against bond mode and currently set options */
static int bond_opt_check_deps(struct bonding *bond,
			       const struct bond_option *opt)
{
	struct bond_params *params = &bond->params;

	if (test_bit(params->mode, &opt->unsuppmodes))
		return -EACCES;
	if ((opt->flags & BOND_OPTFLAG_NOSLAVES) && bond_has_slaves(bond))
		return -ENOTEMPTY;
	if ((opt->flags & BOND_OPTFLAG_IFDOWN) && (bond->dev->flags & IFF_UP))
		return -EBUSY;

	return 0;
}