summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@mellanox.com>2019-09-15 09:46:35 +0300
committerDavid S. Miller <davem@davemloft.net>2019-09-16 21:39:27 +0200
commit58a406def4374c08d063ec9ff97da74a74e1a9bf (patch)
tree551c051e3986aaaf02cdf0e21af5f7ef3e7a9745 /drivers/net
parentdb539cae12a3456cc710855b345542ccd2946e25 (diff)
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>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/netdevsim/dev.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
index 7fba7b271a57..56576d4f34a5 100644
--- a/drivers/net/netdevsim/dev.c
+++ b/drivers/net/netdevsim/dev.c
@@ -374,12 +374,14 @@ static struct sk_buff *nsim_dev_trap_skb_build(void)
return NULL;
tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + data_len;
+ skb_reset_mac_header(skb);
eth = skb_put(skb, sizeof(struct ethhdr));
eth_random_addr(eth->h_dest);
eth_random_addr(eth->h_source);
eth->h_proto = htons(ETH_P_IP);
skb->protocol = htons(ETH_P_IP);
+ skb_set_network_header(skb, skb->len);
iph = skb_put(skb, sizeof(struct iphdr));
iph->protocol = IPPROTO_UDP;
iph->saddr = in_aton("192.0.2.1");
@@ -392,6 +394,7 @@ static struct sk_buff *nsim_dev_trap_skb_build(void)
iph->check = 0;
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
+ skb_set_transport_header(skb, skb->len);
udph = skb_put_zero(skb, sizeof(struct udphdr) + data_len);
get_random_bytes(&udph->source, sizeof(u16));
get_random_bytes(&udph->dest, sizeof(u16));