Skip to content

Commit

Permalink
nat46-core: ignore IPv4 options when translating packets
Browse files Browse the repository at this point in the history
If any IPv4 options are present in the IPv4 packet, they MUST be
ignored and the packet translated normally; there is no attempt to
translate the options.    -RFC 7915 Section 4.1
  • Loading branch information
angus19 authored and ayourtch committed Apr 7, 2022
1 parent 39778c2 commit 95ca1c3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nat46/modules/nat46-core.c
Expand Up @@ -1833,9 +1833,9 @@ void nat46_ipv4_input(struct sk_buff *old_skb) {
#endif

/* expand header (add 20 extra bytes at the beginning of sk_buff) */
pskb_expand_head(new_skb, IPV6V4HDRDELTA + (add_frag_header?8:0), 0, GFP_ATOMIC);
pskb_expand_head(new_skb, IPV6HDRSIZE - (hdr4->ihl << 2) + (add_frag_header?8:0), 0, GFP_ATOMIC);

skb_push(new_skb, IPV6V4HDRDELTA + (add_frag_header?8:0)); /* push boundary by extra 20 bytes */
skb_push(new_skb, IPV6HDRSIZE - (hdr4->ihl << 2) + (add_frag_header?8:0)); /* push boundary by extra 20 bytes */

skb_reset_network_header(new_skb);
skb_set_transport_header(new_skb, IPV6HDRSIZE + (add_frag_header?8:0) ); /* transport (TCP/UDP/ICMP/...) header starts after 40 bytes */
Expand All @@ -1848,7 +1848,7 @@ void nat46_ipv4_input(struct sk_buff *old_skb) {
*(__be32 *)hdr6 = htonl(0x60000000 | (tclass << 20)) | flowlabel; /* version, priority, flowlabel */

/* IPv6 length is a payload length, IPv4 is hdr+payload */
hdr6->payload_len = htons(ntohs(hdr4->tot_len) - sizeof(struct iphdr) + (add_frag_header?8:0));
hdr6->payload_len = htons(ntohs(hdr4->tot_len) - (hdr4->ihl << 2) + (add_frag_header?8:0));
hdr6->nexthdr = hdr4->protocol;
hdr6->hop_limit = hdr4->ttl;
memcpy(&hdr6->saddr, v6saddr, 16);
Expand Down

0 comments on commit 95ca1c3

Please sign in to comment.