Repository: syncthing/syncthing (language: go)

Issue:
"accept: function not implemented" after upgrading to syncthing v1.20.1
**Environment**
Syncthing v1.20.1 running on Synology DSM 6.2 using the `syncthing-linux-arm-v1.20.1.tar.gz` release

**Issue**
Syncthing is failing to accept any new connections on either the GUI/API port or the QUIC listener port after upgrading from 1.19.2 to 1.20.1

Here's my log file

```
[start] 2022/05/04 18:15:17 INFO: syncthing v1.20.1 "Fermium Flea" (go1.18.1 linux-arm) teamcity@build.syncthing.net 2022-05-04 16:17:03 UTC
[6NNOL] 2022/05/04 18:15:18 INFO: My ID: XXXXX
[6NNOL] 2022/05/04 18:15:19 INFO: Single thread SHA256 performance is 9.3 MB/s using minio/sha256-simd (9.2 MB/s using crypto/sha256).
[6NNOL] 2022/05/04 18:15:20 INFO: Hashing performance is 8.55 MB/s
[6NNOL] 2022/05/04 18:15:20 INFO: Detected upgrade from v1.19.2 to v1.20.1
[6NNOL] 2022/05/04 18:15:20 INFO: Overall send rate is unlimited, receive rate is unlimited
[6NNOL] 2022/05/04 18:15:20 INFO: Ready to synchronize "/etc/pve" (5ujtg-5xcfw) (receiveonly)
[6NNOL] 2022/05/04 18:15:20 INFO: TCP listener ([::]:22000) starting
[6NNOL] 2022/05/04 18:15:20 WARNING: Listen (BEP/tcp): Accepting connection: accept tcp [::]:22000: accept: function not implemented
2022/05/04 18:15:20 failed to sufficiently increase receive buffer size (was: 112 kiB, wanted: 2048 kiB, got: 224 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
[6NNOL] 2022/05/04 18:15:20 INFO: QUIC listener ([::]:22000) starting
[6NNOL] 2022/05/04 18:15:20 INFO: GUI and API listening on [::]:8384
[6NNOL] 2022/05/04 18:15:20 INFO: Access the GUI via the following URL: https://127.0.0.1:8384/
[6NNOL] 2022/05/04 18:15:20 WARNING: GUI/API: accept tcp [::]:8384: accept: function not implemented (restarting)
[6NNOL] 2022/05/04 18:15:20 INFO: GUI and API listening on [::]:8384
[6NNOL] 2022/05/04 18:15:20 INFO: Access the GUI via the following URL: https://127.0.0.1:8384/
[6NNOL] 2022/05/04 18:15:20 WARNING: GUI/API: accept tcp [::]:8384: accept: function not implemented (restarting)
[6NNOL] 2022/05/04 18:15:20 INFO: My name is "synology-disk-station-ds209"
[6NNOL] 2022/05/04 18:15:20 INFO: Device C45CR23-DCBR2FO-ZKKBJPX-IXO5X64-TBL5P3X-QKEI3QG-IMBYISB-VSXOHAY is "XXX" at [tcp://XXX:22000]
[6NNOL] 2022/05/04 18:15:20 INFO: GUI and API listening on [::]:8384
[6NNOL] 2022/05/04 18:15:20 INFO: Access the GUI via the following URL: https://127.0.0.1:8384/
[6NNOL] 2022/05/04 18:15:20 WARNING: GUI/API: accept tcp [::]:8384: accept: function not implemented (restarting)
[6NNOL] 2022/05/04 18:15:20 INFO: GUI and API listening on [::]:8384
[6NNOL] 2022/05/04 18:15:20 INFO: Access the GUI via the following URL: https://127.0.0.1:8384/
[6NNOL] 2022/05/04 18:15:20 WARNING: GUI/API: accept tcp [::]:8384: accept: function not implemented (restarting)
[6NNOL] 2022/05/04 18:15:20 INFO: GUI and API listening on [::]:8384
[6NNOL] 2022/05/04 18:15:20 INFO: Access the GUI via the following URL: https://127.0.0.1:8384/
[6NNOL] 2022/05/04 18:15:20 WARNING: GUI/API: accept tcp [::]:8384: accept: function not implemented (restarting)
[6NNOL] 2022/05/04 18:15:20 INFO: GUI and API listening on [::]:8384
[6NNOL] 2022/05/04 18:15:20 INFO: Access the GUI via the following URL: https://127.0.0.1:8384/
[6NNOL] 2022/05/04 18:15:20 WARNING: GUI/API: accept tcp [::]:8384: accept: function not implemented (restarting)
[6NNOL] 2022/05/04 18:15:20 INFO: Completed initial scan of receiveonly folder "/etc/pve" (5ujtg-5xcfw)
[6NNOL] 2022/05/04 18:15:21 WARNING: Listen (BEP/tcp): Accepting connection: accept tcp [::]:22000: accept: function not implemented
[6NNOL] 2022/05/04 18:15:23 WARNING: Listen (BEP/tcp): Accepting connection: accept tcp [::]:22000: accept: function not implemented
[6NNOL] 2022/05/04 18:15:26 WARNING: Listen (BEP/tcp): Accepting connection: accept tcp [::]:22000: accept: function not implemented
[6NNOL] 2022/05/04 18:15:30 WARNING: Listen (BEP/tcp): Accepting connection: accept tcp [::]:22000: accept: function not implemented
[6NNOL] 2022/05/04 18:15:35 WARNING: Listen (BEP/tcp): Accepting connection: accept tcp [::]:22000: accept: function not implemented
```

