netback.c (89e0f4d24c4a430a0893930e4400ff6a63e63864) netback.c (2f4afd21257ea1672763722dae9109bbaced5548)
1/*
2 * Copyright (c) 2006, Cisco Systems, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 16 unchanged lines hidden (view full) ---

25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD$");
1/*
2 * Copyright (c) 2006, Cisco Systems, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 16 unchanged lines hidden (view full) ---

25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD$");
33#include "opt_sctp.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/sockio.h>
37#include <sys/mbuf.h>
38#include <sys/malloc.h>
39#include <sys/kernel.h>
40#include <sys/socket.h>

--- 11 unchanged lines hidden (view full) ---

52#include <net/if_bridgevar.h>
53
54#include <netinet/in_systm.h>
55#include <netinet/in.h>
56#include <netinet/in_var.h>
57#include <netinet/ip.h>
58#include <netinet/tcp.h>
59#include <netinet/udp.h>
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/sockio.h>
38#include <sys/mbuf.h>
39#include <sys/malloc.h>
40#include <sys/kernel.h>
41#include <sys/socket.h>

--- 11 unchanged lines hidden (view full) ---

53#include <net/if_bridgevar.h>
54
55#include <netinet/in_systm.h>
56#include <netinet/in.h>
57#include <netinet/in_var.h>
58#include <netinet/ip.h>
59#include <netinet/tcp.h>
60#include <netinet/udp.h>
61#ifdef SCTP
62#include <netinet/sctp.h>
63#include <netinet/sctp_crc32.h>
64#endif
60
61#include <vm/vm_extern.h>
62#include <vm/vm_kern.h>
63
64#include <machine/in_cksum.h>
65#include <machine/xen-os.h>
66#include <machine/hypervisor.h>
67#include <machine/hypervisor-ifs.h>

--- 222 unchanged lines hidden (view full) ---

290 int iplen = ntohs(ip->ip_len);
291
292 if ((m->m_pkthdr.csum_flags & CSUM_TCP)) {
293 struct tcphdr *th = (struct tcphdr *)((caddr_t)ip + iphlen);
294 th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
295 htons(IPPROTO_TCP + (iplen - iphlen)));
296 th->th_sum = in_cksum_skip(m, iplen + sizeof(*eh), sizeof(*eh) + iphlen);
297 m->m_pkthdr.csum_flags &= ~CSUM_TCP;
65
66#include <vm/vm_extern.h>
67#include <vm/vm_kern.h>
68
69#include <machine/in_cksum.h>
70#include <machine/xen-os.h>
71#include <machine/hypervisor.h>
72#include <machine/hypervisor-ifs.h>

--- 222 unchanged lines hidden (view full) ---

295 int iplen = ntohs(ip->ip_len);
296
297 if ((m->m_pkthdr.csum_flags & CSUM_TCP)) {
298 struct tcphdr *th = (struct tcphdr *)((caddr_t)ip + iphlen);
299 th->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
300 htons(IPPROTO_TCP + (iplen - iphlen)));
301 th->th_sum = in_cksum_skip(m, iplen + sizeof(*eh), sizeof(*eh) + iphlen);
302 m->m_pkthdr.csum_flags &= ~CSUM_TCP;
303#ifdef SCTP
304 } else if (sw_csum & CSUM_SCTP) {
305 sctp_delayed_cksum(m);
306 sw_csum &= ~CSUM_SCTP;
307#endif
298 } else {
299 u_short csum;
300 struct udphdr *uh = (struct udphdr *)((caddr_t)ip + iphlen);
301 uh->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
302 htons(IPPROTO_UDP + (iplen - iphlen)));
303 if ((csum = in_cksum_skip(m, iplen + sizeof(*eh), sizeof(*eh) + iphlen)) == 0)
304 csum = 0xffff;
305 uh->uh_sum = csum;

--- 597 unchanged lines hidden (view full) ---

903 old_mfn = vtomach(vdata) >> PAGE_SHIFT;
904
905 if ((new_mfn = alloc_mfn()) == 0)
906 goto drop;
907
908#ifdef XEN_NETBACK_FIXUP_CSUM
909 /* Check if we need to compute a checksum. This happens */
910 /* when bridging from one domain to another. */
308 } else {
309 u_short csum;
310 struct udphdr *uh = (struct udphdr *)((caddr_t)ip + iphlen);
311 uh->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
312 htons(IPPROTO_UDP + (iplen - iphlen)));
313 if ((csum = in_cksum_skip(m, iplen + sizeof(*eh), sizeof(*eh) + iphlen)) == 0)
314 csum = 0xffff;
315 uh->uh_sum = csum;

--- 597 unchanged lines hidden (view full) ---

913 old_mfn = vtomach(vdata) >> PAGE_SHIFT;
914
915 if ((new_mfn = alloc_mfn()) == 0)
916 goto drop;
917
918#ifdef XEN_NETBACK_FIXUP_CSUM
919 /* Check if we need to compute a checksum. This happens */
920 /* when bridging from one domain to another. */
911 if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA))
921 if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) ||
922 (m->m_pkthdr.csum_flags & CSUM_SCTP))
912 fixup_checksum(m);
913#endif
914
915 xen_phys_machine[(vtophys(vdata) >> PAGE_SHIFT)] = new_mfn;
916
917 mcl->op = __HYPERVISOR_update_va_mapping;
918 mcl->args[0] = vdata;
919 mcl->args[1] = (new_mfn << PAGE_SHIFT) | PG_V | PG_RW | PG_M | PG_A;

--- 666 unchanged lines hidden ---
923 fixup_checksum(m);
924#endif
925
926 xen_phys_machine[(vtophys(vdata) >> PAGE_SHIFT)] = new_mfn;
927
928 mcl->op = __HYPERVISOR_update_va_mapping;
929 mcl->args[0] = vdata;
930 mcl->args[1] = (new_mfn << PAGE_SHIFT) | PG_V | PG_RW | PG_M | PG_A;

--- 666 unchanged lines hidden ---