- Timestamp:
- Jan 10, 2014 2:06:06 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 91535
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r48947 r50046 24 24 #define __STDC_CONSTANT_MACROS 25 25 #include "slirp/libslirp.h" 26 extern "C" { 27 #include "slirp/slirp_dns.h" 28 }; 26 29 #include "slirp/ctl.h" 27 30 … … 218 221 *******************************************************************************/ 219 222 static void drvNATNotifyNATThread(PDRVNAT pThis, const char *pszWho); 223 DECLINLINE(void) drvNATHostNetworkConfigurationChangeEventStrategySelector( 224 PDRVNAT pThis, 225 bool fHostNetworkConfigurationEventListener); 226 static DECLCALLBACK(int) drvNATReinitializeHostNameResolving(PDRVNAT pThis); 220 227 221 228 … … 972 979 CFArrayRef hArrAddresses = (CFArrayRef)CFDictionaryGetValue(hDnsDict, kSCPropNetDNSServerAddresses); 973 980 if (hArrAddresses) 974 pThis->pIAboveConfig->pfnSetLinkState(pThis->pIAboveConfig, PDMNETWORKLINKSTATE_DOWN_RESUME);981 drvNATHostNetworkConfigurationChangeEventStrategySelector(pThis, /* RT_OS_DARWIN */ true); 975 982 976 983 CFRelease(hDnsDict); … … 1045 1052 { 1046 1053 case VMRESUMEREASON_HOST_RESUME: 1054 drvNATHostNetworkConfigurationChangeEventStrategySelector(pThis, !RT_OS_DARWIN); 1055 return; 1056 default: /* Ignore every other resume reason. */ 1057 /* do nothing */ 1058 return; 1059 } 1060 } 1061 1062 1063 static DECLCALLBACK(int) drvNATReinitializeHostNameResolving(PDRVNAT pThis) 1064 { 1065 slirpReleaseDnsSettings(pThis->pNATState); 1066 slirpInitializeDnsSettings(pThis->pNATState); 1067 return VINF_SUCCESS; 1068 } 1069 1070 /** 1071 * This function at this stage could be called from two places, but both from non-NAT thread, 1072 * - drvNATResume (EMT?) 1073 * - drvNatDnsChanged (darwin, GUI or main) "listener" 1074 * When Main's interface IHost will support host network configuration change event on every host, 1075 * we won't call it from drvNATResume, but from listener of Main event in the similar way it done 1076 * for port-forwarding, and it wan't be on GUI/main thread, but on EMT thread only. 1077 * 1078 * Thread here is important, because we need to change DNS server list and domain name (+ perhaps, 1079 * search string) at runtime (VBOX_NAT_ENFORCE_INTERNAL_DNS_UPDATE), we can do it safely on NAT thread, 1080 * so with changing other variables (place where we handle update) the main mechanism of update 1081 * _won't_ be changed, the only thing will change is drop of fHostNetworkConfigurationEventListener parameter. 1082 */ 1083 DECLINLINE(void) drvNATHostNetworkConfigurationChangeEventStrategySelector(PDRVNAT pThis, 1084 bool fHostNetworkConfigurationEventListener) 1085 { 1086 int strategy = slirp_host_network_configuration_change_strategy_selector(pThis->pNATState); 1087 switch (strategy) 1088 { 1089 1090 case VBOX_NAT_HNCE_DNSPROXY: 1091 { 1092 /** 1093 * It's unsafe to to do it directly on non-NAT thread 1094 * so we schedule the worker and kick the NAT thread. 1095 */ 1096 RTREQQUEUE hQueue = pThis->hSlirpReqQueue; 1097 1098 int rc = RTReqQueueCallEx(hQueue, NULL /*ppReq*/, 0 /*cMillies*/, 1099 RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 1100 (PFNRT)drvNATReinitializeHostNameResolving, 1, pThis); 1101 if (RT_SUCCESS(rc)) 1102 drvNATNotifyNATThread(pThis, "drvNATNetworkUp_SendBuf"); 1103 1104 1105 return; 1106 1107 } 1108 case VBOX_NAT_HNCE_EXSPOSED_NAME_RESOLUTION_INFO: 1047 1109 /* 1048 1110 * Host resumed from a suspend and the network might have changed. 1049 1111 * Disconnect the guest from the network temporarily to let it pick up the changes. 1050 1112 */ 1051 #ifndef RT_OS_DARWIN 1052 pThis->pIAboveConfig->pfnSetLinkState(pThis->pIAboveConfig,1053 PDMNETWORKLINKSTATE_DOWN_RESUME);1054 #endif 1113 1114 if (fHostNetworkConfigurationEventListener) 1115 pThis->pIAboveConfig->pfnSetLinkState(pThis->pIAboveConfig, 1116 PDMNETWORKLINKSTATE_DOWN_RESUME); 1055 1117 return; 1056 default: /* Ignore every other resume reason. */1057 /* do nothing */1118 case VBOX_NAT_HNCE_HOSTRESOLVER: 1119 default: 1058 1120 return; 1059 1121 }
Note:
See TracChangeset
for help on using the changeset viewer.