Fossil User Forum

fossil server: Possible regression after recent check-in
Login

fossil server: Possible regression after recent check-in

fossil server: Possible regression after recent check-in

(1) By Peter Laursen (peterml) on 2025-04-15 12:25:03 [source]

Hi, Since check-in src:7ce8400d02, I have experienced some issues when trying to listen on IPv4 addresses on FreeBSD.

While the fix correctly seems to merge IPV4 and IPV6 listening code into one socket, it seems one has not checked the value of the socket option IPV6_V6ONLY. If IPV6_V6ONLY is set to 1, the fix presented in the check-in above results in fossil server listening on IPV6 only. This appears to be FreeBSDs default, while Linux defaults to 0 for that option.

I should also mention that the command line fossil server -P 192.168.0.2:9000 fossil-scm.fossil

fails with the message

"not a valid IP address: 192.168.0.2" after this check-in. This seems to be caused by the switch to IPV6 parsing routines.

Reverting the check-in does (of course) restore the previous behaviour on FreeBSD, but a more future-proof solution may be to check the IPV6_V6ONLY socket option and set it explicitly if its value defers from the value wanted by Fossil.

Let me know if I can provide you with more information or help out in other ways.

All the best,

Peter.

(2) By Richard Hipp (drh) on 2025-04-15 14:16:18 in reply to 1 [link] [source]

Please try again with check-in 2025-04-15T14:13Z or later and let me know whether or not this clears your problem.

(3) By Peter Laursen (peterml) on 2025-04-15 18:41:11 in reply to 2 [link] [source]

Hi Richard, The -P option now once again accepts both IPV4 and IPV6 notation. Thank you for the quick fix.

I still have to modify the socket option mentioned previously to get FreeBSD to listen on both IPV4 and IPV6.

All the best,

Peter.

(4) By Richard Hipp (drh) on 2025-04-15 18:43:26 in reply to 3 [link] [source]

Can you post your patch in a follow-up comment so that I can see it?

(5) By Peter Laursen (peterml) on 2025-04-16 10:02:16 in reply to 4 [link] [source]

Hi Richard,

Here's the patch. I only have access to FreeBSD machines at present; so I haven't tested on Linux.

Note also that you may need to reformat the patch; screen readers make it slightly difficult.

The patch only sets the socket option if its current value is not 0 to match the Linux default.

Patch is made against checkin src:2d3ace5a9f

Index: src/cgi.c
==================================================================
--- src/cgi.c
+++ src/cgi.c
@@ -2625,10 +2625,21 @@
       listener = socket(AF_INET6, SOCK_STREAM, 0);
       if( listener<0 ){
         iPort++;
         continue;
       }
+int ipv6only = -1;
+socklen_t ipv6only_size = sizeof(ipv6only);
+getsockopt(listener, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6only, &ipv6only_size);
+fossil_print("Current value: %d\n", ipv6only);
+/* Match the Linux default */
+if (ipv6only != 0) {
+ipv6only = 0;
+setsockopt(listener, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6only, ipv6only_size);
+fossil_print("Setting IPv6Only to %d\n", ipv6only);
+}
+ 
     }
 
     /* if we can't terminate nicely, at least allow the socket to be reused */
     setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt));
   

Hope this helps,

Peter.