Permalink
Browse files

Network: Increased the limit of host-only interfaces to 128.

git-svn-id: http://www.virtualbox.org/svn/vbox/trunk@41272 cfe28804-0f27-0410-a406-dd0f0b0b656f
  • Loading branch information...
vboxsync
vboxsync committed May 14, 2012
1 parent c36167d commit 6cf78a8f757ba0e31eac36d836ea3aaf597828c5
@@ -636,6 +636,8 @@
linkend="vboxmanage-dhcpserver" /> for details.</para>
</listitem>
</itemizedlist></para>
+ <para><note>On Linux and Mac OS X hosts the number of host-only interfaces is
+ limited to 128.</note></para>
</sect1>
<sect1 id="network_udp_tunnel">
@@ -767,4 +769,4 @@
url="http://wiki.virtualsquare.org/wiki/index.php/VDE_Basic_Networking">http://wiki.virtualsquare.org/wiki/index.php/VDE_Basic_Networking</ulink>.</para>
</footnote></para>
</sect1>
-</chapter>
+</chapter>
@@ -1184,6 +1184,8 @@ int vboxNetAdpInit(void)
*/
memset(g_aUnits, 0, sizeof(g_aUnits));
memset(g_aAdapters, 0, sizeof(g_aAdapters));
+ LogFlow(("vboxnetadp: max host-only interfaces supported: %d (%d bytes)\n",
+ VBOXNETADP_MAX_INSTANCES, sizeof(g_aAdapters)));
for (i = 0; i < RT_ELEMENTS(g_aAdapters); i++)
{
g_aAdapters[i].enmState = kVBoxNetAdpState_Invalid;
@@ -29,7 +29,7 @@ RT_C_DECLS_BEGIN
/** Pointer to the globals. */
typedef struct VBOXNETADPGLOBALS *PVBOXNETADPGLOBALS;
-#define VBOXNETADP_MAX_INSTANCES 8
+#define VBOXNETADP_MAX_INSTANCES 128
#define VBOXNETADP_MAX_UNITS 128
#define VBOXNETADP_NAME "vboxnet"
#define VBOXNETADP_MAX_NAME_LEN 32
@@ -125,17 +125,7 @@ struct VBoxNetAdapter
/** Union alignment to a pointer. */
void *pvAlign;
/** Padding. */
-#if defined(RT_OS_WINDOWS)
-# if defined(VBOX_NETFLT_ONDEMAND_BIND)
- uint8_t abPadding[192];
-# else
- uint8_t abPadding[1024];
-# endif
-#elif defined(RT_OS_LINUX)
uint8_t abPadding[64];
-#else
- uint8_t abPadding[64];
-#endif
} u;
/** The interface name. */
char szName[VBOXNETADP_MAX_NAME_LEN];
@@ -314,7 +314,7 @@ static long VBoxNetAdpLinuxIOCtlUnlocked(struct file *pFilp,
if (RT_FAILURE(rc))
{
Log(("VBoxNetAdpLinuxIOCtl: vboxNetAdpCreate -> %Rrc\n", rc));
- return -EINVAL;
+ return -(rc == VERR_OUT_OF_RESOURCES ? ENOMEM : EINVAL);
}
Assert(strlen(pAdp->szName) < sizeof(Req.szName));
@@ -38,6 +38,7 @@
/** @todo These are duplicates from src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h */
#define VBOXNETADP_CTL_DEV_NAME "/dev/vboxnetctl"
+#define VBOXNETADP_MAX_INSTANCES 128
#define VBOXNETADP_NAME "vboxnet"
#define VBOXNETADP_MAX_NAME_LEN 32
#define VBOXNETADP_CTL_ADD _IOWR('v', 1, VBOXNETADPREQ)
@@ -183,17 +184,19 @@ static int doIOCtl(unsigned long uCmd, VBOXNETADPREQ *pReq)
int fd = open(VBOXNETADP_CTL_DEV_NAME, O_RDWR);
if (fd == -1)
{
- fprintf(stderr, "VBoxNetAdpCtl: Error while %s '%s': ",
- uCmd == VBOXNETADP_CTL_REMOVE ? "removing" : "adding", pReq->szName);
+ fprintf(stderr, "VBoxNetAdpCtl: Error while %s %s: ",
+ uCmd == VBOXNETADP_CTL_REMOVE ? "removing" : "adding",
+ pReq->szName[0] ? pReq->szName : "new interface");
perror("failed to open " VBOXNETADP_CTL_DEV_NAME);
return ADPCTLERR_NO_CTL_DEV;
}
int rc = ioctl(fd, uCmd, pReq);
if (rc == -1)
{
- fprintf(stderr, "VBoxNetAdpCtl: Error while %s '%s': ",
- uCmd == VBOXNETADP_CTL_REMOVE ? "removing" : "adding", pReq->szName);
+ fprintf(stderr, "VBoxNetAdpCtl: Error while %s %s: ",
+ uCmd == VBOXNETADP_CTL_REMOVE ? "removing" : "adding",
+ pReq->szName[0] ? pReq->szName : "new interface");
perror("VBoxNetAdpCtl: ioctl failed for " VBOXNETADP_CTL_DEV_NAME);
rc = ADPCTLERR_IOCTL_FAILED;
}
@@ -209,7 +212,7 @@ static int checkAdapterName(const char *pcszNameIn, char *pszNameOut)
if ( strlen(pcszNameIn) >= VBOXNETADP_MAX_NAME_LEN
|| sscanf(pcszNameIn, "vboxnet%d", &iAdapterIndex) != 1
- || iAdapterIndex < 0 || iAdapterIndex > 99 )
+ || iAdapterIndex < 0 || iAdapterIndex >= VBOXNETADP_MAX_INSTANCES )
{
fprintf(stderr, "VBoxNetAdpCtl: Setting configuration for '%s' is not supported.\n", pcszNameIn);
return ADPCTLERR_BAD_NAME;

0 comments on commit 6cf78a8

Please sign in to comment.