Skip to contentSkip to conversation

make port channel use setsockopt SO_REUSEADDR

PATCH Applied Michael Clark 2 participants 3 messages Jul 6, 2004 – Jul 14, 2004 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make port channel use setsockopt SO_REUSEADDR

Hi All,

Small patch to make port channels allow reuse of local addresses. Useful in the case where you restart a UML from a script and you don't want to have to allocate a new port number each time.

~mc

arch/um/drivers/port_user.c renamed from arch/um/drivers/port_user.c.orig +5 -1
@@ -118,12 +118,16 @@
 int port_listen_fd(int port)
 {
 	struct sockaddr_in addr;
-	int fd, err;
+	int fd, err, arg;
 
 	fd = socket(PF_INET, SOCK_STREAM, 0);
 	if(fd == -1) 
 		return(-errno);
 
+	arg = 1;
+	if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0)
+		return(-errno);
+
 	addr.sin_family = AF_INET;
 	addr.sin_port = htons(port);
 	addr.sin_addr.s_addr = htonl(INADDR_ANY);
Applied
#1 lore raw
Quoted 3 lines · [email protected] said:

Small patch to make port channels allow reuse of local addresses. Useful in the case where you restart a UML from a script and you don't want to have to allocate a new port number each time.

Applied, except I fixed the error case slightly.

Jeff

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#2 lore raw
Quoted 8 lines · Jeff Dike
Quoted 3 lines · [email protected] said:

Small patch to make port channels allow reuse of local addresses. Useful in the case where you restart a UML from a script and you don't want to have to allocate a new port number each time.

Applied, except I fixed the error case slightly.

Ooops, yes, my bad. leaking fd.

Thanks,
~mc

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel