ipv4: Use dscp_t in struct fib_entry_notifier_info
authorGuillaume Nault <gnault@redhat.com>
Fri, 8 Apr 2022 20:08:40 +0000 (22:08 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Apr 2022 00:37:50 +0000 (17:37 -0700)
Use the new dscp_t type to replace the tos field of struct
fib_entry_notifier_info. This ensures ECN bits are ignored and makes it
compatible with the dscp field of struct fib_rt_info.

This also allows sparse to flag potential incorrect uses of DSCP and
ECN bits.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/prestera/prestera_router.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/netdevsim/fib.c
include/net/ip_fib.h
net/ipv4/fib_trie.c

index 99d60c9..a6b608a 100644 (file)
@@ -89,7 +89,7 @@ prestera_kern_fib_cache_destroy(struct prestera_switch *sw,
 static struct prestera_kern_fib_cache *
 prestera_kern_fib_cache_create(struct prestera_switch *sw,
                               struct prestera_kern_fib_cache_key *key,
-                              struct fib_info *fi, u8 tos, u8 type)
+                              struct fib_info *fi, dscp_t dscp, u8 type)
 {
        struct prestera_kern_fib_cache *fib_cache;
        int err;
@@ -101,7 +101,7 @@ prestera_kern_fib_cache_create(struct prestera_switch *sw,
        memcpy(&fib_cache->key, key, sizeof(*key));
        fib_info_hold(fi);
        fib_cache->fi = fi;
-       fib_cache->kern_tos = tos;
+       fib_cache->kern_tos = inet_dscp_to_dsfield(dscp);
        fib_cache->kern_type = type;
 
        err = rhashtable_insert_fast(&sw->router->kern_fib_cache_ht,
@@ -306,7 +306,7 @@ prestera_k_arb_fib_evt(struct prestera_switch *sw,
        if (replace) {
                fib_cache = prestera_kern_fib_cache_create(sw, &fc_key,
                                                           fen_info->fi,
-                                                          fen_info->tos,
+                                                          fen_info->dscp,
                                                           fen_info->type);
                if (!fib_cache) {
                        dev_err(sw->dev->dev, "fib_cache == NULL");
index 596516b..1c451d6 100644 (file)
@@ -5621,7 +5621,7 @@ mlxsw_sp_fib4_offload_failed_flag_set(struct mlxsw_sp *mlxsw_sp,
        fri.tb_id = fen_info->tb_id;
        fri.dst = cpu_to_be32(*p_dst);
        fri.dst_len = fen_info->dst_len;
-       fri.dscp = inet_dsfield_to_dscp(fen_info->tos);
+       fri.dscp = fen_info->dscp;
        fri.type = fen_info->type;
        fri.offload = false;
        fri.trap = false;
@@ -6251,7 +6251,7 @@ mlxsw_sp_fib4_entry_create(struct mlxsw_sp *mlxsw_sp,
        fib_info_hold(fib4_entry->fi);
        fib4_entry->tb_id = fen_info->tb_id;
        fib4_entry->type = fen_info->type;
-       fib4_entry->tos = fen_info->tos;
+       fib4_entry->tos = inet_dscp_to_dsfield(fen_info->dscp);
 
        fib_entry->fib_node = fib_node;
 
@@ -6305,7 +6305,7 @@ mlxsw_sp_fib4_entry_lookup(struct mlxsw_sp *mlxsw_sp,
        fib4_entry = container_of(fib_node->fib_entry,
                                  struct mlxsw_sp_fib4_entry, common);
        if (fib4_entry->tb_id == fen_info->tb_id &&
-           fib4_entry->tos == fen_info->tos &&
+           fib4_entry->tos == inet_dscp_to_dsfield(fen_info->dscp) &&
            fib4_entry->type == fen_info->type &&
            fib4_entry->fi == fen_info->fi)
                return fib4_entry;
index 31e7370..fb9af26 100644 (file)
@@ -284,7 +284,7 @@ nsim_fib4_rt_create(struct nsim_fib_data *data,
 
        fib4_rt->fi = fen_info->fi;
        fib_info_hold(fib4_rt->fi);
-       fib4_rt->tos = fen_info->tos;
+       fib4_rt->tos = inet_dscp_to_dsfield(fen_info->dscp);
        fib4_rt->type = fen_info->type;
 
        return fib4_rt;
@@ -323,7 +323,7 @@ nsim_fib4_rt_offload_failed_flag_set(struct net *net,
        fri.tb_id = fen_info->tb_id;
        fri.dst = cpu_to_be32(*p_dst);
        fri.dst_len = fen_info->dst_len;
-       fri.dscp = inet_dsfield_to_dscp(fen_info->tos);
+       fri.dscp = fen_info->dscp;
        fri.type = fen_info->type;
        fri.offload = false;
        fri.trap = false;
index f08ba53..a378eff 100644 (file)
@@ -225,7 +225,7 @@ struct fib_entry_notifier_info {
        u32 dst;
        int dst_len;
        struct fib_info *fi;
-       u8 tos;
+       dscp_t dscp;
        u8 type;
        u32 tb_id;
 };
index e96f02f..1f7f255 100644 (file)
@@ -82,7 +82,7 @@ static int call_fib_entry_notifier(struct notifier_block *nb,
                .dst = dst,
                .dst_len = dst_len,
                .fi = fa->fa_info,
-               .tos = inet_dscp_to_dsfield(fa->fa_dscp),
+               .dscp = fa->fa_dscp,
                .type = fa->fa_type,
                .tb_id = fa->tb_id,
        };
@@ -99,7 +99,7 @@ static int call_fib_entry_notifiers(struct net *net,
                .dst = dst,
                .dst_len = dst_len,
                .fi = fa->fa_info,
-               .tos = inet_dscp_to_dsfield(fa->fa_dscp),
+               .dscp = fa->fa_dscp,
                .type = fa->fa_type,
                .tb_id = fa->tb_id,
        };