@@ -4377,37 +4377,48 @@ 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 }
43974403 }
43984404
43994405 if (new_ipv6 )
44004406 {
4407+ struct in6_addr old_addr6 = mi -> context .c2 .push_ifconfig_ipv6_local ;
4408+
4409+ struct in6_addr new_addr6 ;
4410+ CLEAR (new_addr6 );
4411+ int addr6_stat = inet_pton (AF_INET6 , new_ipv6 , & new_addr6 );
4412+
44014413 /* Remove old IPv6 */
4402- if (mi -> context .c2 .push_ifconfig_ipv6_defined )
4414+ if (addr6_stat == 1 && memcmp (new_addr6 , old_addr6 , sizeof (old_addr6 )) != 0
4415+ && mi -> context .c2 .push_ifconfig_ipv6_defined )
44034416 {
44044417 unlearn_ifconfig_ipv6 (m , mi );
44054418 }
44064419
44074420 /* Add new IPv6 */
4408- struct in6_addr new_addr6 ;
4409- CLEAR (new_addr6 );
4410- if (inet_pton (AF_INET6 , new_ipv6 , & new_addr6 ) == 1
4421+ if (addr6_stat == 1 && memcmp (new_addr6 , old_addr6 , sizeof (old_addr6 )) != 0
44114422 && multi_learn_in6_addr (m , mi , new_addr6 , -1 , true))
44124423 {
44134424 mi -> context .c2 .push_ifconfig_ipv6_defined = true;
@@ -4462,4 +4473,4 @@ multi_check_push_ifconfig_ipv6_extra_route(struct multi_instance *mi,
44624473
44634474 return (!ipv6_net_contains_host (& ifconfig_local , o -> ifconfig_ipv6_netbits ,
44644475 dest ));
4465- }
4476+ }
0 commit comments