Bug 274618 - if_wg sometimes configured badly and then sent IPv4 packets with src=0.0.0.0
Summary: if_wg sometimes configured badly and then sent IPv4 packets with src=0.0.0.0
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.2-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-net (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-21 00:00 UTC by vova
Modified: 2024-01-30 08:55 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vova 2023-10-21 00:00:03 UTC
13.2-RELEASE-p4

# ifconfig wg0
wg0: flags=80c1<UP,RUNNING,NOARP,MULTICAST> metric 0 mtu 1420
 options=80000<LINKSTATE>
 inet 172.16.1.254 netmask 0xffffffff
 groups: wg
 nd6 options=109<PERFORMNUD,IFDISABLED,NO_DAD>

# wg show
interface: wg0
  public key: ...
  private key: (hidden)
  listening port: 31766

peer: ...
  endpoint: 178.213.227.68:51111
  allowed ips: 172.16.1.0/24
  latest handshake: 17 minutes, 14 seconds ago
  transfer: 851 B received, 908 B sent

# route -n get 172.16.1.192
   route to: 172.16.1.192
destination: 172.16.1.0
       mask: 255.255.255.0
        fib: 0
  interface: wg0
      flags: <UP,DONE,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1420         1         0

Packets originating on WG interface without bind(2) looks ackward - src_ip=0.0.0.0

TCP: 
21:08:43.884120 IP 0.0.0.0.37253 > 172.16.1.192.22: Flags [S], seq 1046603187, win 65535, options [mss 1380,nop,wscale 6,sackOK,TS val 3939364738 ecr 0], length 0

ICMP:
21:03:04.934286 IP 0.0.0.0 > 172.16.1.192: ICMP echo request, id 17204, seq 8, length 64

if, source address fixed with bind(2) (i.e. ping -S 172.16.1.254 ...) - everything gets fine

problem appears just after reboot, to fix it is enough to restart wireguard:
service wireguard restart

problem does not appear if use wireguard-kmod-0.0.20220615_1

problem appears not every boot so, aproxymately - one of two or one of 4 boots - everything fine
preloading any modules from boot/loader does not change situation
Comment 1 Franco Fichtner 2023-10-21 06:09:55 UTC
This commonly happens when you force an interface route without having an IP assigned first. It might even persist when you add the interface address later on.

Seen this multiple times on FreeBSD 13 over the last two years.


Cheers,
Franco
Comment 2 vova 2023-10-22 16:05:27 UTC
Script which starts wg0 intrface is standard from wireguard-tools-1.0.20210914_1

both interface address and route is assigned by the script.