[tproxy] [PATCH] [TPROXY] implemented IP_RECVORIGDSTADDR socket option

Balazs Scheidler bazsi at balabit.hu
Sun Nov 16 18:47:33 CET 2008


On Sun, 2008-11-16 at 17:48 +0200, elyasaf wrote:
> Last week spoofing UDP work fine (before I try UDP patch -
> https://lists.balabit.hu/pipermail/tproxy/2008-November/000999.html)
> But now I get:
> " destination-sendto() error:Invalid argument"
> (I can achieve the source and destination IP for "UDP server")
> I use tproxy 4.1 kernel: 2.6.25
> 
> The code (that work fine before the above patch):
> int fd=socket(AF_INET, SOCK_DGRAM, 0);
> int flags=1;
> if (setsockopt(fd, SOL_IP,  IP_TRANSPARENT, &flags, sizeof(int)) == -1){
> 	perror("destination-setsockopt()  IP_TRANSPARENT error!");
> 	return;
> }else{
> 	printf("destination-setsockopt IP_TRANSPARENT is OK...\n");
> }
> setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags));
> setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &flags, sizeof(flags)); 
> if(bind (fd, (struct sockaddr *) source,sizeof(*source))==-1){
> 	perror("destination-bind() error!");
> 	return;
> }
> flags=0;
> if(sendto(fd,buf,len,flags,
> 	(struct sockaddr *)destination,
> 	sizeof(*destination))==-1){
> 		perror("destination-sendto() error");
> 		return;
> }
> close(fd);
> 
> Any Advice?

I don't see how my patch could cause sendto() to fail. I didn't touch
the sendto() code path. Can you post a strace dump of this code running?

-- 
Bazsi




More information about the tproxy mailing list