From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com,
dsahern@gmail.com, mlxsw@nvidia.com,
Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 01/15] mlxsw: spectrum_router: Compare key with correct object type
Date: Fri, 13 Nov 2020 18:05:45 +0200 [thread overview]
Message-ID: <20201113160559.22148-2-idosch@idosch.org> (raw)
In-Reply-To: <20201113160559.22148-1-idosch@idosch.org>
From: Ido Schimmel <idosch@nvidia.com>
When comparing a key with a nexthop group in rhastable's obj_cmpfn()
callback, make sure that the key and nexthop group are of the same type
(i.e., IPv4 / IPv6).
The bug is not currently visible because IPv6 nexthop groups do not
populate the FIB info pointer and IPv4 nexthop groups do not set the
ifindex for the individual nexthops.
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
.../ethernet/mellanox/mlxsw/spectrum_router.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index e692e5a39f6c..55ae16b03c44 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -3040,6 +3040,12 @@ mlxsw_sp_nexthop6_group_cmp(const struct mlxsw_sp_nexthop_group *nh_grp,
return true;
}
+static int
+mlxsw_sp_nexthop_group_type(const struct mlxsw_sp_nexthop_group *nh_grp)
+{
+ return nh_grp->neigh_tbl->family;
+}
+
static int
mlxsw_sp_nexthop_group_cmp(struct rhashtable_compare_arg *arg, const void *ptr)
{
@@ -3048,8 +3054,12 @@ mlxsw_sp_nexthop_group_cmp(struct rhashtable_compare_arg *arg, const void *ptr)
switch (cmp_arg->proto) {
case MLXSW_SP_L3_PROTO_IPV4:
+ if (mlxsw_sp_nexthop_group_type(nh_grp) != AF_INET)
+ return 1;
return cmp_arg->fi != mlxsw_sp_nexthop4_group_fi(nh_grp);
case MLXSW_SP_L3_PROTO_IPV6:
+ if (mlxsw_sp_nexthop_group_type(nh_grp) != AF_INET6)
+ return 1;
return !mlxsw_sp_nexthop6_group_cmp(nh_grp,
cmp_arg->fib6_entry);
default:
@@ -3058,12 +3068,6 @@ mlxsw_sp_nexthop_group_cmp(struct rhashtable_compare_arg *arg, const void *ptr)
}
}
-static int
-mlxsw_sp_nexthop_group_type(const struct mlxsw_sp_nexthop_group *nh_grp)
-{
- return nh_grp->neigh_tbl->family;
-}
-
static u32 mlxsw_sp_nexthop_group_hash_obj(const void *data, u32 len, u32 seed)
{
const struct mlxsw_sp_nexthop_group *nh_grp = data;
--
2.28.0
next prev parent reply other threads:[~2020-11-13 16:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 16:05 [PATCH net-next 00/15] mlxsw: Preparations for nexthop objects support - part 1/2 Ido Schimmel
2020-11-13 16:05 ` Ido Schimmel [this message]
2020-11-13 16:05 ` [PATCH net-next 02/15] mlxsw: spectrum_router: Add nexthop group type field Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 03/15] mlxsw: spectrum_router: Use nexthop group type in hash table key Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 04/15] mlxsw: spectrum_router: Associate neighbour table with nexthop instead of group Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 05/15] mlxsw: spectrum_router: Store FIB info in route Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 06/15] mlxsw: spectrum_router: Remove unused field 'prio' from IPv4 FIB entry struct Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 07/15] mlxsw: spectrum_router: Move IPv4 FIB info into a union in nexthop group struct Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 08/15] mlxsw: spectrum_router: Split nexthop group configuration to a different struct Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 09/15] mlxsw: spectrum_ipip: Remove overlay protocol from can_offload() callback Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 10/15] mlxsw: spectrum_router: Pass nexthop netdev to mlxsw_sp_nexthop6_type_init() Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 11/15] mlxsw: spectrum_router: Pass nexthop netdev to mlxsw_sp_nexthop4_type_init() Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 12/15] mlxsw: spectrum_router: Remove unused argument from mlxsw_sp_nexthop6_type_init() Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 13/15] mlxsw: spectrum_router: Consolidate mlxsw_sp_nexthop{4, 6}_type_init() Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 14/15] mlxsw: spectrum_router: Consolidate mlxsw_sp_nexthop{4, 6}_type_fini() Ido Schimmel
2020-11-13 16:05 ` [PATCH net-next 15/15] mlxsw: spectrum_router: Remove outdated comment Ido Schimmel
2020-11-15 0:56 ` [PATCH net-next 00/15] mlxsw: Preparations for nexthop objects support - part 1/2 Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201113160559.22148-2-idosch@idosch.org \
--to=idosch@idosch.org \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=idosch@nvidia.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).