VirtualBox

Opened 6 years ago

Closed 5 years ago

#17963 closed defect (fixed)

Trunk interface names truncated to 7 characters on macOS hosts

Reported by: DWPoon Owned by:
Component: network Version: VirtualBox 5.2.18
Keywords: Cc:
Guest type: all Host type: Mac OS X

Description

If the name of a trunk interface on a macOS host is 8 characters or longer, then it causes an error when starting a VirtualBox guest:

Change History (7)

comment:1 by DWPoon, 6 years ago

If the name of a trunk interface on a macOS host is 8 characters or longer, then it causes an error when starting a VirtualBox guest:

Failed to open a session for the virtual machine foo.

Details:

Failed to open/create the internal network 'HostInterfaceNetworking-vlan138' (VERR_INTNET_FLT_IF_NOT_FOUND).

Failed to attach the network LUN (VERR_INTNET_FLT_IF_NOT_FOUND).

Result Code: NS_ERROR_FAILURE (0x80004005)
Component: ConsoleWrap
Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed

Steps to reproduce

  1. In the macOS Terminal, create a tagged VLAN on Ethernet named vlan1387:
    ~ root# ifconfig vlan1387 create
    ~ root# ifconfig vlan1387 vlan 1387 vlan en0
    
  2. Configure a guest to use it. Under Network → Adapter 1:
☑ Enable Network Adapter
Attached to: Bridged Adapter
Name: vlan1387
  1. Start the guest. Obtain the error dialog quoted above. Notice that "vlan1387" has been truncated in "HostInterfaceNetworking-vlan138".

If I try the same steps with a shorter interface name (e.g. vlan0), it works.

Dumps

Excerpts from Logs/VBox.log:

…
00:00:00.978878 ************************* CFGM dump *************************
…
00:00:00.979128 [/Devices/virtio-net/0/Config/] (level 4)
00:00:00.979129   CableConnected <integer> = 0x0000000000000001 (1)
00:00:00.979129   LineSpeed      <integer> = 0x0000000000000000 (0)
00:00:00.979130   MAC            <bytes>   = "00 02 b3 a8 1d 00" (cb=6)
00:00:00.979131 
00:00:00.979131 [/Devices/virtio-net/0/LUN#0/] (level 4)
00:00:00.979132   Driver <string>  = "IntNet" (cb=7)
00:00:00.979133 
00:00:00.979133 [/Devices/virtio-net/0/LUN#0/Config/] (level 5)
00:00:00.979134   IfPolicyPromisc      <string>  = "deny" (cb=5)
00:00:00.979135   IgnoreConnectFailure <integer> = 0x0000000000000000 (0)
00:00:00.979135   Network              <string>  = "HostInterfaceNetworking-vlan138" (cb=32)
00:00:00.979136   Trunk                <string>  = "vlan138" (cb=8)
00:00:00.979137   TrunkType            <integer> = 0x0000000000000003 (3)
00:00:00.979137 
00:00:00.979138 [/Devices/virtio-net/0/LUN#999/] (level 4)
00:00:00.979138   Driver <string>  = "MainStatus" (cb=11)
…
00:00:00.979194 ********************* End of CFGM dump **********************
…
00:00:01.009297 IntNet#0: szNetwork={HostInterfaceNetworking-vlan138} enmTrunkType=3 szTrunk={vlan138} fFlags=0x8000 cbRecv=325632 cbSend=196608 fIgnoreConnectFailure=false
00:00:01.009355 VMSetError: /Users/vbox/tinderbox/5.2-mac-rel/src/VBox/Devices/Network/DrvIntNet.cpp(1768) int drvR3IntNetConstruct(PPDMDRVINS, PCFGMNODE, uint32_t); rc=VERR_INTNET_FLT_IF_NOT_FOUND
00:00:01.009364 VMSetError: Failed to open/create the internal network 'HostInterfaceNetworking-vlan138'
00:00:01.009393 VMSetError: /Users/vbox/tinderbox/5.2-mac-rel/src/VBox/Devices/Network/DevVirtioNet.cpp(2198) int vnetConstruct(PPDMDEVINS, int, PCFGMNODE); rc=VERR_INTNET_FLT_IF_NOT_FOUND
00:00:01.009395 VMSetError: Failed to attach the network LUN
00:00:01.009406 PDM: Failed to construct 'virtio-net'/0! VERR_INTNET_FLT_IF_NOT_FOUND (-3600) - The networking interface to filter was not found.
00:00:01.012019 TxTimer stats (avg/min/max):       0 usec      -1 usec       0 usec
00:00:01.012467 GIM: KVM: Resetting MSRs
00:00:01.013521 ERROR [COM]: aRC=NS_ERROR_FAILURE (0x80004005) aIID={872da645-4a9b-1727-bee2-5585105b9eed} aComponent={ConsoleWrap} aText={Failed to open/create the internal network 'HostInterfaceNetworking-vlan138' (VERR_INTNET_FLT_IF_NOT_FOUND).
00:00:01.013531 Failed to attach the network LUN (VERR_INTNET_FLT_IF_NOT_FOUND)}, preserve=false aResultDetail=0
00:00:01.013629 Console: Machine state changed to 'PoweredOff'
00:00:01.014587 Power up failed (vrc=VERR_INTNET_FLT_IF_NOT_FOUND, rc=NS_ERROR_FAILURE (0X80004005))
00:00:01.025969 GUI: UIMediumEnumerator: Medium-enumeration finished!
00:00:01.520187 GUI: UIMachineViewNormal::resendSizeHint: Restoring guest size-hint for screen 0 to 800x600
00:00:01.520233 ERROR [COM]: aRC=E_ACCESSDENIED (0x80070005) aIID={76eed314-3c72-4bbb-95cf-5eb4947a4041} aComponent={DisplayWrap} aText={The console is not powered up}, preserve=false aResultDetail=0
00:00:01.520267 GUI: Aborting startup due to power up progress issue detected...

Excerpt from the .vbox XML:

<VirtualBox xmlns="http://www.virtualbox.org/" version="1.16-macosx">
  <Machine uuid="{6fe9d89c-998f-42d3-879a-3d32ea1fbe73}" name="foo" OSType="Ubuntu_64" snapshotFolder="Snapshots" lastStateChange="2018-08-29T21:51:08Z">
    …
    <Hardware>
      …
      <Network>
        <Adapter slot="0" enabled="true" MACAddress="0002B3A81D00" type="virtio">
          <DisabledModes>
            <InternalNetwork name="intnet"/>
            <NATNetwork name="NatNetwork"/>
          </DisabledModes>
          <BridgedInterface name="vlan1387"/>
        </Adapter>
      </Network>
    …
    </Hardware>
    …
</VirtualBox>

Diagnosis

In src/VBox/Main/src-client/ConsoleImpl2.cpp, at line 5309:

5309    # if defined(RT_OS_DARWIN)
5310                    /* The name is on the form 'ifX: long name', chop it off at the colon. */
5311                    char szTrunk[8];
5312                    RTStrCopy(szTrunk, sizeof(szTrunk), pszBridgedIfName);
5313                    char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));

5328                    if (pszColon)
5329                        *pszColon = '\0';
5330                    const char *pszTrunk = szTrunk;

5511    # endif
5512    
5513                    InsertConfigString(pLunL0, "Driver", "IntNet");
5514                    InsertConfigNode(pLunL0, "Config", &pCfg);
5515                    InsertConfigString(pCfg, "Trunk", pszTrunk);
5516                    InsertConfigInteger(pCfg, "TrunkType", kIntNetTrunkType_NetFlt);
5517                    InsertConfigInteger(pCfg, "IgnoreConnectFailure", (uint64_t)fIgnoreConnectFailure);
5518                    InsertConfigString(pCfg, "IfPolicyPromisc", pszPromiscuousGuestPolicy);
5519                    char szNetwork[INTNET_MAX_NETWORK_NAME];

The 8-byte buffer char szTrunk[8] is much too short. The Solaris port uses a 256-byte buffer. Another decent choice would be INTNET_MAX_TRUNK_NAME (include/VBox/intnet.h):

1052    /** The maximum length of a network name. */
1053    #define INTNET_MAX_NETWORK_NAME     128
1054    
1055    /** The maximum length of a trunk name. */
1056    #define INTNET_MAX_TRUNK_NAME       64
Last edited 6 years ago by DWPoon (previous) (diff)

comment:2 by Socratis, 6 years ago

I just wanted to say "KUDOS!!!" for a perfectly documented and formatted ticket. It's a rarity these days, so much so, that it almost brought tears in my eyes! :D

I'm building VirtualBox for OSX on a 10.9.6 VM that I have just for that purpose. I'll try your suggestion, which pretty boils down to:

-  char szTrunk[8];
+  char szTrunk[INTNET_MAX_TRUNK_NAME];

Right? I can't run not even DOS after I'm done building VirtualBox (nested virtualization, blah, blah...) but I can definitely see if it's going to work at the configuration level.

Will keep you posted...

comment:3 by Socratis, 6 years ago

The command

sudo ifconfig vlan1387 vlan 1387 vlan en0

didn't work for me, I had to issue the command

sudo ifconfig vlan1387 vlan 1387 vlandev en0

maybe it was a typo. Anyway, after that, ifconfig shows:

vlan1387: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=23<RXCSUM,TXCSUM,TSO4>
        ether 08:00:27:8a:5a:42 
        vlan: 1387 parent interface: en0
        media: autoselect (1000baseT <full-duplex>)
        status: active

and if I start the VM, the VBox.log shows that vlan1387 is indeed chopped off:

00:00:10.546906 [/Devices/pcnet/0/LUN#0/Config/] (level 5)
00:00:10.546909   IfPolicyPromisc      <string>  = "deny" (cb=5)
00:00:10.546911   IgnoreConnectFailure <integer> = 0x0000000000000000 (0)
00:00:10.546914   Network              <string>  = "HostInterfaceNetworking-vlan138" (cb=32)
00:00:10.546916   Trunk                <string>  = "vlan138" (cb=8)
00:00:10.546918   TrunkType            <integer> = 0x0000000000000003 (3)

Applying the patch described in my previous post, I get:

00:00:01.501953 [/Devices/pcnet/0/LUN#0/Config/] (level 5)
00:00:01.501956   IfPolicyPromisc      <string>  = "deny" (cb=5)
00:00:01.501957   IgnoreConnectFailure <integer> = 0x0000000000000000 (0)
00:00:01.501959   Network              <string>  = "HostInterfaceNetworking-vlan1387" (cb=33)
00:00:01.501960   Trunk                <string>  = "vlan1387" (cb=9)
00:00:01.501962   TrunkType            <integer> = 0x0000000000000003 (3)

Success! \o/

And just for completion, here's the full patch. Not sure if it's going to be applied as is. Maybe there needs to be a change in the INTNET_MAX_TRUNK_NAME to 256, and applied "globally" for Win, OSX, Linux and Solaris (which is fixed at 256).

Index: src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 73978)
+++ src/VBox/Main/src-client/ConsoleImpl2.cpp	(working copy)
@@ -5308,7 +5308,7 @@
 
 # if defined(RT_OS_DARWIN)
                 /* The name is on the form 'ifX: long name', chop it off at the colon. */
-                char szTrunk[8];
+                char szTrunk[INTNET_MAX_TRUNK_NAME];
                 RTStrCopy(szTrunk, sizeof(szTrunk), pszBridgedIfName);
                 char *pszColon = (char *)memchr(szTrunk, ':', sizeof(szTrunk));
 // Quick fix for @bugref{5633}

comment:4 by DWPoon, 6 years ago

Thanks for the confirmation and patch. You're right, I had intended to write sudo ifconfig vlan1387 vlan 1387 vlandev en0.

comment:6 by DWPoon, 6 years ago

Patch was applied in Subversion r75331. This ticket should be closed.

comment:7 by janitor, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette