1 # Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
2 # Copyright (C) 2013 Isaku Yamahata <yamahata at valinux co jp>
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 PYTHONPATH=. ./bin/ryu-manager --verbose \
20 ryu.services.protocols.vrrp.dumper \
21 ryu.services.protocols.vrrp.sample_manager.py \
22 ryu.tests.integrated.test_vrrp_linux_multi \
25 ryu.services.protocols.vrrp.dumper is optional.
26 ryu.app.rest is merely to prevent ryu-manager from exiting.
30 Ryu | linux bridge |<--veth2--> command to generate packets
31 \--<--veth1-->| (vrrpbr) |
35 # ip link add veth0 type veth peer name veth0-br
36 # ip link add veth1 type veth peer name veth1-br
37 # ip link add veth2 type veth peer name veth2-br
40 # brctl addif vrrpbr veth0-br
41 # brctl addif vrrpbr veth1-br
42 # brctl addif vrrpbr veth2-br
45 # ip link set veth0 up
46 # ip link set veth0-br up
47 # ip link set veth1 up
48 # ip link set veth1-br up
49 # ip link set veth2 up
50 # ip link set veth2-br up
51 # ip link set vrrpbr up
53 if you like, capture packets on each interfaces like
59 virtual router mac address: 00:00:5E:00:01:{VRID} = 00:00:5E:00:01:07
60 during working, send packets destined to mac address 00:00:5E:00:01:07
61 from veth2 by packet generator like packeth
63 NOTE: vrid: 7 and ip address: 10.0.0.1... are hardcoded below
66 from ryu.base import app_manager
67 from ryu.lib import hub
68 from ryu.lib import mac as lib_mac
69 from ryu.lib.packet import vrrp
70 from ryu.services.protocols.vrrp import api as vrrp_api
71 from ryu.services.protocols.vrrp import event as vrrp_event
72 from ryu.services.protocols.vrrp import monitor_linux
74 from . import vrrp_common
77 class VRRPConfigApp(vrrp_common.VRRPCommon):
81 def __init__(self, *args, **kwargs):
82 super(VRRPConfigApp, self).__init__(*args, **kwargs)
87 def _configure_vrrp_router(self, vrrp_version, priority,
88 primary_ip_address, ifname, vrid):
89 interface = vrrp_event.VRRPInterfaceNetworkDevice(
90 lib_mac.DONTCARE_STR, primary_ip_address, None, ifname)
91 self.logger.debug('%s', interface)
93 vip = '10.0.%d.1' % vrid
95 config = vrrp_event.VRRPConfig(
96 version=vrrp_version, vrid=vrid, priority=priority,
97 ip_addresses=ip_addresses)
98 self.logger.debug('%s', config)
100 rep = vrrp_api.vrrp_config(self, interface, config)
101 self.logger.debug('%s', rep)