From fbb0168164d18cd5f375e046f8fc1a4d9b94f969 Mon Sep 17 00:00:00 2001 From: Ignatious Johnson Christopher Date: Fri, 29 Jul 2016 00:46:40 -0700 Subject: [PATCH] Mapping vlan skb_priority to dot1p value in vlan interfaces to make sure 802.1p bits are rewritten as per the applied qos-config. Change-Id: Id3e20f7424b80fbc7e1d6820d1574fb3eb128bb8 Closes-Bug: 1603031 --- .../common/interface_setup.py | 21 +++++++++++++++++-- .../common/templates/vlan_egress_map.py | 15 +++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 contrail_provisioning/common/templates/vlan_egress_map.py diff --git a/contrail_provisioning/common/interface_setup.py b/contrail_provisioning/common/interface_setup.py index c86a8b28..7a42f5c5 100755 --- a/contrail_provisioning/common/interface_setup.py +++ b/contrail_provisioning/common/interface_setup.py @@ -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) @@ -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 @@ -541,6 +545,18 @@ 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) @@ -548,7 +564,8 @@ def create_vlan_interface(self): '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) diff --git a/contrail_provisioning/common/templates/vlan_egress_map.py b/contrail_provisioning/common/templates/vlan_egress_map.py new file mode 100644 index 00000000..7d21e420 --- /dev/null +++ b/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 + +""")