Lines Matching refs:port

71 static inline bool macvlan_passthru(const struct macvlan_port *port)
73 return port->flags & MACVLAN_F_PASSTHRU;
76 static inline void macvlan_set_passthru(struct macvlan_port *port)
78 port->flags |= MACVLAN_F_PASSTHRU;
81 static inline bool macvlan_addr_change(const struct macvlan_port *port)
83 return port->flags & MACVLAN_F_ADDRCHANGE;
86 static inline void macvlan_set_addr_change(struct macvlan_port *port)
88 port->flags |= MACVLAN_F_ADDRCHANGE;
91 static inline void macvlan_clear_addr_change(struct macvlan_port *port)
93 port->flags &= ~MACVLAN_F_ADDRCHANGE;
120 static struct macvlan_dev *macvlan_hash_lookup(const struct macvlan_port *port,
126 hlist_for_each_entry_rcu(vlan, &port->vlan_hash[idx], hlist,
140 struct hlist_head *h = &vlan->port->vlan_source_hash[idx];
153 struct macvlan_port *port = vlan->port;
167 h = &port->vlan_source_hash[macvlan_eth_hash(addr)];
176 struct macvlan_port *port = vlan->port;
180 hlist_add_head_rcu(&vlan->hlist, &port->vlan_hash[idx]);
207 static bool macvlan_addr_busy(const struct macvlan_port *port,
214 if (!macvlan_passthru(port) && !macvlan_addr_change(port) &&
215 ether_addr_equal_64bits(port->dev->dev_addr, addr))
218 if (macvlan_hash_lookup(port, addr))
259 const struct macvlan_port *port,
274 hlist_for_each_entry_rcu(vlan, &port->vlan_hash[i], hlist) {
297 struct macvlan_port *port = container_of(w, struct macvlan_port,
304 spin_lock_bh(&port->bc_queue.lock);
305 skb_queue_splice_tail_init(&port->bc_queue, &list);
306 spin_unlock_bh(&port->bc_queue.lock);
315 macvlan_broadcast(skb, port, NULL,
322 macvlan_broadcast(skb, port, src->dev,
330 macvlan_broadcast(skb, port, src->dev,
343 static void macvlan_broadcast_enqueue(struct macvlan_port *port,
356 spin_lock(&port->bc_queue.lock);
357 if (skb_queue_len(&port->bc_queue) < MACVLAN_BC_QUEUE_LEN) {
360 __skb_queue_tail(&port->bc_queue, nskb);
363 spin_unlock(&port->bc_queue.lock);
365 schedule_work(&port->bc_work);
378 static void macvlan_flush_sources(struct macvlan_port *port,
386 hlist_for_each_safe(h, n, &port->vlan_source_hash[i]) {
425 struct macvlan_port *port,
430 struct hlist_head *h = &port->vlan_source_hash[idx];
441 struct macvlan_port *port;
455 port = macvlan_port_get_rcu(skb->dev);
464 macvlan_forward_source(skb, port, eth->h_source);
465 src = macvlan_hash_lookup(port, eth->h_source);
468 /* forward to original port. */
477 if (test_bit(hash, port->mc_filter))
478 macvlan_broadcast_enqueue(port, src, skb);
483 macvlan_forward_source(skb, port, eth->h_source);
484 if (macvlan_passthru(port))
485 vlan = list_first_or_null_rcu(&port->vlans,
488 vlan = macvlan_hash_lookup(port, eth->h_dest);
519 const struct macvlan_port *port = vlan->port;
528 macvlan_broadcast(skb, port, dev, MACVLAN_MODE_BRIDGE);
532 dest = macvlan_hash_lookup(port, eth->h_dest);
606 if (macvlan_passthru(vlan->port)) {
616 if (macvlan_addr_busy(vlan->port, dev->dev_addr))
681 if (macvlan_passthru(vlan->port)) {
704 struct macvlan_port *port = vlan->port;
712 if (macvlan_addr_busy(vlan->port, addr))
715 if (!macvlan_passthru(port)) {
725 if (macvlan_passthru(port) && !macvlan_addr_change(port)) {
730 ether_addr_copy(vlan->port->perm_addr,
733 macvlan_clear_addr_change(port);
750 macvlan_set_addr_change(vlan->port);
754 if (macvlan_addr_busy(vlan->port, addr->sa_data))
768 if (!macvlan_passthru(vlan->port) && change & IFF_PROMISC)
818 macvlan_compute_filter(vlan->port->mc_filter, vlan->lowerdev, NULL);
891 struct macvlan_port *port = vlan->port;
910 port->count += 1;
918 struct macvlan_port *port = vlan->port;
922 macvlan_flush_sources(port, vlan);
923 port->count -= 1;
924 if (!port->count)
925 macvlan_port_destroy(port->dev);
999 if (!macvlan_passthru(vlan->port) && is_unicast_ether_addr(addr))
1023 if (!macvlan_passthru(vlan->port) && is_unicast_ether_addr(addr))
1199 struct macvlan_port *port;
1209 port = kzalloc(sizeof(*port), GFP_KERNEL);
1210 if (port == NULL)
1213 port->dev = dev;
1214 ether_addr_copy(port->perm_addr, dev->dev_addr);
1215 INIT_LIST_HEAD(&port->vlans);
1217 INIT_HLIST_HEAD(&port->vlan_hash[i]);
1219 INIT_HLIST_HEAD(&port->vlan_source_hash[i]);
1221 skb_queue_head_init(&port->bc_queue);
1222 INIT_WORK(&port->bc_work, macvlan_process_broadcast);
1224 err = netdev_rx_handler_register(dev, macvlan_handle_frame, port);
1226 kfree(port);
1234 struct macvlan_port *port = macvlan_port_get_rtnl(dev);
1243 cancel_work_sync(&port->bc_work);
1245 while ((skb = __skb_dequeue(&port->bc_queue))) {
1257 if (macvlan_passthru(port) &&
1258 !ether_addr_equal(port->dev->dev_addr, port->perm_addr)) {
1261 sa.sa_family = port->dev->type;
1262 memcpy(&sa.sa_data, port->perm_addr, port->dev->addr_len);
1263 dev_set_mac_address(port->dev, &sa, NULL);
1266 kfree(port);
1375 macvlan_flush_sources(vlan->port, vlan);
1377 macvlan_flush_sources(vlan->port, vlan);
1409 struct macvlan_port *port;
1446 port = macvlan_port_get_rtnl(lowerdev);
1449 if (macvlan_passthru(port)) {
1450 /* The macvlan port must be not created this time,
1459 vlan->port = port;
1470 if (port->count) {
1474 macvlan_set_passthru(port);
1498 list_add_tail_rcu(&vlan->list, &port->vlans);
1505 /* macvlan_uninit would free the macvlan port */
1509 /* the macvlan port may be freed by macvlan_uninit when fail to register.
1510 * so we destroy the macvlan port only when it's valid.
1513 macvlan_flush_sources(port, vlan);
1514 macvlan_port_destroy(port->dev);
1532 macvlan_flush_sources(vlan->port, vlan);
1559 macvlan_flush_sources(vlan->port, vlan);
1565 if (macvlan_passthru(vlan->port) && promisc) {
1614 struct hlist_head *h = &vlan->port->vlan_source_hash[i];
1698 struct macvlan_port *port;
1704 port = macvlan_port_get_rtnl(dev);
1710 list_for_each_entry(vlan, &port->vlans, list)
1715 list_for_each_entry(vlan, &port->vlans, list) {
1722 list_for_each_entry(vlan, &port->vlans, list) {
1729 if (!macvlan_passthru(port))
1732 vlan = list_first_entry_or_null(&port->vlans,
1745 list_for_each_entry_safe(vlan, next, &port->vlans, list)
1757 list_for_each_entry(vlan, &port->vlans, list)