]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
selftests: bpf: crypto: use NULL instead of 0-sized dynptr
authorVadim Fedorenko <vadfed@meta.com>
Thu, 13 Jun 2024 21:18:15 +0000 (14:18 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 13 Jun 2024 23:33:04 +0000 (16:33 -0700)
Adjust selftests to use nullable option for state and IV arg.

Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
Link: https://lore.kernel.org/r/20240613211817.1551967-4-vadfed@meta.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/crypto_sanity.c

index 1be0a3fa5efd9ef095e2e4b16b3a8a4cae4f56e7..645be6cddf36cdf8c5b8796a45c9e8fd96e901e2 100644 (file)
@@ -89,7 +89,7 @@ int decrypt_sanity(struct __sk_buff *skb)
 {
        struct __crypto_ctx_value *v;
        struct bpf_crypto_ctx *ctx;
-       struct bpf_dynptr psrc, pdst, iv;
+       struct bpf_dynptr psrc, pdst;
        int err;
 
        err = skb_dynptr_validate(skb, &psrc);
@@ -114,12 +114,8 @@ int decrypt_sanity(struct __sk_buff *skb)
         * production code, a percpu map should be used to store the result.
         */
        bpf_dynptr_from_mem(dst, sizeof(dst), 0, &pdst);
-       /* iv dynptr has to be initialized with 0 size, but proper memory region
-        * has to be provided anyway
-        */
-       bpf_dynptr_from_mem(dst, 0, 0, &iv);
 
-       status = bpf_crypto_decrypt(ctx, &psrc, &pdst, &iv);
+       status = bpf_crypto_decrypt(ctx, &psrc, &pdst, NULL);
 
        return TC_ACT_SHOT;
 }
@@ -129,7 +125,7 @@ int encrypt_sanity(struct __sk_buff *skb)
 {
        struct __crypto_ctx_value *v;
        struct bpf_crypto_ctx *ctx;
-       struct bpf_dynptr psrc, pdst, iv;
+       struct bpf_dynptr psrc, pdst;
        int err;
 
        status = 0;
@@ -156,12 +152,8 @@ int encrypt_sanity(struct __sk_buff *skb)
         * production code, a percpu map should be used to store the result.
         */
        bpf_dynptr_from_mem(dst, sizeof(dst), 0, &pdst);
-       /* iv dynptr has to be initialized with 0 size, but proper memory region
-        * has to be provided anyway
-        */
-       bpf_dynptr_from_mem(dst, 0, 0, &iv);
 
-       status = bpf_crypto_encrypt(ctx, &psrc, &pdst, &iv);
+       status = bpf_crypto_encrypt(ctx, &psrc, &pdst, NULL);
 
        return TC_ACT_SHOT;
 }