**Workaround** 
I've reverted back to v1.19.2


Discussion / hints:
Which Synology model is this? How did you install Syncthing? Are you sure you have the correct CPU architecture? 
Looks like Go previously tried `accept4()` and fell back to plain `accept()` on `ENOSYS`, while it now just does `accept4()`.

> The accept4() system call is available starting with Linux 2.6.28; support in glibc is available starting with version 2.10.

(https://linux.die.net/man/2/accept4)

How old is the stuff on "DSM 6.2"? And, as acolomb hints to, are you sure you don't want the arm64 variant?
```
Linux restbox 4.4.59+ #25556 SMP Sat Aug 28 02:14:55 CST 2021 aarch64 GNU/Linux synology_rtd1296_ds418j
lrwxrwxrwx 1 root root 20 Apr  8  2021 /usr/lib/libc.so.6 -> libc-2.20-2014.11.so*
```

Taken from my DS418j with DSM 6.2.4-25556 Update 5.  Which is running v1.20.1 (from SynoCommunity) just fine and connected to other devices.
It's a DS209 (Quite old). It's a 32bit architecture CPU. Syncthing has been working great for a long time and only started having issues with v1.20.1

I installed Syncthing as follows

```
wget https://github.com/syncthing/syncthing/releases/download/v1.20.1/syncthing-linux-arm-v1.20.1.tar.gz
tar -xzvf syncthing-linux-arm-v1.20.1.tar.gz
cp syncthing-linux-arm-v1.19.0/syncthing /opt/bin/.
```

I use the following startup script

```
#! /bin/sh


case "$1" in
start)
    echo "Starting Syncthing."
    su syncthing -c "nohup /opt/bin/syncthing > /dev/null 2>&1 &"
    ;;
stop)
    echo "Shutting down Syncthing."
    su syncthing -c "/opt/bin/syncthing cli operations shutdown > /dev/null 2>&1"
    ;;
*)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac

exit

```

Additional details that might be helpful

```
[root][synology-ds209][~]
[12:37:43]bsh ❯uname -a
Linux synology-ds209 2.6.32.12 #25556 Thu Jul 1 14:25:48 CST 2021 armv5tel GNU/Linux synology_88f6281_211j
```

```
[root][synology-ds209][~]
[12:37:43]bsh ❯ls -al /usr/lib/libc.so.6
lrwxrwxrwx 1 root root 12 Sep  2  2002 /usr/lib/libc.so.6 -> libc-2.15.so
```

```
[root][synology-ds209][~]
[12:40:52]bsh ❯ more /proc/cpuinfo
Processor	: Feroceon 88FR131 rev 1 (v5l)
BogoMIPS	: 1192.75
Features	: swp half thumb fastmult edsp
CPU implementer	: 0x56
CPU architecture: 5TE
CPU variant	: 0x2
CPU part	: 0x131
CPU revision	: 1

Hardware	: Feroceon-KW
Revision	: 0000
Serial		: 0000000000000000
```
Did some more digging, it seems `accept4` for ARM was added in 2.6.36.

Since my Synology is no longer receiving DSM updates I guess I'm out of luck unless I decide to cross compile Syncthing using an older version of Go that still had the fallback logic.
Or stay on the previously working v1.19.2 binary. That should stay compatible with newer Syncthing nodes for the foreseeable future.

Anyway, not a bug, hence closing. Feel free to follow up on the forum. 
Hi
Install v1.19.2, when installing uncheck box "Run after install"
edit /volume1/@appstore/syncthing/var/options.conf and add no-upgrade options
SYNCTHING_OPTIONS="--no-upgrade"
  
same issue. pinning mine to v 1.19.2 unless solved. :(
410j DSM5
This is now fixed upstream in Go; see https://github.com/golang/go/issues/57333

It was backported to Go 1.18.x and Go 1.19.x branches (so will be in Go 1.18.10 or Go 1.19.5), and will be included in the upcoming Go 1.20 release in a couple months.

syncthing v1.23.0 released today. Does it contain this fix?
Go 1.19.5 isn't released yet, so no.

Fix patch:
diff --git a/.github/workflows/build-syncthing.yaml b/.github/workflows/build-syncthing.yaml
index 94bb32b7118..e27fe8846ed 100644
--- a/.github/workflows/build-syncthing.yaml
+++ b/.github/workflows/build-syncthing.yaml
@@ -6,7 +6,7 @@ on:
 
 env:
   # The go version to use for builds.
-  GO_VERSION: "1.19.4"
+  GO_VERSION: "1.19.5"
 
   # Optimize compatibility on the slow archictures.
   GO386: softfloat


Test patch: