The kernel side of XDP_FLAGS_SKB_MODE is unsigned, and the rtnetlink
IFLA_XDP_FLAGS is defined as NLA_U32. Thus, userspace programs under
samples/bpf/ should use the correct type.
Fixes:
3993f2cb983b ("samples/bpf: Add support for SKB_MODE to xdp1 and xdp_tx_iptunnel")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
#include <linux/perf_event.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+#include <linux/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/syscall.h>
return &syms[0];
}
-int set_link_xdp_fd(int ifindex, int fd, int flags)
+int set_link_xdp_fd(int ifindex, int fd, __u32 flags)
{
struct sockaddr_nl sa;
int sock, seq = 0, len, ret = -1;
int load_kallsyms(void);
struct ksym *ksym_search(long key);
-int set_link_xdp_fd(int ifindex, int fd, int flags);
+int set_link_xdp_fd(int ifindex, int fd, __u32 flags);
#endif
#include "libbpf.h"
static int ifindex;
-static int flags;
+static __u32 xdp_flags;
static void int_exit(int sig)
{
- set_link_xdp_fd(ifindex, -1, flags);
+ set_link_xdp_fd(ifindex, -1, xdp_flags);
exit(0);
}
while ((opt = getopt(argc, argv, optstr)) != -1) {
switch (opt) {
case 'S':
- flags |= XDP_FLAGS_SKB_MODE;
+ xdp_flags |= XDP_FLAGS_SKB_MODE;
break;
default:
usage(basename(argv[0]));
signal(SIGINT, int_exit);
- if (set_link_xdp_fd(ifindex, prog_fd[0], flags) < 0) {
+ if (set_link_xdp_fd(ifindex, prog_fd[0], xdp_flags) < 0) {
printf("link set xdp fd failed\n");
return 1;
}
struct iptnl_info tnl = {};
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
struct vip vip = {};
+ __u32 xdp_flags = 0;
char filename[256];
- int flags = 0;
int opt;
int i;
kill_after_s = atoi(optarg);
break;
case 'S':
- flags |= XDP_FLAGS_SKB_MODE;
+ xdp_flags |= XDP_FLAGS_SKB_MODE;
break;
default:
usage(argv[0]);
}
}
- if (set_link_xdp_fd(ifindex, prog_fd[0], flags) < 0) {
+ if (set_link_xdp_fd(ifindex, prog_fd[0], xdp_flags) < 0) {
printf("link set xdp fd failed\n");
return 1;
}
poll_stats(kill_after_s);
- set_link_xdp_fd(ifindex, -1, flags);
+ set_link_xdp_fd(ifindex, -1, xdp_flags);
return 0;
}