diff options
author | Naoto Hanaue <hanaue.naoto@po.ntts.co.jp> | 2015-01-22 16:14:37 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-22 20:31:35 +0900 |
commit | 3338cc7c8a914eb1fdde590ff916189766d43c46 (patch) | |
tree | 5ec94c215d84c1991c31cb96d324236704265c04 /test | |
parent | f988619c365f231b176eeb1f0d65d69017906c8c (diff) |
scenario_test: add malformd packet test
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'test')
7 files changed, 268 insertions, 0 deletions
diff --git a/test/scenario_test/dockerfile/exabgp/Dockerfile b/test/scenario_test/dockerfile/exabgp/Dockerfile new file mode 100644 index 00000000..f50ad8de --- /dev/null +++ b/test/scenario_test/dockerfile/exabgp/Dockerfile @@ -0,0 +1,20 @@ +# EXA BGP +# +# Vertion 3.4.5 + +FROM ubuntu:14.04 + +MAINTAINER Naoto Hanaue <hanaue.naoto@po.ntts.co.jp> + +RUN apt-get update +RUN apt-get install -qy --no-install-recommends wget python + +ENV HOME /root +WORKDIR /root + +RUN wget --no-check-certificate https://github.com/Exa-Networks/exabgp/archive/3.4.5.tar.gz +RUN tar xzvf 3.4.5.tar.gz +RUN rm 3.4.5.tar.gz +RUN mv exabgp-3.4.5/ /usr/local/exabgp + +ADD exabgp.env /usr/local/exabgp/etc/exabgp/exabgp.env
\ No newline at end of file diff --git a/test/scenario_test/dockerfile/exabgp/exabgp.env b/test/scenario_test/dockerfile/exabgp/exabgp.env new file mode 100644 index 00000000..44986a6c --- /dev/null +++ b/test/scenario_test/dockerfile/exabgp/exabgp.env @@ -0,0 +1,41 @@ +[exabgp.api] +encoder = text + +[exabgp.cache] +attributes = false +nexthops = false + +[exabgp.daemon] +daemonize = false +pid = '' +user = 'root' + +[exabgp.log] +#all = false +all = false +configuration = false +daemon = true +destination = '/mnt/exabgpd.log' +#destination = 'syslog' +enable = true +level = INFO +message = false +network = true +packets = false +parser = false +processes = true +rib = false +routes = false +short = false +supervisor = true +timers = false + +[exabgp.pdb] +enable = false + +[exabgp.profile] +enable = false +file = '' + +[exabgp.tcp] +timeout = 1
\ No newline at end of file diff --git a/test/scenario_test/exabgp_test_conf/gobgpd.conf b/test/scenario_test/exabgp_test_conf/gobgpd.conf new file mode 100644 index 00000000..31c37640 --- /dev/null +++ b/test/scenario_test/exabgp_test_conf/gobgpd.conf @@ -0,0 +1,78 @@ +[Global] + As = 65000 + RouterId = "192.168.255.1" + [Global.DefaultRouteDistance] + ExternalRouteDistance = 0 + InternalRouteDistance = 0 + [Global.Confederation] + Identifier = 0 + [Global.BgpGlobalState] + StartTime = 0001-01-01T00:00:00Z + +[[NeighborList]] + NeighborAddress = "10.0.0.100" + PeerAs = 65100 + Description = "" + AuthPassword = "hoge100" + PeerType = 0 + RemovePrivateAs = 0 + RouteFlapDamping = false + [NeighborList.RouteSelectionOptions] + AlwaysCompareMed = false + IgnoreAsPathLength = false + ExternalCompareRouterId = false + AdvertiseInactiveRoutes = false + EnableAigp = false + [NeighborList.UseMultiplePaths] + [NeighborList.UseMultiplePaths.Ebgp] + AllowMultipleAs = false + MaximumPaths = 0 + [NeighborList.UseMultiplePaths.Ibgp] + MaximumPaths = 0 + [NeighborList.UseMultiplePaths.Eibgp] + MaximumPaths = 0 + [NeighborList.GracefulRestart] + RestartTime = 0 + StaleRoutesTime = 0.0 + [NeighborList.ApplyPolicy] + [NeighborList.Timers] + ConnectRetry = 0.0 + HoldTime = 0.0 + KeepaliveInterval = 0.0 + MinimumAdvertisementInterval = 0.0 + SendUpdateDelay = 0.0 + [NeighborList.EbgpMultihop] + MultihopTtl = 0 + [NeighborList.RouteReflector] + RouteReflectorClusterId = 0 + RouteReflectorClient = false + [NeighborList.BgpLoggingOptions] + LogNeighborStateChanges = false + [NeighborList.TransportOptions] + TcpMss = 0 + MtuDiscovery = false + PassiveMode = false + [NeighborList.BgpNeighborCommonState] + State = 0 + Uptime = 0001-01-01T00:00:00Z + OpenIn = 0 + OpenOut = 0 + UpdateIn = 0 + UpdateOut = 0 + UpdateRecvTime = 0001-01-01T00:00:00Z + KeepaliveIn = 0 + KeepaliveOut = 0 + NotifyIn = 0 + NotifyOut = 0 + RefreshIn = 0 + RefreshOut = 0 + DynamicCapIn = 0 + DynamicCapOut = 0 + TotalIn = 0 + TotalOut = 0 + EstablishedCount = 0 + DroppedCount = 0 + +[Policy] + [Policy.DefinedSets] + [Policy.PolicyDefinitions] diff --git a/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-AS4_PATH.conf b/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-AS4_PATH.conf new file mode 100644 index 00000000..79502e78 --- /dev/null +++ b/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-AS4_PATH.conf @@ -0,0 +1,19 @@ +neighbor 10.0.255.1 { + router-id 192.168.0.7; + local-address 10.0.0.100; + local-as 65100; + peer-as 65000; + hold-time 90; + md5 "hoge100"; + graceful-restart; + + family { + inet unicast; + } + static { + route 172.16.13.0/24 next-hop 10.0.0.120; + route 192.168.100.100 next-hop 10.0.0.110; + # malformed AS4_PATH + route 10.7.0.17/32 next-hop 10.0.255.7 attribute [ 0x11 0x60 0x11223344 ]; + } +} diff --git a/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-AS_PATH.conf b/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-AS_PATH.conf new file mode 100644 index 00000000..a241c71f --- /dev/null +++ b/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-AS_PATH.conf @@ -0,0 +1,19 @@ +neighbor 10.0.255.1 { + router-id 192.168.0.7; + local-address 10.0.0.100; + local-as 65100; + peer-as 65000; + hold-time 90; + md5 "hoge100"; + graceful-restart; + + family { + inet unicast; + } + static { + route 172.16.13.0/24 next-hop 10.0.0.120; + route 192.168.100.100 next-hop 10.0.0.110; + # malformed AS_PATH + route 10.7.0.2/32 next-hop 10.0.255.7 attribute [ 0x02 0x60 0x11223344 ]; + } +} diff --git a/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-MP_REACH_NLRI.conf b/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-MP_REACH_NLRI.conf new file mode 100644 index 00000000..95ea6ba1 --- /dev/null +++ b/test/scenario_test/exabgp_test_conf/malformed1-exabgp-gobgp-v4-MP_REACH_NLRI.conf @@ -0,0 +1,19 @@ +neighbor 10.0.255.1 { + router-id 192.168.0.7; + local-address 10.0.0.100; + local-as 65100; + peer-as 65000; + hold-time 90; + md5 "hoge100"; + graceful-restart; + + family { + inet unicast; + } + static { + route 172.16.13.0/24 next-hop 10.0.0.120; + route 192.168.100.100 next-hop 10.0.0.110; + # malformed MP_UNREACH_NLRI + route 10.7.0.15/32 next-hop 10.0.255.7 attribute [ 0x0f 0x60 0x11223344 ]; + } +} diff --git a/test/scenario_test/route_server_malformed_test.py b/test/scenario_test/route_server_malformed_test.py new file mode 100644 index 00000000..bfaf874c --- /dev/null +++ b/test/scenario_test/route_server_malformed_test.py @@ -0,0 +1,72 @@ +# Copyright (C) 2014 Nippon Telegraph and Telephone Corporation. +# +# 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. + +import os +import time +import re +import sys +import collections +import docker_control as fab + +sleep_time = 20 + + +def check_pattern(): + """ + if want to add test pattern, please write config name and notification message in this function. + this tests is execute defined order. + sample: + pattern["<File to be used in test>"] = "<at that time the message>" + """ + pattern = collections.OrderedDict() + pattern["malformed1-exabgp-gobgp-v4-MP_REACH_NLRI.conf"] = "UPDATE message error / Attribute Flags Error / 0x600F0411223344" + pattern["malformed1-exabgp-gobgp-v4-AS_PATH.conf"] = "UPDATE message error / Malformed AS_PATH" + pattern["malformed1-exabgp-gobgp-v4-AS4_PATH.conf"] = "UPDATE message error / Malformed AS_PATH" + + return pattern + + +def test_malformed_packet(): + pwd = os.getcwd() + pattern = check_pattern() + if len(pattern) <= 0: + print "read test patten is faild." + print "csv element is " + str(len(pattern)) + sys.exit(1) + + for pkey in pattern: + conf_file = pwd + "/exabgp_test_conf/" + pkey + if os.path.isfile(conf_file) is True: + fab.init_malformed_test_env_executor(pkey) + print "please wait" + time.sleep(sleep_time) + yield check_em, pkey, pattern[pkey] + + else: + print "config file not exists." + print conf_file + sys.exit(1) + + +def check_em(exabgp_conf, result): + err_msg = fab.get_notification_from_exabgp_log() + parse_msg = re.search(r'error.*', err_msg).group(0) + notification_src = parse_msg[5:] + + print "notification message : " + print " >>> " + notification_src + notification = notification_src[1:-1] + + assert notification == result
\ No newline at end of file |