View | Details | Raw Unified | Return to bug 187149 | Differences between
and this patch

Collapse All | Expand All

(-)tools/tools/netmap/pkt-gen.c (-1 / +26 lines)
Lines 174-179 Link Here
174
	int nthreads;
174
	int nthreads;
175
	int cpus;
175
	int cpus;
176
	int options;	/* testing */
176
	int options;	/* testing */
177
	int softchecksum;	/* Software UDP checksum calculation */
177
#define OPT_PREFETCH	1
178
#define OPT_PREFETCH	1
178
#define OPT_ACCESS	2
179
#define OPT_ACCESS	2
179
#define OPT_COPY	4
180
#define OPT_COPY	4
Lines 565-570 Link Here
565
{
566
{
566
	uint32_t a;
567
	uint32_t a;
567
	uint16_t p;
568
	uint16_t p;
569
	struct ether_header *eh = &pkt->eh;
568
	struct ip *ip = &pkt->ip;
570
	struct ip *ip = &pkt->ip;
569
	struct udphdr *udp = &pkt->udp;
571
	struct udphdr *udp = &pkt->udp;
570
572
Lines 611-616 Link Here
611
	ip->ip_dst.s_addr = htonl(g->dst_ip.start);
613
	ip->ip_dst.s_addr = htonl(g->dst_ip.start);
612
    } while (0);
614
    } while (0);
613
    // update checksum
615
    // update checksum
616
	/* Some NIC disable hardware CRC checksum in netmap mode
617
	 * and don't allow to re-enable it */
618
619
	if (g->softchecksum) {
620
		ip->ip_sum = 0;
621
		ip->ip_sum = wrapsum(checksum(ip, sizeof(*ip), 0));
622
		/* UDP checksum */
623
		uint16_t paylen = g->pkt_size - sizeof(*eh) - sizeof(struct ip);
624
		udp->uh_sum = 0;
625
		udp->uh_sum = wrapsum(checksum(udp, sizeof(*udp),
626
			checksum(pkt->body,
627
				paylen - sizeof(*udp),
628
				checksum(&ip->ip_src, 2 * sizeof(ip->ip_src),
629
					IPPROTO_UDP + (u_int32_t)ntohs(udp->uh_ulen)
630
				)
631
			)
632
		));
633
	}
634
614
}
635
}
615
636
616
/*
637
/*
Lines 1409-1414 Link Here
1409
		"\t-X			dump payload\n"
1430
		"\t-X			dump payload\n"
1410
		"\t-H len		add empty virtio-net-header with size 'len'\n"
1431
		"\t-H len		add empty virtio-net-header with size 'len'\n"
1411
	        "\t-P file		load packet from pcap file\n"
1432
	        "\t-P file		load packet from pcap file\n"
1433
		"\t-U			enable software UDP CRC chekcsum\n"
1412
		"\t-z			use random IPv4 src address/port\n"
1434
		"\t-z			use random IPv4 src address/port\n"
1413
		"\t-Z			use random IPv4 dst address/port\n"
1435
		"\t-Z			use random IPv4 dst address/port\n"
1414
		"",
1436
		"",
Lines 1683-1689 Link Here
1683
	g.virt_header = 0;
1705
	g.virt_header = 0;
1684
1706
1685
	while ( (ch = getopt(arc, argv,
1707
	while ( (ch = getopt(arc, argv,
1686
			"a:f:F:n:i:Il:d:s:D:S:b:c:o:p:T:w:WvR:XC:H:e:m:P:zZ")) != -1) {
1708
			"a:f:F:n:i:Il:d:s:D:S:b:c:o:p:T:Uw:WvR:XC:H:e:m:P:zZ")) != -1) {
1687
		struct sf *fn;
1709
		struct sf *fn;
1688
1710
1689
		switch(ch) {
1711
		switch(ch) {
Lines 1785-1790 Link Here
1785
		case 'b':	/* burst */
1807
		case 'b':	/* burst */
1786
			g.burst = atoi(optarg);
1808
			g.burst = atoi(optarg);
1787
			break;
1809
			break;
1810
		case 'U':	/* software UDP checksum */
1811
			g.softchecksum = 1;
1812
			break;
1788
		case 'c':
1813
		case 'c':
1789
			g.cpus = atoi(optarg);
1814
			g.cpus = atoi(optarg);
1790
			break;
1815
			break;

Return to bug 187149