• A
    util: centralize tap device MAC address 1st byte "0xFE" modification · c1b164d7
    Ansis Atteka 提交于
    When a tap device for a domain is created and attached to a bridge,
    the first byte of the tap device MAC address is set to 0xFE, while the
    rest is set to match the MAC address that will be presented to the
    guest as its network device MAC address. Setting this high value in
    the tap's MAC address discourages the bridge from using the tap
    device's MAC address as the bridge's own MAC address (Linux bridges
    always take on the lowest numbered MAC address of all attached devices
    as their own).
    
    In one case within libvirt, a tap device is created and attached to
    the bridge with the intent that its MAC address be taken on by the
    bridge as its own (this is used to assure that the bridge has a fixed
    MAC address to prevent network outages created by the bridge MAC
    address "flapping" as guests are started and stopped). In this case,
    the first byte of the mac address is *not* altered to 0xFE.
    
    In the current code, callers to virNetDevTapCreateInBridgePort each
    make the MAC address modification themselves before calling, which
    leads to code duplication, and also prevents lower level functions
    from knowing the real MAC address being used by the guest. The problem
    here is that openvswitch bridges must be informed about this MAC
    address, or they will be unable to pass traffic to/from the guest.
    
    This patch centralizes the location of the MAC address "0xFE fixup"
    into virNetDevTapCreateInBridgePort(), meaning 1) callers of this
    function no longer need the extra strange bit of code, and 2)
    bitNetDevTapCreateBridgeInPort itself now is called with the guest's
    unaltered MAC address, and can pass it on, unmodified, to
    virNetDevOpenvswitchAddPort.
    
    There is no other behavioral change created by this patch.
    c1b164d7
uml_conf.c 14.3 KB