Re: in_cksum() for ip packets with multiple mbufs

From: kamal kc (kamal_ckk_at_yahoo.com)
Date: 10/23/05

  • Next message: Giorgos Keramidas: "Re: in_cksum() for ip packets with multiple mbufs"
    Date: Sun, 23 Oct 2005 04:13:33 -0700 (PDT)
    To: Giorgos Keramidas <keramida@freebsd.org>
    
    

    > > i changed the ip_tos field of the struct ip and
    > computed the checksum
    > > by using in_cksum().
    > >
    > > when the packet uses only one mbuf the computed
    > checksum is ok but
    > > when the packet uses more than one mbuf then the
    > computed checksum is
    > > wrong.
    >
    > Note that the IP header contains a checksum of the
    > IP header only.
    >
    > A common mistake is to calculate the checksum of
    > data too, which results
    > in an invalid IP header checksum.

    ok i made this mistake to calculate the checksum
    over the entire IP payload.

    i corrected this and used the ip_hl field :::
       
    /* the argument m is the (struct mbuf *) that
     * contains the packet data
     */

    void copy_the_memorybuffer(struct mbuf **m)
    {
       struct mbuf *mbuf_pointer=*m;
       struct mbuf **next_packet;
        
       next_packet=&mbuf_pointer;

       struct ip *my_ip_hdr;
       my_ip_hdr=mtod((*next_packet),struct ip *);
       my_ip_hdr->ip_tos=64;
       my_ip_hdr->ip_sum=0;
      
       my_ip_hdr->ip_sum=
           in_cksum((*next_packet),(my_ip_hdr->ip_hl<<2));
      .......
    }

    but still it doesn't seem to work. and the problem
    is still there.

    i am really confused ..
     
    > > eg. pinging with payload less than 1470 bytes is
    > ok but with payload
    > > greater than 1480 bytes does not work. (the error
    > being bad checksum
    > > --that i knew by capturing network packets by
    > ethereal)
    > >
    > > is it a real problem or i have made some mistake.
    > >
    > > i put the code before the if_output() in the
    > ip_output() function.
    >
    > Show us the diff, if possible :)

    sorry i did not understand what to show here.
    does it mean to show the packet data captured by
    the ethereal..

    thanks kamal

                    
    __________________________________
    Yahoo! FareChase: Search multiple travel sites in one click.
    http://farechase.yahoo.com
    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"


  • Next message: Giorgos Keramidas: "Re: in_cksum() for ip packets with multiple mbufs"

    Relevant Pages

    • Entirely ignoring TCP and UDP checksum in kernel level
      ... - We have an old network concentrator device in our WAN, ... TCP SYN ACK reply from 192.168.1.1 ... The client from which we send telnet requests to the device gets a packet ... The network concentrator computes the TCP checksum with the source address ...
      (Linux-Kernel)
    • RE: Strange kernel happenings
      ... > packet has arrived intact. ... the ip header check sum covers the ip header only. ... The checksum in the IP header covers the ip header only, ... ICMP has a checksum, which covers the entire ICMP message. ...
      (Incidents)
    • Re: Entirely ignoring TCP and UDP checksum in kernel level
      ... > TCP SYN ACK reply from 192.168.1.1 ... > The client from which we send telnet requests to the device gets a packet ... > The network concentrator computes the TCP checksum with the source address ... > I also investigated terms such as CRC checksum offloading and such, ...
      (Linux-Kernel)
    • Re: Bad TCP checksum error
      ... TCP checksum from scratch, I was just recalculating it by incremental ... model to capture the packet. ... struct in_addr foreign; ...
      (Linux-Kernel)
    • Re: tap interface and locally generated packets
      ... > and packets don't go to the hardware card, but head to the tap ... because physical ethernet card can do ip checksumming, ... the packet hits the bridge ...
      (freebsd-net)