Skip to contentSkip to conversation

src: Fix IPv4 checksum calculation in AF_BRIDGE packet buffer

PATCH Superseded Duncan Roe 2 participants 3 messages Nov 16, 2019 – Nov 21, 2019 netfilter

lore
Share & tools
lore

Duncan Roe

author
#0 lore raw

PATCH 1/1 src: Fix IPv4 checksum calculation in AF_BRIDGE packet buffer

Updated:

src/extra/pktbuff.c If pktb was created in family AF_BRIDGE, then pktb->len
will include the bytes in the network header. So set the IPv4 length to "tail - network_header" rather than len

---
 src/extra/ipv4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/extra/ipv4.c +1 -1
index 0227b62..1b0f96b 100644
@@ -117,7 +117,7 @@ int nfq_ip_mangle(struct pkt_buff *pktb, unsigned int dataoff,
 		return 0;
 
 	/* fix IP hdr checksum information */
-	iph->tot_len = htons(pktb->len);
+	iph->tot_len = htons(pktb->tail -pktb->network_header);
 	nfq_ip_set_checksum(iph);
 
 	return 1;
Signature · 1 line
2.14.5
author
#1 lore raw

PATCH v2 1/1 src: Fix IPv4 checksum calculation in AF_BRIDGE packet buffer

Updated:

src/extra/pktbuff.c: If pktb was created in family AF_BRIDGE, then pktb->len
will include the bytes in the network header. So set the IPv4 length to "tail - network_header" rather than len

---
v2: fix whitespace

 src/extra/ipv4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/extra/ipv4.c +1 -1
index 0227b62..c03f23f 100644
@@ -117,7 +117,7 @@ int nfq_ip_mangle(struct pkt_buff *pktb, unsigned int dataoff,
 		return 0;
 
 	/* fix IP hdr checksum information */
-	iph->tot_len = htons(pktb->len);
+	iph->tot_len = htons(pktb->tail - pktb->network_header);
 	nfq_ip_set_checksum(iph);
 
 	return 1;
Signature · 1 line
2.14.5
maintainer Applied
#2 lore raw
Quoted 6 lines · Duncan Roe

Updated:

src/extra/pktbuff.c: If pktb was created in family AF_BRIDGE, then pktb->len
will include the bytes in the network header. So set the IPv4 length to "tail - network_header" rather than len

Applied, thanks.