Lines Matching +full:master +full:- +full:stats
1 // SPDX-License-Identifier: GPL-2.0-only
17 u16 vid = *(u16 *)arg->key; in br_vlan_cmp()
19 return vle->vid != vid; in br_vlan_cmp()
40 if (vg->pvid == v->vid) in __vlan_add_pvid()
44 br_vlan_set_pvid_state(vg, v->state); in __vlan_add_pvid()
45 vg->pvid = v->vid; in __vlan_add_pvid()
50 if (vg->pvid != vid) in __vlan_delete_pvid()
54 vg->pvid = 0; in __vlan_delete_pvid()
68 vg = br_vlan_group(v->br); in __vlan_flags_update()
70 vg = nbp_vlan_group(v->port); in __vlan_flags_update()
73 change = !!(flags & BRIDGE_VLAN_INFO_PVID) == !!(vg->pvid != v->vid) || in __vlan_flags_update()
74 ((flags ^ v->flags) & BRIDGE_VLAN_INFO_UNTAGGED); in __vlan_flags_update()
82 __vlan_delete_pvid(vg, v->vid); in __vlan_flags_update()
85 v->flags |= BRIDGE_VLAN_INFO_UNTAGGED; in __vlan_flags_update()
87 v->flags &= ~BRIDGE_VLAN_INFO_UNTAGGED; in __vlan_flags_update()
112 err = br_switchdev_port_vlan_add(dev, v->vid, flags, false, extack); in __vlan_vid_add()
113 if (err == -EOPNOTSUPP) in __vlan_vid_add()
114 return vlan_vid_add(dev, br->vlan_proto, v->vid); in __vlan_vid_add()
115 v->priv_flags |= BR_VLFLAG_ADDED_BY_SWITCHDEV; in __vlan_vid_add()
126 vg = br_vlan_group(v->br); in __vlan_add_list()
128 vg = nbp_vlan_group(v->port); in __vlan_add_list()
130 headp = &vg->vlan_list; in __vlan_add_list()
133 if (v->vid >= vent->vid) in __vlan_add_list()
136 list_add_rcu(&v->vlist, hpos); in __vlan_add_list()
141 list_del_rcu(&v->vlist); in __vlan_del_list()
152 err = br_switchdev_port_vlan_del(dev, v->vid); in __vlan_vid_del()
153 if (!(v->priv_flags & BR_VLFLAG_ADDED_BY_SWITCHDEV)) in __vlan_vid_del()
154 vlan_vid_del(dev, br->vlan_proto, v->vid); in __vlan_vid_del()
155 return err == -EOPNOTSUPP ? 0 : err; in __vlan_vid_del()
158 /* Returns a master vlan, if it didn't exist it gets created. In all cases
159 * a reference is taken to the master vlan before returning.
179 refcount_set(&masterv->refcnt, 1); in br_vlan_get_master()
182 refcount_inc(&masterv->refcnt); in br_vlan_get_master()
193 free_percpu(v->stats); in br_master_vlan_rcu_free()
194 v->stats = NULL; in br_master_vlan_rcu_free()
205 vg = br_vlan_group(masterv->br); in br_vlan_put_master()
206 if (refcount_dec_and_test(&masterv->refcnt)) { in br_vlan_put_master()
207 rhashtable_remove_fast(&vg->vlan_hash, in br_vlan_put_master()
208 &masterv->vnode, br_vlan_rht_params); in br_vlan_put_master()
211 br_multicast_ctx_deinit(&masterv->br_mcast_ctx); in br_vlan_put_master()
212 call_rcu(&masterv->rcu, br_master_vlan_rcu_free); in br_vlan_put_master()
222 /* if we had per-port stats configured then free them here */ in nbp_vlan_rcu_free()
223 if (v->priv_flags & BR_VLFLAG_PER_PORT_STATS) in nbp_vlan_rcu_free()
224 free_percpu(v->stats); in nbp_vlan_rcu_free()
225 v->stats = NULL; in nbp_vlan_rcu_free()
234 br = v->br; in br_vlan_init_state()
236 br = v->port->br; in br_vlan_init_state()
243 v->state = BR_STATE_FORWARDING; in br_vlan_init_state()
244 v->msti = 0; in br_vlan_init_state()
250 * 1. vlan is being added on a port (no master flags, global entry exists)
251 * 2. vlan is being added on a bridge (both master and brentry flags)
253 * is being created right now (master flag set, brentry flag unset), the
254 * global entry is used for global per-vlan features, but not for filtering
255 * 4. same as 3 but with both master and brentry flags set so the entry
269 br = v->br; in __vlan_add()
270 dev = br->dev; in __vlan_add()
273 p = v->port; in __vlan_add()
274 br = p->br; in __vlan_add()
275 dev = p->dev; in __vlan_add()
288 /* need to work on the master vlan too */ in __vlan_add()
292 err = br_vlan_add(br, v->vid, in __vlan_add()
299 br_vlan_notify(br, NULL, v->vid, 0, in __vlan_add()
303 masterv = br_vlan_get_master(br, v->vid, extack); in __vlan_add()
305 err = -ENOMEM; in __vlan_add()
308 v->brvlan = masterv; in __vlan_add()
310 v->stats = in __vlan_add()
312 if (!v->stats) { in __vlan_add()
313 err = -ENOMEM; in __vlan_add()
316 v->priv_flags |= BR_VLFLAG_PER_PORT_STATS; in __vlan_add()
318 v->stats = masterv->stats; in __vlan_add()
320 br_multicast_port_ctx_init(p, v, &v->port_mcast_ctx); in __vlan_add()
323 err = br_switchdev_port_vlan_add(dev, v->vid, flags, in __vlan_add()
325 if (err && err != -EOPNOTSUPP) in __vlan_add()
328 br_multicast_ctx_init(br, v, &v->br_mcast_ctx); in __vlan_add()
329 v->priv_flags |= BR_VLFLAG_GLOBAL_MCAST_ENABLED; in __vlan_add()
334 err = br_fdb_add_local(br, p, dev->dev_addr, v->vid); in __vlan_add()
339 vg->num_vlans++; in __vlan_add()
345 err = rhashtable_lookup_insert_fast(&vg->vlan_hash, &v->vnode, in __vlan_add()
355 nbp_vlan_set_vlan_dev_state(p, v->vid); in __vlan_add()
361 br_fdb_find_delete_local(br, p, dev->dev_addr, v->vid); in __vlan_add()
362 vg->num_vlans--; in __vlan_add()
369 if (v->stats && masterv->stats != v->stats) in __vlan_add()
370 free_percpu(v->stats); in __vlan_add()
371 v->stats = NULL; in __vlan_add()
374 v->brvlan = NULL; in __vlan_add()
377 br_switchdev_port_vlan_del(dev, v->vid); in __vlan_add()
391 vg = br_vlan_group(v->br); in __vlan_del()
393 p = v->port; in __vlan_del()
394 vg = nbp_vlan_group(v->port); in __vlan_del()
395 masterv = v->brvlan; in __vlan_del()
398 __vlan_delete_pvid(vg, v->vid); in __vlan_del()
400 err = __vlan_vid_del(p->dev, p->br, v); in __vlan_del()
404 err = br_switchdev_port_vlan_del(v->br->dev, v->vid); in __vlan_del()
405 if (err && err != -EOPNOTSUPP) in __vlan_del()
411 v->flags &= ~BRIDGE_VLAN_INFO_BRENTRY; in __vlan_del()
412 vg->num_vlans--; in __vlan_del()
417 rhashtable_remove_fast(&vg->vlan_hash, &v->vnode, in __vlan_del()
420 nbp_vlan_set_vlan_dev_state(p, v->vid); in __vlan_del()
422 br_multicast_port_ctx_deinit(&v->port_mcast_ctx); in __vlan_del()
423 call_rcu(&v->rcu, nbp_vlan_rcu_free); in __vlan_del()
433 WARN_ON(!list_empty(&vg->vlan_list)); in __vlan_group_free()
434 rhashtable_destroy(&vg->vlan_hash); in __vlan_group_free()
447 __vlan_delete_pvid(vg, vg->pvid); in __vlan_flush()
448 list_for_each_entry_safe(vlan, tmp, &vg->vlan_list, vlist) { in __vlan_flush()
451 v_start = vlan->vid; in __vlan_flush()
452 } else if (vlan->vid - v_end != 1) { in __vlan_flush()
455 v_start = vlan->vid; in __vlan_flush()
457 v_end = vlan->vid; in __vlan_flush()
463 (unsigned int) p->port_no, p->dev->name, in __vlan_flush()
464 vlan->vid, ERR_PTR(err)); in __vlan_flush()
478 struct pcpu_sw_netstats *stats; in br_handle_vlan() local
483 if (!BR_INPUT_SKB_CB(skb)->vlan_filtered) in br_handle_vlan()
498 if ((br->dev->flags & IFF_PROMISC) && skb->dev == br->dev) { in br_handle_vlan()
506 stats = this_cpu_ptr(v->stats); in br_handle_vlan()
507 u64_stats_update_begin(&stats->syncp); in br_handle_vlan()
508 u64_stats_add(&stats->tx_bytes, skb->len); in br_handle_vlan()
509 u64_stats_inc(&stats->tx_packets); in br_handle_vlan()
510 u64_stats_update_end(&stats->syncp); in br_handle_vlan()
520 if (v->flags & BRIDGE_VLAN_INFO_UNTAGGED && in br_handle_vlan()
524 if (p && (p->flags & BR_VLAN_TUNNEL) && in br_handle_vlan()
540 struct pcpu_sw_netstats *stats; in __allowed_ingress() local
544 BR_INPUT_SKB_CB(skb)->vlan_filtered = true; in __allowed_ingress()
550 skb->protocol == br->vlan_proto)) { in __allowed_ingress()
558 if (skb->vlan_proto != br->vlan_proto) { in __allowed_ingress()
559 /* Protocol-mismatch, empty out vlan_tci for new tag */ in __allowed_ingress()
561 skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto, in __allowed_ingress()
583 * vlan untagged or priority-tagged traffic belongs to. in __allowed_ingress()
588 /* PVID is set on this port. Any untagged or priority-tagged in __allowed_ingress()
594 __vlan_hwaccel_put_tag(skb, br->vlan_proto, pvid); in __allowed_ingress()
596 /* Priority-tagged Frame. in __allowed_ingress()
597 * At this point, we know that skb->vlan_tci VID in __allowed_ingress()
601 skb->vlan_tci |= pvid; in __allowed_ingress()
603 /* if snooping and stats are disabled we can avoid the lookup */ in __allowed_ingress()
625 stats = this_cpu_ptr(v->stats); in __allowed_ingress()
626 u64_stats_update_begin(&stats->syncp); in __allowed_ingress()
627 u64_stats_add(&stats->rx_bytes, skb->len); in __allowed_ingress()
628 u64_stats_inc(&stats->rx_packets); in __allowed_ingress()
629 u64_stats_update_end(&stats->syncp); in __allowed_ingress()
651 BR_INPUT_SKB_CB(skb)->vlan_filtered = false; in br_allowed_ingress()
666 if (!BR_INPUT_SKB_CB(skb)->vlan_filtered) in br_allowed_egress()
682 struct net_bridge *br = p->br; in br_should_learn()
690 if (!vg || !vg->num_vlans) in br_should_learn()
693 if (!br_vlan_get_tag(skb, vid) && skb->vlan_proto != br->vlan_proto) in br_should_learn()
723 /* Trying to change flags of non-existent bridge vlan */ in br_vlan_add_existing()
725 return -EINVAL; in br_vlan_add_existing()
730 /* Master VLANs that aren't brentries weren't notified before, in br_vlan_add_existing()
734 err = br_switchdev_port_vlan_add(br->dev, vlan->vid, flags, in br_vlan_add_existing()
736 if (err && err != -EOPNOTSUPP) in br_vlan_add_existing()
742 err = br_fdb_add_local(br, NULL, br->dev->dev_addr, vlan->vid); in br_vlan_add_existing()
748 refcount_inc(&vlan->refcnt); in br_vlan_add_existing()
749 vlan->flags |= BRIDGE_VLAN_INFO_BRENTRY; in br_vlan_add_existing()
750 vg->num_vlans++; in br_vlan_add_existing()
762 br_switchdev_port_vlan_del(br->dev, vlan->vid); in br_vlan_add_existing()
788 return -ENOMEM; in br_vlan_add()
790 vlan->stats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); in br_vlan_add()
791 if (!vlan->stats) { in br_vlan_add()
793 return -ENOMEM; in br_vlan_add()
795 vlan->vid = vid; in br_vlan_add()
796 vlan->flags = flags | BRIDGE_VLAN_INFO_MASTER; in br_vlan_add()
797 vlan->flags &= ~BRIDGE_VLAN_INFO_PVID; in br_vlan_add()
798 vlan->br = br; in br_vlan_add()
800 refcount_set(&vlan->refcnt, 1); in br_vlan_add()
803 free_percpu(vlan->stats); in br_vlan_add()
825 return -ENOENT; in br_vlan_delete()
827 br_fdb_find_delete_local(br, NULL, br->dev->dev_addr, vid); in br_vlan_delete()
843 RCU_INIT_POINTER(br->vlgrp, NULL); in br_vlan_flush()
853 return br_vlan_lookup(&vg->vlan_hash, vid); in br_vlan_find()
862 spin_lock_bh(&br->lock); in recalculate_group_addr()
864 br->vlan_proto == htons(ETH_P_8021Q)) { in recalculate_group_addr()
866 br->group_addr[5] = 0x00; in recalculate_group_addr()
869 br->group_addr[5] = 0x08; in recalculate_group_addr()
871 spin_unlock_bh(&br->lock); in recalculate_group_addr()
878 br->vlan_proto == htons(ETH_P_8021Q)) in br_recalculate_fwd_mask()
879 br->group_fwd_mask_required = BR_GROUPFWD_DEFAULT; in br_recalculate_fwd_mask()
881 br->group_fwd_mask_required = BR_GROUPFWD_8021AD & in br_recalculate_fwd_mask()
882 ~(1u << br->group_addr[5]); in br_recalculate_fwd_mask()
889 .orig_dev = br->dev, in br_vlan_filter_toggle()
901 err = switchdev_port_attr_set(br->dev, &attr, extack); in br_vlan_filter_toggle()
902 if (err && err != -EOPNOTSUPP) { in br_vlan_filter_toggle()
930 *p_proto = ntohs(br->vlan_proto); in br_vlan_get_proto()
940 .orig_dev = br->dev, in __br_vlan_set_proto()
949 __be16 oldproto = br->vlan_proto; in __br_vlan_set_proto()
951 if (br->vlan_proto == proto) in __br_vlan_set_proto()
954 err = switchdev_port_attr_set(br->dev, &attr, extack); in __br_vlan_set_proto()
955 if (err && err != -EOPNOTSUPP) in __br_vlan_set_proto()
959 list_for_each_entry(p, &br->port_list, list) { in __br_vlan_set_proto()
961 list_for_each_entry(vlan, &vg->vlan_list, vlist) { in __br_vlan_set_proto()
962 if (vlan->priv_flags & BR_VLFLAG_ADDED_BY_SWITCHDEV) in __br_vlan_set_proto()
964 err = vlan_vid_add(p->dev, proto, vlan->vid); in __br_vlan_set_proto()
970 br->vlan_proto = proto; in __br_vlan_set_proto()
976 list_for_each_entry(p, &br->port_list, list) { in __br_vlan_set_proto()
978 list_for_each_entry(vlan, &vg->vlan_list, vlist) { in __br_vlan_set_proto()
979 if (vlan->priv_flags & BR_VLFLAG_ADDED_BY_SWITCHDEV) in __br_vlan_set_proto()
981 vlan_vid_del(p->dev, oldproto, vlan->vid); in __br_vlan_set_proto()
989 switchdev_port_attr_set(br->dev, &attr, NULL); in __br_vlan_set_proto()
991 list_for_each_entry_continue_reverse(vlan, &vg->vlan_list, vlist) { in __br_vlan_set_proto()
992 if (vlan->priv_flags & BR_VLFLAG_ADDED_BY_SWITCHDEV) in __br_vlan_set_proto()
994 vlan_vid_del(p->dev, proto, vlan->vid); in __br_vlan_set_proto()
997 list_for_each_entry_continue_reverse(p, &br->port_list, list) { in __br_vlan_set_proto()
999 list_for_each_entry(vlan, &vg->vlan_list, vlist) { in __br_vlan_set_proto()
1000 if (vlan->priv_flags & BR_VLFLAG_ADDED_BY_SWITCHDEV) in __br_vlan_set_proto()
1002 vlan_vid_del(p->dev, proto, vlan->vid); in __br_vlan_set_proto()
1013 return -EPROTONOSUPPORT; in br_vlan_set_proto()
1026 return -EINVAL; in br_vlan_set_stats()
1037 list_for_each_entry(p, &br->port_list, list) { in br_vlan_set_stats_per_port()
1040 if (vg->num_vlans) in br_vlan_set_stats_per_port()
1041 return -EBUSY; in br_vlan_set_stats_per_port()
1050 return -EINVAL; in br_vlan_set_stats_per_port()
1060 if (vid != vg->pvid) in vlan_default_pvid()
1063 v = br_vlan_lookup(&vg->vlan_hash, vid); in vlan_default_pvid()
1065 (v->flags & BRIDGE_VLAN_INFO_UNTAGGED)) in vlan_default_pvid()
1074 u16 pvid = br->default_pvid; in br_vlan_disable_default_pvid()
1084 list_for_each_entry(p, &br->port_list, list) { in br_vlan_disable_default_pvid()
1090 br->default_pvid = 0; in br_vlan_disable_default_pvid()
1111 return -ENOMEM; in __br_vlan_set_default_pvid()
1113 old_pvid = br->default_pvid; in __br_vlan_set_default_pvid()
1136 list_for_each_entry(p, &br->port_list, list) { in __br_vlan_set_default_pvid()
1154 br_vlan_notify(p->br, p, pvid, 0, RTM_NEWVLAN); in __br_vlan_set_default_pvid()
1155 __set_bit(p->port_no, changed); in __br_vlan_set_default_pvid()
1158 br->default_pvid = pvid; in __br_vlan_set_default_pvid()
1165 list_for_each_entry_continue_reverse(p, &br->port_list, list) { in __br_vlan_set_default_pvid()
1166 if (!test_bit(p->port_no, changed)) in __br_vlan_set_default_pvid()
1174 br_vlan_notify(p->br, p, old_pvid, 0, RTM_NEWVLAN); in __br_vlan_set_default_pvid()
1202 return -EINVAL; in br_vlan_set_default_pvid()
1204 if (pvid == br->default_pvid) in br_vlan_set_default_pvid()
1210 err = -EPERM; in br_vlan_set_default_pvid()
1221 int ret = -ENOMEM; in br_vlan_init()
1226 ret = rhashtable_init(&vg->vlan_hash, &br_vlan_rht_params); in br_vlan_init()
1232 INIT_LIST_HEAD(&vg->vlan_list); in br_vlan_init()
1233 br->vlan_proto = htons(ETH_P_8021Q); in br_vlan_init()
1234 br->default_pvid = 1; in br_vlan_init()
1235 rcu_assign_pointer(br->vlgrp, vg); in br_vlan_init()
1241 rhashtable_destroy(&vg->vlan_hash); in br_vlan_init()
1251 .orig_dev = p->br->dev, in nbp_vlan_init()
1254 .u.vlan_filtering = br_opt_get(p->br, BROPT_VLAN_ENABLED), in nbp_vlan_init()
1257 int ret = -ENOMEM; in nbp_vlan_init()
1263 ret = switchdev_port_attr_set(p->dev, &attr, extack); in nbp_vlan_init()
1264 if (ret && ret != -EOPNOTSUPP) in nbp_vlan_init()
1267 ret = rhashtable_init(&vg->vlan_hash, &br_vlan_rht_params); in nbp_vlan_init()
1273 INIT_LIST_HEAD(&vg->vlan_list); in nbp_vlan_init()
1274 rcu_assign_pointer(p->vlgrp, vg); in nbp_vlan_init()
1275 if (p->br->default_pvid) { in nbp_vlan_init()
1278 ret = nbp_vlan_add(p, p->br->default_pvid, in nbp_vlan_init()
1284 br_vlan_notify(p->br, p, p->br->default_pvid, 0, RTM_NEWVLAN); in nbp_vlan_init()
1290 RCU_INIT_POINTER(p->vlgrp, NULL); in nbp_vlan_init()
1294 rhashtable_destroy(&vg->vlan_hash); in nbp_vlan_init()
1321 ret = br_switchdev_port_vlan_add(port->dev, vid, flags, in nbp_vlan_add()
1323 if (ret && ret != -EOPNOTSUPP) in nbp_vlan_add()
1335 return -ENOMEM; in nbp_vlan_add()
1337 vlan->vid = vid; in nbp_vlan_add()
1338 vlan->port = port; in nbp_vlan_add()
1359 return -ENOENT; in nbp_vlan_delete()
1360 br_fdb_find_delete_local(port->br, port, port->dev->dev_addr, vid); in nbp_vlan_delete()
1361 br_fdb_delete_by_port(port->br, port, vid, 0); in nbp_vlan_delete()
1373 __vlan_flush(port->br, port, vg); in nbp_vlan_flush()
1374 RCU_INIT_POINTER(port->vlgrp, NULL); in nbp_vlan_flush()
1380 struct pcpu_sw_netstats *stats) in br_vlan_get_stats() argument
1384 memset(stats, 0, sizeof(*stats)); in br_vlan_get_stats()
1390 cpu_stats = per_cpu_ptr(v->stats, i); in br_vlan_get_stats()
1392 start = u64_stats_fetch_begin(&cpu_stats->syncp); in br_vlan_get_stats()
1393 rxpackets = u64_stats_read(&cpu_stats->rx_packets); in br_vlan_get_stats()
1394 rxbytes = u64_stats_read(&cpu_stats->rx_bytes); in br_vlan_get_stats()
1395 txbytes = u64_stats_read(&cpu_stats->tx_bytes); in br_vlan_get_stats()
1396 txpackets = u64_stats_read(&cpu_stats->tx_packets); in br_vlan_get_stats()
1397 } while (u64_stats_fetch_retry(&cpu_stats->syncp, start)); in br_vlan_get_stats()
1399 u64_stats_add(&stats->rx_packets, rxpackets); in br_vlan_get_stats()
1400 u64_stats_add(&stats->rx_bytes, rxbytes); in br_vlan_get_stats()
1401 u64_stats_add(&stats->tx_bytes, txbytes); in br_vlan_get_stats()
1402 u64_stats_add(&stats->tx_packets, txpackets); in br_vlan_get_stats()
1418 return -EINVAL; in br_vlan_get_pvid()
1436 return -EINVAL; in br_vlan_get_pvid_rcu()
1448 int idx = ctx->num_vlans - 1; in br_vlan_fill_forward_path_pvid()
1451 path->bridge.vlan_mode = DEV_PATH_BR_VLAN_KEEP; in br_vlan_fill_forward_path_pvid()
1459 ctx->vlan[idx].proto == br->vlan_proto) { in br_vlan_fill_forward_path_pvid()
1460 vid = ctx->vlan[idx].id; in br_vlan_fill_forward_path_pvid()
1462 path->bridge.vlan_mode = DEV_PATH_BR_VLAN_TAG; in br_vlan_fill_forward_path_pvid()
1466 path->bridge.vlan_id = vid; in br_vlan_fill_forward_path_pvid()
1467 path->bridge.vlan_proto = br->vlan_proto; in br_vlan_fill_forward_path_pvid()
1481 v = br_vlan_find(vg, path->bridge.vlan_id); in br_vlan_fill_forward_path_mode()
1483 return -EINVAL; in br_vlan_fill_forward_path_mode()
1485 if (!(v->flags & BRIDGE_VLAN_INFO_UNTAGGED)) in br_vlan_fill_forward_path_mode()
1488 if (path->bridge.vlan_mode == DEV_PATH_BR_VLAN_TAG) in br_vlan_fill_forward_path_mode()
1489 path->bridge.vlan_mode = DEV_PATH_BR_VLAN_KEEP; in br_vlan_fill_forward_path_mode()
1490 else if (v->priv_flags & BR_VLFLAG_ADDED_BY_SWITCHDEV) in br_vlan_fill_forward_path_mode()
1491 path->bridge.vlan_mode = DEV_PATH_BR_VLAN_UNTAG_HW; in br_vlan_fill_forward_path_mode()
1493 path->bridge.vlan_mode = DEV_PATH_BR_VLAN_UNTAG; in br_vlan_fill_forward_path_mode()
1512 return -EINVAL; in br_vlan_get_info()
1516 return -ENOENT; in br_vlan_get_info()
1518 p_vinfo->vid = vid; in br_vlan_get_info()
1519 p_vinfo->flags = v->flags; in br_vlan_get_info()
1521 p_vinfo->flags |= BRIDGE_VLAN_INFO_PVID; in br_vlan_get_info()
1539 return -EINVAL; in br_vlan_get_info_rcu()
1543 return -ENOENT; in br_vlan_get_info_rcu()
1545 p_vinfo->vid = vid; in br_vlan_get_info_rcu()
1546 p_vinfo->flags = v->flags; in br_vlan_get_info_rcu()
1548 p_vinfo->flags |= BRIDGE_VLAN_INFO_PVID; in br_vlan_get_info_rcu()
1556 !!(vlan_dev_priv(dev)->flags & VLAN_FLAG_BRIDGE_BINDING); in br_vlan_is_bind_vlan_dev()
1585 struct br_vlan_bind_walk_data *data = priv->data; in br_vlan_match_bind_vlan_dev_fn()
1589 vlan_dev_priv(dev)->vlan_id == data->vid) { in br_vlan_match_bind_vlan_dev_fn()
1590 data->result = dev; in br_vlan_match_bind_vlan_dev_fn()
1617 return !!(dev->flags & IFF_UP) && netif_oper_up(dev); in br_vlan_is_dev_up()
1623 u16 vid = vlan_dev_priv(vlan_dev)->vlan_id; in br_vlan_set_vlan_dev_state()
1628 if (!netif_carrier_ok(br->dev)) { in br_vlan_set_vlan_dev_state()
1633 list_for_each_entry(p, &br->port_list, list) { in br_vlan_set_vlan_dev_state()
1635 if (br_vlan_find(vg, vid) && br_vlan_is_dev_up(p->dev)) { in br_vlan_set_vlan_dev_state()
1653 list_for_each_entry(vlan, &vg->vlan_list, vlist) { in br_vlan_set_all_vlan_dev_state()
1654 vlan_dev = br_vlan_get_upper_bind_vlan_dev(p->br->dev, in br_vlan_set_all_vlan_dev_state()
1655 vlan->vid); in br_vlan_set_all_vlan_dev_state()
1657 if (br_vlan_is_dev_up(p->dev)) { in br_vlan_set_all_vlan_dev_state()
1658 if (netif_carrier_ok(p->br->dev)) in br_vlan_set_all_vlan_dev_state()
1661 br_vlan_set_vlan_dev_state(p->br, vlan_dev); in br_vlan_set_all_vlan_dev_state()
1692 struct br_vlan_link_state_walk_data *data = priv->data; in br_vlan_link_state_change_fn()
1695 br_vlan_set_vlan_dev_state(data->br, vlan_dev); in br_vlan_link_state_change_fn()
1721 if (!br_opt_get(p->br, BROPT_VLAN_BRIDGE_BINDING)) in nbp_vlan_set_vlan_dev_state()
1724 vlan_dev = br_vlan_get_upper_bind_vlan_dev(p->br->dev, vid); in nbp_vlan_set_vlan_dev_state()
1726 br_vlan_set_vlan_dev_state(p->br, vlan_dev); in nbp_vlan_set_vlan_dev_state()
1739 ret = br_vlan_add(br, br->default_pvid, in br_vlan_bridge_event()
1746 changed = !br_vlan_delete(br, br->default_pvid); in br_vlan_bridge_event()
1751 br_vlan_upper_change(dev, info->upper_dev, info->linking); in br_vlan_bridge_event()
1762 br_vlan_notify(br, NULL, br->default_pvid, 0, vlcmd); in br_vlan_bridge_event()
1770 if (!br_opt_get(p->br, BROPT_VLAN_BRIDGE_BINDING)) in br_vlan_port_event()
1785 struct pcpu_sw_netstats stats; in br_vlan_stats_fill() local
1792 br_vlan_get_stats(v, &stats); in br_vlan_stats_fill()
1794 u64_stats_read(&stats.rx_bytes), in br_vlan_stats_fill()
1797 u64_stats_read(&stats.rx_packets), in br_vlan_stats_fill()
1800 u64_stats_read(&stats.tx_bytes), in br_vlan_stats_fill()
1803 u64_stats_read(&stats.tx_packets), in br_vlan_stats_fill()
1881 int err = -ENOBUFS; in br_vlan_notify()
1890 ifindex = p->dev->ifindex; in br_vlan_notify()
1892 net = dev_net(p->dev); in br_vlan_notify()
1894 ifindex = br->dev->ifindex; in br_vlan_notify()
1896 net = dev_net(br->dev); in br_vlan_notify()
1903 err = -EMSGSIZE; in br_vlan_notify()
1909 bvm->family = AF_BRIDGE; in br_vlan_notify()
1910 bvm->ifindex = ifindex; in br_vlan_notify()
1919 flags = v->flags; in br_vlan_notify()
1920 if (br_get_pvid(vg) == v->vid) in br_vlan_notify()
1946 return v_curr->vid - range_end->vid == 1 && in br_vlan_can_enter_range()
1947 range_end->flags == v_curr->flags && in br_vlan_can_enter_range()
1960 int idx = 0, s_idx = cb->args[1]; in br_vlan_dump_dev()
1969 return -EINVAL; in br_vlan_dump_dev()
1982 return -EINVAL; in br_vlan_dump_dev()
1984 br = p->br; in br_vlan_dump_dev()
1990 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, in br_vlan_dump_dev()
1993 return -EMSGSIZE; in br_vlan_dump_dev()
1996 bvm->family = PF_BRIDGE; in br_vlan_dump_dev()
1997 bvm->ifindex = dev->ifindex; in br_vlan_dump_dev()
2001 list_for_each_entry_rcu(v, &vg->vlan_list, vlist) { in br_vlan_dump_dev()
2018 if (!br_vlan_global_opts_fill(skb, range_start->vid, in br_vlan_dump_dev()
2019 range_end->vid, in br_vlan_dump_dev()
2021 err = -EMSGSIZE; in br_vlan_dump_dev()
2025 idx += range_end->vid - range_start->vid + 1; in br_vlan_dump_dev()
2028 } else if (dump_stats || v->vid == pvid || in br_vlan_dump_dev()
2032 if (!br_vlan_fill_vids(skb, range_start->vid, in br_vlan_dump_dev()
2033 range_end->vid, range_start, in br_vlan_dump_dev()
2035 err = -EMSGSIZE; in br_vlan_dump_dev()
2039 idx += range_end->vid - range_start->vid + 1; in br_vlan_dump_dev()
2048 * - first vlan (range_start == range_end) in br_vlan_dump_dev()
2049 * - last vlan (range_start == range_end, not in range) in br_vlan_dump_dev()
2050 * - last vlan range (range_start != range_end, in range) in br_vlan_dump_dev()
2054 !br_vlan_global_opts_fill(skb, range_start->vid, in br_vlan_dump_dev()
2055 range_end->vid, range_start)) in br_vlan_dump_dev()
2056 err = -EMSGSIZE; in br_vlan_dump_dev()
2058 !br_vlan_fill_vids(skb, range_start->vid, in br_vlan_dump_dev()
2059 range_end->vid, range_start, in br_vlan_dump_dev()
2062 err = -EMSGSIZE; in br_vlan_dump_dev()
2065 cb->args[1] = err ? idx : 0; in br_vlan_dump_dev()
2079 int idx = 0, err = 0, s_idx = cb->args[0]; in br_vlan_rtm_dump()
2080 struct net *net = sock_net(skb->sk); in br_vlan_rtm_dump()
2085 err = nlmsg_parse(cb->nlh, sizeof(*bvm), dtb, BRIDGE_VLANDB_DUMP_MAX, in br_vlan_rtm_dump()
2086 br_vlan_db_dump_pol, cb->extack); in br_vlan_rtm_dump()
2090 bvm = nlmsg_data(cb->nlh); in br_vlan_rtm_dump()
2095 if (bvm->ifindex) { in br_vlan_rtm_dump()
2096 dev = dev_get_by_index_rcu(net, bvm->ifindex); in br_vlan_rtm_dump()
2098 err = -ENODEV; in br_vlan_rtm_dump()
2103 if (err != -EMSGSIZE) in br_vlan_rtm_dump()
2111 if (err == -EMSGSIZE) in br_vlan_rtm_dump()
2117 cb->args[0] = idx; in br_vlan_rtm_dump()
2120 return skb->len; in br_vlan_rtm_dump()
2158 return -ENODEV; in br_vlan_rtm_process_one()
2159 br = p->br; in br_vlan_rtm_process_one()
2164 return -ENODEV; in br_vlan_rtm_process_one()
2173 return -EINVAL; in br_vlan_rtm_process_one()
2178 if (vinfo->flags & (BRIDGE_VLAN_INFO_RANGE_BEGIN | in br_vlan_rtm_process_one()
2180 NL_SET_ERR_MSG_MOD(extack, "Old-style vlan ranges are not allowed when using RTM vlan calls"); in br_vlan_rtm_process_one()
2181 return -EINVAL; in br_vlan_rtm_process_one()
2183 if (!br_vlan_valid_id(vinfo->vid, extack)) in br_vlan_rtm_process_one()
2184 return -EINVAL; in br_vlan_rtm_process_one()
2188 /* validate user-provided flags without RANGE_BEGIN */ in br_vlan_rtm_process_one()
2189 vrange_end.flags = BRIDGE_VLAN_INFO_RANGE_END | vinfo->flags; in br_vlan_rtm_process_one()
2190 vinfo->flags |= BRIDGE_VLAN_INFO_RANGE_BEGIN; in br_vlan_rtm_process_one()
2196 if (!br_vlan_valid_id(vinfo->vid, extack) || in br_vlan_rtm_process_one()
2198 return -EINVAL; in br_vlan_rtm_process_one()
2204 skip_processing = !!(vinfo->flags & BRIDGE_VLAN_INFO_ONLY_OPTS); in br_vlan_rtm_process_one()
2231 range_start = br_vlan_find(vg, vinfo_last->vid); in br_vlan_rtm_process_one()
2232 range_end = br_vlan_find(vg, vinfo->vid); in br_vlan_rtm_process_one()
2234 range_start = br_vlan_find(vg, vinfo->vid); in br_vlan_rtm_process_one()
2248 struct net *net = sock_net(skb->sk); in br_vlan_rtm_process()
2262 dev = __dev_get_by_index(net, bvm->ifindex); in br_vlan_rtm_process()
2264 return -ENODEV; in br_vlan_rtm_process()
2268 return -EINVAL; in br_vlan_rtm_process()
2275 nlh->nlmsg_type, in br_vlan_rtm_process()
2280 nlh->nlmsg_type, in br_vlan_rtm_process()
2293 err = -EINVAL; in br_vlan_rtm_process()