Lines Matching refs:bond_dev
261 static int bond_init(struct net_device *bond_dev);
262 static void bond_uninit(struct net_device *bond_dev);
263 static void bond_get_stats(struct net_device *bond_dev,
364 * @bond_dev: bonding net device that got called
368 static int bond_vlan_rx_add_vid(struct net_device *bond_dev,
371 struct bonding *bond = netdev_priv(bond_dev);
398 * @bond_dev: bonding net device that got called
402 static int bond_vlan_rx_kill_vid(struct net_device *bond_dev,
405 struct bonding *bond = netdev_priv(bond_dev);
429 struct net_device *bond_dev = xs->xso.dev;
435 if (!bond_dev)
439 bond = netdev_priv(bond_dev);
477 struct net_device *bond_dev = bond->dev;
491 slave_warn(bond_dev, slave->dev,
502 slave_warn(bond_dev, slave->dev, "%s: failed to add SA\n", __func__);
517 struct net_device *bond_dev = xs->xso.dev;
522 if (!bond_dev)
526 bond = netdev_priv(bond_dev);
540 slave_warn(bond_dev, slave->dev, "%s: no slave xdo_dev_state_delete\n", __func__);
560 struct net_device *bond_dev = bond->dev;
579 slave_warn(bond_dev, slave->dev,
598 struct net_device *bond_dev = xs->xso.dev;
604 bond = netdev_priv(bond_dev);
864 static void bond_hw_addr_flush(struct net_device *bond_dev,
867 struct bonding *bond = netdev_priv(bond_dev);
869 dev_uc_unsync(slave_dev, bond_dev);
870 dev_mc_unsync(slave_dev, bond_dev);
916 * @bond_dev: bond net device
921 static int bond_set_dev_addr(struct net_device *bond_dev,
926 slave_dbg(bond_dev, slave_dev, "bond_dev=%p slave_dev=%p slave_dev->addr_len=%d\n",
927 bond_dev, slave_dev, slave_dev->addr_len);
928 err = dev_pre_changeaddr_notify(bond_dev, slave_dev->dev_addr, NULL);
932 __dev_addr_set(bond_dev, slave_dev->dev_addr, slave_dev->addr_len);
933 bond_dev->addr_assign_type = NET_ADDR_STOLEN;
934 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond_dev);
1327 static void bond_poll_controller(struct net_device *bond_dev)
1329 struct bonding *bond = netdev_priv(bond_dev);
1355 static void bond_netpoll_cleanup(struct net_device *bond_dev)
1357 struct bonding *bond = netdev_priv(bond_dev);
1390 static void bond_netpoll_cleanup(struct net_device *bond_dev)
1441 struct net_device *bond_dev = bond->dev;
1478 bond_dev->hard_header_len = max_hard_header_len;
1481 bond_dev->vlan_features = vlan_features;
1482 bond_dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL |
1486 bond_dev->hw_enc_features |= xfrm_features;
1488 bond_dev->mpls_features = mpls_features;
1489 netif_set_tso_max_segs(bond_dev, tso_max_segs);
1490 netif_set_tso_max_size(bond_dev, tso_max_size);
1492 bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
1493 if ((bond_dev->priv_flags & IFF_XMIT_DST_RELEASE_PERM) &&
1495 bond_dev->priv_flags |= IFF_XMIT_DST_RELEASE;
1497 netdev_change_features(bond_dev);
1500 static void bond_setup_by_slave(struct net_device *bond_dev,
1503 bool was_up = !!(bond_dev->flags & IFF_UP);
1505 dev_close(bond_dev);
1507 bond_dev->header_ops = slave_dev->header_ops;
1509 bond_dev->type = slave_dev->type;
1510 bond_dev->hard_header_len = slave_dev->hard_header_len;
1511 bond_dev->needed_headroom = slave_dev->needed_headroom;
1512 bond_dev->addr_len = slave_dev->addr_len;
1514 memcpy(bond_dev->broadcast, slave_dev->broadcast,
1518 bond_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST);
1519 bond_dev->flags |= (IFF_POINTOPOINT | IFF_NOARP);
1522 dev_open(bond_dev, NULL);
1777 #define BOND_NL_ERR(bond_dev, extack, errmsg) do { \
1781 netdev_err(bond_dev, "Error: %s\n", errmsg); \
1784 #define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) do { \
1788 slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg); \
1796 static void bond_ether_setup(struct net_device *bond_dev)
1798 unsigned int flags = bond_dev->flags & (IFF_SLAVE | IFF_UP);
1800 ether_setup(bond_dev);
1801 bond_dev->flags |= IFF_MASTER | flags;
1802 bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING;
1805 void bond_xdp_set_features(struct net_device *bond_dev)
1807 struct bonding *bond = netdev_priv(bond_dev);
1815 xdp_clear_features_flag(bond_dev);
1824 xdp_set_features_flag(bond_dev, val);
1828 int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
1831 struct bonding *bond = netdev_priv(bond_dev);
1840 BOND_NL_ERR(bond_dev, extack,
1848 slave_warn(bond_dev, slave_dev, "no link monitoring support\n");
1853 SLAVE_NL_ERR(bond_dev, slave_dev, extack,
1858 if (bond_dev == slave_dev) {
1859 BOND_NL_ERR(bond_dev, extack, "Cannot enslave bond to itself.");
1866 slave_dbg(bond_dev, slave_dev, "is NETIF_F_VLAN_CHALLENGED\n");
1867 if (vlan_uses_dev(bond_dev)) {
1868 SLAVE_NL_ERR(bond_dev, slave_dev, extack,
1872 slave_warn(bond_dev, slave_dev, "enslaved VLAN challenged slave. Adding VLANs will be blocked as long as it is part of bond.\n");
1875 slave_dbg(bond_dev, slave_dev, "is !NETIF_F_VLAN_CHALLENGED\n");
1879 slave_dbg(bond_dev, slave_dev, "is esp-hw-offload capable\n");
1887 SLAVE_NL_ERR(bond_dev, slave_dev, extack,
1900 if (bond_dev->type != slave_dev->type) {
1901 slave_dbg(bond_dev, slave_dev, "change device type from %d to %d\n",
1902 bond_dev->type, slave_dev->type);
1905 bond_dev);
1908 slave_err(bond_dev, slave_dev, "refused to change device type\n");
1913 dev_uc_flush(bond_dev);
1914 dev_mc_flush(bond_dev);
1917 bond_setup_by_slave(bond_dev, slave_dev);
1919 bond_ether_setup(bond_dev);
1922 bond_dev);
1924 } else if (bond_dev->type != slave_dev->type) {
1925 SLAVE_NL_ERR(bond_dev, slave_dev, extack,
1932 SLAVE_NL_ERR(bond_dev, slave_dev, extack,
1940 slave_warn(bond_dev, slave_dev, "The slave device specified does not support setting the MAC address\n");
1945 slave_warn(bond_dev, slave_dev, "Setting fail_over_mac to active for active-backup mode\n");
1947 SLAVE_NL_ERR(bond_dev, slave_dev, extack,
1982 slave_err(bond_dev, slave_dev, "Error %d calling dev_set_mtu\n", res);
1998 memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len);
2003 slave_err(bond_dev, slave_dev, "Error %d calling set_mac_address\n", res);
2014 slave_err(bond_dev, slave_dev, "Opening slave failed\n");
2031 res = vlan_vids_add_by_dev(slave_dev, bond_dev);
2033 slave_err(bond_dev, slave_dev, "Couldn't add bond vlan ids\n");
2065 slave_warn(bond_dev, slave_dev, "MII and ETHTOOL support not available for slave, and arp_interval/arp_ip_target module parameters not specified, thus bonding will not detect link failures! see bonding.txt for details\n");
2068 slave_warn(bond_dev, slave_dev, "can't get link status from slave; the network driver associated with this interface does not support MII or ETHTOOL link status reporting, thus miimon has no effect on this interface\n");
2102 slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n",
2145 slave_dbg(bond_dev, slave_dev, "This slave is always active in trunk mode\n");
2164 slave_info(bond_dev, slave_dev, "master_dev is using netpoll, but new slave device does not support netpoll\n");
2171 if (!(bond_dev->features & NETIF_F_LRO))
2177 slave_dbg(bond_dev, slave_dev, "Error %d calling netdev_rx_handler_register\n", res);
2183 slave_dbg(bond_dev, slave_dev, "Error %d calling bond_master_upper_dev_link\n", res);
2191 slave_dbg(bond_dev, slave_dev, "Error %d calling bond_sysfs_slave_add\n", res);
2200 if (bond_dev->flags & IFF_PROMISC) {
2207 if (bond_dev->flags & IFF_ALLMULTI) {
2210 if (bond_dev->flags & IFF_PROMISC)
2216 if (bond_dev->flags & IFF_UP) {
2217 netif_addr_lock_bh(bond_dev);
2218 dev_mc_sync_multiple(slave_dev, bond_dev);
2219 dev_uc_sync_multiple(slave_dev, bond_dev);
2220 netif_addr_unlock_bh(bond_dev);
2244 SLAVE_NL_ERR(bond_dev, slave_dev, extack,
2258 SLAVE_NL_ERR(bond_dev, slave_dev, extack,
2267 slave_dbg(bond_dev, slave_dev, "Error %d calling ndo_bpf\n", res);
2274 bond_xdp_set_features(bond_dev);
2276 slave_info(bond_dev, slave_dev, "Enslaving as %s interface with %s link\n",
2295 vlan_vids_del_by_dev(slave_dev, bond_dev);
2336 if (ether_addr_equal_64bits(bond_dev->dev_addr,
2338 eth_hw_addr_random(bond_dev);
2339 if (bond_dev->type != ARPHRD_ETHER) {
2340 dev_close(bond_dev);
2341 bond_ether_setup(bond_dev);
2359 static int __bond_release_one(struct net_device *bond_dev,
2363 struct bonding *bond = netdev_priv(bond_dev);
2366 int old_flags = bond_dev->flags;
2367 netdev_features_t old_features = bond_dev->features;
2371 !netdev_has_upper_dev(slave_dev, bond_dev)) {
2372 slave_dbg(bond_dev, slave_dev, "cannot release slave\n");
2381 slave_info(bond_dev, slave_dev, "interface not enslaved\n");
2401 slave_warn(bond_dev, slave_dev, "failed to unload XDP program\n");
2417 slave_info(bond_dev, slave_dev, "Releasing %s interface\n",
2426 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) &&
2428 slave_warn(bond_dev, slave_dev, "the permanent HWaddr of slave - %pM - is still in use by bond - set the HWaddr of slave to a different address to avoid conflicts\n",
2459 eth_hw_addr_random(bond_dev);
2471 if (!(bond_dev->features & NETIF_F_VLAN_CHALLENGED) &&
2473 slave_info(bond_dev, slave_dev, "last VLAN challenged slave left bond - VLAN blocking is removed\n");
2475 vlan_vids_del_by_dev(slave_dev, bond_dev);
2483 * of the IFF_PROMISC flag in the bond_dev, but we need the
2496 bond_hw_addr_flush(bond_dev, slave_dev);
2523 bond_xdp_set_features(bond_dev);
2530 int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
2532 return __bond_release_one(bond_dev, slave_dev, false, false);
2538 static int bond_release_and_destroy(struct net_device *bond_dev,
2541 struct bonding *bond = netdev_priv(bond_dev);
2544 ret = __bond_release_one(bond_dev, slave_dev, false, true);
2546 bond_dev->reg_state != NETREG_UNREGISTERING) {
2547 bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
2548 netdev_info(bond_dev, "Destroying bond\n");
2550 unregister_netdevice(bond_dev);
2555 static void bond_info_query(struct net_device *bond_dev, struct ifbond *info)
2557 struct bonding *bond = netdev_priv(bond_dev);
2562 static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *info)
2564 struct bonding *bond = netdev_priv(bond_dev);
2894 struct net_device *bond_dev = slave->bond->dev;
2910 slave_dbg(bond_dev, slave_dev, "inner tag: proto %X vid %X\n",
2923 slave_dbg(bond_dev, slave_dev, "outer tag: proto %X vid %X\n",
2939 struct net_device *bond_dev = slave->bond->dev;
2943 slave_dbg(bond_dev, slave_dev, "arp %d on slave: dst %pI4 src %pI4\n",
3160 struct net_device *bond_dev = slave->bond->dev;
3165 slave_dbg(bond_dev, slave_dev, "NS on slave: dst %pI6c src %pI6c\n",
3844 struct net_device *bond_dev)
3846 struct bonding *event_bond = netdev_priv(bond_dev);
3848 netdev_dbg(bond_dev, "%s called\n", __func__);
3856 xfrm_dev_state_flush(dev_net(bond_dev), bond_dev, true);
3874 struct net_device *bond_dev;
3885 bond_dev = slave->bond->dev;
3889 slave_dbg(bond_dev, slave_dev, "%s called\n", __func__);
3893 if (bond_dev->type != ARPHRD_ETHER)
3894 bond_release_and_destroy(bond_dev, slave_dev);
3896 __bond_release_one(bond_dev, slave_dev, false, true);
3978 bond_xdp_set_features(bond_dev);
4264 static int bond_open(struct net_device *bond_dev)
4266 struct bonding *bond = netdev_priv(bond_dev);
4324 static int bond_close(struct net_device *bond_dev)
4326 struct bonding *bond = netdev_priv(bond_dev);
4339 bond_hw_addr_flush(bond_dev, slave->dev);
4345 bond_hw_addr_flush(bond_dev, slave->dev);
4421 static void bond_get_stats(struct net_device *bond_dev,
4424 struct bonding *bond = netdev_priv(bond_dev);
4433 nest_level = bond_get_lowest_level_rcu(bond_dev);
4454 static int bond_eth_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd)
4456 struct bonding *bond = netdev_priv(bond_dev);
4459 netdev_dbg(bond_dev, "bond_eth_ioctl: cmd=%d\n", cmd);
4491 static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd)
4493 struct bonding *bond = netdev_priv(bond_dev);
4503 netdev_dbg(bond_dev, "bond_ioctl: cmd=%d\n", cmd);
4512 bond_info_query(bond_dev, &k_binfo);
4523 res = bond_slave_info_query(bond_dev, &k_sinfo);
4533 net = dev_net(bond_dev);
4540 slave_dbg(bond_dev, slave_dev, "slave_dev=%p:\n", slave_dev);
4547 res = bond_enslave(bond_dev, slave_dev, NULL);
4550 res = bond_release(bond_dev, slave_dev);
4553 res = bond_set_dev_addr(bond_dev, slave_dev);
4567 static int bond_siocdevprivate(struct net_device *bond_dev, struct ifreq *ifr,
4574 return bond_do_ioctl(bond_dev, &ifrdata, SIOCBONDINFOQUERY);
4576 return bond_do_ioctl(bond_dev, &ifrdata, SIOCBONDSLAVEINFOQUERY);
4578 return bond_do_ioctl(bond_dev, ifr, SIOCBONDENSLAVE);
4580 return bond_do_ioctl(bond_dev, ifr, SIOCBONDRELEASE);
4582 return bond_do_ioctl(bond_dev, ifr, SIOCBONDSETHWADDR);
4584 return bond_do_ioctl(bond_dev, ifr, SIOCBONDCHANGEACTIVE);
4590 static void bond_change_rx_flags(struct net_device *bond_dev, int change)
4592 struct bonding *bond = netdev_priv(bond_dev);
4596 bond_dev->flags & IFF_PROMISC ? 1 : -1);
4600 bond_dev->flags & IFF_ALLMULTI ? 1 : -1);
4603 static void bond_set_rx_mode(struct net_device *bond_dev)
4605 struct bonding *bond = netdev_priv(bond_dev);
4613 dev_uc_sync(slave->dev, bond_dev);
4614 dev_mc_sync(slave->dev, bond_dev);
4618 dev_uc_sync_multiple(slave->dev, bond_dev);
4619 dev_mc_sync_multiple(slave->dev, bond_dev);
4681 static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
4683 struct bonding *bond = netdev_priv(bond_dev);
4688 netdev_dbg(bond_dev, "bond=%p, new_mtu=%d\n", bond, new_mtu);
4691 slave_dbg(bond_dev, slave->dev, "s %p c_m %p\n",
4705 slave_dbg(bond_dev, slave->dev, "err %d setting mtu to %d\n",
4711 bond_dev->mtu = new_mtu;
4723 tmp_res = dev_set_mtu(rollback_slave->dev, bond_dev->mtu);
4725 slave_dbg(bond_dev, rollback_slave->dev, "unwind err %d\n",
4738 static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
4740 struct bonding *bond = netdev_priv(bond_dev);
4747 return bond_alb_set_mac_address(bond_dev, addr);
4750 netdev_dbg(bond_dev, "%s: bond=%p\n", __func__, bond);
4763 slave_dbg(bond_dev, slave->dev, "%s: slave=%p\n",
4773 slave_dbg(bond_dev, slave->dev, "%s: err %d\n",
4780 dev_addr_set(bond_dev, ss->__data);
4784 memcpy(tmp_ss.__data, bond_dev->dev_addr, bond_dev->addr_len);
4785 tmp_ss.ss_family = bond_dev->type;
4797 slave_dbg(bond_dev, rollback_slave->dev, "%s: unwind err %d\n",
4953 struct net_device *bond_dev)
4955 struct bonding *bond = netdev_priv(bond_dev);
4962 return bond_tx_drop(bond_dev, skb);
4974 struct net_device *bond_dev)
4976 struct bonding *bond = netdev_priv(bond_dev);
4983 return bond_tx_drop(bond_dev, skb);
5192 struct net_device *bond_dev)
5194 struct bonding *bond = netdev_priv(bond_dev);
5213 bond_dev->name, __func__);
5228 dev_core_stats_tx_dropped_inc(bond_dev);
5476 bond_xdp_get_xmit_slave(struct net_device *bond_dev, struct xdp_buff *xdp)
5478 struct bonding *bond = netdev_priv(bond_dev);
5499 netdev_err(bond_dev, "Unknown bonding mode %d for xdp xmit\n", BOND_MODE(bond));
5510 static int bond_xdp_xmit(struct net_device *bond_dev,
5525 slave_dev = bond_xdp_get_xmit_slave(bond_dev, &xdp);
5711 static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev,
5714 struct bonding *bond = netdev_priv(bond_dev);
5747 static void bond_ethtool_get_drvinfo(struct net_device *bond_dev,
5755 static int bond_ethtool_get_ts_info(struct net_device *bond_dev,
5758 struct bonding *bond = netdev_priv(bond_dev);
5868 static void bond_destructor(struct net_device *bond_dev)
5870 struct bonding *bond = netdev_priv(bond_dev);
5878 void bond_setup(struct net_device *bond_dev)
5880 struct bonding *bond = netdev_priv(bond_dev);
5886 bond->dev = bond_dev;
5889 ether_setup(bond_dev);
5890 bond_dev->max_mtu = ETH_MAX_MTU;
5891 bond_dev->netdev_ops = &bond_netdev_ops;
5892 bond_dev->ethtool_ops = &bond_ethtool_ops;
5894 bond_dev->needs_free_netdev = true;
5895 bond_dev->priv_destructor = bond_destructor;
5897 SET_NETDEV_DEVTYPE(bond_dev, &bond_type);
5900 bond_dev->flags |= IFF_MASTER;
5901 bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT | IFF_NO_QUEUE;
5902 bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING);
5906 bond_dev->xfrmdev_ops = &bond_xfrmdev_ops;
5912 bond_dev->features |= NETIF_F_LLTX;
5922 bond_dev->features |= NETIF_F_NETNS_LOCAL;
5924 bond_dev->hw_features = BOND_VLAN_FEATURES |
5930 bond_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL;
5931 bond_dev->features |= bond_dev->hw_features;
5932 bond_dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
5934 bond_dev->hw_features |= BOND_XFRM_FEATURES;
5937 bond_dev->features |= BOND_XFRM_FEATURES;
5944 static void bond_uninit(struct net_device *bond_dev)
5946 struct bonding *bond = netdev_priv(bond_dev);
5950 bond_netpoll_cleanup(bond_dev);
5954 __bond_release_one(bond_dev, slave->dev, true, true);
5955 netdev_info(bond_dev, "Released all slaves\n");
6356 static int bond_init(struct net_device *bond_dev)
6358 struct bonding *bond = netdev_priv(bond_dev);
6359 struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id);
6361 netdev_dbg(bond_dev, "Begin bond_init\n");
6363 bond->wq = alloc_ordered_workqueue(bond_dev->name, WQ_MEM_RECLAIM);
6370 netdev_lockdep_set_classes(bond_dev);
6379 if (is_zero_ether_addr(bond_dev->dev_addr) &&
6380 bond_dev->addr_assign_type == NET_ADDR_PERM)
6381 eth_hw_addr_random(bond_dev);
6398 struct net_device *bond_dev;
6404 bond_dev = alloc_netdev_mq(sizeof(struct bonding),
6407 if (!bond_dev)
6410 bond = netdev_priv(bond_dev);
6411 dev_net_set(bond_dev, net);
6412 bond_dev->rtnl_link_ops = &bond_link_ops;
6414 res = register_netdevice(bond_dev);
6416 free_netdev(bond_dev);
6420 netif_carrier_off(bond_dev);