Thread (1 message) 1 message, 1 author, 2021-04-28

Re: [PATCH net-next v3] virtio-net: page_to_skb() use build_skb when there's sufficient tailroom

From: Jason Wang <jasowang@redhat.com>
Date: 2021-04-28 01:22:13
Also in: virtualization

在 2021/4/27 上午10:46, Xuan Zhuo 写道:
On Tue, 20 Apr 2021 10:41:03 +0800, Jason Wang [off-list ref] wrote:
quoted
Btw, since the patch modifies a critical path of virtio-net I suggest to
test the following cases:

1) netperf TCP stream
2) netperf UDP with packet size from 64 to PAGE_SIZE
3) XDP_PASS with 1)
4) XDP_PASS with 2)
5) XDP metadata with 1)
6) XDP metadata with 2)
I have completed the above test on the latest net-next branch. The tested script
and xdp code are as follows. The kernel is with KCOV and everything is normal
without exception.

Thanks.

Looks good.

Thanks for the testing.

## test script:
	#!/usr/bin/env sh


	for s in $(seq 64 4096)
	do
	    netperf -H 192.168.122.202  -t UDP_STREAM -- -m $s
	done

	for s in $(seq 64 4096)
	do
	    netperf -H 192.168.122.202  -t TCP_STREAM -- -m $s
	done

## xdp pass:

	#define KBUILD_MODNAME "foo"
	#include <linux/bpf.h>
	#include <linux/in.h>
	#include <linux/if_ether.h>
	#include <linux/if_packet.h>
	#include <linux/if_vlan.h>
	#include <linux/ip.h>
	#include <linux/icmp.h>

	#define DEFAULT_TTL 64
	#define MAX_PCKT_SIZE 600
	#define ICMP_TOOBIG_SIZE 98
	#define ICMP_TOOBIG_PAYLOAD_SIZE 92


	#define SEC(NAME) __attribute__((section(NAME), used))


	SEC("xdp")
	int _xdp(struct xdp_md *xdp)
	{
	        return XDP_PASS;
	}

	char _license[] SEC("license") = "GPL";

## xdp metadata:

	#define KBUILD_MODNAME "foo"
	#include <linux/bpf.h>
	#include <linux/in.h>
	#include <linux/if_ether.h>
	#include <linux/if_packet.h>
	#include <linux/if_vlan.h>
	#include <linux/ip.h>
	#include <linux/icmp.h>

	static long (*bpf_xdp_adjust_meta)(struct xdp_md *xdp_md, int delta) = (void *) 54;


	#define SEC(NAME) __attribute__((section(NAME), used))

	struct meta_info {
	        __u32 mark;
	} __attribute__((aligned(4)));

	SEC("xdp_mark")
	int _xdp_mark(struct xdp_md *ctx)
	{
	        struct meta_info *meta;
	        void *data, *data_end;
	        int ret;

	        /* Reserve space in-front of data pointer for our meta info.
	         * (Notice drivers not supporting data_meta will fail here!)
	         */
	        ret = bpf_xdp_adjust_meta(ctx, -(int)sizeof(*meta));
	        if (ret < 0)
	                return XDP_ABORTED;

	        /* Notice: Kernel-side verifier requires that loading of
	         * ctx->data MUST happen _after_ helper bpf_xdp_adjust_meta(),
	         * as pkt-data pointers are invalidated.  Helpers that require
	         * this are determined/marked by bpf_helper_changes_pkt_data()
	         */
	        data = (void *)(unsigned long)ctx->data;

	        /* Check data_meta have room for meta_info struct */
	        meta = (void *)(unsigned long)ctx->data_meta;
	        if ((void *)(meta + 1) > data)
	                return XDP_ABORTED;

	        meta->mark = 42;

	        return XDP_PASS;
	}


	char _license[] SEC("license") = "GPL";
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help