Skip to content

Commit 583419f

Browse files
idoschdavem330
authored andcommitted
mlxsw: spectrum_router: Sanitize IPv6 FIB rules
We only allow FIB offload in the presence of default rules or an l3mdev rule. In a similar fashion to IPv4 FIB rules, sanitize IPv6 rules. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 66a5763 commit 583419f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <net/neighbour.h>
4949
#include <net/arp.h>
5050
#include <net/ip_fib.h>
51+
#include <net/ip6_fib.h>
5152
#include <net/fib_rules.h>
5253
#include <net/l3mdev.h>
5354
#include <net/addrconf.h>
@@ -3087,6 +3088,23 @@ static void mlxsw_sp_router_fib4_event_work(struct work_struct *work)
30873088

30883089
static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
30893090
{
3091+
struct mlxsw_sp_fib_event_work *fib_work =
3092+
container_of(work, struct mlxsw_sp_fib_event_work, work);
3093+
struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp;
3094+
struct fib_rule *rule;
3095+
3096+
rtnl_lock();
3097+
switch (fib_work->event) {
3098+
case FIB_EVENT_RULE_ADD: /* fall through */
3099+
case FIB_EVENT_RULE_DEL:
3100+
rule = fib_work->fr_info.rule;
3101+
if (!fib6_rule_default(rule) && !rule->l3mdev)
3102+
mlxsw_sp_router_fib_abort(mlxsw_sp);
3103+
fib_rule_put(rule);
3104+
break;
3105+
}
3106+
rtnl_unlock();
3107+
kfree(fib_work);
30903108
}
30913109

30923110
static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
@@ -3119,6 +3137,13 @@ static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
31193137
static void mlxsw_sp_router_fib6_event(struct mlxsw_sp_fib_event_work *fib_work,
31203138
struct fib_notifier_info *info)
31213139
{
3140+
switch (fib_work->event) {
3141+
case FIB_EVENT_RULE_ADD: /* fall through */
3142+
case FIB_EVENT_RULE_DEL:
3143+
memcpy(&fib_work->fr_info, info, sizeof(fib_work->fr_info));
3144+
fib_rule_get(fib_work->fr_info.rule);
3145+
break;
3146+
}
31223147
}
31233148

31243149
/* Called with rcu_read_lock() */

0 commit comments

Comments
 (0)