mirror of https://github.com/xemu-project/xemu.git
ebpf: Updated eBPF program and skeleton.
Updated section name, so libbpf should init/gues proper program type without specifications during open/load. Also, added map_flags with explicitly declared BPF_F_MMAPABLE. Added check for BPF_F_MMAPABLE flag to meson script and requirements to libbpf version. Also changed fragmentation flag check - some TCP/UDP packets may be considered fragmented if DF flag is set. Signed-off-by: Andrew Melnychenko <andrew@daynix.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
e88899fa90
commit
0cc14182ab
File diff suppressed because it is too large
Load Diff
10
meson.build
10
meson.build
|
@ -2006,19 +2006,23 @@ elif get_option('vduse_blk_export').disabled()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# libbpf
|
# libbpf
|
||||||
libbpf = dependency('libbpf', required: get_option('bpf'), method: 'pkg-config')
|
bpf_version = '1.1.0'
|
||||||
|
libbpf = dependency('libbpf', version: '>=' + bpf_version, required: get_option('bpf'), method: 'pkg-config')
|
||||||
if libbpf.found() and not cc.links('''
|
if libbpf.found() and not cc.links('''
|
||||||
#include <bpf/libbpf.h>
|
#include <bpf/libbpf.h>
|
||||||
|
#include <linux/bpf.h>
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
// check flag availability
|
||||||
|
int flag = BPF_F_MMAPABLE;
|
||||||
bpf_object__destroy_skeleton(NULL);
|
bpf_object__destroy_skeleton(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}''', dependencies: libbpf)
|
}''', dependencies: libbpf)
|
||||||
libbpf = not_found
|
libbpf = not_found
|
||||||
if get_option('bpf').enabled()
|
if get_option('bpf').enabled()
|
||||||
error('libbpf skeleton test failed')
|
error('libbpf skeleton/mmaping test failed')
|
||||||
else
|
else
|
||||||
warning('libbpf skeleton test failed, disabling')
|
warning('libbpf skeleton/mmaping test failed, disabling')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ struct {
|
||||||
__uint(key_size, sizeof(__u32));
|
__uint(key_size, sizeof(__u32));
|
||||||
__uint(value_size, sizeof(struct rss_config_t));
|
__uint(value_size, sizeof(struct rss_config_t));
|
||||||
__uint(max_entries, 1);
|
__uint(max_entries, 1);
|
||||||
|
__uint(map_flags, BPF_F_MMAPABLE);
|
||||||
} tap_rss_map_configurations SEC(".maps");
|
} tap_rss_map_configurations SEC(".maps");
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -88,6 +89,7 @@ struct {
|
||||||
__uint(key_size, sizeof(__u32));
|
__uint(key_size, sizeof(__u32));
|
||||||
__uint(value_size, sizeof(struct toeplitz_key_data_t));
|
__uint(value_size, sizeof(struct toeplitz_key_data_t));
|
||||||
__uint(max_entries, 1);
|
__uint(max_entries, 1);
|
||||||
|
__uint(map_flags, BPF_F_MMAPABLE);
|
||||||
} tap_rss_map_toeplitz_key SEC(".maps");
|
} tap_rss_map_toeplitz_key SEC(".maps");
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -95,6 +97,7 @@ struct {
|
||||||
__uint(key_size, sizeof(__u32));
|
__uint(key_size, sizeof(__u32));
|
||||||
__uint(value_size, sizeof(__u16));
|
__uint(value_size, sizeof(__u16));
|
||||||
__uint(max_entries, INDIRECTION_TABLE_SIZE);
|
__uint(max_entries, INDIRECTION_TABLE_SIZE);
|
||||||
|
__uint(map_flags, BPF_F_MMAPABLE);
|
||||||
} tap_rss_map_indirection_table SEC(".maps");
|
} tap_rss_map_indirection_table SEC(".maps");
|
||||||
|
|
||||||
static inline void net_rx_rss_add_chunk(__u8 *rss_input, size_t *bytes_written,
|
static inline void net_rx_rss_add_chunk(__u8 *rss_input, size_t *bytes_written,
|
||||||
|
@ -317,7 +320,7 @@ static inline int parse_packet(struct __sk_buff *skb,
|
||||||
|
|
||||||
info->in_src = ip.saddr;
|
info->in_src = ip.saddr;
|
||||||
info->in_dst = ip.daddr;
|
info->in_dst = ip.daddr;
|
||||||
info->is_fragmented = !!ip.frag_off;
|
info->is_fragmented = !!(bpf_ntohs(ip.frag_off) & (0x2000 | 0x1fff));
|
||||||
|
|
||||||
l4_protocol = ip.protocol;
|
l4_protocol = ip.protocol;
|
||||||
l4_offset = ip.ihl * 4;
|
l4_offset = ip.ihl * 4;
|
||||||
|
@ -528,7 +531,7 @@ static inline __u32 calculate_rss_hash(struct __sk_buff *skb,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEC("tun_rss_steering")
|
SEC("socket")
|
||||||
int tun_rss_steering_prog(struct __sk_buff *skb)
|
int tun_rss_steering_prog(struct __sk_buff *skb)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue