diff options
author | Christian Trautman <ctrautma@redhat.com> | 2018-06-18 19:13:58 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-06-18 19:13:58 +0000 |
commit | d45a59c342f0b12f9e9f7f5652e121868b7b270b (patch) | |
tree | 8bd1acfe7530cd0153f67814232a7de79b06c4a9 /tools/pkt_gen/xena/json/xena_json.py | |
parent | 7e3db8dbc23d91484cc608bd8cb1d42ea7729396 (diff) | |
parent | 11be4868b77d49174afafcd515d1037325796d04 (diff) |
Merge "Xena_Flow_Fix: Fixes multistream of greater than 64k values"
Diffstat (limited to 'tools/pkt_gen/xena/json/xena_json.py')
-rw-r--r-- | tools/pkt_gen/xena/json/xena_json.py | 106 |
1 files changed, 82 insertions, 24 deletions
diff --git a/tools/pkt_gen/xena/json/xena_json.py b/tools/pkt_gen/xena/json/xena_json.py index df2aa55f..e56b4125 100644 --- a/tools/pkt_gen/xena/json/xena_json.py +++ b/tools/pkt_gen/xena/json/xena_json.py @@ -26,6 +26,7 @@ Xena JSON module from collections import OrderedDict import locale import logging +import math import os from tools.pkt_gen.xena.json import json_utilities @@ -71,30 +72,87 @@ class XenaJSON(object): 3: ('Dest IP Addr', 'Src IP Addr'), 4: ('Dest Port', 'Src Port') } - segments = [ - { - "Offset": 0, - "Mask": "//8=", # mask of 255/255 - "Action": "INC", - "StartValue": 0, - "StopValue": stop_value, - "StepValue": 1, - "RepeatCount": 1, - "SegmentId": seg_uuid, - "FieldName": field_name[int(layer)][0] - }, - { - "Offset": 0, - "Mask": "//8=", # mask of 255/255 - "Action": "INC", - "StartValue": 0, - "StopValue": stop_value, - "StepValue": 1, - "RepeatCount": 1, - "SegmentId": seg_uuid, - "FieldName": field_name[int(layer)][1] - } - ] + + if stop_value > 4294836225: + _LOGGER.debug('Flow mods exceeds highest value, changing to 4294836225') + stop_value = 4294836225 + + if stop_value <= 65535 or layer == 4: + segments = [ + { + "Offset": 0 if layer == 4 else 2, + "Mask": "//8=", # mask of 255/255 + "Action": "INC", + "StartValue": 0, + "StopValue": stop_value - 1, + "StepValue": 1, + "RepeatCount": 1, + "SegmentId": seg_uuid, + "FieldName": field_name[int(layer)][0] + }, + { + "Offset": 0 if layer == 4 else 2, + "Mask": "//8=", # mask of 255/255 + "Action": "INC", + "StartValue": 0, + "StopValue": stop_value - 1, + "StepValue": 1, + "RepeatCount": 1, + "SegmentId": seg_uuid, + "FieldName": field_name[int(layer)][1] + } + ] + else: + stop_value = int(math.sqrt(stop_value)) + _LOGGER.debug('Flow count modified to %s', stop_value * stop_value) + segments = [ + { + "Offset": 0 if layer == 3 else 1, + "Mask": "//8=", # mask of 255/255 + "Action": "INC", + "StartValue": 0, + "StopValue": stop_value - 1, + "StepValue": 1, + "RepeatCount": stop_value, + "SegmentId": seg_uuid, + "FieldName": field_name[int(layer)][0] + }, + { + "Offset": 2 if layer == 3 else 3, + "Mask": "//8=", # mask of 255/255 + "Action": "INC", + "StartValue": 0, + "StopValue": stop_value - 1, + "StepValue": 1, + "RepeatCount": 1, + "SegmentId": seg_uuid, + "FieldName": field_name[int(layer)][0] + }, + { + "Offset": 0 if layer == 3 else 1, + "Mask": "//8=", # mask of 255/255 + "Action": "INC", + "StartValue": 0, + "StopValue": stop_value - 1, + "StepValue": 1, + "RepeatCount": stop_value, + "SegmentId": seg_uuid, + "FieldName": field_name[int(layer)][1] + }, + { + "Offset": 2 if layer == 3 else 3, + "Mask": "//8=", # mask of 255/255 + "Action": "INC", + "StartValue": 0, + "StopValue": stop_value - 1, + "StepValue": 1, + "RepeatCount": 1, + "SegmentId": seg_uuid, + "FieldName": field_name[int(layer)][1] + } + ] + + self.json_data['StreamProfileHandler']['EntityList'][entity][ 'StreamConfig']['HwModifiers'] = (segments) |