Patch "libbpf: Fix bpf_xdp_query() in old kernels" has been added to the 6.3-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

    libbpf: Fix bpf_xdp_query() in old kernels

to the 6.3-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:
     libbpf-fix-bpf_xdp_query-in-old-kernels.patch
and it can be found in the queue-6.3 subdirectory.

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



commit 5e649ac8cddeb4591f6e2bdd67d3cbc535864348
Author: Yonghong Song <yhs@xxxxxx>
Date:   Mon Feb 27 14:49:43 2023 -0800

    libbpf: Fix bpf_xdp_query() in old kernels
    
    [ Upstream commit c8ee37bde4021a275d2e4f33bd48d54912bb00c4 ]
    
    Commit 04d58f1b26a4("libbpf: add API to get XDP/XSK supported features")
    added feature_flags to struct bpf_xdp_query_opts. If a user uses
    bpf_xdp_query_opts with feature_flags member, the bpf_xdp_query()
    will check whether 'netdev' family exists or not in the kernel.
    If it does not exist, the bpf_xdp_query() will return -ENOENT.
    
    But 'netdev' family does not exist in old kernels as it is
    introduced in the same patch set as Commit 04d58f1b26a4.
    So old kernel with newer libbpf won't work properly with
    bpf_xdp_query() api call.
    
    To fix this issue, if the return value of
    libbpf_netlink_resolve_genl_family_id() is -ENOENT, bpf_xdp_query()
    will just return 0, skipping the rest of xdp feature query.
    This preserves backward compatibility.
    
    Fixes: 04d58f1b26a4 ("libbpf: add API to get XDP/XSK supported features")
    Signed-off-by: Yonghong Song <yhs@xxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20230227224943.1153459-1-yhs@xxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c
index 1653e7a8b0a11..84dd5fa149058 100644
--- a/tools/lib/bpf/netlink.c
+++ b/tools/lib/bpf/netlink.c
@@ -468,8 +468,13 @@ int bpf_xdp_query(int ifindex, int xdp_flags, struct bpf_xdp_query_opts *opts)
 		return 0;
 
 	err = libbpf_netlink_resolve_genl_family_id("netdev", sizeof("netdev"), &id);
-	if (err < 0)
+	if (err < 0) {
+		if (err == -ENOENT) {
+			opts->feature_flags = 0;
+			goto skip_feature_flags;
+		}
 		return libbpf_err(err);
+	}
 
 	memset(&req, 0, sizeof(req));
 	req.nh.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
@@ -489,6 +494,7 @@ int bpf_xdp_query(int ifindex, int xdp_flags, struct bpf_xdp_query_opts *opts)
 
 	opts->feature_flags = md.flags;
 
+skip_feature_flags:
 	return 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