Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jan 2001 22:59:27 -0500 (EST)
From:      Alwyn Goodloe <agoodloe@gradient.cis.upenn.edu>
To:        hackers@FreeBSD.org
Subject:   Divert Sockets & Fragmentation revisited
Message-ID:  <Pine.SOL.4.21.0101252258280.9067-100000@gradient.cis.upenn.edu>

next in thread | raw e-mail | index | archive | help
  Guys still having problems with divert sockets and fragmentation. 

As I said in a previous post the divert operations and corresponding program
work fine when the datagram  sent have size < MTU (1500) but when the
datagram has size > MTU and hence get fragmented the recfrom just
waits never receiving anything.  I am attaching the relevent code
fragments below.

  tcpdump tells me that the packets arrive on the interface.
Hence I know the fragments arrive.

  Now my ipfw commands are:

ipfw add 60000 divert 4422 udp from any  to any 3322  in
ipfw add 65000 allow ip from any to any 

  Now I thought that that maybe the divert being so specific was
a problem so I tried flushing ipfw and using the command:
  ipfw add 60000 divert  4422 ip from any to any 

thus diverting any ip packets and still nothing.

 
Now according to the man page on divert:

  Incomming packets which get diverted are fully reassembled before
  delivery of any one fragment. Diversion of any one packet causes
  the entire packet to get diverted. I different fragments get 
  diverted to different ports, then which port ultimately gets
  diverted is unpredictable.

  
I was under the impression that the packets wern't reassemblembed before
diversion. Am I wrong here?

If the packets are reassembled before the diversion but as it says about
that it may be unpredictable as to where they are sent could explain the
case where I was redirecting udp packets heading toward 3322 but not the 
case where I was redirecting all IP packets. 


  Any suggestions as to what stupid thing I have failed to do here.


Alwyn Goodloe


agoodloe@gradient.cis.upenn.edu


Here is the important code fragments:

Note: I have played with the MAX_PACKET_SIZE in hopes that it would make some 
difference but to no avail.

#define MAX_PACKET_SIZE  300000
#define DIVERTPort  4422
#define ACTIVE_UDP_PORT 3322


if ((divert_sock = socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT)) < 0)  
   sys_error("divert socket error");   
 set_sock_data(&server_divert,PF_INET,DIVERTPort,INADDR_ANY); 
 printf("Step 1  \n");    /* Register address and port with the system */ 
 if (bind(divert_sock, (struct sockaddr*) &server_divert,sizeof(server_divert)) < 0)   
    sys_error("server_divert bind error");  
for ( ; ; ) {  

    n = recvfrom (divert_sock,encaped_pkt,MAX_PACKET_SIZE,0,
		  ( struct sockaddr * ) &client_add,&clilen); 
  



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.4.21.0101252258280.9067-100000>