def __init__(self, app, sonata_fields): # LOGGING log_level = logging.DEBUG self.logger = get_logger('P4Application', 'INFO') self.logger.setLevel(log_level) self.logger.info('init') # Define the root layer for raw packet # self.root_layer = Ethernet() # self.p4_raw_fields = P4RawFields(self.root_layer) self.root_layer = "ethernet" self.p4_raw_fields = sonata_fields # define the application metadata self.drop_meta_field = 'drop' self.satisfied_meta_field = 'satisfied' self.clone_meta_field = 'clone' self.mirror_session = None self.field_list = None self.final_header = None self.final_header_action = None self.final_header_table = None self.init_action = None self.init_action_table = None self.report_action = None self.report_action_table = None self.nop_action = None self.metadata = None self.queries = self.init_application(app)
def __init__(self, name, qid, operator_id, keys, p4_raw_fields): self.name = name self.operator_name = '%s_%i_%i' % (name.lower(), qid, operator_id) self.query_id = qid self.operator_id = operator_id self.keys = list(keys) self.out_headers = list(keys) self.p4_raw_fields = p4_raw_fields self.create_operator_specific_fields() # LOGGING self.logger = get_logger(name, 'DEBUG')
def __init__(self, query_id, parse_payload, payload_fields, read_register, filter_payload, filter_payload_str, generic_operators, nop_name, drop_meta_field, satisfied_meta_field, clone_meta_field, p4_raw_fields): # LOGGING log_level = logging.ERROR self.logger = get_logger('P4Query - %i' % query_id, 'DEBUG') self.logger.setLevel(log_level) self.logger.info('init') self.id = query_id self.parse_payload = parse_payload self.payload_fields = payload_fields self.read_register = read_register self.filter_payload = filter_payload self.filter_payload_str = filter_payload_str self.registers_to_read = [] self.meta_init_name = '' # print '$$$$$$$$$$$$$ vals: ' + str(self.parse_payload) + ":" + str(self.read_register) self.src_to_filter_operator = dict() self.nop_action = nop_name self.drop_meta_field = '%s_%i' % (drop_meta_field, self.id) self.satisfied_meta_field = '%s_%i' % (satisfied_meta_field, self.id) self.clone_meta_field = clone_meta_field self.p4_raw_fields = p4_raw_fields self.actions = dict() # general drop action which is applied when a packet doesn't satisfy this query self.add_general_drop_action() # action and table to mark query as satisfied at end of query processing in ingress self.mark_satisfied() # initialize operators self.get_all_fields(generic_operators) self.operators = self.init_operators(generic_operators) # create an out header layer self.create_out_header() # action and table to populate out_header in egress self.append_out_header()
def __init__(self, em_conf, target_conf, internal_interfaces): self.em_conf = em_conf # Code Compilation self.COMPILED_SRCS = target_conf['compiled_srcs'] self.JSON_P4_COMPILED = self.COMPILED_SRCS + target_conf['json_p4_compiled'] self.P4_COMPILED = self.COMPILED_SRCS + target_conf['p4_compiled'] self.P4C_BM_SCRIPT = target_conf['p4c_bm_script'] self.internal_interfaces = internal_interfaces # Initialization of Switch self.BMV2_PATH = target_conf['bmv2_path'] self.BMV2_SWITCH_BASE = self.BMV2_PATH + target_conf['bmv2_switch_base'] self.SWITCH_PATH = self.BMV2_SWITCH_BASE + target_conf['switch_path'] self.CLI_PATH = self.BMV2_SWITCH_BASE + target_conf['cli_path'] self.THRIFTPORT = target_conf['thriftport'] self.P4_COMMANDS = self.COMPILED_SRCS + target_conf['p4_commands'] self.P4_DELTA_COMMANDS = self.COMPILED_SRCS + target_conf['p4_delta_commands'] # interfaces self.interfaces = { 'receiver': ['m-veth-1', 'out-veth-1'], 'sender': ['m-veth-2', 'out-veth-2'], 'original': ['m-veth-3', 'out-veth-3'] } self.supported_operations = ['Map', 'Filter', 'Reduce', 'Distinct'] # LOGGING log_level = logging.INFO self.logger = get_logger('P4Target', 'INFO') self.logger.setLevel(log_level) self.logger.info('init') # init dataplane self.dataplane = P4DataPlane(self.interfaces, self.SWITCH_PATH, self.CLI_PATH, self.THRIFTPORT, self.P4C_BM_SCRIPT, self.internal_interfaces) # p4 app object self.app = None print "P4 target initialized"
def __init__(self, name): self.name = name # LOGGING self.logger = get_logger(name, 'DEBUG')