bgp: bug fix of handling nexthop for eBGP peering

RyuBGP doesn't work properly becase of handling wrong nexthop address.
Therefore, in spite of receiving BGP UPDATE Message in the peering router,
the router fails to learn a new route entry from RyuBGP in BGP table.
(Memo: this issue has not occurred in Vpnv4/mpBGP environment.)

(1) register route entry as prefix_add(prefix='x,x,x,x', next_hop='y.y.y.y')

                 static               eBGP
    ------- R1 ------------ RyuBGP ---------> Router
    x.x.x.x   y.y.y.y            z.z.z.z       => Drop UPDATE(Nexthop: y.y.y.y)

(2) receiving BGP UPDATE Message from iBGP session

                 iBGP                 eBGP
    ------- R1 -----------> RyuBGP ---------> Router
    x.x.x.x   y.y.y.y            z.z.z.z       => Drop UPDATE(Nexthop: y.y.y.y)

Signed-off-by: Toshiki Tsuboi <t.tsubo2000@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_/2/3: Modify match_to_str() to use new match field parser

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_/2/3: Modify to_match() to use new match api

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
test_ofctl: Modify to use new match api and field parser

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Workaround of os.path.samefile

os.path.samrfile not implemented on Windows. Adding alternative using
os.stat

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
fix security problem of some RESTful apps

I'm very sorry I didn't include rest_firewall.py and rest_qos.py in my patch.
I suggested for ofctl_rest.py only...

Here is the patch for rest_firewall.py and rest_qos.py.

---------------------------------------------------------------
Subject: [PATCH] fix security problem of some RESTful apps

It is not safe to use eval function because input data(request body) is not checked
For example, someone can send this data to remove all files in the directory
"import('os').system('rm -rf .')"

I suggest to use json.loads to parse the request body if the data is json format
or disable builtin functions like:
eval(req.body, {"__builtins__":None})

Signed-off-by: Takeshi <a86487817@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
ofctl_v1_2/3: Fully support the match combinations for VLAN ID

Currently, when VLAN ID match field is specified,
ofctl_v1_[23] is compatible with only match combination 1) of
the following three match combinations.
This patch makes it possible to set the all three combinations.

  Match combinations for VLAN ID :
    1) To match only packets with VLAN tag and VID equal value
    2) To match only packets without a VLAN tag
    3) To match only packets with a VLAN tag regardless of its value

In order to set the match combinations 2) or 3), please describe
"dl_vlan" field as hexadecimal string value like as follows.

  Before applying this patch:
    {"dl_vlan": 3 }              # int

  After applying this patch:
    {"dl_vlan": 3 }              # int (same as before applying)
    {"dl_vlan": "0x0000"}        # hexadecimal string without mask
    {"dl_vlan": "0x1000/0x1000"} # hexadecimal string with mask

NOTE: When "dl_vlan" field is described as decimal int value,
      OFPVID_PRESENT(0x1000) bit is automatically applied.
      OTOH, OFPVID_PRESENT(0x1000) bit is NOT automatically applied
      to hexadecimal string value.

For curl command examples, please refer to the following page in Ryu-documentation.
http://ryu.readthedocs.org/en/latest/app/ofctl_rest.html#example-of-vlan-id-match-field

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
doc/app/ofctl_rest: Add command examples for OFPVID_NONE/PRESENT

Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bmp: bug fix of peer bgp ID in BMP Message

Ryu BGP sets self-BGP ID as Peer BGP ID in BMP Message.

Signed-off-by: Yuji Oshima <yuji.oshima0x3fd@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
packet lib: don't crash with bogus ospf packet

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Ryu 3.16

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Merge remote-tracking branch 'upstream/master'