Lines Matching +full:free +full:- +full:flowing
1 // SPDX-License-Identifier: GPL-2.0-or-later
53 if (!strncmp(dev->name, "lec", 3)) in port_cost()
56 if (!strncmp(dev->name, "plip", 4)) in port_cost()
66 struct net_device *dev = p->dev; in br_port_carrier_check()
67 struct net_bridge *br = p->br; in br_port_carrier_check()
69 if (!(p->flags & BR_ADMIN_COST) && in br_port_carrier_check()
71 p->path_cost = port_cost(dev); in br_port_carrier_check()
74 if (!netif_running(br->dev)) in br_port_carrier_check()
77 spin_lock_bh(&br->lock); in br_port_carrier_check()
79 if (p->state == BR_STATE_DISABLED) { in br_port_carrier_check()
84 if (p->state != BR_STATE_DISABLED) { in br_port_carrier_check()
89 spin_unlock_bh(&br->lock); in br_port_carrier_check()
99 err = dev_set_promiscuity(p->dev, 1); in br_port_set_promisc()
103 br_fdb_unsync_static(p->br, p); in br_port_set_promisc()
104 p->flags |= BR_PROMISC; in br_port_set_promisc()
111 /* Check if the port is already non-promisc or if it doesn't in br_port_clear_promisc()
113 * we'll end up re-enabling promisc mode anyway, so just check for in br_port_clear_promisc()
116 if (!br_promisc_port(p) || !(p->dev->priv_flags & IFF_UNICAST_FLT)) in br_port_clear_promisc()
122 err = br_fdb_sync_static(p->br, p); in br_port_clear_promisc()
126 dev_set_promiscuity(p->dev, -1); in br_port_clear_promisc()
127 p->flags &= ~BR_PROMISC; in br_port_clear_promisc()
143 if ((br->dev->flags & IFF_PROMISC) || !br_vlan_enabled(br->dev)) in br_manage_promisc()
146 list_for_each_entry(p, &br->port_list, list) { in br_manage_promisc()
150 /* If the number of auto-ports is <= 1, then all other in br_manage_promisc()
153 * on the auto-port becomes forwarding/egress to other in br_manage_promisc()
156 * auto-port is also statically known. in br_manage_promisc()
160 if ((p->dev->priv_flags & IFF_UNICAST_FLT) && in br_manage_promisc()
161 (br->auto_cnt == 0 || in br_manage_promisc()
162 (br->auto_cnt == 1 && br_auto_port(p)))) in br_manage_promisc()
173 struct net_bridge_port *old_backup = rtnl_dereference(p->backup_port); in nbp_backup_change()
180 return -ENOENT; in nbp_backup_change()
183 if (backup_p->br != p->br) in nbp_backup_change()
184 return -EINVAL; in nbp_backup_change()
188 return -EINVAL; in nbp_backup_change()
195 old_backup->backup_redirected_cnt--; in nbp_backup_change()
198 backup_p->backup_redirected_cnt++; in nbp_backup_change()
199 rcu_assign_pointer(p->backup_port, backup_p); in nbp_backup_change()
207 if (p->backup_redirected_cnt) { in nbp_backup_clear()
210 list_for_each_entry(cur_p, &p->br->port_list, list) { in nbp_backup_clear()
213 backup_p = rtnl_dereference(cur_p->backup_port); in nbp_backup_clear()
219 WARN_ON(rcu_access_pointer(p->backup_port) || p->backup_redirected_cnt); in nbp_backup_clear()
227 list_for_each_entry(p, &br->port_list, list) { in nbp_update_port_count()
231 if (br->auto_cnt != cnt) { in nbp_update_port_count()
232 br->auto_cnt = cnt; in nbp_update_port_count()
243 dev_set_allmulti(p->dev, -1); in nbp_delete_promisc()
245 dev_set_promiscuity(p->dev, -1); in nbp_delete_promisc()
247 br_fdb_unsync_static(p->br, p); in nbp_delete_promisc()
261 net_ns_get_ownership(dev_net(p->dev), uid, gid); in brport_get_ownership()
274 struct net_device *dev = p->dev; in destroy_nbp()
276 p->br = NULL; in destroy_nbp()
277 p->dev = NULL; in destroy_nbp()
280 kobject_put(&p->kobj); in destroy_nbp()
295 list_for_each_entry(p, &br->port_list, list) { in get_max_headroom()
296 unsigned dev_headroom = netdev_get_fwd_headroom(p->dev); in get_max_headroom()
309 list_for_each_entry(p, &br->port_list, list) in update_headroom()
310 netdev_set_rx_headroom(p->dev, new_hr); in update_headroom()
312 br->dev->needed_headroom = new_hr; in update_headroom()
317 * all the timers and stops new packets from flowing through.
326 struct net_bridge *br = p->br; in del_nbp()
327 struct net_device *dev = p->dev; in del_nbp()
329 sysfs_remove_link(br->ifobj, p->dev->name); in del_nbp()
333 spin_lock_bh(&br->lock); in del_nbp()
335 spin_unlock_bh(&br->lock); in del_nbp()
341 list_del_rcu(&p->list); in del_nbp()
342 if (netdev_get_fwd_headroom(dev) == br->dev->needed_headroom) in del_nbp()
353 netdev_upper_dev_unlink(dev, br->dev); in del_nbp()
355 dev->priv_flags &= ~IFF_BRIDGE_PORT; in del_nbp()
361 kobject_uevent(&p->kobj, KOBJ_REMOVE); in del_nbp()
362 kobject_del(&p->kobj); in del_nbp()
366 call_rcu(&p->rcu, destroy_nbp_rcu); in del_nbp()
375 list_for_each_entry_safe(p, n, &br->port_list, list) { in br_dev_delete()
383 cancel_delayed_work_sync(&br->gc_work); in br_dev_delete()
385 br_sysfs_delbr(br->dev); in br_dev_delete()
386 unregister_netdevice_queue(br->dev, head); in br_dev_delete()
398 return -ENOMEM; in find_portno()
401 list_for_each_entry(p, &br->port_list, list) { in find_portno()
402 set_bit(p->port_no, inuse); in find_portno()
407 return (index >= BR_MAX_PORTS) ? -EXFULL : index; in find_portno()
423 return ERR_PTR(-ENOMEM); in new_nbp()
425 p->br = br; in new_nbp()
427 p->dev = dev; in new_nbp()
428 p->path_cost = port_cost(dev); in new_nbp()
429 p->priority = 0x8000 >> BR_PORT_BITS; in new_nbp()
430 p->port_no = index; in new_nbp()
431 p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD; in new_nbp()
454 return -ENOMEM; in br_add_bridge()
457 dev->rtnl_link_ops = &br_link_ops; in br_add_bridge()
473 ret = -ENXIO; /* Could not find device */ in br_del_bridge()
475 else if (!(dev->priv_flags & IFF_EBRIDGE)) { in br_del_bridge()
477 ret = -EPERM; in br_del_bridge()
480 else if (dev->flags & IFF_UP) { in br_del_bridge()
482 ret = -EBUSY; in br_del_bridge()
492 /* MTU of the bridge pseudo-device: ETH_DATA_LEN or the minimum of the ports */
498 list_for_each_entry(p, &br->port_list, list) in br_mtu_min()
499 if (!ret_mtu || ret_mtu > p->dev->mtu) in br_mtu_min()
500 ret_mtu = p->dev->mtu; in br_mtu_min()
516 dev_set_mtu(br->dev, br_mtu_min(br)); in br_mtu_auto_adjust()
526 list_for_each_entry(p, &br->port_list, list) { in br_set_gso_limits()
527 gso_max_size = min(gso_max_size, p->dev->gso_max_size); in br_set_gso_limits()
528 gso_max_segs = min(gso_max_segs, p->dev->gso_max_segs); in br_set_gso_limits()
530 br->dev->gso_max_size = gso_max_size; in br_set_gso_limits()
531 br->dev->gso_max_segs = gso_max_segs; in br_set_gso_limits()
543 if (list_empty(&br->port_list)) in br_features_recompute()
549 list_for_each_entry(p, &br->port_list, list) { in br_features_recompute()
551 p->dev->features, mask); in br_features_recompute()
567 /* Don't allow bridging non-ethernet like devices. */ in br_add_if()
568 if ((dev->flags & IFF_LOOPBACK) || in br_add_if()
569 dev->type != ARPHRD_ETHER || dev->addr_len != ETH_ALEN || in br_add_if()
570 !is_valid_ether_addr(dev->dev_addr)) in br_add_if()
571 return -EINVAL; in br_add_if()
584 list_for_each_entry(p, &br->port_list, list) { in br_add_if()
585 if (!netdev_port_same_parent_id(dev, p->dev)) { in br_add_if()
588 return -EINVAL; in br_add_if()
594 if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit) { in br_add_if()
597 return -ELOOP; in br_add_if()
602 return -EBUSY; in br_add_if()
605 if (dev->priv_flags & IFF_DONT_BRIDGE) { in br_add_if()
608 return -EOPNOTSUPP; in br_add_if()
620 kfree(p); /* kobject not yet init'd, manually free */ in br_add_if()
624 err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj), in br_add_if()
641 dev->priv_flags |= IFF_BRIDGE_PORT; in br_add_if()
643 err = netdev_master_upper_dev_link(dev, br->dev, NULL, NULL, extack); in br_add_if()
653 list_add_rcu(&p->list, &br->port_list); in br_add_if()
656 if (!br_promisc_port(p) && (p->dev->priv_flags & IFF_UNICAST_FLT)) { in br_add_if()
662 * non-promiscuous ports and *new* ports, so we need to in br_add_if()
670 netdev_update_features(br->dev); in br_add_if()
672 br_hr = br->dev->needed_headroom; in br_add_if()
679 if (br_fdb_insert(br, p, dev->dev_addr, 0)) in br_add_if()
682 if (br->dev->addr_assign_type != NET_ADDR_SET) { in br_add_if()
686 err = dev_pre_changeaddr_notify(br->dev, dev->dev_addr, extack); in br_add_if()
697 spin_lock_bh(&br->lock); in br_add_if()
701 (br->dev->flags & IFF_UP)) in br_add_if()
703 spin_unlock_bh(&br->lock); in br_add_if()
708 call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev); in br_add_if()
713 kobject_uevent(&p->kobj, KOBJ_ADD); in br_add_if()
720 list_del_rcu(&p->list); in br_add_if()
724 netdev_upper_dev_unlink(dev, br->dev); in br_add_if()
726 dev->priv_flags &= ~IFF_BRIDGE_PORT; in br_add_if()
731 sysfs_remove_link(br->ifobj, p->dev->name); in br_add_if()
734 kobject_put(&p->kobj); in br_add_if()
735 dev_set_allmulti(dev, -1); in br_add_if()
748 if (!p || p->br != br) in br_del_if()
749 return -EINVAL; in br_del_if()
760 spin_lock_bh(&br->lock); in br_del_if()
762 spin_unlock_bh(&br->lock); in br_del_if()
765 call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev); in br_del_if()
767 netdev_update_features(br->dev); in br_del_if()
774 struct net_bridge *br = p->br; in br_port_flags_change()
791 return p->flags & flag; in br_port_flag_is_set()