diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2016-08-22 17:21:38 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-08-25 13:33:55 +0900 |
commit | c8b8a34f3dc7e5b108783b1b17a402e518868989 (patch) | |
tree | 6008664ec28c12720116fdfa4c946cd6a4e1e9b9 | |
parent | ba150be4b1492c452dc436c0c630e00144f3c5bf (diff) |
BGPSpeaker: Raise exception when validation fails
In the validator for the API arguments should raise exception
when the validator detects invalid arguments, otherwise the
decorator for registering API functions, RegisterWithArgChecks,
can pass through the invalid arguments.
This patch fixes this problem.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/services/protocols/bgp/api/prefix.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ryu/services/protocols/bgp/api/prefix.py b/ryu/services/protocols/bgp/api/prefix.py index 3340112f..f047b6ae 100644 --- a/ryu/services/protocols/bgp/api/prefix.py +++ b/ryu/services/protocols/bgp/api/prefix.py @@ -64,13 +64,19 @@ class PrefixError(RuntimeConfigError): @validate(name=PREFIX) -def is_valid_prefix(ipv4_prefix): - return validation.is_valid_ipv4_prefix(ipv4_prefix) +def is_valid_prefix(prefix): + if not (validation.is_valid_ipv4_prefix(prefix) + or validation.is_valid_ipv6_prefix(prefix)): + raise ConfigValueError(conf_name=PREFIX, + conf_value=prefix) @validate(name=NEXT_HOP) -def is_valid_next_hop(next_hop_addr): - return validation.is_valid_ipv4(next_hop_addr) +def is_valid_next_hop(next_hop): + if not (validation.is_valid_ipv4(next_hop) + or validation.is_valid_ipv6(next_hop)): + raise ConfigValueError(conf_name=NEXT_HOP, + conf_value=next_hop) @validate(name=EVPN_ROUTE_TYPE) |