lkml.org 
[lkml]   [2021]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 33/62] net: dsa: sja1105: fix broken backpressure in .port_fdb_dump
    Date
    From: Vladimir Oltean <vladimir.oltean@nxp.com>

    [ Upstream commit 21b52fed928e96d2f75d2f6aa9eac7a4b0b55d22 ]

    rtnl_fdb_dump() has logic to split a dump of PF_BRIDGE neighbors into
    multiple netlink skbs if the buffer provided by user space is too small
    (one buffer will typically handle a few hundred FDB entries).

    When the current buffer becomes full, nlmsg_put() in
    dsa_slave_port_fdb_do_dump() returns -EMSGSIZE and DSA saves the index
    of the last dumped FDB entry, returns to rtnl_fdb_dump() up to that
    point, and then the dump resumes on the same port with a new skb, and
    FDB entries up to the saved index are simply skipped.

    Since dsa_slave_port_fdb_do_dump() is pointed to by the "cb" passed to
    drivers, then drivers must check for the -EMSGSIZE error code returned
    by it. Otherwise, when a netlink skb becomes full, DSA will no longer
    save newly dumped FDB entries to it, but the driver will continue
    dumping. So FDB entries will be missing from the dump.

    Fix the broken backpressure by propagating the "cb" return code and
    allow rtnl_fdb_dump() to restart the FDB dump with a new skb.

    Fixes: 291d1e72b756 ("net: dsa: sja1105: Add support for FDB and MDB management")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/dsa/sja1105/sja1105_main.c | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)

    diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
    index a07d8051ec3e..eab861352bf2 100644
    --- a/drivers/net/dsa/sja1105/sja1105_main.c
    +++ b/drivers/net/dsa/sja1105/sja1105_main.c
    @@ -1312,7 +1312,9 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
    /* We need to hide the dsa_8021q VLANs from the user. */
    if (!dsa_port_is_vlan_filtering(&ds->ports[port]))
    l2_lookup.vlanid = 0;
    - cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data);
    + rc = cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data);
    + if (rc)
    + return rc;
    }
    return 0;
    }
    --
    2.30.2


    \
     
     \ /
      Last update: 2021-08-16 15:13    [W:2.545 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site