0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _NET_BONDING_H
0016 #define _NET_BONDING_H
0017
0018 #include <linux/timer.h>
0019 #include <linux/proc_fs.h>
0020 #include <linux/if_bonding.h>
0021 #include <linux/cpumask.h>
0022 #include <linux/in6.h>
0023 #include <linux/netpoll.h>
0024 #include <linux/inetdevice.h>
0025 #include <linux/etherdevice.h>
0026 #include <linux/reciprocal_div.h>
0027 #include <linux/if_link.h>
0028
0029 #include <net/bond_3ad.h>
0030 #include <net/bond_alb.h>
0031 #include <net/bond_options.h>
0032 #include <net/ipv6.h>
0033 #include <net/addrconf.h>
0034
0035 #define BOND_MAX_ARP_TARGETS 16
0036 #define BOND_MAX_NS_TARGETS BOND_MAX_ARP_TARGETS
0037
0038 #define BOND_DEFAULT_MIIMON 100
0039
0040 #ifndef __long_aligned
0041 #define __long_aligned __attribute__((aligned((sizeof(long)))))
0042 #endif
0043
0044 #define slave_info(bond_dev, slave_dev, fmt, ...) \
0045 netdev_info(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
0046 #define slave_warn(bond_dev, slave_dev, fmt, ...) \
0047 netdev_warn(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
0048 #define slave_dbg(bond_dev, slave_dev, fmt, ...) \
0049 netdev_dbg(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
0050 #define slave_err(bond_dev, slave_dev, fmt, ...) \
0051 netdev_err(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ##__VA_ARGS__)
0052
0053 #define BOND_MODE(bond) ((bond)->params.mode)
0054
0055
0056 #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
0057
0058 #define bond_has_slaves(bond) !list_empty(bond_slave_list(bond))
0059
0060
0061 #define bond_first_slave(bond) \
0062 (bond_has_slaves(bond) ? \
0063 netdev_adjacent_get_private(bond_slave_list(bond)->next) : \
0064 NULL)
0065 #define bond_last_slave(bond) \
0066 (bond_has_slaves(bond) ? \
0067 netdev_adjacent_get_private(bond_slave_list(bond)->prev) : \
0068 NULL)
0069
0070
0071 #define bond_first_slave_rcu(bond) \
0072 netdev_lower_get_first_private_rcu(bond->dev)
0073
0074 #define bond_is_first_slave(bond, pos) (pos == bond_first_slave(bond))
0075 #define bond_is_last_slave(bond, pos) (pos == bond_last_slave(bond))
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 #define bond_for_each_slave(bond, pos, iter) \
0086 netdev_for_each_lower_private((bond)->dev, pos, iter)
0087
0088
0089 #define bond_for_each_slave_rcu(bond, pos, iter) \
0090 netdev_for_each_lower_private_rcu((bond)->dev, pos, iter)
0091
0092 #define BOND_XFRM_FEATURES (NETIF_F_HW_ESP | NETIF_F_HW_ESP_TX_CSUM | \
0093 NETIF_F_GSO_ESP)
0094
0095 #define BOND_TLS_FEATURES (NETIF_F_HW_TLS_TX | NETIF_F_HW_TLS_RX)
0096
0097 #ifdef CONFIG_NET_POLL_CONTROLLER
0098 extern atomic_t netpoll_block_tx;
0099
0100 static inline void block_netpoll_tx(void)
0101 {
0102 atomic_inc(&netpoll_block_tx);
0103 }
0104
0105 static inline void unblock_netpoll_tx(void)
0106 {
0107 atomic_dec(&netpoll_block_tx);
0108 }
0109
0110 static inline int is_netpoll_tx_blocked(struct net_device *dev)
0111 {
0112 if (unlikely(netpoll_tx_running(dev)))
0113 return atomic_read(&netpoll_block_tx);
0114 return 0;
0115 }
0116 #else
0117 #define block_netpoll_tx()
0118 #define unblock_netpoll_tx()
0119 #define is_netpoll_tx_blocked(dev) (0)
0120 #endif
0121
0122 struct bond_params {
0123 int mode;
0124 int xmit_policy;
0125 int miimon;
0126 u8 num_peer_notif;
0127 u8 missed_max;
0128 int arp_interval;
0129 int arp_validate;
0130 int arp_all_targets;
0131 int use_carrier;
0132 int fail_over_mac;
0133 int updelay;
0134 int downdelay;
0135 int peer_notif_delay;
0136 int lacp_active;
0137 int lacp_fast;
0138 unsigned int min_links;
0139 int ad_select;
0140 char primary[IFNAMSIZ];
0141 int primary_reselect;
0142 __be32 arp_targets[BOND_MAX_ARP_TARGETS];
0143 int tx_queues;
0144 int all_slaves_active;
0145 int resend_igmp;
0146 int lp_interval;
0147 int packets_per_slave;
0148 int tlb_dynamic_lb;
0149 struct reciprocal_value reciprocal_packets_per_slave;
0150 u16 ad_actor_sys_prio;
0151 u16 ad_user_port_key;
0152 #if IS_ENABLED(CONFIG_IPV6)
0153 struct in6_addr ns_targets[BOND_MAX_NS_TARGETS];
0154 #endif
0155
0156
0157 u8 ad_actor_system[ETH_ALEN + 2];
0158 };
0159
0160 struct slave {
0161 struct net_device *dev;
0162 struct bonding *bond;
0163 int delay;
0164
0165 unsigned long last_link_up;
0166 unsigned long last_tx;
0167 unsigned long last_rx;
0168 unsigned long target_last_arp_rx[BOND_MAX_ARP_TARGETS];
0169 s8 link;
0170 s8 link_new_state;
0171 u8 backup:1,
0172
0173 inactive:1,
0174 should_notify:1,
0175 should_notify_link:1;
0176 u8 duplex;
0177 u32 original_mtu;
0178 u32 link_failure_count;
0179 u32 speed;
0180 u16 queue_id;
0181 u8 perm_hwaddr[MAX_ADDR_LEN];
0182 int prio;
0183 struct ad_slave_info *ad_info;
0184 struct tlb_slave_info tlb_info;
0185 #ifdef CONFIG_NET_POLL_CONTROLLER
0186 struct netpoll *np;
0187 #endif
0188 struct delayed_work notify_work;
0189 struct kobject kobj;
0190 struct rtnl_link_stats64 slave_stats;
0191 };
0192
0193 static inline struct slave *to_slave(struct kobject *kobj)
0194 {
0195 return container_of(kobj, struct slave, kobj);
0196 }
0197
0198 struct bond_up_slave {
0199 unsigned int count;
0200 struct rcu_head rcu;
0201 struct slave *arr[];
0202 };
0203
0204
0205
0206
0207 #define BOND_LINK_NOCHANGE -1
0208
0209 struct bond_ipsec {
0210 struct list_head list;
0211 struct xfrm_state *xs;
0212 };
0213
0214
0215
0216
0217
0218 struct bonding {
0219 struct net_device *dev;
0220 struct slave __rcu *curr_active_slave;
0221 struct slave __rcu *current_arp_slave;
0222 struct slave __rcu *primary_slave;
0223 struct bond_up_slave __rcu *usable_slaves;
0224 struct bond_up_slave __rcu *all_slaves;
0225 bool force_primary;
0226 s32 slave_cnt;
0227 int (*recv_probe)(const struct sk_buff *, struct bonding *,
0228 struct slave *);
0229
0230
0231
0232
0233
0234
0235
0236 spinlock_t mode_lock;
0237 spinlock_t stats_lock;
0238 u8 send_peer_notif;
0239 u8 igmp_retrans;
0240 #ifdef CONFIG_PROC_FS
0241 struct proc_dir_entry *proc_entry;
0242 char proc_file_name[IFNAMSIZ];
0243 #endif
0244 struct list_head bond_list;
0245 u32 __percpu *rr_tx_counter;
0246 struct ad_bond_info ad_info;
0247 struct alb_bond_info alb_info;
0248 struct bond_params params;
0249 struct workqueue_struct *wq;
0250 struct delayed_work mii_work;
0251 struct delayed_work arp_work;
0252 struct delayed_work alb_work;
0253 struct delayed_work ad_work;
0254 struct delayed_work mcast_work;
0255 struct delayed_work slave_arr_work;
0256 #ifdef CONFIG_DEBUG_FS
0257
0258 struct dentry *debug_dir;
0259 #endif
0260 struct rtnl_link_stats64 bond_stats;
0261 #ifdef CONFIG_XFRM_OFFLOAD
0262 struct list_head ipsec_list;
0263
0264 spinlock_t ipsec_lock;
0265 #endif
0266 struct bpf_prog *xdp_prog;
0267 };
0268
0269 #define bond_slave_get_rcu(dev) \
0270 ((struct slave *) rcu_dereference(dev->rx_handler_data))
0271
0272 #define bond_slave_get_rtnl(dev) \
0273 ((struct slave *) rtnl_dereference(dev->rx_handler_data))
0274
0275 void bond_queue_slave_event(struct slave *slave);
0276 void bond_lower_state_changed(struct slave *slave);
0277
0278 struct bond_vlan_tag {
0279 __be16 vlan_proto;
0280 unsigned short vlan_id;
0281 };
0282
0283 bool bond_sk_check(struct bonding *bond);
0284
0285
0286
0287
0288
0289
0290 static inline struct slave *bond_get_slave_by_dev(struct bonding *bond,
0291 struct net_device *slave_dev)
0292 {
0293 return netdev_lower_dev_get_private(bond->dev, slave_dev);
0294 }
0295
0296 static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
0297 {
0298 return slave->bond;
0299 }
0300
0301 static inline bool bond_should_override_tx_queue(struct bonding *bond)
0302 {
0303 return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
0304 BOND_MODE(bond) == BOND_MODE_ROUNDROBIN;
0305 }
0306
0307 static inline bool bond_is_lb(const struct bonding *bond)
0308 {
0309 return BOND_MODE(bond) == BOND_MODE_TLB ||
0310 BOND_MODE(bond) == BOND_MODE_ALB;
0311 }
0312
0313 static inline bool bond_needs_speed_duplex(const struct bonding *bond)
0314 {
0315 return BOND_MODE(bond) == BOND_MODE_8023AD || bond_is_lb(bond);
0316 }
0317
0318 static inline bool bond_is_nondyn_tlb(const struct bonding *bond)
0319 {
0320 return (bond_is_lb(bond) && bond->params.tlb_dynamic_lb == 0);
0321 }
0322
0323 static inline bool bond_mode_can_use_xmit_hash(const struct bonding *bond)
0324 {
0325 return (BOND_MODE(bond) == BOND_MODE_8023AD ||
0326 BOND_MODE(bond) == BOND_MODE_XOR ||
0327 BOND_MODE(bond) == BOND_MODE_TLB ||
0328 BOND_MODE(bond) == BOND_MODE_ALB);
0329 }
0330
0331 static inline bool bond_mode_uses_xmit_hash(const struct bonding *bond)
0332 {
0333 return (BOND_MODE(bond) == BOND_MODE_8023AD ||
0334 BOND_MODE(bond) == BOND_MODE_XOR ||
0335 bond_is_nondyn_tlb(bond));
0336 }
0337
0338 static inline bool bond_mode_uses_arp(int mode)
0339 {
0340 return mode != BOND_MODE_8023AD && mode != BOND_MODE_TLB &&
0341 mode != BOND_MODE_ALB;
0342 }
0343
0344 static inline bool bond_mode_uses_primary(int mode)
0345 {
0346 return mode == BOND_MODE_ACTIVEBACKUP || mode == BOND_MODE_TLB ||
0347 mode == BOND_MODE_ALB;
0348 }
0349
0350 static inline bool bond_uses_primary(struct bonding *bond)
0351 {
0352 return bond_mode_uses_primary(BOND_MODE(bond));
0353 }
0354
0355 static inline struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond)
0356 {
0357 struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave);
0358
0359 return bond_uses_primary(bond) && slave ? slave->dev : NULL;
0360 }
0361
0362 static inline bool bond_slave_is_up(struct slave *slave)
0363 {
0364 return netif_running(slave->dev) && netif_carrier_ok(slave->dev);
0365 }
0366
0367 static inline void bond_set_active_slave(struct slave *slave)
0368 {
0369 if (slave->backup) {
0370 slave->backup = 0;
0371 bond_queue_slave_event(slave);
0372 bond_lower_state_changed(slave);
0373 }
0374 }
0375
0376 static inline void bond_set_backup_slave(struct slave *slave)
0377 {
0378 if (!slave->backup) {
0379 slave->backup = 1;
0380 bond_queue_slave_event(slave);
0381 bond_lower_state_changed(slave);
0382 }
0383 }
0384
0385 static inline void bond_set_slave_state(struct slave *slave,
0386 int slave_state, bool notify)
0387 {
0388 if (slave->backup == slave_state)
0389 return;
0390
0391 slave->backup = slave_state;
0392 if (notify) {
0393 bond_lower_state_changed(slave);
0394 bond_queue_slave_event(slave);
0395 slave->should_notify = 0;
0396 } else {
0397 if (slave->should_notify)
0398 slave->should_notify = 0;
0399 else
0400 slave->should_notify = 1;
0401 }
0402 }
0403
0404 static inline void bond_slave_state_change(struct bonding *bond)
0405 {
0406 struct list_head *iter;
0407 struct slave *tmp;
0408
0409 bond_for_each_slave(bond, tmp, iter) {
0410 if (tmp->link == BOND_LINK_UP)
0411 bond_set_active_slave(tmp);
0412 else if (tmp->link == BOND_LINK_DOWN)
0413 bond_set_backup_slave(tmp);
0414 }
0415 }
0416
0417 static inline void bond_slave_state_notify(struct bonding *bond)
0418 {
0419 struct list_head *iter;
0420 struct slave *tmp;
0421
0422 bond_for_each_slave(bond, tmp, iter) {
0423 if (tmp->should_notify) {
0424 bond_lower_state_changed(tmp);
0425 tmp->should_notify = 0;
0426 }
0427 }
0428 }
0429
0430 static inline int bond_slave_state(struct slave *slave)
0431 {
0432 return slave->backup;
0433 }
0434
0435 static inline bool bond_is_active_slave(struct slave *slave)
0436 {
0437 return !bond_slave_state(slave);
0438 }
0439
0440 static inline bool bond_slave_can_tx(struct slave *slave)
0441 {
0442 return bond_slave_is_up(slave) && slave->link == BOND_LINK_UP &&
0443 bond_is_active_slave(slave);
0444 }
0445
0446 static inline bool bond_is_active_slave_dev(const struct net_device *slave_dev)
0447 {
0448 struct slave *slave;
0449 bool active;
0450
0451 rcu_read_lock();
0452 slave = bond_slave_get_rcu(slave_dev);
0453 active = bond_is_active_slave(slave);
0454 rcu_read_unlock();
0455
0456 return active;
0457 }
0458
0459 static inline void bond_hw_addr_copy(u8 *dst, const u8 *src, unsigned int len)
0460 {
0461 if (len == ETH_ALEN) {
0462 ether_addr_copy(dst, src);
0463 return;
0464 }
0465
0466 memcpy(dst, src, len);
0467 }
0468
0469 #define BOND_PRI_RESELECT_ALWAYS 0
0470 #define BOND_PRI_RESELECT_BETTER 1
0471 #define BOND_PRI_RESELECT_FAILURE 2
0472
0473 #define BOND_FOM_NONE 0
0474 #define BOND_FOM_ACTIVE 1
0475 #define BOND_FOM_FOLLOW 2
0476
0477 #define BOND_ARP_TARGETS_ANY 0
0478 #define BOND_ARP_TARGETS_ALL 1
0479
0480 #define BOND_ARP_VALIDATE_NONE 0
0481 #define BOND_ARP_VALIDATE_ACTIVE (1 << BOND_STATE_ACTIVE)
0482 #define BOND_ARP_VALIDATE_BACKUP (1 << BOND_STATE_BACKUP)
0483 #define BOND_ARP_VALIDATE_ALL (BOND_ARP_VALIDATE_ACTIVE | \
0484 BOND_ARP_VALIDATE_BACKUP)
0485 #define BOND_ARP_FILTER (BOND_ARP_VALIDATE_ALL + 1)
0486 #define BOND_ARP_FILTER_ACTIVE (BOND_ARP_VALIDATE_ACTIVE | \
0487 BOND_ARP_FILTER)
0488 #define BOND_ARP_FILTER_BACKUP (BOND_ARP_VALIDATE_BACKUP | \
0489 BOND_ARP_FILTER)
0490
0491 #define BOND_SLAVE_NOTIFY_NOW true
0492 #define BOND_SLAVE_NOTIFY_LATER false
0493
0494 static inline int slave_do_arp_validate(struct bonding *bond,
0495 struct slave *slave)
0496 {
0497 return bond->params.arp_validate & (1 << bond_slave_state(slave));
0498 }
0499
0500 static inline int slave_do_arp_validate_only(struct bonding *bond)
0501 {
0502 return bond->params.arp_validate & BOND_ARP_FILTER;
0503 }
0504
0505 static inline int bond_is_ip_target_ok(__be32 addr)
0506 {
0507 return !ipv4_is_lbcast(addr) && !ipv4_is_zeronet(addr);
0508 }
0509
0510 #if IS_ENABLED(CONFIG_IPV6)
0511 static inline int bond_is_ip6_target_ok(struct in6_addr *addr)
0512 {
0513 return !ipv6_addr_any(addr) &&
0514 !ipv6_addr_loopback(addr) &&
0515 !ipv6_addr_is_multicast(addr);
0516 }
0517 #endif
0518
0519
0520
0521
0522 static inline unsigned long slave_oldest_target_arp_rx(struct bonding *bond,
0523 struct slave *slave)
0524 {
0525 int i = 1;
0526 unsigned long ret = slave->target_last_arp_rx[0];
0527
0528 for (; (i < BOND_MAX_ARP_TARGETS) && bond->params.arp_targets[i]; i++)
0529 if (time_before(slave->target_last_arp_rx[i], ret))
0530 ret = slave->target_last_arp_rx[i];
0531
0532 return ret;
0533 }
0534
0535 static inline unsigned long slave_last_rx(struct bonding *bond,
0536 struct slave *slave)
0537 {
0538 if (bond->params.arp_all_targets == BOND_ARP_TARGETS_ALL)
0539 return slave_oldest_target_arp_rx(bond, slave);
0540
0541 return slave->last_rx;
0542 }
0543
0544 static inline void slave_update_last_tx(struct slave *slave)
0545 {
0546 WRITE_ONCE(slave->last_tx, jiffies);
0547 }
0548
0549 static inline unsigned long slave_last_tx(struct slave *slave)
0550 {
0551 return READ_ONCE(slave->last_tx);
0552 }
0553
0554 #ifdef CONFIG_NET_POLL_CONTROLLER
0555 static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave,
0556 struct sk_buff *skb)
0557 {
0558 return netpoll_send_skb(slave->np, skb);
0559 }
0560 #else
0561 static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave,
0562 struct sk_buff *skb)
0563 {
0564 BUG();
0565 return NETDEV_TX_OK;
0566 }
0567 #endif
0568
0569 static inline void bond_set_slave_inactive_flags(struct slave *slave,
0570 bool notify)
0571 {
0572 if (!bond_is_lb(slave->bond))
0573 bond_set_slave_state(slave, BOND_STATE_BACKUP, notify);
0574 if (!slave->bond->params.all_slaves_active)
0575 slave->inactive = 1;
0576 }
0577
0578 static inline void bond_set_slave_active_flags(struct slave *slave,
0579 bool notify)
0580 {
0581 bond_set_slave_state(slave, BOND_STATE_ACTIVE, notify);
0582 slave->inactive = 0;
0583 }
0584
0585 static inline bool bond_is_slave_inactive(struct slave *slave)
0586 {
0587 return slave->inactive;
0588 }
0589
0590 static inline void bond_propose_link_state(struct slave *slave, int state)
0591 {
0592 slave->link_new_state = state;
0593 }
0594
0595 static inline void bond_commit_link_state(struct slave *slave, bool notify)
0596 {
0597 if (slave->link_new_state == BOND_LINK_NOCHANGE)
0598 return;
0599
0600 slave->link = slave->link_new_state;
0601 if (notify) {
0602 bond_queue_slave_event(slave);
0603 bond_lower_state_changed(slave);
0604 slave->should_notify_link = 0;
0605 } else {
0606 if (slave->should_notify_link)
0607 slave->should_notify_link = 0;
0608 else
0609 slave->should_notify_link = 1;
0610 }
0611 }
0612
0613 static inline void bond_set_slave_link_state(struct slave *slave, int state,
0614 bool notify)
0615 {
0616 bond_propose_link_state(slave, state);
0617 bond_commit_link_state(slave, notify);
0618 }
0619
0620 static inline void bond_slave_link_notify(struct bonding *bond)
0621 {
0622 struct list_head *iter;
0623 struct slave *tmp;
0624
0625 bond_for_each_slave(bond, tmp, iter) {
0626 if (tmp->should_notify_link) {
0627 bond_queue_slave_event(tmp);
0628 bond_lower_state_changed(tmp);
0629 tmp->should_notify_link = 0;
0630 }
0631 }
0632 }
0633
0634 static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be32 local)
0635 {
0636 struct in_device *in_dev;
0637 __be32 addr = 0;
0638
0639 rcu_read_lock();
0640 in_dev = __in_dev_get_rcu(dev);
0641
0642 if (in_dev)
0643 addr = inet_confirm_addr(dev_net(dev), in_dev, dst, local,
0644 RT_SCOPE_HOST);
0645 rcu_read_unlock();
0646 return addr;
0647 }
0648
0649 struct bond_net {
0650 struct net *net;
0651 struct list_head dev_list;
0652 #ifdef CONFIG_PROC_FS
0653 struct proc_dir_entry *proc_dir;
0654 #endif
0655 struct class_attribute class_attr_bonding_masters;
0656 };
0657
0658 int bond_rcv_validate(const struct sk_buff *skb, struct bonding *bond, struct slave *slave);
0659 netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
0660 int bond_create(struct net *net, const char *name);
0661 int bond_create_sysfs(struct bond_net *net);
0662 void bond_destroy_sysfs(struct bond_net *net);
0663 void bond_prepare_sysfs_group(struct bonding *bond);
0664 int bond_sysfs_slave_add(struct slave *slave);
0665 void bond_sysfs_slave_del(struct slave *slave);
0666 int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
0667 struct netlink_ext_ack *extack);
0668 int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
0669 u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb);
0670 int bond_set_carrier(struct bonding *bond);
0671 void bond_select_active_slave(struct bonding *bond);
0672 void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
0673 void bond_create_debugfs(void);
0674 void bond_destroy_debugfs(void);
0675 void bond_debug_register(struct bonding *bond);
0676 void bond_debug_unregister(struct bonding *bond);
0677 void bond_debug_reregister(struct bonding *bond);
0678 const char *bond_mode_name(int mode);
0679 void bond_setup(struct net_device *bond_dev);
0680 unsigned int bond_get_num_tx_queues(void);
0681 int bond_netlink_init(void);
0682 void bond_netlink_fini(void);
0683 struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
0684 const char *bond_slave_link_status(s8 link);
0685 struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev,
0686 struct net_device *end_dev,
0687 int level);
0688 int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave);
0689 void bond_slave_arr_work_rearm(struct bonding *bond, unsigned long delay);
0690 void bond_work_init_all(struct bonding *bond);
0691
0692 #ifdef CONFIG_PROC_FS
0693 void bond_create_proc_entry(struct bonding *bond);
0694 void bond_remove_proc_entry(struct bonding *bond);
0695 void bond_create_proc_dir(struct bond_net *bn);
0696 void bond_destroy_proc_dir(struct bond_net *bn);
0697 #else
0698 static inline void bond_create_proc_entry(struct bonding *bond)
0699 {
0700 }
0701
0702 static inline void bond_remove_proc_entry(struct bonding *bond)
0703 {
0704 }
0705
0706 static inline void bond_create_proc_dir(struct bond_net *bn)
0707 {
0708 }
0709
0710 static inline void bond_destroy_proc_dir(struct bond_net *bn)
0711 {
0712 }
0713 #endif
0714
0715 static inline struct slave *bond_slave_has_mac(struct bonding *bond,
0716 const u8 *mac)
0717 {
0718 struct list_head *iter;
0719 struct slave *tmp;
0720
0721 bond_for_each_slave(bond, tmp, iter)
0722 if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr))
0723 return tmp;
0724
0725 return NULL;
0726 }
0727
0728
0729 static inline bool bond_slave_has_mac_rx(struct bonding *bond, const u8 *mac)
0730 {
0731 struct list_head *iter;
0732 struct slave *tmp;
0733 struct netdev_hw_addr *ha;
0734
0735 bond_for_each_slave_rcu(bond, tmp, iter)
0736 if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr))
0737 return true;
0738
0739 if (netdev_uc_empty(bond->dev))
0740 return false;
0741
0742 netdev_for_each_uc_addr(ha, bond->dev)
0743 if (ether_addr_equal_64bits(mac, ha->addr))
0744 return true;
0745
0746 return false;
0747 }
0748
0749
0750
0751
0752 static inline int bond_get_targets_ip(__be32 *targets, __be32 ip)
0753 {
0754 int i;
0755
0756 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++)
0757 if (targets[i] == ip)
0758 return i;
0759 else if (targets[i] == 0)
0760 break;
0761
0762 return -1;
0763 }
0764
0765 #if IS_ENABLED(CONFIG_IPV6)
0766 static inline int bond_get_targets_ip6(struct in6_addr *targets, struct in6_addr *ip)
0767 {
0768 int i;
0769
0770 for (i = 0; i < BOND_MAX_NS_TARGETS; i++)
0771 if (ipv6_addr_equal(&targets[i], ip))
0772 return i;
0773 else if (ipv6_addr_any(&targets[i]))
0774 break;
0775
0776 return -1;
0777 }
0778 #endif
0779
0780
0781 extern unsigned int bond_net_id;
0782
0783
0784 extern struct rtnl_link_ops bond_link_ops;
0785
0786
0787 extern const struct sysfs_ops slave_sysfs_ops;
0788
0789
0790 extern const u8 lacpdu_mcast_addr[];
0791
0792 static inline netdev_tx_t bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
0793 {
0794 dev_core_stats_tx_dropped_inc(dev);
0795 dev_kfree_skb_any(skb);
0796 return NET_XMIT_DROP;
0797 }
0798
0799 #endif