Patch "samples/bpf: Fix map iteration in xdp1_user" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    samples/bpf: Fix map iteration in xdp1_user

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     samples-bpf-fix-map-iteration-in-xdp1_user.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit bbcb5df86597477912666b75cfbdac035834454c
Author: Gerhard Engleder <gerhard@xxxxxxxxxxxxxxxxxxxxx>
Date:   Thu Oct 13 22:09:22 2022 +0200

    samples/bpf: Fix map iteration in xdp1_user
    
    [ Upstream commit 05ee658c654bacda03f7fecef367e62aaf8e1cfe ]
    
    BPF map iteration in xdp1_user results in endless loop without any
    output, because the return value of bpf_map_get_next_key() is checked
    against the wrong value.
    
    Other call locations of bpf_map_get_next_key() check for equal 0 for
    continuing the iteration. xdp1_user checks against unequal -1. This is
    wrong for a function which can return arbitrary negative errno values,
    because a return value of e.g. -2 results in an endless loop.
    
    With this fix xdp1_user is printing statistics again:
    proto 0:          1 pkt/s
    proto 0:          1 pkt/s
    proto 17:     107383 pkt/s
    proto 17:     881655 pkt/s
    proto 17:     882083 pkt/s
    proto 17:     881758 pkt/s
    
    Fixes: bd054102a8c7 ("libbpf: enforce strict libbpf 1.0 behaviors")
    Signed-off-by: Gerhard Engleder <gerhard@xxxxxxxxxxxxxxxxxxxxx>
    Acked-by: Song Liu <song@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221013200922.17167-1-gerhard@xxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/samples/bpf/xdp1_user.c b/samples/bpf/xdp1_user.c
index ac370e638fa3..281dc964de8d 100644
--- a/samples/bpf/xdp1_user.c
+++ b/samples/bpf/xdp1_user.c
@@ -51,7 +51,7 @@ static void poll_stats(int map_fd, int interval)
 
 		sleep(interval);
 
-		while (bpf_map_get_next_key(map_fd, &key, &key) != -1) {
+		while (bpf_map_get_next_key(map_fd, &key, &key) == 0) {
 			__u64 sum = 0;
 
 			assert(bpf_map_lookup_elem(map_fd, &key, values) == 0);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux