OSDN Git Service

net: bridge: create a common function for populating switchdev FDB entries
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 26 Oct 2021 14:27:42 +0000 (17:27 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 Oct 2021 13:54:02 +0000 (14:54 +0100)
commitfab9eca88410ddd22e4c4bb275849b8327b49a60
tree565bed9f31f026fa883518f5bca8ebeba67cf56e
parent5cda5272a4605c34740859378bf7a7940229feca
net: bridge: create a common function for populating switchdev FDB entries

There are two places where a switchdev FDB entry is constructed, one is
br_switchdev_fdb_notify() and the other is br_fdb_replay(). One uses a
struct initializer, and the other declares the structure as
uninitialized and populates the elements one by one.

One problem when introducing new members of struct
switchdev_notifier_fdb_info is that there is a risk for one of these
functions to run with an uninitialized value.

So centralize the logic of populating such structure into a dedicated
function. Being the primary location where these structures are created,
using an uninitialized variable and populating the members one by one
should be fine, since this one function is supposed to assign values to
all its members.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_switchdev.c