Commit ef40b7ef181b7b1a24df2ef2d1ef84956bffa635

Authored by Toshiaki Makita
Committed by David S. Miller
1 parent 5c751c9344

bridge: Use the correct bit length for bitmap functions in the VLAN code

The VLAN code needs to know the length of the per-port VLAN bitmap to
perform its most basic operations (retrieving VLAN informations, removing
VLANs, forwarding database manipulation, etc). Unfortunately, in the
current implementation we are using a macro that indicates the bitmap
size in longs in places where the size in bits is expected, which in
some cases can cause what appear to be random failures.
Use the correct macro.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 3 changed files with 9 additions and 9 deletions Side-by-side Diff

... ... @@ -161,7 +161,7 @@
161 161 if (!pv)
162 162 return;
163 163  
164   - for_each_set_bit_from(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
  164 + for_each_set_bit_from(vid, pv->vlan_bitmap, VLAN_N_VID) {
165 165 f = __br_fdb_get(br, br->dev->dev_addr, vid);
166 166 if (f && f->is_local && !f->dst)
167 167 fdb_delete(br, f);
... ... @@ -730,7 +730,7 @@
730 730 /* VID was specified, so use it. */
731 731 err = __br_fdb_add(ndm, p, addr, nlh_flags, vid);
732 732 } else {
733   - if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN)) {
  733 + if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID)) {
734 734 err = __br_fdb_add(ndm, p, addr, nlh_flags, 0);
735 735 goto out;
736 736 }
... ... @@ -739,7 +739,7 @@
739 739 * specify a VLAN. To be nice, add/update entry for every
740 740 * vlan on this port.
741 741 */
742   - for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
  742 + for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
743 743 err = __br_fdb_add(ndm, p, addr, nlh_flags, vid);
744 744 if (err)
745 745 goto out;
... ... @@ -817,7 +817,7 @@
817 817  
818 818 err = __br_fdb_delete(p, addr, vid);
819 819 } else {
820   - if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN)) {
  820 + if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID)) {
821 821 err = __br_fdb_delete(p, addr, 0);
822 822 goto out;
823 823 }
... ... @@ -827,7 +827,7 @@
827 827 * vlan on this port.
828 828 */
829 829 err = -ENOENT;
830   - for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
  830 + for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
831 831 err &= __br_fdb_delete(p, addr, vid);
832 832 }
833 833 }
net/bridge/br_netlink.c
... ... @@ -132,7 +132,7 @@
132 132 else
133 133 pv = br_get_vlan_info(br);
134 134  
135   - if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN))
  135 + if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID))
136 136 goto done;
137 137  
138 138 af = nla_nest_start(skb, IFLA_AF_SPEC);
... ... @@ -140,7 +140,7 @@
140 140 goto nla_put_failure;
141 141  
142 142 pvid = br_get_pvid(pv);
143   - for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) {
  143 + for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
144 144 vinfo.vid = vid;
145 145 vinfo.flags = 0;
146 146 if (vid == pvid)
net/bridge/br_vlan.c
... ... @@ -108,7 +108,7 @@
108 108  
109 109 clear_bit(vid, v->vlan_bitmap);
110 110 v->num_vlans--;
111   - if (bitmap_empty(v->vlan_bitmap, BR_VLAN_BITMAP_LEN)) {
  111 + if (bitmap_empty(v->vlan_bitmap, VLAN_N_VID)) {
112 112 if (v->port_idx)
113 113 rcu_assign_pointer(v->parent.port->vlan_info, NULL);
114 114 else
... ... @@ -122,7 +122,7 @@
122 122 {
123 123 smp_wmb();
124 124 v->pvid = 0;
125   - bitmap_zero(v->vlan_bitmap, BR_VLAN_BITMAP_LEN);
  125 + bitmap_zero(v->vlan_bitmap, VLAN_N_VID);
126 126 if (v->port_idx)
127 127 rcu_assign_pointer(v->parent.port->vlan_info, NULL);
128 128 else