Re: Transparent IPv6 proxying on OpenBSD

From: Marios Makassikis <mmakassikis_at_gmail.com>
Date: Thu, 8 Mar 2012 15:28:30 +0100

> Are you able to add IPv4 tests to that probe function and see if it
> works on IPv4-only ports?
> I'm happy to accept the patch, but would ideally like something that
> covers IPv4 as well.

The code below tests for IPv4 support. Unfortunately, I can't thoroughly
test it right away to see if it works as expected. The code compiles,
and it doesn't produce any errors at runtime.
The same problem that occurs with bridging on IPv6 must be occurring
on IPv4 as I had the same symptoms as in the first post during a quick
test. I'd have to remove the bridge and retest but I can't do that right away.

This can be annoying, as the bridge is no longer a bridge, but I suppose
it can still be useful in case you want to avoid NATing (assuming you can
do that too - lucky you).

--
Marios
+    if (test.IsIPv4()) {
+        debugs(3, 3, "...Probing for IPv4 SO_BINDANY support.");
+
+        struct sockaddr_in tmp_ipv4;
+        Ip::Address tmp = "127.0.0.2";
+        tmp.SetPort(0);
+        tmp.GetSockAddr(tmp_ipv4);
+
+        enter_suid();
+        if ((tmp_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) >=0 &&
+            (setsockopt(tmp_sock, SOL_SOCKET, SO_BINDANY, (char *)&tos,
+                       sizeof(tos)) == 0) &&
+            (bind(tmp_sock, (struct sockaddr*)&tmp_ipv4,
sizeof(struct sockaddr_in)) == 0)) {
+            leave_suid();
+            debugs(3, 3, "IPv4 BINDANY support detected. Using.");
+            close(tmp_sock);
+            return true;
+        }
+    }
Received on Thu Mar 08 2012 - 14:28:39 MST

This archive was generated by hypermail 2.2.0 : Thu Mar 08 2012 - 12:00:06 MST