Re: Help about ip_filter, check sum always wrong
Re: Help about ip_filter, check sum always wrong
- Subject: Re: Help about ip_filter, check sum always wrong
- From: Peter Sichel <email@hidden>
- Date: Sun, 2 Aug 2009 14:09:37 -0400
On Aug 2, 2009, at 6:22 AM, Jan Deng wrote:
I have a emergency problem.
This solution works fine on most platform. But recently, I tried PPC
G4 with 10.5.7. The connection always be reset by client( such as
browser ).
From TCP dump, I can see the TCP checksum of packet from local proxy
to client( browser ) is aways wrong with number 0xb5d0.
Some machines do hardware checksum computation in the device driver,
so for outbound packets, it is important that you "finalize" the mbuf
before you attempt to modify it.
For inbound packets, the ip input processing may believe the driver
has computed the checksum based on the mbuf flags.
The whole sequence looks something like this:
if (packet->direction == kDirectionInbound) {
mbuf_inbound_modified(mbuf_ref); // mbuf->m_pkthdr.csum_flags = 0;
mbuf_clear_csum_requested(mbuf_ref); // mbuf->m_pkthdr.csum_data = 0;
}
else {
// Convert header fields back to network byte order for
mbuf_outbound_finalize checksum computation
KFT_htonPacket(packet, kOptionFinalize);
mbuf_outbound_finalize(mbuf_ref, AF_INET, packet->ipOffset);
// might have done m_pullup
packet->datagram = (u_int8_t*)mbuf_data(*packet->mbuf_ptr);
packet->datagram = &packet->datagram[packet->ipOffset];
// clear csum flags
mbuf_inbound_modified(mbuf_ref); // mbuf->m_pkthdr.csum_flags = 0;
mbuf_clear_csum_requested(mbuf_ref); // mbuf->m_pkthdr.csum_data = 0;
// Convert header fields back to host byte order for further
processing
KFT_ntohPacket(packet, kOptionFinalize);
I hope this helps.
- Peter Sichel
Sustainable Softworks
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden