]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ovpn: rehash peer in by_transp_addr table on CMD_PEER_SET
authorAntonio Quartulli <antonio@openvpn.net>
Tue, 28 Jul 2026 11:48:48 +0000 (13:48 +0200)
committerAntonio Quartulli <antonio@openvpn.net>
Thu, 30 Jul 2026 09:28:30 +0000 (11:28 +0200)
commitcc12f7240c8c4dee557749d33237542613992f14
treebada866b522fdccbc9480ddb214d8353bf6bdeea
parent33ec10567fe14456063daf549fdf1a4f53448e4c
ovpn: rehash peer in by_transp_addr table on CMD_PEER_SET

When userspace updates a peer's remote endpoint via OVPN_CMD_PEER_SET,
ovpn_nl_peer_modify() installs a new ovpn_bind through
ovpn_peer_reset_sockaddr(), but ovpn_nl_peer_set_doit() only calls
ovpn_peer_hash_vpn_ip() to refresh the VPN-IP hashtables. The peer is
left in the bucket of peers->by_transp_addr corresponding to its old
remote address.

As a consequence, datagrams arriving at the UDP RX path from the newly
configured remote hash to a different slot and the lockless lookup in
ovpn_peer_get_by_transp_addr() (called from ovpn_udp_encap_recv()) does
not find the peer, until either a float event or a peer re-add fixes
the bucket.

Introduce ovpn_peer_hash_transp_addr() (modeled after
ovpn_peer_hash_vpn_ip()) and invoke it from ovpn_nl_peer_set_doit()
whenever the request carried a new remote address. The helper bails
out in P2P mode and on peers without a bind (TCP), and relies on
hlist_nulls_del_init_rcu()'s pprev==NULL short-circuit to handle the
case of an entry not currently linked in the table.

Fixes: 1d36a36f6d53 ("ovpn: implement peer add/get/dump/delete via netlink")
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
drivers/net/ovpn/netlink.c
drivers/net/ovpn/peer.c
drivers/net/ovpn/peer.h