bgp: fix bug when restart neighbor

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: make marker private variable

stop showing when stringified because it's noisy

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgpspeaker: refine logs

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: remove an unused variable from bgpspeaker

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add neighbor_reset method to bgpspeaker

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
unit test for ofctl_v1_2/3

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_2/3: fix tcp_dst/src match fields

when enclosed the value of "ip_proto" in double quotes,
following match fields is not set at mod_flow_stats command:

  * tcp_dst, tcp_src

this patch fixes this problem.

Reported-by: jalee <jalee@inno-tech.com.tw>
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_2/3: fix unsuitable log

when using action type below, the log unsuitable is outputted:
Unknown action type: [action type]

  * GOTO_TABLE, WRITE_METADATA, METER(only ofctl_v1_3.py)

this patch fixes this problem.

Reported-by: jalee <jalee@inno-tech.com.tw>
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: move filter class under info_base/

move filter class from bgpspeaker.py to info_base/base.py to fix the error
shown below.

$ sudo env PYTHONPATH=/home/wataru/ryu ~/ryu/bin/ryu run --config-file=~/etc/ryu01.conf ./application.py

loading app ./application.py
instantiating app ./application.py of RyuBGPSpeaker
INFO 2014-07-21 06:14:48,066 base 207 API method core.start called with
args: {'router_id': '10.10.0.1', 'label_range': (100, 100000), 'waiter':
<ryu.lib.hub.Event object at 0x1a15dd0>, 'local_as': 64512,
'bgp_server_port': 179, 'refresh_max_eor_time': 0,
'refresh_stalepath_time': 0}
Traceback (most recent call last):
  File "/home/wataru/ryu/bin/ryu", line 20, in <module>
    main()
  File "/home/wataru/ryu/ryu/cmd/ryu_base.py", line 75, in main
    subcmd.run(base_conf.subcommand_args)
  File "/home/wataru/ryu/ryu/cmd/ryu_base.py", line 58, in run
    self.entry(args=args, prog=prog)
  File "/home/wataru/ryu/ryu/cmd/manager.py", line 81, in main
    services.extend(app_mgr.instantiate_apps(**contexts))
  File "/home/wataru/ryu/ryu/base/app_manager.py", line 486, in
instantiate_apps
    t = app.start()
  File "/home/wataru/ryu/ryu/services/protocols/bgp/application.py",
line 93, in start
    self._start_core(settings)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/application.py",
line 168, in _start_core
    call('core.start', waiter=waiter, **common_settings)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/api/base.py", line
210, in call
    import all  # noqa
  File "/home/wataru/ryu/ryu/services/protocols/bgp/api/all.py", line 4,
in <module>
    import prefix
  File "/home/wataru/ryu/ryu/services/protocols/bgp/api/prefix.py", line
29, in <module>
    from ryu.services.protocols.bgp.core import BgpCoreError
  File "/home/wataru/ryu/ryu/services/protocols/bgp/core.py", line 37,
in <module>
    from ryu.services.protocols.bgp import core_managers
  File
"/home/wataru/ryu/ryu/services/protocols/bgp/core_managers/__init__.py",
line 19, in <module>
    from peer_manager import PeerManager
  File
"/home/wataru/ryu/ryu/services/protocols/bgp/core_managers/peer_manager.py",
line 6, in <module>
    from ryu.services.protocols.bgp.peer import Peer
  File "/home/wataru/ryu/ryu/services/protocols/bgp/peer.py", line 32,
in <module>
    from ryu.services.protocols.bgp.bgpspeaker import PrefixList
  File "/home/wataru/ryu/ryu/services/protocols/bgp/bgpspeaker.py", line
56, in <module>
    from ryu.services.protocols.bgp.application import RyuBGPSpeaker
  File "/home/wataru/ryu/ryu/services/protocols/bgp/application.py",
line 64, in <module>
    def_desc='Unknown bootstrap exception.')
  File "/home/wataru/ryu/ryu/services/protocols/bgp/base.py", line 105,
in add_bgp_error_metadata
    'already defined.' % (code, sub_code))
ValueError: BGPSException with code 300 and sub-code 1 already defined.

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: enable filter configuration via configuration file

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add in-filter function

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: create adjacent rib in peer instance

this will be used when in-bound and out-bound filter changed at runtime
and to implement BMP(BGP monitering protocol) client

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: manage filter in a peer instance instead of rtconf

rtconf is basically for static configuration and filter is
dynamic and also specific configuration for peer instance.

move filter things under peer instance, and change rtconf to do only
static configuration things from a configuration file

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: refine and fix filter code

- change the name of the filter class from PrefixList to PrefixFilter to
  make it easy to understand the role of this class.
- update docs
- fix bugs

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: add show neighbor command to ssh client

looks like,

bgpd> show neighbor
 IP Address   AS Number    BGP State
 10.0.0.1     64514        Established

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: make 'core.reset_neighbor' API asynchronously

'core.reset_neighbor' was synchronous API and the caller had to wait
until neighbor comes up. This behavior doesn't work well with rpc_cli.

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofproto_v1_3_parser: Remove a stale comment on OFPTableFeaturesStatsReply

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofproto_v1_4_parser: Remove a stale comment on OFPTableFeaturesStatsReply

Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: fix NameError bug

variable 'nlri_str' was not defined in peer.py

bgpspeaker.speaker l.566  |    DEBUG | Traceback (most recent call last):
  File "/home/wataru/ryu/ryu/services/protocols/bgp/speaker.py", line
560, in _recv_loop
    self.data_received(next_bytes)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/speaker.py", line
275, in data_received
    self._data_received(next_bytes)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/speaker.py", line
355, in _data_received
    self._handle_msg(msg)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/speaker.py", line
508, in _handle_msg
    self._peer.handle_msg(msg)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/peer.py", line 1564,
in handle_msg
    self._handle_update_msg(msg)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/peer.py", line 1230,
in _handle_update_msg
    self._extract_and_handle_mpbgp_new_paths(update_msg)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/peer.py", line 1445,
in _extract_and_handle_mpbgp_new_paths
    self._adj_rib_in[nlri_str] = received_route
NameError: global name 'nlri_str' is not defined

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bgp: fix AttributeError bug

for BGPPathAttributeMpUnreachNLRI, use 'withdrawn_routes' instead of
'nlri_list'

bgpspeaker.speaker l.566  |    DEBUG | Traceback (most recent
call last):
  File "/home/wataru/ryu/ryu/services/protocols/bgp/speaker.py", line
560, in _recv_loop
    self.data_received(next_bytes)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/speaker.py", line
275, in data_received
    self._data_received(next_bytes)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/speaker.py", line
355, in _data_received
    self._handle_msg(msg)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/speaker.py", line
508, in _handle_msg
    self._peer.handle_msg(msg)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/peer.py", line 1567,
in handle_msg
    self._handle_update_msg(msg)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/peer.py", line 1234,
in _handle_update_msg
    self._extract_and_handle_mpbgp_withdraws(mp_unreach_attr)
  File "/home/wataru/ryu/ryu/services/protocols/bgp/peer.py", line 1496,
in _extract_and_handle_mpbgp_withdraws
    w_nlris = mp_unreach_attr.nlri_list
AttributeError: 'BGPPathAttributeMpUnreachNLRI' object has no attribute
'nlri_list'

Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>