LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-13-2014, 05:58 PM   #1
samiller
LQ Newbie
 
Registered: May 2014
Posts: 4

Rep: Reputation: Disabled
PF_RING: packet of length 1518 is too long to send?


As a first step to a more complicated application, I am trying to create a bridge with PF_RING Zero Copy. I am running 64-bit Ubuntu 12.04 on a Core i7, and have an Intel X540 dual-port 10Gbps card which uses the ixgbe driver. I run the code included below to forward from one port to the other. When I run it using the default driver, it works, but I don't get the benefit of a PF_RING-aware driver. When I run with the ixgbe driver built in the PF_RING_aware directory of the PF_RING source, it runs until it tries to send a packet of length 1518, at which point pfring_zc_send_pkt() fails with an EMSGSIZE error ("Message too long"). This despite the fact that the packet buffer size is set to 1600 (MTU+100).

It seems that the source for pfring_zc_send_pkt() is hidden; it is only available in compiled form, so I cannot dig further into how exactly it is determined that the message is "too long."

Does anyone have any suggestions on how to proceed? Any configurations to check?

Code:
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <net/ethernet.h>
#include "pfring.h"
#include "pfring_zc.h"


int main(int argc, char* argv[]) {
	pfring_zc_cluster *cluster;
	int cpu_id;
	static u_int32_t buffer_len = ETHERMTU + 100;
	static u_int32_t queue_len = 1000;
	char *source_dev, *dest_dev;
	pfring_zc_queue *recv_queue, *send_queue;
	pfring_zc_pkt_buff *recv_buff;

	if (argc != 4) {
		printf("USAGE: %s <src> <dest> <cpu_id>\n", argv[0]);
		exit(-1);
	}

	// get device names
	source_dev = argv[1];
	dest_dev = argv[2];

	// get CPU ID
	cpu_id = atoi(argv[3]);

	// create cluster
	cluster = pfring_zc_create_cluster(cpu_id, buffer_len,
		0, queue_len, numa_node_of_cpu(cpu_id), NULL);
	if (cluster == NULL) {
		perror("pfring_zc_create_cluster failed");
		exit(-1);
	}
	recv_buff = pfring_zc_get_packet_handle(cluster);

	// open devices
	recv_queue = pfring_zc_open_device(cluster, source_dev, rx_only, 0);
	if (recv_queue == NULL) {
		perror("pfring_zc_open_device");
		fprintf(stderr, "error opening device %s for receive\n", source_dev);
		exit(-1);
	}
	send_queue = pfring_zc_open_device(cluster, dest_dev, tx_only, 0);
	if (send_queue == NULL) {
		perror("pfring_zc_open_device");
		fprintf(stderr, "error opening device %s for transmit\n", dest_dev);
		exit(-1);
	}

	// forward traffic packet-by-packet
	while (1) {
		static u_int8_t wait_for_packet = 1;
		static u_int8_t flush_packet = 0;

		// receive a packet
		if (pfring_zc_recv_pkt(recv_queue, &recv_buff, wait_for_packet) < 0) {
			perror("error receiving packet");
			exit(-1);
		}

		printf("packet length %d\n", recv_buff->len);

		// send a packet
		if (pfring_zc_send_pkt(send_queue, &recv_buff, flush_packet) < 0) {
			perror("error sending packet");
			exit(-1);
		}
	}

}
 
Old 05-14-2014, 12:10 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,181

Rep: Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272
http://en.wikipedia.org/wiki/Maximum_transmission_unit
 
Old 05-14-2014, 12:15 PM   #3
samiller
LQ Newbie
 
Registered: May 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
Please elaborate. Are you saying that recv_buff->len only counts the payload, not the whole packet? Because MTU only limits the payload size.

Also, the packet of size 1518 was successfully received by PF_RING, so why can't it be sent?

It is worth noting that I have disabled all packet segmentation offloading on the card, so all packets received should be proper ethernet frames.
 
Old 05-14-2014, 05:56 PM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,181

Rep: Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272
Sorry for the short answer. Actually, EMSGSIZE is not a popular error in the kernel. ixgbe generates it only when doing certain ethtool operations, and there are a few places in ipv6 raw, but none jumps out at me. My guess would be pf_ring itself.
 
Old 05-14-2014, 05:59 PM   #5
Lantzvillian
Member
 
Registered: Oct 2007
Location: BC, Canada
Distribution: Fedora, Debian
Posts: 210

Rep: Reputation: 41
I didn't realize pfring could send packets - I thought it was only for capture?
 
Old 05-15-2014, 04:13 PM   #6
samiller
LQ Newbie
 
Registered: May 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Here's an update. I recompiled the ixgbe driver provided with PF_RING, but took out the -DHAVE_PF_RING preprocessor flag in the Makefile. It worked -- no long messages. So the problem is definitely contained in the PF_RING additions. I scanned through the source but didn't find anything obvious. I think I will submit a bug report to ntop.org.
 
Old 05-27-2014, 03:44 PM   #7
samiller
LQ Newbie
 
Registered: May 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
This bug has been fixed in PF_RING revision 7673. The bug report is here, if you have an ntop.org bugzilla account.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pcap only displays the packet length TAN Linux - Networking 2 08-26-2011 11:06 AM
received UDP packet length sasubillis Linux - Software 1 02-12-2010 07:57 AM
packet queue length question vlyamtse Linux - Networking 4 10-08-2009 12:29 AM
Bad Packet Length 1349676916 satishp Linux - Software 1 07-16-2007 12:21 PM
Disconnect: Bad packet length 12030 basbosco Linux - Networking 1 11-05-2003 08:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration