OSDN Git Service

samples/bpf: xdpsock: Add option to specify tx packet size
authorJay Jayatheerthan <jay.jayatheerthan@intel.com>
Fri, 20 Dec 2019 08:55:29 +0000 (14:25 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 21 Dec 2019 00:10:39 +0000 (16:10 -0800)
commit4a3c23ae3acc6185a9d418830f22672a52ff986a
treeabe2b6d44e23d7c9735db6b44cb9bfd87d12827d
parentece6e9694751a4f0b99372724a0705a0217132b3
samples/bpf: xdpsock: Add option to specify tx packet size

New option '-s' or '--tx-pkt-size' has been added to specify the transmit
packet size. The packet size ranges from 47 to 4096 bytes. When this
option is not provided, it defaults to 64 byte packet.

The code uses struct ethhdr, struct iphdr and struct udphdr to form the
transmit packet. The MAC address, IP address and UDP ports are set to default
values.

The code calculates IP and UDP checksums before sending the packet.
Checksum calculation code in Linux kernel is used for this purpose.
The Ethernet FCS is not filled by the code.

Signed-off-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191220085530.4980-6-jay.jayatheerthan@intel.com
samples/bpf/xdpsock_user.c