Lines Matching +full:slave +full:- +full:addr

1 /* SPDX-License-Identifier: GPL-1.0+ */
5 * Portions are (c) Copyright 1995 Simon "Guru Aleph-Null" Janes
43 netdev_info(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
45 netdev_warn(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
47 netdev_dbg(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
49 netdev_err(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
51 #define BOND_MODE(bond) ((bond)->params.mode)
53 /* slave list primitives */
54 #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
61 netdev_adjacent_get_private(bond_slave_list(bond)->next) : \
65 netdev_adjacent_get_private(bond_slave_list(bond)->prev) : \
70 netdev_lower_get_first_private_rcu(bond->dev)
76 * bond_for_each_slave - iterate over all slaves
78 * @pos: current slave
84 netdev_for_each_lower_private((bond)->dev, pos, iter)
88 netdev_for_each_lower_private_rcu((bond)->dev, pos, iter)
157 struct slave { struct
158 struct net_device *dev; /* first - useful for panic debug */
168 u8 backup:1, /* indicates backup slave. Value corresponds with argument
170 inactive:1, /* indicates inactive slave */ argument
171 rx_disabled:1, /* indicates whether slave's Rx is disabled */ argument
191 static inline struct slave *to_slave(struct kobject *kobj) in to_slave() argument
193 return container_of(kobj, struct slave, kobj); in to_slave()
199 struct slave *arr[];
203 * Link pseudo-state only used internally by monitors
205 #define BOND_LINK_NOCHANGE -1
214 * Get rcu_read_lock when reading or RTNL when writing slave list.
217 struct net_device *dev; /* first - useful for panic debug */
218 struct slave __rcu *curr_active_slave;
219 struct slave __rcu *current_arp_slave;
220 struct slave __rcu *primary_slave;
227 struct slave *);
228 /* mode_lock is used for mode-specific locking needs, currently used by:
229 * 3ad mode (4) - protect against running bond_3ad_unbind_slave() and
232 * TLB mode (5) - to sync the use and modifications of its hash table
233 * ALB mode (6) - to sync the use and modifications of its hash table
269 ((struct slave *) rcu_dereference(dev->rx_handler_data))
272 ((struct slave *) rtnl_dereference(dev->rx_handler_data))
274 void bond_queue_slave_event(struct slave *slave);
275 void bond_lower_state_changed(struct slave *slave);
287 static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, in bond_get_slave_by_dev()
290 return netdev_lower_dev_get_private(bond->dev, slave_dev); in bond_get_slave_by_dev()
293 static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) in bond_get_bond_by_slave() argument
295 return slave->bond; in bond_get_bond_by_slave()
317 return (bond_is_lb(bond) && bond->params.tlb_dynamic_lb == 0); in bond_is_nondyn_tlb()
354 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); in bond_option_active_slave_get_rcu() local
356 return bond_uses_primary(bond) && slave ? slave->dev : NULL; in bond_option_active_slave_get_rcu()
359 static inline bool bond_slave_is_up(struct slave *slave) in bond_slave_is_up() argument
361 return netif_running(slave->dev) && netif_carrier_ok(slave->dev); in bond_slave_is_up()
364 static inline void bond_set_active_slave(struct slave *slave) in bond_set_active_slave() argument
366 if (slave->backup) { in bond_set_active_slave()
367 slave->backup = 0; in bond_set_active_slave()
368 bond_queue_slave_event(slave); in bond_set_active_slave()
369 bond_lower_state_changed(slave); in bond_set_active_slave()
373 static inline void bond_set_backup_slave(struct slave *slave) in bond_set_backup_slave() argument
375 if (!slave->backup) { in bond_set_backup_slave()
376 slave->backup = 1; in bond_set_backup_slave()
377 bond_queue_slave_event(slave); in bond_set_backup_slave()
378 bond_lower_state_changed(slave); in bond_set_backup_slave()
382 static inline void bond_set_slave_state(struct slave *slave, in bond_set_slave_state() argument
385 if (slave->backup == slave_state) in bond_set_slave_state()
388 slave->backup = slave_state; in bond_set_slave_state()
390 bond_lower_state_changed(slave); in bond_set_slave_state()
391 bond_queue_slave_event(slave); in bond_set_slave_state()
392 slave->should_notify = 0; in bond_set_slave_state()
394 if (slave->should_notify) in bond_set_slave_state()
395 slave->should_notify = 0; in bond_set_slave_state()
397 slave->should_notify = 1; in bond_set_slave_state()
404 struct slave *tmp; in bond_slave_state_change()
407 if (tmp->link == BOND_LINK_UP) in bond_slave_state_change()
409 else if (tmp->link == BOND_LINK_DOWN) in bond_slave_state_change()
417 struct slave *tmp; in bond_slave_state_notify()
420 if (tmp->should_notify) { in bond_slave_state_notify()
422 tmp->should_notify = 0; in bond_slave_state_notify()
427 static inline int bond_slave_state(struct slave *slave) in bond_slave_state() argument
429 return slave->backup; in bond_slave_state()
432 static inline bool bond_is_active_slave(struct slave *slave) in bond_is_active_slave() argument
434 return !bond_slave_state(slave); in bond_is_active_slave()
437 static inline bool bond_slave_can_tx(struct slave *slave) in bond_slave_can_tx() argument
439 return bond_slave_is_up(slave) && slave->link == BOND_LINK_UP && in bond_slave_can_tx()
440 bond_is_active_slave(slave); in bond_slave_can_tx()
445 struct slave *slave; in bond_is_active_slave_dev() local
449 slave = bond_slave_get_rcu(slave_dev); in bond_is_active_slave_dev()
450 active = bond_is_active_slave(slave); in bond_is_active_slave_dev()
492 struct slave *slave) in slave_do_arp_validate() argument
494 return bond->params.arp_validate & (1 << bond_slave_state(slave)); in slave_do_arp_validate()
499 return bond->params.arp_validate & BOND_ARP_FILTER; in slave_do_arp_validate_only()
502 static inline int bond_is_ip_target_ok(__be32 addr) in bond_is_ip_target_ok() argument
504 return !ipv4_is_lbcast(addr) && !ipv4_is_zeronet(addr); in bond_is_ip_target_ok()
508 static inline int bond_is_ip6_target_ok(struct in6_addr *addr) in bond_is_ip6_target_ok() argument
510 return !ipv6_addr_any(addr) && in bond_is_ip6_target_ok()
511 !ipv6_addr_loopback(addr) && in bond_is_ip6_target_ok()
512 !ipv6_addr_is_multicast(addr); in bond_is_ip6_target_ok()
516 /* Get the oldest arp which we've received on this slave for bond's
520 struct slave *slave) in slave_oldest_target_arp_rx() argument
523 unsigned long ret = slave->target_last_arp_rx[0]; in slave_oldest_target_arp_rx()
525 for (; (i < BOND_MAX_ARP_TARGETS) && bond->params.arp_targets[i]; i++) in slave_oldest_target_arp_rx()
526 if (time_before(slave->target_last_arp_rx[i], ret)) in slave_oldest_target_arp_rx()
527 ret = slave->target_last_arp_rx[i]; in slave_oldest_target_arp_rx()
533 struct slave *slave) in slave_last_rx() argument
535 if (bond->params.arp_all_targets == BOND_ARP_TARGETS_ALL) in slave_last_rx()
536 return slave_oldest_target_arp_rx(bond, slave); in slave_last_rx()
538 return slave->last_rx; in slave_last_rx()
541 static inline void slave_update_last_tx(struct slave *slave) in slave_update_last_tx() argument
543 WRITE_ONCE(slave->last_tx, jiffies); in slave_update_last_tx()
546 static inline unsigned long slave_last_tx(struct slave *slave) in slave_last_tx() argument
548 return READ_ONCE(slave->last_tx); in slave_last_tx()
552 static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave, in bond_netpoll_send_skb() argument
555 return netpoll_send_skb(slave->np, skb); in bond_netpoll_send_skb()
558 static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave, in bond_netpoll_send_skb() argument
566 static inline void bond_set_slave_inactive_flags(struct slave *slave, in bond_set_slave_inactive_flags() argument
569 if (!bond_is_lb(slave->bond)) in bond_set_slave_inactive_flags()
570 bond_set_slave_state(slave, BOND_STATE_BACKUP, notify); in bond_set_slave_inactive_flags()
571 if (!slave->bond->params.all_slaves_active) in bond_set_slave_inactive_flags()
572 slave->inactive = 1; in bond_set_slave_inactive_flags()
573 if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) in bond_set_slave_inactive_flags()
574 slave->rx_disabled = 1; in bond_set_slave_inactive_flags()
577 static inline void bond_set_slave_tx_disabled_flags(struct slave *slave, in bond_set_slave_tx_disabled_flags() argument
580 bond_set_slave_state(slave, BOND_STATE_BACKUP, notify); in bond_set_slave_tx_disabled_flags()
583 static inline void bond_set_slave_active_flags(struct slave *slave, in bond_set_slave_active_flags() argument
586 bond_set_slave_state(slave, BOND_STATE_ACTIVE, notify); in bond_set_slave_active_flags()
587 slave->inactive = 0; in bond_set_slave_active_flags()
588 if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) in bond_set_slave_active_flags()
589 slave->rx_disabled = 0; in bond_set_slave_active_flags()
592 static inline void bond_set_slave_rx_enabled_flags(struct slave *slave, in bond_set_slave_rx_enabled_flags() argument
595 slave->rx_disabled = 0; in bond_set_slave_rx_enabled_flags()
598 static inline bool bond_is_slave_inactive(struct slave *slave) in bond_is_slave_inactive() argument
600 return slave->inactive; in bond_is_slave_inactive()
603 static inline bool bond_is_slave_rx_disabled(struct slave *slave) in bond_is_slave_rx_disabled() argument
605 return slave->rx_disabled; in bond_is_slave_rx_disabled()
608 static inline void bond_propose_link_state(struct slave *slave, int state) in bond_propose_link_state() argument
610 slave->link_new_state = state; in bond_propose_link_state()
613 static inline void bond_commit_link_state(struct slave *slave, bool notify) in bond_commit_link_state() argument
615 if (slave->link_new_state == BOND_LINK_NOCHANGE) in bond_commit_link_state()
618 slave->link = slave->link_new_state; in bond_commit_link_state()
620 bond_queue_slave_event(slave); in bond_commit_link_state()
621 bond_lower_state_changed(slave); in bond_commit_link_state()
622 slave->should_notify_link = 0; in bond_commit_link_state()
624 if (slave->should_notify_link) in bond_commit_link_state()
625 slave->should_notify_link = 0; in bond_commit_link_state()
627 slave->should_notify_link = 1; in bond_commit_link_state()
631 static inline void bond_set_slave_link_state(struct slave *slave, int state, in bond_set_slave_link_state() argument
634 bond_propose_link_state(slave, state); in bond_set_slave_link_state()
635 bond_commit_link_state(slave, notify); in bond_set_slave_link_state()
641 struct slave *tmp; in bond_slave_link_notify()
644 if (tmp->should_notify_link) { in bond_slave_link_notify()
647 tmp->should_notify_link = 0; in bond_slave_link_notify()
655 __be32 addr = 0; in bond_confirm_addr() local
661 addr = inet_confirm_addr(dev_net(dev), in_dev, dst, local, in bond_confirm_addr()
664 return addr; in bond_confirm_addr()
676 int bond_rcv_validate(const struct sk_buff *skb, struct bonding *bond, struct slave *slave);
682 int bond_sysfs_slave_add(struct slave *slave);
683 void bond_sysfs_slave_del(struct slave *slave);
691 void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
707 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave);
734 static inline struct slave *bond_slave_has_mac(struct bonding *bond, in bond_slave_has_mac()
738 struct slave *tmp; in bond_slave_has_mac()
741 if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) in bond_slave_has_mac()
751 struct slave *tmp; in bond_slave_has_mac_rcu()
754 if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) in bond_slave_has_mac_rcu()
760 * Returns -1 if not found, index if found
772 return -1; in bond_get_targets_ip()
790 return -1; in bond_get_targets_ip6()