#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/filter.h>
#include <linux/interrupt.h>
#include <linux/ptrace.h>
#include <linux/ioport.h>
#include <linux/in.h>
#include <net/ip.h>
#include <linux/ip.h>
#include <linux/icmp.h>
#include <linux/icmpv6.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/timer.h>
#include <linux/socket.h>
#include <linux/ctype.h>
#include <linux/inet.h>
#include <linux/bitops.h>
#include <linux/io.h>
#include <asm/dma.h>
#include <linux/uaccess.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/igmp.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <linux/rtnetlink.h>
#include <linux/smp.h>
#include <linux/if_ether.h>
#include <net/arp.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
#include <linux/if_bonding.h>
#include <linux/phy.h>
#include <linux/jiffies.h>
#include <linux/preempt.h>
#include <net/route.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>
#include <net/pkt_sched.h>
#include <linux/rculist.h>
#include <net/flow_dissector.h>
#include <net/xfrm.h>
#include <net/bonding.h>
#include <net/bond_3ad.h>
#include <net/bond_alb.h>
#if IS_ENABLED(CONFIG_TLS_DEVICE)
#include <net/tls.h>
#endif
#include <net/ip6_route.h>
#include <net/xdp.h>
#include "bonding_priv.h"
static int max_bonds = …;
static int tx_queues = …;
static int num_peer_notif = …;
static int miimon;
static int updelay;
static int downdelay;
static int use_carrier = …;
static char *mode;
static char *primary;
static char *primary_reselect;
static char *lacp_rate;
static int min_links;
static char *ad_select;
static char *xmit_hash_policy;
static int arp_interval;
static char *arp_ip_target[BOND_MAX_ARP_TARGETS];
static char *arp_validate;
static char *arp_all_targets;
static char *fail_over_mac;
static int all_slaves_active;
static struct bond_params bonding_defaults;
static int resend_igmp = …;
static int packets_per_slave = …;
static int lp_interval = …;
module_param(max_bonds, int, 0);
MODULE_PARM_DESC(…) …;
module_param(tx_queues, int, 0);
MODULE_PARM_DESC(…) …;
module_param_named(num_grat_arp, num_peer_notif, int, 0644);
MODULE_PARM_DESC(…) …;
module_param_named(num_unsol_na, num_peer_notif, int, 0644);
MODULE_PARM_DESC(…) …;
module_param(miimon, int, 0);
MODULE_PARM_DESC(…) …;
module_param(updelay, int, 0);
MODULE_PARM_DESC(…) …;
module_param(downdelay, int, 0);
MODULE_PARM_DESC(…) …;
module_param(use_carrier, int, 0);
MODULE_PARM_DESC(…) …;
module_param(mode, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(primary, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(primary_reselect, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(lacp_rate, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(ad_select, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(min_links, int, 0);
MODULE_PARM_DESC(…) …;
module_param(xmit_hash_policy, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(arp_interval, int, 0);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param(arp_validate, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(arp_all_targets, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(fail_over_mac, charp, 0);
MODULE_PARM_DESC(…) …;
module_param(all_slaves_active, int, 0);
MODULE_PARM_DESC(…) …;
module_param(resend_igmp, int, 0);
MODULE_PARM_DESC(…) …;
module_param(packets_per_slave, int, 0);
MODULE_PARM_DESC(…) …;
module_param(lp_interval, uint, 0);
MODULE_PARM_DESC(…) …;
#ifdef CONFIG_NET_POLL_CONTROLLER
atomic_t netpoll_block_tx = …;
#endif
unsigned int bond_net_id __read_mostly;
static const struct flow_dissector_key flow_keys_bonding_keys[] = …;
static struct flow_dissector flow_keys_bonding __read_mostly;
static int bond_init(struct net_device *bond_dev);
static void bond_uninit(struct net_device *bond_dev);
static void bond_get_stats(struct net_device *bond_dev,
struct rtnl_link_stats64 *stats);
static void bond_slave_arr_handler(struct work_struct *work);
static bool bond_time_in_interval(struct bonding *bond, unsigned long last_act,
int mod);
static void bond_netdev_notify_work(struct work_struct *work);
const char *bond_mode_name(int mode)
{ … }
netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
struct net_device *slave_dev)
{ … }
static bool bond_sk_check(struct bonding *bond)
{ … }
static bool bond_xdp_check(struct bonding *bond)
{ … }
static int bond_vlan_rx_add_vid(struct net_device *bond_dev,
__be16 proto, u16 vid)
{ … }
static int bond_vlan_rx_kill_vid(struct net_device *bond_dev,
__be16 proto, u16 vid)
{ … }
#ifdef CONFIG_XFRM_OFFLOAD
static int bond_ipsec_add_sa(struct xfrm_state *xs,
struct netlink_ext_ack *extack)
{ … }
static void bond_ipsec_add_sa_all(struct bonding *bond)
{ … }
static void bond_ipsec_del_sa(struct xfrm_state *xs)
{ … }
static void bond_ipsec_del_sa_all(struct bonding *bond)
{ … }
static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)
{ … }
static const struct xfrmdev_ops bond_xfrmdev_ops = …;
#endif
int bond_set_carrier(struct bonding *bond)
{ … }
static int bond_update_speed_duplex(struct slave *slave)
{ … }
const char *bond_slave_link_status(s8 link)
{ … }
static int bond_check_dev_link(struct bonding *bond,
struct net_device *slave_dev, int reporting)
{ … }
static int bond_set_promiscuity(struct bonding *bond, int inc)
{ … }
static int bond_set_allmulti(struct bonding *bond, int inc)
{ … }
static void bond_resend_igmp_join_requests_delayed(struct work_struct *work)
{ … }
static void bond_hw_addr_flush(struct net_device *bond_dev,
struct net_device *slave_dev)
{ … }
static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
struct slave *old_active)
{ … }
static int bond_set_dev_addr(struct net_device *bond_dev,
struct net_device *slave_dev)
{ … }
static struct slave *bond_get_old_active(struct bonding *bond,
struct slave *new_active)
{ … }
static void bond_do_fail_over_mac(struct bonding *bond,
struct slave *new_active,
struct slave *old_active)
{ … }
static struct slave *bond_choose_primary_or_current(struct bonding *bond)
{ … }
static struct slave *bond_find_best_slave(struct bonding *bond)
{ … }
static bool bond_should_notify_peers(struct bonding *bond)
{ … }
void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
{ … }
void bond_select_active_slave(struct bonding *bond)
{ … }
#ifdef CONFIG_NET_POLL_CONTROLLER
static inline int slave_enable_netpoll(struct slave *slave)
{ … }
static inline void slave_disable_netpoll(struct slave *slave)
{ … }
static void bond_poll_controller(struct net_device *bond_dev)
{ … }
static void bond_netpoll_cleanup(struct net_device *bond_dev)
{ … }
static int bond_netpoll_setup(struct net_device *dev, struct netpoll_info *ni)
{ … }
#else
static inline int slave_enable_netpoll(struct slave *slave)
{
return 0;
}
static inline void slave_disable_netpoll(struct slave *slave)
{
}
static void bond_netpoll_cleanup(struct net_device *bond_dev)
{
}
#endif
static netdev_features_t bond_fix_features(struct net_device *dev,
netdev_features_t features)
{ … }
#define BOND_VLAN_FEATURES …
#define BOND_ENC_FEATURES …
#define BOND_MPLS_FEATURES …
static void bond_compute_features(struct bonding *bond)
{ … }
static void bond_setup_by_slave(struct net_device *bond_dev,
struct net_device *slave_dev)
{ … }
static bool bond_should_deliver_exact_match(struct sk_buff *skb,
struct slave *slave,
struct bonding *bond)
{ … }
static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
{ … }
static enum netdev_lag_tx_type bond_lag_tx_type(struct bonding *bond)
{ … }
static enum netdev_lag_hash bond_lag_hash_type(struct bonding *bond,
enum netdev_lag_tx_type type)
{ … }
static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave,
struct netlink_ext_ack *extack)
{ … }
static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave)
{ … }
static void slave_kobj_release(struct kobject *kobj)
{ … }
static struct kobj_type slave_ktype = …;
static int bond_kobj_init(struct slave *slave)
{ … }
static struct slave *bond_alloc_slave(struct bonding *bond,
struct net_device *slave_dev)
{ … }
static void bond_fill_ifbond(struct bonding *bond, struct ifbond *info)
{ … }
static void bond_fill_ifslave(struct slave *slave, struct ifslave *info)
{ … }
static void bond_netdev_notify_work(struct work_struct *_work)
{ … }
void bond_queue_slave_event(struct slave *slave)
{ … }
void bond_lower_state_changed(struct slave *slave)
{ … }
#define BOND_NL_ERR(bond_dev, extack, errmsg) …
#define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) …
static void bond_ether_setup(struct net_device *bond_dev)
{ … }
void bond_xdp_set_features(struct net_device *bond_dev)
{ … }
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
struct netlink_ext_ack *extack)
{ … }
static int __bond_release_one(struct net_device *bond_dev,
struct net_device *slave_dev,
bool all, bool unregister)
{ … }
int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
{ … }
static int bond_release_and_destroy(struct net_device *bond_dev,
struct net_device *slave_dev)
{ … }
static void bond_info_query(struct net_device *bond_dev, struct ifbond *info)
{ … }
static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *info)
{ … }
static int bond_miimon_inspect(struct bonding *bond)
{ … }
static void bond_miimon_link_change(struct bonding *bond,
struct slave *slave,
char link)
{ … }
static void bond_miimon_commit(struct bonding *bond)
{ … }
static void bond_mii_monitor(struct work_struct *work)
{ … }
static int bond_upper_dev_walk(struct net_device *upper,
struct netdev_nested_priv *priv)
{ … }
static bool bond_has_this_ip(struct bonding *bond, __be32 ip)
{ … }
#define BOND_VLAN_PROTO_NONE …
static bool bond_handle_vlan(struct slave *slave, struct bond_vlan_tag *tags,
struct sk_buff *skb)
{ … }
static void bond_arp_send(struct slave *slave, int arp_op, __be32 dest_ip,
__be32 src_ip, struct bond_vlan_tag *tags)
{ … }
struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev,
struct net_device *end_dev,
int level)
{ … }
static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
{ … }
static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 sip, __be32 tip)
{ … }
static int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond,
struct slave *slave)
{ … }
#if IS_ENABLED(CONFIG_IPV6)
static void bond_ns_send(struct slave *slave, const struct in6_addr *daddr,
const struct in6_addr *saddr, struct bond_vlan_tag *tags)
{ … }
static void bond_ns_send_all(struct bonding *bond, struct slave *slave)
{ … }
static int bond_confirm_addr6(struct net_device *dev,
struct netdev_nested_priv *priv)
{ … }
static bool bond_has_this_ip6(struct bonding *bond, struct in6_addr *addr)
{ … }
static void bond_validate_na(struct bonding *bond, struct slave *slave,
struct in6_addr *saddr, struct in6_addr *daddr)
{ … }
static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
struct slave *slave)
{ … }
#endif
int bond_rcv_validate(const struct sk_buff *skb, struct bonding *bond,
struct slave *slave)
{ … }
static void bond_send_validate(struct bonding *bond, struct slave *slave)
{ … }
static bool bond_time_in_interval(struct bonding *bond, unsigned long last_act,
int mod)
{ … }
static void bond_loadbalance_arp_mon(struct bonding *bond)
{ … }
static int bond_ab_arp_inspect(struct bonding *bond)
{ … }
static void bond_ab_arp_commit(struct bonding *bond)
{ … }
static bool bond_ab_arp_probe(struct bonding *bond)
{ … }
static void bond_activebackup_arp_mon(struct bonding *bond)
{ … }
static void bond_arp_monitor(struct work_struct *work)
{ … }
static int bond_event_changename(struct bonding *bond)
{ … }
static int bond_master_netdev_event(unsigned long event,
struct net_device *bond_dev)
{ … }
static int bond_slave_netdev_event(unsigned long event,
struct net_device *slave_dev)
{ … }
static int bond_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr)
{ … }
static struct notifier_block bond_netdev_notifier = …;
static inline const void *bond_pull_data(struct sk_buff *skb,
const void *data, int hlen, int n)
{ … }
static inline u32 bond_eth_hash(struct sk_buff *skb, const void *data, int mhoff, int hlen)
{ … }
static bool bond_flow_ip(struct sk_buff *skb, struct flow_keys *fk, const void *data,
int hlen, __be16 l2_proto, int *nhoff, int *ip_proto, bool l34)
{ … }
static u32 bond_vlan_srcmac_hash(struct sk_buff *skb, const void *data, int mhoff, int hlen)
{ … }
static bool bond_flow_dissect(struct bonding *bond, struct sk_buff *skb, const void *data,
__be16 l2_proto, int nhoff, int hlen, struct flow_keys *fk)
{ … }
static u32 bond_ip_hash(u32 hash, struct flow_keys *flow, int xmit_policy)
{ … }
static u32 __bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, const void *data,
__be16 l2_proto, int mhoff, int nhoff, int hlen)
{ … }
u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb)
{ … }
static u32 bond_xmit_hash_xdp(struct bonding *bond, struct xdp_buff *xdp)
{ … }
void bond_work_init_all(struct bonding *bond)
{ … }
static void bond_work_cancel_all(struct bonding *bond)
{ … }
static int bond_open(struct net_device *bond_dev)
{ … }
static int bond_close(struct net_device *bond_dev)
{ … }
static void bond_fold_stats(struct rtnl_link_stats64 *_res,
const struct rtnl_link_stats64 *_new,
const struct rtnl_link_stats64 *_old)
{ … }
#ifdef CONFIG_LOCKDEP
static int bond_get_lowest_level_rcu(struct net_device *dev)
{ … }
#endif
static void bond_get_stats(struct net_device *bond_dev,
struct rtnl_link_stats64 *stats)
{ … }
static int bond_eth_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd)
{ … }
static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd)
{ … }
static int bond_siocdevprivate(struct net_device *bond_dev, struct ifreq *ifr,
void __user *data, int cmd)
{ … }
static void bond_change_rx_flags(struct net_device *bond_dev, int change)
{ … }
static void bond_set_rx_mode(struct net_device *bond_dev)
{ … }
static int bond_neigh_init(struct neighbour *n)
{ … }
static int bond_neigh_setup(struct net_device *dev,
struct neigh_parms *parms)
{ … }
static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
{ … }
static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
{ … }
static struct slave *bond_get_slave_by_id(struct bonding *bond,
int slave_id)
{ … }
static u32 bond_rr_gen_slave_id(struct bonding *bond)
{ … }
static struct slave *bond_xmit_roundrobin_slave_get(struct bonding *bond,
struct sk_buff *skb)
{ … }
static struct slave *bond_xdp_xmit_roundrobin_slave_get(struct bonding *bond,
struct xdp_buff *xdp)
{ … }
static netdev_tx_t bond_xmit_roundrobin(struct sk_buff *skb,
struct net_device *bond_dev)
{ … }
static struct slave *bond_xmit_activebackup_slave_get(struct bonding *bond)
{ … }
static netdev_tx_t bond_xmit_activebackup(struct sk_buff *skb,
struct net_device *bond_dev)
{ … }
void bond_slave_arr_work_rearm(struct bonding *bond, unsigned long delay)
{ … }
static void bond_slave_arr_handler(struct work_struct *work)
{ … }
static void bond_skip_slave(struct bond_up_slave *slaves,
struct slave *skipslave)
{ … }
static void bond_set_slave_arr(struct bonding *bond,
struct bond_up_slave *usable_slaves,
struct bond_up_slave *all_slaves)
{ … }
static void bond_reset_slave_arr(struct bonding *bond)
{ … }
int bond_update_slave_arr(struct bonding *bond, struct slave *skipslave)
{ … }
static struct slave *bond_xmit_3ad_xor_slave_get(struct bonding *bond,
struct sk_buff *skb,
struct bond_up_slave *slaves)
{ … }
static struct slave *bond_xdp_xmit_3ad_xor_slave_get(struct bonding *bond,
struct xdp_buff *xdp)
{ … }
static netdev_tx_t bond_3ad_xor_xmit(struct sk_buff *skb,
struct net_device *dev)
{ … }
static netdev_tx_t bond_xmit_broadcast(struct sk_buff *skb,
struct net_device *bond_dev)
{ … }
static inline int bond_slave_override(struct bonding *bond,
struct sk_buff *skb)
{ … }
static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb,
struct net_device *sb_dev)
{ … }
static struct net_device *bond_xmit_get_slave(struct net_device *master_dev,
struct sk_buff *skb,
bool all_slaves)
{ … }
static void bond_sk_to_flow(struct sock *sk, struct flow_keys *flow)
{ … }
static u32 bond_sk_hash_l34(struct sock *sk)
{ … }
static struct net_device *__bond_sk_get_lower_dev(struct bonding *bond,
struct sock *sk)
{ … }
static struct net_device *bond_sk_get_lower_dev(struct net_device *dev,
struct sock *sk)
{ … }
#if IS_ENABLED(CONFIG_TLS_DEVICE)
static netdev_tx_t bond_tls_device_xmit(struct bonding *bond, struct sk_buff *skb,
struct net_device *dev)
{ … }
#endif
static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
{ … }
static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
{ … }
static struct net_device *
bond_xdp_get_xmit_slave(struct net_device *bond_dev, struct xdp_buff *xdp)
{ … }
static int bond_xdp_xmit(struct net_device *bond_dev,
int n, struct xdp_frame **frames, u32 flags)
{ … }
static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
struct netlink_ext_ack *extack)
{ … }
static int bond_xdp(struct net_device *dev, struct netdev_bpf *xdp)
{ … }
static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed)
{ … }
static int bond_set_phc_index_flag(struct kernel_hwtstamp_config *kernel_cfg)
{ … }
static int bond_hwtstamp_get(struct net_device *dev,
struct kernel_hwtstamp_config *cfg)
{ … }
static int bond_hwtstamp_set(struct net_device *dev,
struct kernel_hwtstamp_config *cfg,
struct netlink_ext_ack *extack)
{ … }
static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev,
struct ethtool_link_ksettings *cmd)
{ … }
static void bond_ethtool_get_drvinfo(struct net_device *bond_dev,
struct ethtool_drvinfo *drvinfo)
{ … }
static int bond_ethtool_get_ts_info(struct net_device *bond_dev,
struct kernel_ethtool_ts_info *info)
{ … }
static const struct ethtool_ops bond_ethtool_ops = …;
static const struct net_device_ops bond_netdev_ops = …;
static const struct device_type bond_type = …;
static void bond_destructor(struct net_device *bond_dev)
{ … }
void bond_setup(struct net_device *bond_dev)
{ … }
static void bond_uninit(struct net_device *bond_dev)
{ … }
static int __init bond_check_params(struct bond_params *params)
{ … }
static int bond_init(struct net_device *bond_dev)
{ … }
unsigned int bond_get_num_tx_queues(void)
{ … }
int bond_create(struct net *net, const char *name)
{ … }
static int __net_init bond_net_init(struct net *net)
{ … }
static void __net_exit bond_net_pre_exit(struct net *net)
{ … }
static void __net_exit bond_net_exit_batch_rtnl(struct list_head *net_list,
struct list_head *dev_kill_list)
{ … }
static void __net_exit bond_net_exit_batch(struct list_head *net_list)
{ … }
static struct pernet_operations bond_net_ops = …;
static int __init bonding_init(void)
{ … }
static void __exit bonding_exit(void)
{ … }
module_init(…) …;
module_exit(bonding_exit);
MODULE_LICENSE(…) …;
MODULE_DESCRIPTION(…);
MODULE_AUTHOR(…) …;