Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Nov 2015 11:00:57 -0500
From:      Larry Baird <lab@gta.com>
To:        Roger Pau Monn?? <roger.pau@citrix.com>
Cc:        freebsd-xen@freebsd.org, alans@spectralogic.com, johns@spectralogic.com, ken@FreeBSD.org
Subject:   Re: Checksum forwarding issue on XEN
Message-ID:  <20151105160057.GA2268@gta.com>
In-Reply-To: <563B72B2.6060308@citrix.com>
References:  <20151103201250.GA92469@gta.com> <563B72B2.6060308@citrix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Roger,

> Adding the persons that contributed that code in case they can shed some
> light.
> 
> El 03/11/15 a les 21.12, Larry Baird ha escrit:
> > Has anybody made any progress on "Bug 188261 - [xen] FreeBSD DomU PVHVM
> > guests cannot 'route' traffic for other Xen PV guests on same Dom0 Host."
> > (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=188261)?
> >
> > The code for checksum calculation in the function xnb_add_mbuf_cksum() looks
> > suspect.
> > 
> >         switch (iph->ip_p) {
> >         case IPPROTO_TCP:
> >                 if (mbufc->m_pkthdr.csum_flags & CSUM_IP_VALID) {
> >                         size_t tcplen = ntohs(iph->ip_len) - sizeof(struct ip);
> >                         struct tcphdr *th = (struct tcphdr*)(iph + 1);
> >                         th->th_sum = in_pseudo(iph->ip_src.s_addr,
> >                             iph->ip_dst.s_addr, htons(IPPROTO_TCP + tcplen));
> >                         th->th_sum = in_cksum_skip(mbufc,
> >                             sizeof(struct ether_header) + ntohs(iph->ip_len),
> >                             sizeof(struct ether_header) + (iph->ip_hl << 2));
> >                 }
> >                 break;
> >         case IPPROTO_UDP:
> >                 if (mbufc->m_pkthdr.csum_flags & CSUM_IP_VALID) {
> >                         size_t udplen = ntohs(iph->ip_len) - sizeof(struct ip);
> >                         struct udphdr *uh = (struct udphdr*)(iph + 1);
> >                         uh->uh_sum = in_pseudo(iph->ip_src.s_addr,
> >                             iph->ip_dst.s_addr, htons(IPPROTO_UDP + udplen));
> >                         uh->uh_sum = in_cksum_skip(mbufc,
> >                             sizeof(struct ether_header) + ntohs(iph->ip_len),
> >                             sizeof(struct ether_header) + (iph->ip_hl << 2));
> >                 }
> >                 break;
> >         default:
> >                 break;
> >         }
> > 
> > 
> > Both in_pseudo() and in_cksum_skip() set the same checksum. Does this
> > make since to anybody?
> 
> The bug you are referring to affects FreeBSD when running as a guest
> using xen-netfront, but the code snipped above and the function
> referenced (xnb_add_mbuf_cksum) is only used on FreeBSD when running as
> a host (AKA Dom0) by xen-netback.
> 
> TBH, I don't know that much about FreeBSD network subsystem to have an
> opinion, but it certainly looks weird. Patches are welcome :).

Xyper-V has a similar forward issue. I found they were misusing csum_flags
and were always attempting to do checksum offloading if CSUM_IP_VALID was
set. I have given them a patch that fixes the issue. I was hoping that
Xen's issue was similar.  I found the issue above by looking at all uses
of csum_flags in sys/dev/xen. It is hard to tell what the correct fix
is, without fulling understand the protocal used when communicating between
backend and frontend of Xen. 

I am sure issue with XEN guest forwarding has to with checksum offloading.
If I am not misinterpreting your comments, I can ignore code in netback and
concentrate on code in netfront when trying to understand what is going wrong.

Thank you for some insite,
Larry


-- 
------------------------------------------------------------------------
Larry Baird
Global Technology Associates, Inc. 1992-2012 	| http://www.gta.com
Celebrating Twenty Years of Software Innovation | Orlando, FL
Email: lab@gta.com                 		| TEL 407-380-0220



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20151105160057.GA2268>