Add a packet logger application
Add an application which logs the data and metadata of every packet received to the log file. Change-Id: I665c03c9bdf9f00f9c734ae355336396e15bd27b Closes-Bug: #1815886
This commit is contained in:
parent
b8fb4de2f6
commit
e077ff987d
|
@ -0,0 +1,58 @@
|
||||||
|
# Copyright (c) 2015 OpenStack Foundation.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from os_ken.lib.packet import packet as os_ken_packet
|
||||||
|
from oslo_log import log
|
||||||
|
|
||||||
|
from dragonflow.controller import app_base
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app_base.define_specification(
|
||||||
|
states=('main',),
|
||||||
|
entrypoints=(
|
||||||
|
app_base.Entrypoint(
|
||||||
|
name='default',
|
||||||
|
target='main',
|
||||||
|
consumes=(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
exitpoints=(
|
||||||
|
app_base.Exitpoint(
|
||||||
|
name='default',
|
||||||
|
provides=(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
class LogPacketApp(app_base.Base):
|
||||||
|
def initialize(self):
|
||||||
|
self.api.register_table_handler(self.states.main,
|
||||||
|
self._packet_in_handler)
|
||||||
|
self.mod_flow(
|
||||||
|
table_id=self.states.main,
|
||||||
|
actions=[
|
||||||
|
self.parser.OFPActionOutput(self.ofproto.OFPP_CONTROLLER,
|
||||||
|
self.ofproto.OFPCML_NO_BUFFER),
|
||||||
|
self.parser.NXActionResubmitTable(
|
||||||
|
table_id=self.exitpoints.default),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def _packet_in_handler(self, event):
|
||||||
|
msg = event.msg
|
||||||
|
pkt = os_ken_packet.Packet(msg.data)
|
||||||
|
LOG.info("LogPacketApp: Got message: %s, match: %s, packet: %s",
|
||||||
|
msg, msg.match, pkt)
|
|
@ -1,8 +1,11 @@
|
||||||
vertices:
|
vertices:
|
||||||
portsec:
|
portsec:
|
||||||
type: portsec
|
type: portsec
|
||||||
|
log:
|
||||||
|
type: log
|
||||||
|
|
||||||
edges:
|
edges:
|
||||||
dragonflow-legacy.out.1: portsec.in.default
|
dragonflow-legacy.out.1: log.in.default
|
||||||
|
log.out.default: portsec.in.default
|
||||||
portsec.out.default: dragonflow-legacy.in.10
|
portsec.out.default: dragonflow-legacy.in.10
|
||||||
portsec.out.services: dragonflow-legacy.in.20
|
portsec.out.services: dragonflow-legacy.in.20
|
||||||
|
|
|
@ -106,6 +106,7 @@ dragonflow.controller.apps =
|
||||||
sg = dragonflow.controller.apps.sg:SGApp
|
sg = dragonflow.controller.apps.sg:SGApp
|
||||||
trunk = dragonflow.controller.apps.trunk:TrunkApp
|
trunk = dragonflow.controller.apps.trunk:TrunkApp
|
||||||
tunneling = dragonflow.controller.apps.tunneling:TunnelingApp
|
tunneling = dragonflow.controller.apps.tunneling:TunnelingApp
|
||||||
|
log = dragonflow.controller.apps.packet_log:LogPacketApp
|
||||||
dragonflow.db.models =
|
dragonflow.db.models =
|
||||||
active_port = dragonflow.db.models.active_port
|
active_port = dragonflow.db.models.active_port
|
||||||
bgp = dragonflow.db.models.bgp
|
bgp = dragonflow.db.models.bgp
|
||||||
|
|
Loading…
Reference in New Issue