net: dsa: b53: Bound check ARL searches
authorFlorian Fainelli <f.fainelli@gmail.com>
Thu, 30 Apr 2020 18:49:10 +0000 (11:49 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 May 2020 00:43:29 +0000 (17:43 -0700)
ARL searches are done by reading two ARL entries at a time, do not cap
the search at 1024 which would only limit us to half of the possible ARL
capacity, but use b53_max_arl_entries() instead which does the right
multiplication between bins and indexes.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/b53/b53_common.c
drivers/net/dsa/b53/b53_priv.h

index aa0836ac751ccac58410fff37155b83b21cd3e2c..9550d972f8c569ab46192bd20c7b91a9c5b2b8e0 100644 (file)
@@ -1702,7 +1702,7 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
                                break;
                }
 
-       } while (count++ < 1024);
+       } while (count++ < b53_max_arl_entries(priv) / 2);
 
        return 0;
 }
index 694e26cdfd4dcd020a90fa4ad835ff4085c6187b..e942c60e4365cfa414f2707b1f5a6d5b69fd7464 100644 (file)
@@ -213,6 +213,11 @@ static inline int is58xx(struct b53_device *dev)
 #define B53_CPU_PORT_25        5
 #define B53_CPU_PORT   8
 
+static inline unsigned int b53_max_arl_entries(struct b53_device *dev)
+{
+       return dev->num_arl_buckets * dev->num_arl_bins;
+}
+
 struct b53_device *b53_switch_alloc(struct device *base,
                                    const struct b53_io_ops *ops,
                                    void *priv);