Skip to content

Commit d703d1b

Browse files
author
Jon Chiappetta
committed
Old/New IP - Logic Redo
1 parent 2777cdd commit d703d1b

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/openvpn/multi.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4377,20 +4377,26 @@ update_vhash(struct multi_context *m, struct multi_instance *mi, const char *new
43774377
{
43784378
if (new_ip)
43794379
{
4380+
in_addr_t old_addr_t = mi->context.c2.push_ifconfig_local;
4381+
4382+
struct in_addr new_addr;
4383+
CLEAR(new_addr);
4384+
int addr_stat = inet_pton(AF_INET, new_ip, &new_addr);
4385+
in_addr_t new_addr_t = ntohl(new_addr.s_addr);
4386+
43804387
/* Remove old IP */
4381-
if (mi->context.c2.push_ifconfig_defined)
4388+
if (addr_stat == 1 && new_addr_t != old_addr_t
4389+
&& mi->context.c2.push_ifconfig_defined)
43824390
{
43834391
unlearn_ifconfig(m, mi);
43844392
}
43854393

43864394
/* Add new IP */
4387-
struct in_addr new_addr;
4388-
CLEAR(new_addr);
4389-
if (inet_pton(AF_INET, new_ip, &new_addr) == 1
4390-
&& multi_learn_in_addr_t(m, mi, ntohl(new_addr.s_addr), -1, true))
4395+
if (addr_stat == 1 && new_addr_t != old_addr_t
4396+
&& multi_learn_in_addr_t(m, mi, new_addr_t, -1, true))
43914397
{
43924398
mi->context.c2.push_ifconfig_defined = true;
4393-
mi->context.c2.push_ifconfig_local = ntohl(new_addr.s_addr);
4399+
mi->context.c2.push_ifconfig_local = new_addr_t;
43944400
/* set our client's VPN endpoint for status reporting purposes */
43954401
mi->reporting_addr = mi->context.c2.push_ifconfig_local;
43964402
}
@@ -4462,4 +4468,4 @@ multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi,
44624468

44634469
return (!ipv6_net_contains_host(&ifconfig_local, o->ifconfig_ipv6_netbits,
44644470
dest));
4465-
}
4471+
}

0 commit comments

Comments
 (0)