Skip to content

Commit

Permalink
Zero checksum handling (#25)
Browse files Browse the repository at this point in the history
Merge the compile warning fix  from the zero-csum branch:

* ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

Co-authored-by: Richard Patterson <richard@helix.net.nz>
Co-authored-by: Det <detobate@users.noreply.github.com>
  • Loading branch information
3 people committed Apr 15, 2021
1 parent 7688102 commit 9df230a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nat46/modules/nat46-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1576,12 +1576,13 @@ void nat46_ipv6_input(struct sk_buff *old_skb) {
}
case NEXTHDR_UDP: {
struct udphdr *udp = add_offset(ip6h, v6packet_l3size);
u16 sum1, sum2;
if ((udp->check == 0) && zero_csum_pass) {
/* zero checksum and the config to pass it is set - do nothing with it */
break;
}
u16 sum1 = csum_ipv6_unmagic(nat46, &ip6h->saddr, &ip6h->daddr, l3_infrag_payload_len, NEXTHDR_UDP, udp->check);
u16 sum2 = csum_tcpudp_remagic(v4saddr, v4daddr, l3_infrag_payload_len, NEXTHDR_UDP, sum1);
sum1 = csum_ipv6_unmagic(nat46, &ip6h->saddr, &ip6h->daddr, l3_infrag_payload_len, NEXTHDR_UDP, udp->check);
sum2 = csum_tcpudp_remagic(v4saddr, v4daddr, l3_infrag_payload_len, NEXTHDR_UDP, sum1);
udp->check = sum2;
break;
}
Expand Down

0 comments on commit 9df230a

Please sign in to comment.