add support to monitor specific type of traffic tcp/udp/all supported for now

parent 6e868c3f
......@@ -232,6 +232,7 @@ class TapPolicyController(ControllerBase):
dpid_pd = flow.get('dpid')
tap_port = flow.get('output')
vlan_id = flow.get('vlan_id')
trafficType = flow.get('traffic', None)
LOG.debug("dpid_pd: %s", str(dpid_pd))
LOG.debug("tap_port: %d", tap_port)
LOG.debug("vlan_id : %d", vlan_id)
......@@ -241,9 +242,13 @@ class TapPolicyController(ControllerBase):
rateKBps = round(rate /8); #Kbps -> KBps
dbTrafficType = 'all';
if trafficType is not None:
dbTrafficType = trafficType
tapDbEntry= {
'dpid': dpid_pd, 'monitorPort':tap_port, 'bandwidth':10,
'trafficType':'all', 'tunnelVlan':int(vlan_id),
'trafficType':dbTrafficType, 'tunnelVlan':int(vlan_id),
'destinationVlan':int(vlan_id), 'ratelimit':rateKBps
}
......@@ -279,7 +284,7 @@ class TapPolicyController(ControllerBase):
#vlan_id = graph.edge[src][dst]['vlan']
in_vlan_id = vlan_id
iresponse = self.installSafeTapStart(tap_id, dpid_pd,
tap_port, ids_port, vlan_id, rate)
tap_port, ids_port, vlan_id, rate, trafficType)
LOG.debug("iresponse: %s", str(iresponse))
else:
LOG.debug("We have an intermediary switch as src :%s push to port:%d" , src,ids_port)
......@@ -521,7 +526,7 @@ class TapPolicyController(ControllerBase):
return True
def installSafeTapStart(self, tap_id, dpid_pd, tap_port, ids_port,
vlan_id, rate):
vlan_id, rate, trafficType=None):
dpid = hex_to_int(dpid_pd)
dp = self.dpset.get(dpid)
......@@ -609,7 +614,7 @@ class TapPolicyController(ControllerBase):
ids_actions = self.str_to_actions_lim(ofp, actual_action,
supress_outputport=True);
flowDbEntry = self.installIDSEntry(flowDbEntry, dp, match_list, ids_actions, ids_port,
vlan_id, tap_id)
vlan_id, tap_id, trafficType)
objDbEntry = copy.deepcopy(flowDbEntry)
flowID = tapDB.insertFlowDBDict(flowDbEntry);
if flowID is None:
......@@ -650,7 +655,7 @@ class TapPolicyController(ControllerBase):
return flowDbEntry;
def installIDSEntry(self, flowDbEntry, dp, match, action, ids_port,
vlan_id, tap_id):
vlan_id, tap_id, trafficType=None):
LOG.debug("installing IDS flow...")
LOG.debug("flowDbEntry : %s", str(flowDbEntry))
of = dp.ofproto
......@@ -673,6 +678,18 @@ class TapPolicyController(ControllerBase):
inst = [ofp.OFPInstructionActions(of.OFPIT_APPLY_ACTIONS, ids_action)] #working
inst.append(meter_inst)
if trafficType == 'tcp':
LOG.info("Monitoring only TCP")
match.set_dl_type(ether.ETH_TYPE_IP)
match.set_ip_proto(inet.IPPROTO_TCP)
elif trafficType == 'udp':
LOG.info("Monitoring only UDP")
match.set_dl_type(ether.ETH_TYPE_IP)
match.set_ip_proto(inet.IPPROTO_UDP)
else:
LOG.info("supporting tcp, udp and all for now")
LOG.info("fine grained access as future work")
LOG.debug("inst: %s", str(inst))
LOG.debug("match: %s", str(match))
flowDbEntry['modf2Table']= self.IDS_TABLE
......@@ -684,6 +701,7 @@ class TapPolicyController(ControllerBase):
str(flowDbEntry['modf2Action']))
flowDbEntry['pipelineDepth'] = 2
self.DBEntry['mod'].append({'table': self.IDS_TABLE, 'match': match, 'inst': inst})
self.mod_flow(dp,table_id=self.IDS_TABLE,command=of.OFPFC_ADD,match=match, inst=inst);
return flowDbEntry;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment