ovpn: allow keepalive timeout and interval to be set individually
Subsystems (2)
RFC 1/1 ovpn: allow keepalive timeout and interval to be set individually
Currently the netlink API rejects PEER_SET/PEER_NEW messages that carry only one of the two keepalive attributes (interval or timeout) and requires both to be provided at the same time.
Relax this restriction so that userspace can configure either value independently.
Refactor ovpn_peer_keepalive_set() to handle the two parameters separately.
Update the periodic worker so that it correctly handles peers that have only a timeout or only an interval configured, instead of skipping them entirely.
Signed-off-by Marco Baffo <[email protected]>
--- drivers/net/ovpn/netlink.c | 20 ++------ drivers/net/ovpn/peer.c | 98 +++++++++++++++++++++++++------------- drivers/net/ovpn/peer.h | 4 +- 3 files changed, 72 insertions(+), 50 deletions(-)
drivers/net/ovpn/netlink.c +3 -17
@@ -254,15 +254,6 @@ static int ovpn_nl_peer_precheck(struct ovpn_priv *ovpn,return -EINVAL ; } -if ((attrs[OVPN_A_PEER_KEEPALIVE_INTERVAL ] && - !attrs[OVPN_A_PEER_KEEPALIVE_TIMEOUT ]) || - (!attrs[OVPN_A_PEER_KEEPALIVE_INTERVAL ] && - attrs[OVPN_A_PEER_KEEPALIVE_TIMEOUT ])) { -NL_SET_ERR_MSG_FMT_MOD (info->extack, -"keepalive interval and timeout are required together" ); -return -EINVAL ; - } -return 0 ; }
@@ -281,7 +272,6 @@ static int ovpn_nl_peer_modify(struct ovpn_peer *peer, struct genl_info *info, {struct sockaddr_storage ss = {};void *local_ip =NULL ; -u32 interv, timeout;bool rehash = false;int ret;
@@ -323,13 +313,9 @@ static int ovpn_nl_peer_modify(struct ovpn_peer *peer, struct genl_info *info,nla_get_in6_addr (attrs[OVPN_A_PEER_VPN_IPV6 ]); } -/* when setting the keepalive, both parameters have to be configured */ -if (attrs[OVPN_A_PEER_KEEPALIVE_INTERVAL ] && - attrs[OVPN_A_PEER_KEEPALIVE_TIMEOUT ]) { - interv =nla_get_u32 (attrs[OVPN_A_PEER_KEEPALIVE_INTERVAL ]); - timeout =nla_get_u32 (attrs[OVPN_A_PEER_KEEPALIVE_TIMEOUT ]); -ovpn_peer_keepalive_set (peer, interv, timeout); - } +ovpn_peer_keepalive_set (peer, + attrs[OVPN_A_PEER_KEEPALIVE_INTERVAL ], + attrs[OVPN_A_PEER_KEEPALIVE_TIMEOUT ]); netdev_dbg(peer->ovpn->dev, "modify peer id=%u tx_id=%u endpoint=%pIScp VPN-IPv4=%pI4 VPN-IPv6=%pI6c\n",
drivers/net/ovpn/peer.c +66 -32
145 lines not on this page · raw message
drivers/net/ovpn/peer.h +3 -1
@@ -154,7 +154,9 @@ void ovpn_peer_hash_vpn_ip(struct ovpn_peer *peer);bool ovpn_peer_check_by_src (struct ovpn_priv *ovpn,struct sk_buff *skb,struct ovpn_peer *peer); -void ovpn_peer_keepalive_set (struct ovpn_peer *peer,u32 interval,u32 timeout); +void ovpn_peer_keepalive_set (struct ovpn_peer *peer, +const struct nlattr *nla_interval, +const struct nlattr *nla_timeout);void ovpn_peer_keepalive_work (struct work_struct *work);void ovpn_peer_endpoints_update (struct ovpn_peer *peer,struct sk_buff *skb);
Signature · 8 lines
2.43.0 _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel