Skip to content

Commit

Permalink
Mapping vlan skb_priority to dot1p value in vlan interfaces
Browse files Browse the repository at this point in the history
to make sure 802.1p bits are rewritten as per the applied qos-config.

Change-Id: Id3e20f7424b80fbc7e1d6820d1574fb3eb128bb8
Closes-Bug: 1603031
  • Loading branch information
cijohnson committed Jul 29, 2016
1 parent ffac775 commit fbb0168
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
21 changes: 19 additions & 2 deletions contrail_provisioning/common/interface_setup.py
Expand Up @@ -27,6 +27,9 @@
except ImportError:
pass

from contrail_provisioning.common.templates import vlan_egress_map


logging.basicConfig(format='%(asctime)-15s:: %(funcName)s:%(levelname)s::\
%(message)s',
level=logging.INFO)
Expand Down Expand Up @@ -148,7 +151,8 @@ def create_vlan_interface(self):
'NM_CONTROLLED' : 'no',
'NETMASK' : self.netmask,
'IPADDR' : self.ipaddr,
'VLAN' : 'yes'
'VLAN' : 'yes',
'VLAN_EGRESS_PRIORITY_MAP' : '0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7',
}
if self.gw:
cfg['GATEWAY'] = self.gw
Expand Down Expand Up @@ -541,14 +545,27 @@ def create_bond_members(self):
%(self.device, each, each))
self.write_network_script(each, cfg)

def get_vlan_egress_map_script(self, interface):
vlan_egress_map_config = \
vlan_egress_map.template.safe_substitute(
{'__interface__' : interface})
egress_map_script = '/opt/contrail/bin/vconfig-%s' % interface
with open(egress_map_script, 'w+') as fd:
fd.write(vlan_egress_map_config)
fd.flush()
os.chmod(egress_map_script, 0755)

return egress_map_script

def create_vlan_interface(self):
'''Create interface config for vlan sub interface'''
interface = "%s.%s"%(self.device, self.vlan)
cfg = ['auto %s' %interface,
'iface %s inet static' %interface,
'address %s' %self.ipaddr,
'netmask %s' %self.netmask,
'vlan-raw-device %s' %self.device]
'vlan-raw-device %s' %self.device,
'post-up %s' % self.get_vlan_egress_map_script(interface)]
if self.gw:
cfg.append('gateway %s' %self.gw)
self.write_network_script(interface, cfg)
Expand Down
15 changes: 15 additions & 0 deletions contrail_provisioning/common/templates/vlan_egress_map.py
@@ -0,0 +1,15 @@
import string

template = string.Template("""
#!/bin/bash
vconfig set_egress_map $__interface__ 0 0
vconfig set_egress_map $__interface__ 1 1
vconfig set_egress_map $__interface__ 2 2
vconfig set_egress_map $__interface__ 3 3
vconfig set_egress_map $__interface__ 4 4
vconfig set_egress_map $__interface__ 5 5
vconfig set_egress_map $__interface__ 6 6
vconfig set_egress_map $__interface__ 7 7
""")

0 comments on commit fbb0168

Please sign in to comment.