Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netdevsim: Set offsets to various protocol layers

The driver periodically generates "trapped" UDP packets that it then
passes on to devlink. Set the offsets to the various protocol layers.

This is a prerequisite to the next patch, where drop monitor is taught
to check that the offset to the MAC header was set.

Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ido Schimmel and committed by
David S. Miller
58a406de db539cae

+3
+3
drivers/net/netdevsim/dev.c
··· 374 374 return NULL; 375 375 tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + data_len; 376 376 377 + skb_reset_mac_header(skb); 377 378 eth = skb_put(skb, sizeof(struct ethhdr)); 378 379 eth_random_addr(eth->h_dest); 379 380 eth_random_addr(eth->h_source); 380 381 eth->h_proto = htons(ETH_P_IP); 381 382 skb->protocol = htons(ETH_P_IP); 382 383 384 + skb_set_network_header(skb, skb->len); 383 385 iph = skb_put(skb, sizeof(struct iphdr)); 384 386 iph->protocol = IPPROTO_UDP; 385 387 iph->saddr = in_aton("192.0.2.1"); ··· 394 392 iph->check = 0; 395 393 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); 396 394 395 + skb_set_transport_header(skb, skb->len); 397 396 udph = skb_put_zero(skb, sizeof(struct udphdr) + data_len); 398 397 get_random_bytes(&udph->source, sizeof(u16)); 399 398 get_random_bytes(&udph->dest, sizeof(u16));