net: marvell: prestera: Use dscp_t in struct prestera_kern_fib_cache
authorGuillaume Nault <gnault@redhat.com>
Fri, 8 Apr 2022 20:08:50 +0000 (22:08 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Apr 2022 00:38:02 +0000 (17:38 -0700)
Use the new dscp_t type to replace the kern_tos field of struct
prestera_kern_fib_cache. This ensures ECN bits are ignored and makes it
compatible with the dscp fields of struct fib_entry_notifier_info and
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: Yevhen Orlov <yevhen.orlov@plvision.eu>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/prestera/prestera_router.c

index a6b608ade2b9698d300730a253fab437e74c2c68..3754d8aec76d749af7f99106b0a94f5d0b496f22 100644 (file)
@@ -27,7 +27,7 @@ struct prestera_kern_fib_cache {
        /* Indicate if route is not overlapped by another table */
        struct rhash_head ht_node; /* node of prestera_router */
        struct fib_info *fi;
-       u8 kern_tos;
+       dscp_t kern_dscp;
        u8 kern_type;
        bool reachable;
 };
@@ -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 = inet_dscp_to_dsfield(dscp);
+       fib_cache->kern_dscp = dscp;
        fib_cache->kern_type = type;
 
        err = rhashtable_insert_fast(&sw->router->kern_fib_cache_ht,
@@ -133,7 +133,7 @@ __prestera_k_arb_fib_lpm_offload_set(struct prestera_switch *sw,
        fri.tb_id = fc->key.kern_tb_id;
        fri.dst = fc->key.addr.u.ipv4;
        fri.dst_len = fc->key.prefix_len;
-       fri.dscp = inet_dsfield_to_dscp(fc->kern_tos);
+       fri.dscp = fc->kern_dscp;
        fri.type = fc->kern_type;
        /* flags begin */
        fri.offload = offload;