unused in_cksum_update() ?

Luigi Rizzo rizzo at iet.unipi.it
Thu Jan 9 21:40:56 UTC 2014


On Thu, Jan 09, 2014 at 01:27:52PM -0800, Adrian Chadd wrote:
> It's likely used elsewhere; it's the kind of thing you abuse when
> doing header rewriting and reinjection. So, what's the NAT and such
> code using?

natd/libalias has its own code with a DifferentialChecksum() function
in sys/netinet/libalias/alias_util.c which adds and subtracts
the chunks in the old and new packet.

ip_fastfwd.c does it inline:

        /*
         * Decrement the TTL and incrementally change the IP header checksum.
         * Don't bother doing this with hw checksum offloading, it's faster
         * doing it right here.
         */
        ip->ip_ttl -= IPTTLDEC;
        if (ip->ip_sum >= (u_int16_t) ~htons(IPTTLDEC << 8))
                ip->ip_sum -= ~htons(IPTTLDEC << 8);
        else
                ip->ip_sum += htons(IPTTLDEC << 8);


ip_forward() relies on the recomputation done in ip_output().

And there is no trace of in_cksum_update() in the entire source
tree apart from its definition.

cheers
luigi


More information about the freebsd-current mailing list