Browse code

tun: get rid of tt->did_ifconfig member

tt->did_ifconfig is currently only read by the Linux platform, but
it is currently uselessly set also by every other system.

The Linux platform does not actually even need this member and can
directly rely on tt->did_ifconfig_setup.

For the reasons above, remove the tt->did_ifconfig at all and use
tt->did_ifconfig_setup where needed (close_tun() on Linux).

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180613122824.4207-4-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17046.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Antonio Quartulli authored on 2018/06/13 21:28:24
Showing 2 changed files
... ...
@@ -987,7 +987,6 @@ do_ifconfig(struct tuntap *tt,
987 987
             argv_msg(M_INFO, &argv);
988 988
             openvpn_execve_check(&argv, es, S_FATAL, "Linux ip -6 addr add failed");
989 989
         }
990
-        tt->did_ifconfig = true;
991 990
 #else  /* ifdef ENABLE_IPROUTE */
992 991
         if (tun)
993 992
         {
... ...
@@ -1026,7 +1025,6 @@ do_ifconfig(struct tuntap *tt,
1026 1026
             argv_msg(M_INFO, &argv);
1027 1027
             openvpn_execve_check(&argv, es, S_FATAL, "Linux ifconfig inet6 failed");
1028 1028
         }
1029
-        tt->did_ifconfig = true;
1030 1029
 
1031 1030
 #endif /*ENABLE_IPROUTE*/
1032 1031
 #elif defined(TARGET_ANDROID)
... ...
@@ -1186,8 +1184,6 @@ do_ifconfig(struct tuntap *tt,
1186 1186
             add_route(&r, tt, 0, NULL, es);
1187 1187
         }
1188 1188
 
1189
-        tt->did_ifconfig = true;
1190
-
1191 1189
 #elif defined(TARGET_OPENBSD)
1192 1190
 
1193 1191
         in_addr_t remote_end;           /* for "virtual" subnet topology */
... ...
@@ -1265,7 +1261,6 @@ do_ifconfig(struct tuntap *tt,
1265 1265
             /* and, hooray, we explicitely need to add a route... */
1266 1266
             add_route_connected_v6_net(tt, es);
1267 1267
         }
1268
-        tt->did_ifconfig = true;
1269 1268
 
1270 1269
 #elif defined(TARGET_NETBSD)
1271 1270
 
... ...
@@ -1327,7 +1322,6 @@ do_ifconfig(struct tuntap *tt,
1327 1327
             /* and, hooray, we explicitely need to add a route... */
1328 1328
             add_route_connected_v6_net(tt, es);
1329 1329
         }
1330
-        tt->did_ifconfig = true;
1331 1330
 
1332 1331
 #elif defined(TARGET_DARWIN)
1333 1332
         /*
... ...
@@ -1384,7 +1378,6 @@ do_ifconfig(struct tuntap *tt,
1384 1384
 
1385 1385
         argv_msg(M_INFO, &argv);
1386 1386
         openvpn_execve_check(&argv, es, S_FATAL, "Mac OS X ifconfig failed");
1387
-        tt->did_ifconfig = true;
1388 1387
 
1389 1388
         /* Add a network route for the local tun interface */
1390 1389
         if (!tun && tt->topology == TOP_SUBNET)
... ...
@@ -1457,7 +1450,6 @@ do_ifconfig(struct tuntap *tt,
1457 1457
 
1458 1458
         argv_msg(M_INFO, &argv);
1459 1459
         openvpn_execve_check(&argv, es, S_FATAL, "FreeBSD ifconfig failed");
1460
-        tt->did_ifconfig = true;
1461 1460
 
1462 1461
         /* Add a network route for the local tun interface */
1463 1462
         if (!tun && tt->topology == TOP_SUBNET)
... ...
@@ -1507,7 +1499,6 @@ do_ifconfig(struct tuntap *tt,
1507 1507
 
1508 1508
             argv_msg(M_INFO, &argv);
1509 1509
             openvpn_execve_check(&argv, aix_es, S_FATAL, "AIX ifconfig failed");
1510
-            tt->did_ifconfig = true;
1511 1510
 
1512 1511
             if (do_ipv6)
1513 1512
             {
... ...
@@ -1545,7 +1536,6 @@ do_ifconfig(struct tuntap *tt,
1545 1545
 
1546 1546
                     break;
1547 1547
             }
1548
-            tt->did_ifconfig = true;
1549 1548
         }
1550 1549
 
1551 1550
         if (do_ipv6)
... ...
@@ -2104,7 +2094,7 @@ close_tun(struct tuntap *tt)
2104 2104
 {
2105 2105
     ASSERT(tt);
2106 2106
 
2107
-    if (tt->type != DEV_TYPE_NULL && tt->did_ifconfig)
2107
+    if (tt->type != DEV_TYPE_NULL && tt->did_ifconfig_setup)
2108 2108
     {
2109 2109
         struct argv argv = argv_new();
2110 2110
         struct gc_arena gc = gc_new();
... ...
@@ -138,7 +138,6 @@ struct tuntap
138 138
 
139 139
     bool did_ifconfig_setup;
140 140
     bool did_ifconfig_ipv6_setup;
141
-    bool did_ifconfig;
142 141
 
143 142
     bool persistent_if;         /* if existed before, keep on program end */
144 143