Skip to contentSkip to conversation

GRE: Refactor GRE tunneling code.

DISCUSSION Dan Carpenter 2 participants 2 messages Apr 2, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Pravin,

I had a question about c54419321455: "GRE: Refactor GRE tunneling code." from Mar 25, 2013:

net/ipv4/ip_gre.c
392 if (tpi->flags&TUNNEL_CSUM &&
393 !(skb_shinfo(skb)->gso_type & SKB_GSO_GRE)) {
394 *(__sum16 *)ptr = 0;
395 *(__sum16 *)ptr = csum_fold(skb_checksum(skb, 0,
396 skb->len, 0));

What are we doing here when we set *ptr = 0 and then reset it on the next line? Is there a ptr++ or ptr-- missing?

397 }

regards,
dan carpenter

#1 lore raw
Quoted 6 lines · Dan Carpenter

I had a question about c54419321455: "GRE: Refactor GRE tunneling code." from Mar 25, 2013:

net/ipv4/ip_gre.c
392 if (tpi->flags&TUNNEL_CSUM &&

Quoted 7 lines
   393                      !(skb_shinfo(skb)->gso_type & SKB_GSO_GRE)) {
   394                          *(__sum16 *)ptr = 0;
   395                          *(__sum16 *)ptr = csum_fold(skb_checksum(skb, 0,
   396                                                                   skb->len, 0));

What are we doing here when we set *ptr = 0 and then reset it on the next line? Is there a ptr++ or ptr-- missing?

AFAICS, skb_checksum() calculates the checksum over a block containing the checksum field the result is to be written into (which is where ptr points). This fields needs to be reset first.

Michal Kubecek