xt_RAWNAT: skb writable part might not include whole L4 header (IPv4 case)

Consider TCP/IPv4 packet with IP options: sizeof(*iph) + sizeof(struct
tcphdr) is not enough to include tcp checksum. It may hurt if this
packet is fragmented.

Therefore, we should use iph->ihl * 4 instead of sizeof(*iph).

Signed-off-by: Dmitry Popov <dp@highloadlab.com>
This commit is contained in:
Dmitry Popov
2013-05-05 20:05:04 +02:00
committed by Jan Engelhardt
parent 3f04148501
commit b70905e7cb
2 changed files with 3 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
HEAD
====
Fixes:
- xt_RAWNAT: ensure correct operation in the presence of IPv4 options
v2.2 (2013-03-31)

View File

@@ -109,7 +109,7 @@ static void rawnat4_update_l4(struct sk_buff *skb, __be32 oldip, __be32 newip)
static unsigned int rawnat4_writable_part(const struct iphdr *iph)
{
unsigned int wlen = sizeof(*iph);
unsigned int wlen = iph->ihl * 4;
switch (iph->protocol) {
case IPPROTO_TCP: