projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vconn: Fix byte-swapping of message type when validating OpenFlow actions.
[openvswitch]
/
xenserver
/
opt_xensource_libexec_interface-reconfigure
diff --git
a/xenserver/opt_xensource_libexec_interface-reconfigure
b/xenserver/opt_xensource_libexec_interface-reconfigure
index 49b306f10b20e533a82fc5218c5f7649667b382e..301251f7623a640d5a9d0e3cbfc2a8c5c6341d1e 100755
(executable)
--- a/
xenserver/opt_xensource_libexec_interface-reconfigure
+++ b/
xenserver/opt_xensource_libexec_interface-reconfigure
@@
-265,16
+265,12
@@
def get_netdev_tx_queue_len(device):
return None
def get_netdev_by_mac(mac):
return None
def get_netdev_by_mac(mac):
- maybe = None
for device in os.listdir("/sys/class/net"):
dev_mac = get_netdev_mac(device)
for device in os.listdir("/sys/class/net"):
dev_mac = get_netdev_mac(device)
- if
dev_mac and mac.lower() == dev_mac.lower():
-
if get_netdev_tx_queue_len(device
):
+ if
(dev_mac and mac.lower() == dev_mac.lower() and
+
get_netdev_tx_queue_len(device)
):
return device
return device
- if not maybe:
- # Probably a datapath internal port.
- maybe = device
- return maybe
+ return None
class DatabaseCache(object):
def __init__(self, session_ref=None, cache_file=None):
class DatabaseCache(object):
def __init__(self, session_ref=None, cache_file=None):
@@
-461,7
+457,7
@@
The ipdev name is the same as the bridge name.
pifrec = db.get_pif_record(pif)
return bridge_name(pif)
pifrec = db.get_pif_record(pif)
return bridge_name(pif)
-def physdev_pifs(pif):
+def
get_
physdev_pifs(pif):
"""Return the PIFs for the physical network device(s) associated with pif.
For a VLAN PIF, this is the VLAN slave's physical device PIF.
For a bond master PIF, these are the bond slave PIFs.
"""Return the PIFs for the physical network device(s) associated with pif.
For a VLAN PIF, this is the VLAN slave's physical device PIF.
For a bond master PIF, these are the bond slave PIFs.
@@
-471,20
+467,20
@@
For a non-VLAN, non-bond master PIF, the PIF is its own physical device PIF.
pifrec = db.get_pif_record(pif)
if pifrec['VLAN'] != '-1':
pifrec = db.get_pif_record(pif)
if pifrec['VLAN'] != '-1':
- return
[get_vlan_slave_of_pif(pif)]
+ return
get_physdev_pifs(get_vlan_slave_of_pif(pif))
elif len(pifrec['bond_master_of']) != 0:
return get_bond_slaves_of_pif(pif)
else:
return [pif]
elif len(pifrec['bond_master_of']) != 0:
return get_bond_slaves_of_pif(pif)
else:
return [pif]
-def physdev_names(pif):
+def
get_
physdev_names(pif):
"""Return the name(s) of the physical network device(s) associated with pif.
For a VLAN PIF, the physical devices are the VLAN slave's physical devices.
For a bond master PIF, the physical devices are the bond slaves.
For a non-VLAN, non-bond master PIF, the physical device is the PIF itself.
"""
"""Return the name(s) of the physical network device(s) associated with pif.
For a VLAN PIF, the physical devices are the VLAN slave's physical devices.
For a bond master PIF, the physical devices are the bond slaves.
For a non-VLAN, non-bond master PIF, the physical device is the PIF itself.
"""
- return [db.get_pif_record(phys)['device'] for phys in physdev_pifs(pif)]
+ return [db.get_pif_record(phys)['device'] for phys in
get_
physdev_pifs(pif)]
def log_pif_action(action, pif):
pifrec = db.get_pif_record(pif)
def log_pif_action(action, pif):
pifrec = db.get_pif_record(pif)
@@
-697,8
+693,8
@@
we should bring down that master."""
return peerdns_pif, defaultroute_pif
return peerdns_pif, defaultroute_pif
-def
ethtool_settings(
oc):
- #
Options for "ethtool -s"
+def
run_ethtool(device,
oc):
+ #
Run "ethtool -s" if there are any settings.
settings = []
if oc.has_key('ethtool-speed'):
val = oc['ethtool-speed']
settings = []
if oc.has_key('ethtool-speed'):
val = oc['ethtool-speed']
@@
-720,8
+716,10
@@
def ethtool_settings(oc):
settings += ['autoneg', 'off']
else:
log("Invalid value for ethtool-autoneg = %s. Must be on|true|off|false." % val)
settings += ['autoneg', 'off']
else:
log("Invalid value for ethtool-autoneg = %s. Must be on|true|off|false." % val)
+ if settings:
+ run_command(['/sbin/ethtool', '-s', device] + settings)
- #
Options for "ethtool -K"
+ #
Run "ethtool -K" if there are any offload settings.
offload = []
for opt in ("rx", "tx", "sg", "tso", "ufo", "gso"):
if oc.has_key("ethtool-" + opt):
offload = []
for opt in ("rx", "tx", "sg", "tso", "ufo", "gso"):
if oc.has_key("ethtool-" + opt):
@@
-732,10
+730,19
@@
def ethtool_settings(oc):
offload += [opt, 'off']
else:
log("Invalid value for ethtool-%s = %s. Must be on|true|off|false." % (opt, val))
offload += [opt, 'off']
else:
log("Invalid value for ethtool-%s = %s. Must be on|true|off|false." % (opt, val))
+ if offload:
+ run_command(['/sbin/ethtool', '-K', device] + offload)
- return settings, offload
+def mtu_setting(oc):
+ if oc.has_key('mtu'):
+ try:
+ int(oc['mtu']) # Check that the value is an integer
+ return ['mtu', oc['mtu']]
+ except ValueError, x:
+ log("Invalid value for mtu = %s" % mtu)
+ return []
-def configure_
netdev
(pif):
+def configure_
local_port
(pif):
pifrec = db.get_pif_record(pif)
datapath = datapath_name(pif)
ipdev = ipdev_name(pif)
pifrec = db.get_pif_record(pif)
datapath = datapath_name(pif)
ipdev = ipdev_name(pif)
@@
-744,6
+751,10
@@
def configure_netdev(pif):
nw = pifrec['network']
nwrec = db.get_network_record(nw)
nw = pifrec['network']
nwrec = db.get_network_record(nw)
+ pif_oc = pifrec['other_config']
+ nw_oc = nwrec['other_config']
+
+ # IP (except DHCP) and MTU.
ifconfig_argv = ['/sbin/ifconfig', ipdev, 'up']
gateway = ''
if pifrec['ip_configuration_mode'] == "DHCP":
ifconfig_argv = ['/sbin/ifconfig', ipdev, 'up']
gateway = ''
if pifrec['ip_configuration_mode'] == "DHCP":
@@
-757,46
+768,37
@@
def configure_netdev(pif):
pass
else:
raise Error("Unknown IP-configuration-mode %s" % pifrec['ip_configuration_mode'])
pass
else:
raise Error("Unknown IP-configuration-mode %s" % pifrec['ip_configuration_mode'])
-
- oc = pifrec['other_config']
- if oc.has_key('mtu'):
- try:
- int(oc['mtu']) # Check that the value is an integer
- ifconfig_argv += ['mtu', oc['mtu']]
- except ValueError, x:
- log("Invalid value for mtu = %s" % mtu)
-
+ ifconfig_argv += mtu_setting(nw_oc)
run_command(ifconfig_argv)
(peerdns_pif, defaultroute_pif) = find_distinguished_pifs(pif)
run_command(ifconfig_argv)
(peerdns_pif, defaultroute_pif) = find_distinguished_pifs(pif)
+ # /etc/resolv.conf
if peerdns_pif == pif:
f = ConfigurationFile('resolv.conf', "/etc")
if peerdns_pif == pif:
f = ConfigurationFile('resolv.conf', "/etc")
- if oc.has_key('domain'):
- f.write("search %s\n" % oc['domain'])
+ if
pif_
oc.has_key('domain'):
+ f.write("search %s\n" %
pif_
oc['domain'])
for dns in pifrec['DNS'].split(","):
f.write("nameserver %s\n" % dns)
f.close()
f.apply()
f.commit()
for dns in pifrec['DNS'].split(","):
f.write("nameserver %s\n" % dns)
f.close()
f.apply()
f.commit()
+ # Routing.
if defaultroute_pif == pif and gateway != '':
run_command(['/sbin/ip', 'route', 'replace', 'default',
'via', gateway, 'dev', ipdev])
if defaultroute_pif == pif and gateway != '':
run_command(['/sbin/ip', 'route', 'replace', 'default',
'via', gateway, 'dev', ipdev])
-
- if oc.has_key('static-routes'):
- for line in oc['static-routes'].split(','):
+ if nw_oc.has_key('static-routes'):
+ for line in nw_oc['static-routes'].split(','):
network, masklen, gateway = line.split('/')
run_command(['/sbin/ip', 'route', 'add',
'%s/%s' % (network, masklen), 'via', gateway,
'dev', ipdev])
network, masklen, gateway = line.split('/')
run_command(['/sbin/ip', 'route', 'add',
'%s/%s' % (network, masklen), 'via', gateway,
'dev', ipdev])
- settings, offload = ethtool_settings(oc)
- if settings:
- run_command(['/sbin/ethtool', '-s', ipdev] + settings)
- if offload:
- run_command(['/sbin/ethtool', '-K', ipdev] + offload)
+ # Ethtool.
+ run_ethtool(ipdev, nw_oc)
+ # DHCP.
if pifrec['ip_configuration_mode'] == "DHCP":
print
print "Determining IP information for %s..." % ipdev,
if pifrec['ip_configuration_mode'] == "DHCP":
print
print "Determining IP information for %s..." % ipdev,
@@
-809,6
+811,14
@@
def configure_netdev(pif):
else:
print 'failed.'
else:
print 'failed.'
+def configure_physdev(pif):
+ pifrec = db.get_pif_record(pif)
+ device = pifrec['device']
+ oc = pifrec['other_config']
+
+ run_command(['/sbin/ifconfig', device, 'up'] + mtu_setting(oc))
+ run_ethtool(device, oc)
+
def modify_config(commands):
run_command(['/root/vswitch/bin/ovs-cfg-mod', '-vANY:console:emer',
'-F', '/etc/ovs-vswitchd.conf']
def modify_config(commands):
run_command(['/root/vswitch/bin/ovs-cfg-mod', '-vANY:console:emer',
'-F', '/etc/ovs-vswitchd.conf']
@@
-824,12
+834,12
@@
def configure_bond(pif):
interface = interface_name(pif)
ipdev = ipdev_name(pif)
datapath = datapath_name(pif)
interface = interface_name(pif)
ipdev = ipdev_name(pif)
datapath = datapath_name(pif)
- physdev
s =
physdev_names(pif)
+ physdev
_names = get_
physdev_names(pif)
argv = ['--del-match=bonding.%s.[!0-9]*' % interface]
argv += ["--add=bonding.%s.slave=%s" % (interface, slave)
argv = ['--del-match=bonding.%s.[!0-9]*' % interface]
argv += ["--add=bonding.%s.slave=%s" % (interface, slave)
- for slave in physdevs]
- argv += ['--add=bonding.%s.fake-iface=true']
+ for slave in physdev
_name
s]
+ argv += ['--add=bonding.%s.fake-iface=true'
% interface
]
if pifrec['MAC'] != "":
argv += ['--add=port.%s.mac=%s' % (interface, pifrec['MAC'])]
if pifrec['MAC'] != "":
argv += ['--add=port.%s.mac=%s' % (interface, pifrec['MAC'])]
@@
-860,7
+870,8
@@
def action_up(pif):
interface = interface_name(pif)
ipdev = ipdev_name(pif)
datapath = datapath_name(pif)
interface = interface_name(pif)
ipdev = ipdev_name(pif)
datapath = datapath_name(pif)
- physdevs = physdev_names(pif)
+ physdev_pifs = get_physdev_pifs(pif)
+ physdev_names = get_physdev_names(pif)
vlan_slave = None
if pifrec['VLAN'] != '-1':
vlan_slave = get_vlan_slave_of_pif(pif)
vlan_slave = None
if pifrec['VLAN'] != '-1':
vlan_slave = get_vlan_slave_of_pif(pif)
@@
-916,13
+927,13
@@
def action_up(pif):
# Check the MAC address of each network device and remap if
# necessary to make names match our expectations.
# Check the MAC address of each network device and remap if
# necessary to make names match our expectations.
- for physdev_pif in physdev_pifs
(pif)
:
+ for physdev_pif in physdev_pifs:
remap_pif(physdev_pif)
# "ifconfig down" the network device and delete its IP address, etc.
down_netdev(ipdev)
remap_pif(physdev_pif)
# "ifconfig down" the network device and delete its IP address, etc.
down_netdev(ipdev)
- for physdev
in physdev
s:
- down_netdev(physdev)
+ for physdev
_name in physdev_name
s:
+ down_netdev(physdev
_name
)
# If we are bringing up a bond, remove IP addresses from the
# slaves (because we are implicitly being asked to take them down).
# If we are bringing up a bond, remove IP addresses from the
# slaves (because we are implicitly being asked to take them down).
@@
-934,7
+945,7
@@
def action_up(pif):
run_command(["/sbin/ifconfig", ipdev_name(bond_pif), '0.0.0.0'])
# Remove all keys related to pif and any bond masters linked to PIF.
run_command(["/sbin/ifconfig", ipdev_name(bond_pif), '0.0.0.0'])
# Remove all keys related to pif and any bond masters linked to PIF.
- del_ports = [ipdev] + physdevs + bond_masters
+ del_ports = [ipdev] + physdev
_name
s + bond_masters
if vlan_slave and bond_master:
del_ports += [interface_name(bond_master)]
if vlan_slave and bond_master:
del_ports += [interface_name(bond_master)]
@@
-945,7
+956,7
@@
def action_up(pif):
# port.
add_ports = [ipdev, datapath]
if not bond_master:
# port.
add_ports = [ipdev, datapath]
if not bond_master:
- add_ports += physdevs
+ add_ports += physdev
_name
s
else:
add_ports += [interface_name(bond_master)]
else:
add_ports += [interface_name(bond_master)]
@@
-960,7
+971,7
@@
def action_up(pif):
# - The bond masters for pif. (Ordinarily pif shouldn't have any
# bond masters. If it does then interface-reconfigure is
# implicitly being asked to take them down.)
# - The bond masters for pif. (Ordinarily pif shouldn't have any
# bond masters. If it does then interface-reconfigure is
# implicitly being asked to take them down.)
- del_ports = add_ports + physdevs + bond_masters
+ del_ports = add_ports + physdev
_name
s + bond_masters
# What networks does this datapath carry?
#
# What networks does this datapath carry?
#
@@
-978,11
+989,11
@@
def action_up(pif):
# enables or disables bond slaves based on whether carrier is
# detected when they are added, and a network device that is down
# always reports "no carrier".
# enables or disables bond slaves based on whether carrier is
# detected when they are added, and a network device that is down
# always reports "no carrier".
- bond_slave_physdevs = []
+ bond_slave_physdev
_pif
s = []
for slave in bond_slaves:
for slave in bond_slaves:
- bond_slave_physdev
s += physdev_name
s(slave)
- for slave_physdev
in bond_slave_physdevs
:
-
up_netdev(slave_physdev
)
+ bond_slave_physdev
_pifs += get_physdev_pif
s(slave)
+ for slave_physdev
_pif in set(bond_slave_physdev_pifs)
:
+
configure_physdev(slave_physdev_pif
)
# Now modify the ovs-vswitchd config file.
argv = []
# Now modify the ovs-vswitchd config file.
argv = []
@@
-1019,11
+1030,11
@@
def action_up(pif):
# slaves (which we brought up earlier).
if vlan_slave:
up_netdev(ipdev_name(vlan_slave))
# slaves (which we brought up earlier).
if vlan_slave:
up_netdev(ipdev_name(vlan_slave))
- for physdev
in set(physdevs) - set(bond_slave_physdev
s):
-
up_netdev(physdev
)
+ for physdev
_pif in set(physdev_pifs) - set(bond_slave_physdev_pif
s):
+
configure_physdev(physdev_pif
)
- # Configure network device
s
.
- configure_
netdev
(pif)
+ # Configure network device
for local port
.
+ configure_
local_port
(pif)
# Update /etc/issue (which contains the IP address of the management interface)
os.system("/sbin/update-issue")
# Update /etc/issue (which contains the IP address of the management interface)
os.system("/sbin/update-issue")