Commit 7b8f7a402d4c ("neighbour: fix nlmsg_pid in notifications") made
neighbour notifications carry the netlink port ID of the process that
triggered them in nlmsg_pid. Similarly route and nexthop update
notifications carry the port ID. This allows applications to tell
their own changes apart from those made by someone else. For
notifications related to FDB entries, port ID is currently always
zero, which makes this sort of notification filtering impossible.
After the preceding patches, port ID is available for bridge and VXLAN
to use by way of the struct ndo_fdb_parms' portid field, and the two
drivers pass the value through to the notifications. The field itself
however has so far been not initialized by rtnl_fdb_add() and
rtnl_fdb_del().
In this patch do that. With that, the RTM_NEWNEIGH and RTM_DELNEIGH
notifications that bridge and VXLAN FDB send carry the port ID.
Notifications that are not a result of a netlink request, such as
those for learning, aging, or switchdev events, still carry zero.
Bulk deletion (flush) goes through ndo_fdb_del_bulk instead, and is
converted in a separate patch.
Drivers other than bridge and VXLAN, which implement ndo_fdb_add and
ndo_fdb_del but fall back to the default implementations, still
report zero as well. That also is converted in a later patch.
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
---
net/core/rtnetlink.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f31549923848..e0d411c251aa 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4857,6 +4857,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
.addr = addr,
.vid = vid,
.flags = nlh->nlmsg_flags,
+ .portid = NETLINK_CB(skb).portid,
};
err = -EOPNOTSUPP;
@@ -4927,6 +4928,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
{
bool del_bulk = !!(nlh->nlmsg_flags & NLM_F_BULK);
struct net *net = sock_net(skb->sk);
+ u32 portid = NETLINK_CB(skb).portid;
const struct net_device_ops *ops;
struct ndmsg *ndm;
struct nlattr *tb[NDA_MAX+1];@@ -4975,6 +4977,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
.dev = dev,
.addr = addr,
.vid = vid,
+ .portid = portid,
};
}
--
2.56.1