drivers/net/bonding/bond_options.c
Source file repositories/reference/linux-study-clean/drivers/net/bonding/bond_options.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/bonding/bond_options.c- Extension
.c- Size
- 57559 bytes
- Lines
- 1942
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/hex.hlinux/if.hlinux/netdevice.hlinux/spinlock.hlinux/rcupdate.hlinux/ctype.hlinux/inet.hlinux/sched/signal.hnet/bonding.hnet/ndisc.h
Detected Declarations
function bond_opt_check_rangefunction bond_opt_check_depsfunction bond_opt_dep_printfunction bond_opt_error_interpretfunction __bond_opt_setfunction __bond_opt_set_notifyfunction bond_opt_tryset_rtnlfunction bond_set_xfrm_featuresfunction bond_option_mode_setfunction bond_option_active_slave_setfunction bond_option_miimon_setfunction _bond_option_delay_setfunction bond_option_updelay_setfunction bond_option_downdelay_setfunction bond_option_peer_notif_delay_setfunction bond_option_use_carrier_setfunction bond_option_arp_interval_setfunction _bond_options_arp_ip_target_setfunction _bond_option_arp_ip_target_addfunction bond_option_arp_ip_target_addfunction bond_option_arp_ip_target_remfunction bond_for_each_slavefunction bond_option_arp_ip_targets_clearfunction bond_option_arp_ip_targets_setfunction slave_can_set_ns_maddrfunction Solicitationfunction bond_slave_ns_maddrs_addfunction bond_slave_ns_maddrs_delfunction Solicitationfunction _bond_options_ns_ip6_target_setfunction bond_option_ns_ip6_targets_clearfunction bond_option_ns_ip6_targets_setfunction bond_option_ns_ip6_targets_setfunction slave_set_ns_maddrsfunction bond_option_arp_all_targets_setfunction bond_option_missed_max_setfunction bond_option_prio_setfunction bond_option_primary_setfunction bond_for_each_slavefunction bond_option_primary_reselect_setfunction bond_option_fail_over_mac_setfunction bond_option_xmit_hash_policy_setfunction bond_option_resend_igmp_setfunction bond_option_num_peer_notif_setfunction bond_option_all_slaves_active_setfunction bond_option_min_links_setfunction bond_option_lp_interval_setfunction bond_option_pps_set
Annotated Snippet
if (*p) {
rv = sscanf(val->string, "%32s", valstr);
} else {
rv = sscanf(val->string, "%llu", &val->value);
checkval = true;
}
if (!rv)
goto out;
}
for (i = 0; tbl[i].string; i++) {
/* Check for exact match */
if (checkval) {
if (val->value == tbl[i].value)
ret = &tbl[i];
} else {
if (!strcmp(valstr, "default") &&
(tbl[i].flags & BOND_VALFLAG_DEFAULT))
ret = &tbl[i];
if (!strcmp(valstr, tbl[i].string))
ret = &tbl[i];
}
/* Found an exact match */
if (ret)
goto out;
}
/* Possible range match */
if (checkval && bond_opt_check_range(opt, val->value))
ret = val;
out:
return ret;
}
/* 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;
}
static void bond_opt_dep_print(struct bonding *bond,
const struct bond_option *opt,
struct nlattr *bad_attr,
struct netlink_ext_ack *extack)
{
const struct bond_opt_value *modeval;
struct bond_params *params;
params = &bond->params;
modeval = bond_opt_get_val(BOND_OPT_MODE, params->mode);
if (test_bit(params->mode, &opt->unsuppmodes)) {
netdev_err(bond->dev, "option %s: mode dependency failed, not supported in mode %s(%llu)\n",
opt->name, modeval->string, modeval->value);
NL_SET_ERR_MSG_ATTR(extack, bad_attr,
"option not supported in mode");
}
}
static void bond_opt_error_interpret(struct bonding *bond,
const struct bond_option *opt,
int error, const struct bond_opt_value *val,
struct nlattr *bad_attr,
struct netlink_ext_ack *extack)
{
const struct bond_opt_value *minval, *maxval;
char *p;
switch (error) {
case -EINVAL:
NL_SET_ERR_MSG_ATTR(extack, bad_attr, "invalid option value");
if (val) {
if (val->string) {
/* sometimes RAWVAL opts may have new lines */
p = strchr(val->string, '\n');
if (p)
*p = '\0';
netdev_err(bond->dev, "option %s: invalid value (%s)\n",
opt->name, val->string);
} else {
netdev_err(bond->dev, "option %s: invalid value (%llu)\n",
Annotation
- Immediate include surface: `linux/errno.h`, `linux/hex.h`, `linux/if.h`, `linux/netdevice.h`, `linux/spinlock.h`, `linux/rcupdate.h`, `linux/ctype.h`, `linux/inet.h`.
- Detected declarations: `function bond_opt_check_range`, `function bond_opt_check_deps`, `function bond_opt_dep_print`, `function bond_opt_error_interpret`, `function __bond_opt_set`, `function __bond_opt_set_notify`, `function bond_opt_tryset_rtnl`, `function bond_set_xfrm_features`, `function bond_option_mode_set`, `function bond_option_active_slave_set`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.