Commit f3e619bb authored by Magnus Karlsson's avatar Magnus Karlsson Committed by Alexei Starovoitov

selftests: xsk: do not send zero-length packets

Do not try to send packets of zero length since they are dropped by
veth after commit 726e2c59 ("veth: Ensure eth header is in skb's
linear part"). Replace these two packets with packets of length 60 so
that they are not dropped.

Also clean up the confusing naming. MIN_PKT_SIZE was really
MIN_ETH_PKT_SIZE and PKT_SIZE was both MIN_ETH_SIZE and the default
packet size called just PKT_SIZE. Make it consistent by using the
right define in the right place.
Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/r/20220510115604.8717-3-magnus.karlsson@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 685e64a3
...@@ -575,7 +575,7 @@ static struct pkt *pkt_generate(struct ifobject *ifobject, u32 pkt_nb) ...@@ -575,7 +575,7 @@ static struct pkt *pkt_generate(struct ifobject *ifobject, u32 pkt_nb)
if (!pkt) if (!pkt)
return NULL; return NULL;
if (!pkt->valid || pkt->len < PKT_SIZE) if (!pkt->valid || pkt->len < MIN_PKT_SIZE)
return pkt; return pkt;
data = xsk_umem__get_data(ifobject->umem->buffer, pkt->addr); data = xsk_umem__get_data(ifobject->umem->buffer, pkt->addr);
...@@ -677,8 +677,8 @@ static bool is_pkt_valid(struct pkt *pkt, void *buffer, u64 addr, u32 len) ...@@ -677,8 +677,8 @@ static bool is_pkt_valid(struct pkt *pkt, void *buffer, u64 addr, u32 len)
return false; return false;
} }
if (len < PKT_SIZE) { if (len < MIN_PKT_SIZE || pkt->len < MIN_PKT_SIZE) {
/*Do not try to verify packets that are smaller than minimum size. */ /* Do not try to verify packets that are smaller than minimum size. */
return true; return true;
} }
...@@ -1282,10 +1282,10 @@ static void testapp_single_pkt(struct test_spec *test) ...@@ -1282,10 +1282,10 @@ static void testapp_single_pkt(struct test_spec *test)
static void testapp_invalid_desc(struct test_spec *test) static void testapp_invalid_desc(struct test_spec *test)
{ {
struct pkt pkts[] = { struct pkt pkts[] = {
/* Zero packet length at address zero allowed */ /* Zero packet address allowed */
{0, 0, 0, true}, {0, PKT_SIZE, 0, true},
/* Zero packet length allowed */ /* Allowed packet */
{0x1000, 0, 0, true}, {0x1000, PKT_SIZE, 0, true},
/* Straddling the start of umem */ /* Straddling the start of umem */
{-2, PKT_SIZE, 0, false}, {-2, PKT_SIZE, 0, false},
/* Packet too large */ /* Packet too large */
......
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
#define MAX_TEARDOWN_ITER 10 #define MAX_TEARDOWN_ITER 10
#define PKT_HDR_SIZE (sizeof(struct ethhdr) + sizeof(struct iphdr) + \ #define PKT_HDR_SIZE (sizeof(struct ethhdr) + sizeof(struct iphdr) + \
sizeof(struct udphdr)) sizeof(struct udphdr))
#define MIN_PKT_SIZE 64 #define MIN_ETH_PKT_SIZE 64
#define ETH_FCS_SIZE 4 #define ETH_FCS_SIZE 4
#define PKT_SIZE (MIN_PKT_SIZE - ETH_FCS_SIZE) #define MIN_PKT_SIZE (MIN_ETH_PKT_SIZE - ETH_FCS_SIZE)
#define PKT_SIZE (MIN_PKT_SIZE)
#define IP_PKT_SIZE (PKT_SIZE - sizeof(struct ethhdr)) #define IP_PKT_SIZE (PKT_SIZE - sizeof(struct ethhdr))
#define IP_PKT_VER 0x4 #define IP_PKT_VER 0x4
#define IP_PKT_TOS 0x9 #define IP_PKT_TOS 0x9
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment