1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Userspace interface 4 * Linux ethernet bridge 5 * 6 * Authors: 7 * Lennert Buytenhek <buytenh@gnu.org> 8 */ 9 10 #include <linux/kernel.h> 11 #include <linux/netdevice.h> 12 #include <linux/etherdevice.h> 13 #include <linux/netpoll.h> 14 #include <linux/ethtool.h> 15 #include <linux/if_arp.h> 16 #include <linux/module.h> 17 #include <linux/init.h> 18 #include <linux/rtnetlink.h> 19 #include <linux/if_ether.h> 20 #include <linux/slab.h> 21 #include <net/dsa.h> 22 #include <net/netdev_lock.h> 23 #include <net/sock.h> 24 #include <linux/if_vlan.h> 25 #include <net/switchdev.h> 26 #include <net/net_namespace.h> 27 28 #include "br_private.h" 29 30 /* 31 * Determine initial path cost based on speed. 32 * using recommendations from 802.1d standard 33 * 34 * Since driver might sleep, we need to not be holding any bridge spinlocks. 35 */ 36 static int port_cost(struct net_device *dev) 37 { 38 struct ethtool_link_ksettings ecmd; 39 40 if (!netif_get_link_ksettings(dev, &ecmd)) { 41 switch (ecmd.base.speed) { 42 case SPEED_10000: 43 return 2; 44 case SPEED_5000: 45 return 3; 46 case SPEED_2500: 47 return 4; 48 case SPEED_1000: 49 return 5; 50 case SPEED_100: 51 return 19; 52 case SPEED_10: 53 return 100; 54 case SPEED_UNKNOWN: 55 return 100; 56 default: 57 if (ecmd.base.speed > SPEED_10000) 58 return 1; 59 } 60 } 61 62 /* Old silly heuristics based on name */ 63 if (!strncmp(dev->name, "lec", 3)) 64 return 7; 65 66 if (!strncmp(dev->name, "plip", 4)) 67 return 2500; 68 69 return 100; /* assume old 10Mbps */ 70 } 71 72 73 /* Check for port carrier transitions. */ 74 void br_port_carrier_check(struct net_bridge_port *p, bool *notified) 75 { 76 struct net_device *dev = p->dev; 77 struct net_bridge *br = p->br; 78 79 if (!test_bit(BR_ADMIN_COST_BIT, &p->flags) && 80 netif_running(dev) && netif_oper_up(dev)) 81 WRITE_ONCE(p->path_cost, port_cost(dev)); 82 83 *notified = false; 84 if (!netif_running(br->dev)) 85 return; 86 87 spin_lock_bh(&br->lock); 88 if (netif_running(dev) && netif_oper_up(dev)) { 89 if (p->state == BR_STATE_DISABLED) { 90 br_stp_enable_port(p); 91 *notified = true; 92 } 93 } else { 94 if (p->state != BR_STATE_DISABLED) { 95 br_stp_disable_port(p); 96 *notified = true; 97 } 98 } 99 spin_unlock_bh(&br->lock); 100 } 101 102 static void br_port_set_promisc(struct net_bridge_port *p) 103 { 104 int err = 0; 105 106 if (br_promisc_port(p)) 107 return; 108 109 err = dev_set_promiscuity(p->dev, 1); 110 if (err) 111 return; 112 113 br_fdb_unsync_static(p->br, p); 114 set_bit(BR_PROMISC_BIT, &p->flags); 115 } 116 117 static void br_port_clear_promisc(struct net_bridge_port *p) 118 { 119 int err; 120 121 /* Check if the port is already non-promisc or if it doesn't 122 * support UNICAST filtering. Without unicast filtering support 123 * we'll end up re-enabling promisc mode anyway, so just check for 124 * it here. 125 */ 126 if (!br_promisc_port(p) || !(p->dev->priv_flags & IFF_UNICAST_FLT)) 127 return; 128 129 /* Since we'll be clearing the promisc mode, program the port 130 * first so that we don't have interruption in traffic. 131 */ 132 err = br_fdb_sync_static(p->br, p); 133 if (err) 134 return; 135 136 dev_set_promiscuity(p->dev, -1); 137 clear_bit(BR_PROMISC_BIT, &p->flags); 138 } 139 140 /* When a port is added or removed or when certain port flags 141 * change, this function is called to automatically manage 142 * promiscuity setting of all the bridge ports. We are always called 143 * under RTNL so can skip using rcu primitives. 144 */ 145 void br_manage_promisc(struct net_bridge *br) 146 { 147 struct net_bridge_port *p; 148 bool set_all = false; 149 150 /* If vlan filtering is disabled or bridge interface is placed 151 * into promiscuous mode, place all ports in promiscuous mode. 152 */ 153 if ((br->dev->flags & IFF_PROMISC) || !br_vlan_enabled(br->dev)) 154 set_all = true; 155 156 list_for_each_entry(p, &br->port_list, list) { 157 if (set_all) { 158 br_port_set_promisc(p); 159 } else { 160 /* If the number of auto-ports is <= 1, then all other 161 * ports will have their output configuration 162 * statically specified through fdbs. Since ingress 163 * on the auto-port becomes forwarding/egress to other 164 * ports and egress configuration is statically known, 165 * we can say that ingress configuration of the 166 * auto-port is also statically known. 167 * This lets us disable promiscuous mode and write 168 * this config to hw. 169 */ 170 if ((p->dev->priv_flags & IFF_UNICAST_FLT) && 171 (br->auto_cnt == 0 || 172 (br->auto_cnt == 1 && br_auto_port(p)))) 173 br_port_clear_promisc(p); 174 else 175 br_port_set_promisc(p); 176 } 177 } 178 } 179 180 int nbp_backup_change(struct net_bridge_port *p, 181 struct net_device *backup_dev) 182 { 183 struct net_bridge_port *old_backup = rtnl_dereference(p->backup_port); 184 struct net_bridge_port *backup_p = NULL; 185 186 ASSERT_RTNL(); 187 188 if (backup_dev) { 189 if (!netif_is_bridge_port(backup_dev)) 190 return -ENOENT; 191 192 backup_p = br_port_get_rtnl(backup_dev); 193 if (backup_p->br != p->br) 194 return -EINVAL; 195 } 196 197 if (p == backup_p) 198 return -EINVAL; 199 200 if (old_backup == backup_p) 201 return 0; 202 203 /* if the backup link is already set, clear it */ 204 if (old_backup) 205 old_backup->backup_redirected_cnt--; 206 207 if (backup_p) 208 backup_p->backup_redirected_cnt++; 209 rcu_assign_pointer(p->backup_port, backup_p); 210 211 return 0; 212 } 213 214 static void nbp_backup_clear(struct net_bridge_port *p) 215 { 216 nbp_backup_change(p, NULL); 217 if (p->backup_redirected_cnt) { 218 struct net_bridge_port *cur_p; 219 220 list_for_each_entry(cur_p, &p->br->port_list, list) { 221 struct net_bridge_port *backup_p; 222 223 backup_p = rtnl_dereference(cur_p->backup_port); 224 if (backup_p == p) 225 nbp_backup_change(cur_p, NULL); 226 } 227 } 228 229 WARN_ON(rcu_access_pointer(p->backup_port) || p->backup_redirected_cnt); 230 } 231 232 static void nbp_update_port_count(struct net_bridge *br) 233 { 234 struct net_bridge_port *p; 235 u32 cnt = 0; 236 237 list_for_each_entry(p, &br->port_list, list) { 238 if (br_auto_port(p)) 239 cnt++; 240 } 241 if (br->auto_cnt != cnt) { 242 br->auto_cnt = cnt; 243 br_manage_promisc(br); 244 } 245 } 246 247 static void nbp_delete_promisc(struct net_bridge_port *p) 248 { 249 /* If port is currently promiscuous, unset promiscuity. 250 * Otherwise, it is a static port so remove all addresses 251 * from it. 252 */ 253 dev_set_allmulti(p->dev, -1); 254 if (br_promisc_port(p)) 255 dev_set_promiscuity(p->dev, -1); 256 else 257 br_fdb_unsync_static(p->br, p); 258 } 259 260 static void release_nbp(struct kobject *kobj) 261 { 262 struct net_bridge_port *p 263 = container_of(kobj, struct net_bridge_port, kobj); 264 kfree(p); 265 } 266 267 static void brport_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid) 268 { 269 struct net_bridge_port *p = kobj_to_brport(kobj); 270 271 net_ns_get_ownership(dev_net(p->dev), uid, gid); 272 } 273 274 static const struct kobj_type brport_ktype = { 275 #ifdef CONFIG_SYSFS 276 .sysfs_ops = &brport_sysfs_ops, 277 #endif 278 .release = release_nbp, 279 .get_ownership = brport_get_ownership, 280 }; 281 282 static void destroy_nbp(struct net_bridge_port *p) 283 { 284 struct net_device *dev = p->dev; 285 286 p->br = NULL; 287 p->dev = NULL; 288 netdev_put(dev, &p->dev_tracker); 289 290 kobject_put(&p->kobj); 291 } 292 293 static void destroy_nbp_rcu(struct rcu_head *head) 294 { 295 struct net_bridge_port *p = 296 container_of(head, struct net_bridge_port, rcu); 297 destroy_nbp(p); 298 } 299 300 static unsigned get_max_headroom(struct net_bridge *br) 301 { 302 unsigned max_headroom = 0; 303 struct net_bridge_port *p; 304 305 list_for_each_entry(p, &br->port_list, list) { 306 unsigned dev_headroom = netdev_get_fwd_headroom(p->dev); 307 308 if (dev_headroom > max_headroom) 309 max_headroom = dev_headroom; 310 } 311 312 return max_headroom; 313 } 314 315 static void update_headroom(struct net_bridge *br, int new_hr) 316 { 317 struct net_bridge_port *p; 318 319 list_for_each_entry(p, &br->port_list, list) 320 netdev_set_rx_headroom(p->dev, new_hr); 321 322 br->dev->needed_headroom = new_hr; 323 } 324 325 /* Delete port(interface) from bridge is done in two steps. 326 * via RCU. First step, marks device as down. That deletes 327 * all the timers and stops new packets from flowing through. 328 * 329 * Final cleanup doesn't occur until after all CPU's finished 330 * processing packets. 331 * 332 * Protected from multiple admin operations by RTNL mutex 333 */ 334 static void del_nbp(struct net_bridge_port *p) 335 { 336 struct net_bridge_vlan_group *vg; 337 struct net_device *dev = p->dev; 338 struct net_bridge *br = p->br; 339 340 sysfs_remove_link(br->ifobj, p->dev->name); 341 342 nbp_delete_promisc(p); 343 344 spin_lock_bh(&br->lock); 345 br_stp_disable_port(p); 346 spin_unlock_bh(&br->lock); 347 348 br_mrp_port_del(br, p); 349 br_cfm_port_del(br, p); 350 351 br_ifinfo_notify(RTM_DELLINK, NULL, p); 352 353 list_del_rcu(&p->list); 354 if (netdev_get_fwd_headroom(dev) == br->dev->needed_headroom) 355 update_headroom(br, get_max_headroom(br)); 356 netdev_reset_rx_headroom(dev); 357 358 vg = nbp_vlan_group(p); 359 nbp_vlan_group_unpublish(p); 360 br_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 1); 361 nbp_vlan_flush(p, vg); 362 switchdev_deferred_process(); 363 nbp_backup_clear(p); 364 365 nbp_update_port_count(br); 366 367 netdev_upper_dev_unlink(dev, br->dev); 368 369 dev->priv_flags &= ~IFF_BRIDGE_PORT; 370 371 netdev_rx_handler_unregister(dev); 372 373 br_multicast_del_port(p); 374 375 kobject_uevent(&p->kobj, KOBJ_REMOVE); 376 kobject_del(&p->kobj); 377 378 br_netpoll_disable(p); 379 380 call_rcu(&p->rcu, destroy_nbp_rcu); 381 } 382 383 /* Delete bridge device */ 384 void br_dev_delete(struct net_device *dev, struct list_head *head) 385 { 386 struct net_bridge *br = netdev_priv(dev); 387 struct net_bridge_port *p, *n; 388 389 list_for_each_entry_safe(p, n, &br->port_list, list) { 390 del_nbp(p); 391 } 392 393 br_mst_uninit(br); 394 br_recalculate_neigh_suppress_enabled(br); 395 396 br_fdb_cleanup_by_dst(br, br_port_to_dst(NULL), 0, 1); 397 398 timer_shutdown_sync(&br->hello_timer); 399 timer_shutdown_sync(&br->topology_change_timer); 400 timer_shutdown_sync(&br->tcn_timer); 401 cancel_delayed_work_sync(&br->gc_work); 402 403 br_sysfs_delbr(br->dev); 404 unregister_netdevice_queue(br->dev, head); 405 } 406 407 /* find an available port number */ 408 static int find_portno(struct net_bridge *br) 409 { 410 int index; 411 struct net_bridge_port *p; 412 unsigned long *inuse; 413 414 inuse = bitmap_zalloc(BR_MAX_PORTS, GFP_KERNEL); 415 if (!inuse) 416 return -ENOMEM; 417 418 __set_bit(0, inuse); /* zero is reserved */ 419 list_for_each_entry(p, &br->port_list, list) 420 __set_bit(p->port_no, inuse); 421 422 index = find_first_zero_bit(inuse, BR_MAX_PORTS); 423 bitmap_free(inuse); 424 425 return (index >= BR_MAX_PORTS) ? -EXFULL : index; 426 } 427 428 /* called with RTNL but without bridge lock */ 429 static struct net_bridge_port *new_nbp(struct net_bridge *br, 430 struct net_device *dev) 431 { 432 struct net_bridge_port *p; 433 int index, err; 434 435 index = find_portno(br); 436 if (index < 0) 437 return ERR_PTR(index); 438 439 p = kzalloc_obj(*p); 440 if (p == NULL) 441 return ERR_PTR(-ENOMEM); 442 443 p->br = br; 444 netdev_hold(dev, &p->dev_tracker, GFP_KERNEL); 445 p->dev = dev; 446 netdev_lock_ops(dev); 447 p->path_cost = port_cost(dev); 448 netdev_unlock_ops(dev); 449 p->priority = 0x8000 >> BR_PORT_BITS; 450 p->port_no = index; 451 p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD; 452 br_init_port(p); 453 br_set_state(p, BR_STATE_DISABLED); 454 br_stp_port_timer_init(p); 455 err = br_multicast_add_port(p); 456 if (err) { 457 netdev_put(dev, &p->dev_tracker); 458 kfree(p); 459 p = ERR_PTR(err); 460 } 461 462 return p; 463 } 464 465 int br_add_bridge(struct net *net, const char *name) 466 { 467 struct net_device *dev; 468 int res; 469 470 dev = alloc_netdev(sizeof(struct net_bridge), name, NET_NAME_UNKNOWN, 471 br_dev_setup); 472 473 if (!dev) 474 return -ENOMEM; 475 476 dev_net_set(dev, net); 477 dev->rtnl_link_ops = &br_link_ops; 478 479 res = register_netdevice(dev); 480 if (res) 481 free_netdev(dev); 482 return res; 483 } 484 485 int br_del_bridge(struct net *net, const char *name) 486 { 487 struct net_device *dev; 488 int ret = 0; 489 490 dev = __dev_get_by_name(net, name); 491 if (dev == NULL) 492 ret = -ENXIO; /* Could not find device */ 493 494 else if (!netif_is_bridge_master(dev)) { 495 /* Attempt to delete non bridge device! */ 496 ret = -EPERM; 497 } 498 499 else if (dev->flags & IFF_UP) { 500 /* Not shutdown yet. */ 501 ret = -EBUSY; 502 } 503 504 else 505 br_dev_delete(dev, NULL); 506 507 return ret; 508 } 509 510 /* MTU of the bridge pseudo-device: ETH_DATA_LEN or the minimum of the ports */ 511 static int br_mtu_min(const struct net_bridge *br) 512 { 513 const struct net_bridge_port *p; 514 int ret_mtu = 0; 515 516 list_for_each_entry(p, &br->port_list, list) 517 if (!ret_mtu || ret_mtu > p->dev->mtu) 518 ret_mtu = p->dev->mtu; 519 520 return ret_mtu ? ret_mtu : ETH_DATA_LEN; 521 } 522 523 void br_mtu_auto_adjust(struct net_bridge *br) 524 { 525 ASSERT_RTNL(); 526 527 /* if the bridge MTU was manually configured don't mess with it */ 528 if (br_opt_get(br, BROPT_MTU_SET_BY_USER)) 529 return; 530 531 /* change to the minimum MTU and clear the flag which was set by 532 * the bridge ndo_change_mtu callback 533 */ 534 dev_set_mtu(br->dev, br_mtu_min(br)); 535 br_opt_toggle(br, BROPT_MTU_SET_BY_USER, false); 536 } 537 538 /* 539 * Recomputes features using slave's features 540 */ 541 netdev_features_t br_features_recompute(struct net_bridge *br, 542 netdev_features_t features) 543 { 544 struct net_bridge_port *p; 545 netdev_features_t mask; 546 547 if (list_empty(&br->port_list)) 548 return features; 549 550 mask = features; 551 features &= ~NETIF_F_ONE_FOR_ALL; 552 553 list_for_each_entry(p, &br->port_list, list) { 554 features = netdev_increment_features(features, 555 p->dev->features, mask); 556 } 557 features = netdev_add_tso_features(features, mask); 558 559 return features; 560 } 561 562 /* called with RTNL */ 563 int br_add_if(struct net_bridge *br, struct net_device *dev, 564 struct netlink_ext_ack *extack) 565 { 566 struct net_bridge_port *p; 567 int err = 0; 568 unsigned br_hr, dev_hr; 569 bool changed_addr, fdb_synced = false; 570 571 /* Don't allow bridging non-ethernet like devices. */ 572 if ((dev->flags & IFF_LOOPBACK) || 573 dev->type != ARPHRD_ETHER || dev->addr_len != ETH_ALEN || 574 !is_valid_ether_addr(dev->dev_addr)) 575 return -EINVAL; 576 577 /* No bridging of bridges */ 578 if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit) { 579 NL_SET_ERR_MSG(extack, 580 "Can not enslave a bridge to a bridge"); 581 return -ELOOP; 582 } 583 584 /* Device has master upper dev */ 585 if (netdev_master_upper_dev_get(dev)) 586 return -EBUSY; 587 588 /* No bridging devices that dislike that (e.g. wireless) */ 589 if (dev->priv_flags & IFF_DONT_BRIDGE) { 590 NL_SET_ERR_MSG(extack, 591 "Device does not allow enslaving to a bridge"); 592 return -EOPNOTSUPP; 593 } 594 595 p = new_nbp(br, dev); 596 if (IS_ERR(p)) 597 return PTR_ERR(p); 598 599 call_netdevice_notifiers(NETDEV_JOIN, dev); 600 601 err = dev_set_allmulti(dev, 1); 602 if (err) { 603 br_multicast_del_port(p); 604 netdev_put(dev, &p->dev_tracker); 605 kfree(p); /* kobject not yet init'd, manually free */ 606 goto err1; 607 } 608 609 err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj), 610 SYSFS_BRIDGE_PORT_ATTR); 611 if (err) 612 goto err2; 613 614 err = br_sysfs_addif(p); 615 if (err) 616 goto err2; 617 618 err = br_netpoll_enable(p); 619 if (err) 620 goto err3; 621 622 err = netdev_rx_handler_register(dev, br_get_rx_handler(dev), p); 623 if (err) 624 goto err4; 625 626 dev->priv_flags |= IFF_BRIDGE_PORT; 627 628 err = netdev_master_upper_dev_link(dev, br->dev, NULL, NULL, extack); 629 if (err) 630 goto err5; 631 632 dev_disable_lro(dev); 633 634 list_add_rcu(&p->list, &br->port_list); 635 636 nbp_update_port_count(br); 637 if (!br_promisc_port(p) && (p->dev->priv_flags & IFF_UNICAST_FLT)) { 638 /* When updating the port count we also update all ports' 639 * promiscuous mode. 640 * A port leaving promiscuous mode normally gets the bridge's 641 * fdb synced to the unicast filter (if supported), however, 642 * `br_port_clear_promisc` does not distinguish between 643 * non-promiscuous ports and *new* ports, so we need to 644 * sync explicitly here. 645 */ 646 fdb_synced = br_fdb_sync_static(br, p) == 0; 647 if (!fdb_synced) 648 netdev_err(dev, "failed to sync bridge static fdb addresses to this port\n"); 649 } 650 651 br_hr = br->dev->needed_headroom; 652 dev_hr = netdev_get_fwd_headroom(dev); 653 if (br_hr < dev_hr) 654 update_headroom(br, dev_hr); 655 else 656 netdev_set_rx_headroom(dev, br_hr); 657 658 if (br_fdb_add_local(br, p, dev->dev_addr, 0)) 659 netdev_err(dev, "failed insert local address bridge forwarding table\n"); 660 661 if (br->dev->addr_assign_type != NET_ADDR_SET) { 662 /* Ask for permission to use this MAC address now, even if we 663 * don't end up choosing it below. 664 */ 665 err = netif_pre_changeaddr_notify(br->dev, dev->dev_addr, 666 extack); 667 if (err) 668 goto err6; 669 } 670 671 err = nbp_vlan_init(p, extack); 672 if (err) { 673 netdev_err(dev, "failed to initialize vlan filtering on this port\n"); 674 goto err6; 675 } 676 677 spin_lock_bh(&br->lock); 678 changed_addr = br_stp_recalculate_bridge_id(br); 679 680 if (netif_running(dev) && netif_oper_up(dev) && 681 (br->dev->flags & IFF_UP)) 682 br_stp_enable_port(p); 683 spin_unlock_bh(&br->lock); 684 685 br_ifinfo_notify(RTM_NEWLINK, NULL, p); 686 687 if (changed_addr) 688 call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev); 689 690 br_mtu_auto_adjust(br); 691 692 netdev_compute_master_upper_features(br->dev, false); 693 694 kobject_uevent(&p->kobj, KOBJ_ADD); 695 696 return 0; 697 698 err6: 699 if (fdb_synced) 700 br_fdb_unsync_static(br, p); 701 list_del_rcu(&p->list); 702 br_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 1); 703 nbp_update_port_count(br); 704 netdev_upper_dev_unlink(dev, br->dev); 705 err5: 706 dev->priv_flags &= ~IFF_BRIDGE_PORT; 707 netdev_rx_handler_unregister(dev); 708 err4: 709 br_netpoll_disable(p); 710 err3: 711 sysfs_remove_link(br->ifobj, p->dev->name); 712 err2: 713 br_multicast_del_port(p); 714 netdev_put(dev, &p->dev_tracker); 715 kobject_put(&p->kobj); 716 dev_set_allmulti(dev, -1); 717 err1: 718 return err; 719 } 720 721 /* called with RTNL */ 722 int br_del_if(struct net_bridge *br, struct net_device *dev) 723 { 724 struct net_bridge_port *p; 725 bool changed_addr; 726 727 p = br_port_get_rtnl(dev); 728 if (!p || p->br != br) 729 return -EINVAL; 730 731 /* Since more than one interface can be attached to a bridge, 732 * there still maybe an alternate path for netconsole to use; 733 * therefore there is no reason for a NETDEV_RELEASE event. 734 */ 735 del_nbp(p); 736 737 br_mtu_auto_adjust(br); 738 739 spin_lock_bh(&br->lock); 740 changed_addr = br_stp_recalculate_bridge_id(br); 741 spin_unlock_bh(&br->lock); 742 743 if (changed_addr) 744 call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev); 745 746 netdev_compute_master_upper_features(br->dev, false); 747 748 return 0; 749 } 750 751 void br_port_flags_change(struct net_bridge_port *p, unsigned long mask) 752 { 753 struct net_bridge *br = p->br; 754 755 if (mask & BR_AUTO_MASK) 756 nbp_update_port_count(br); 757 758 if (mask & (BR_NEIGH_SUPPRESS | BR_NEIGH_VLAN_SUPPRESS)) 759 br_recalculate_neigh_suppress_enabled(br); 760 } 761 762 bool br_port_flag_is_set(const struct net_device *dev, unsigned long flag) 763 { 764 struct net_bridge_port *p; 765 766 p = br_port_get_rtnl_rcu(dev); 767 if (!p) 768 return false; 769 770 return READ_ONCE(p->flags) & flag; 771 } 772 EXPORT_SYMBOL_GPL(br_port_flag_is_set); 773