Beispiel #1
0
/* If maxval is missing then there's no range to check. In case minval is
 * missing then it's considered to be 0.
 */
static bool bond_opt_check_range(const struct bond_option *opt, u64 val)
{
	const struct bond_opt_value *minval, *maxval;

	minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN);
	maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX);
	if (!maxval || (minval && val < minval->value) || val > maxval->value)
		return false;

	return true;
}
Beispiel #2
0
static void bond_opt_error_interpret(struct bonding *bond,
				     const struct bond_option *opt,
				     int error, struct bond_opt_value *val)
{
	struct bond_opt_value *minval, *maxval;
	char *p;

	switch (error) {
	case -EINVAL:
		if (val) {
			if (val->string) {
				/* sometimes RAWVAL opts may have new lines */
				p = strchr(val->string, '\n');
				if (p)
					*p = '\0';
				pr_err("%s: option %s: invalid value (%s).\n",
				       bond->dev->name, opt->name, val->string);
			} else {
				pr_err("%s: option %s: invalid value (%llu).\n",
				       bond->dev->name, opt->name, val->value);
			}
		}
		minval = bond_opt_get_flags(opt, BOND_VALFLAG_MIN);
		maxval = bond_opt_get_flags(opt, BOND_VALFLAG_MAX);
		if (!maxval)
			break;
		pr_err("%s: option %s: allowed values %llu - %llu.\n",
		       bond->dev->name, opt->name, minval ? minval->value : 0,
		       maxval->value);
		break;
	case -EACCES:
		bond_opt_dep_print(bond, opt);
		break;
	case -ENOTEMPTY:
		pr_err("%s: option %s: unable to set because the bond device has slaves.\n",
		       bond->dev->name, opt->name);
		break;
	case -EBUSY:
		pr_err("%s: option %s: unable to set because the bond device is up.\n",
		       bond->dev->name, opt->name);
		break;
	default:
		break;
	}
}