From f77e913549bbe08c09431e2f7d4bea61e4027fea Mon Sep 17 00:00:00 2001 From: Pavel Kotucek Date: Wed, 16 Aug 2017 15:45:37 +0200 Subject: Fix small issues in ACL api Enable IP address without prefix length, if not given use max (32/128) Parse correctly type of acl (ipv4). Change-Id: I3d5d6b45037c9e0f95d2d112ae584f006c6cb4d1 Signed-off-by: Pavel Kotucek --- src/plugins/acl/acl_test.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 704906a9..2b517585 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -886,7 +886,7 @@ static int api_macip_acl_add (vat_main_t * vam) else if (unformat (i, "ipv4")) { vec_validate_macip_acl_rules(rules, rule_idx); - rules[rule_idx].is_ipv6 = 1; + rules[rule_idx].is_ipv6 = 0; } else if (unformat (i, "permit")) { @@ -908,8 +908,12 @@ static int api_macip_acl_add (vat_main_t * vam) rules[rule_idx].is_permit = action; } else if (unformat (i, "ip %U/%d", - unformat_ip4_address, &src_v4address, &src_prefix_length)) + unformat_ip4_address, &src_v4address, &src_prefix_length) || + unformat (i, "ip %U", + unformat_ip4_address, &src_v4address)) { + if (src_prefix_length == 0) + src_prefix_length = 32; vec_validate_macip_acl_rules(rules, rule_idx); memcpy (rules[rule_idx].src_ip_addr, &src_v4address, 4); rules[rule_idx].src_ip_prefix_len = src_prefix_length; @@ -920,8 +924,12 @@ static int api_macip_acl_add (vat_main_t * vam) /* Everything in MACIP is "source" but allow this verbosity */ } else if (unformat (i, "ip %U/%d", - unformat_ip6_address, &src_v6address, &src_prefix_length)) + unformat_ip6_address, &src_v6address, &src_prefix_length) || + unformat (i, "ip %U", + unformat_ip6_address, &src_v6address)) { + if (src_prefix_length == 0) + src_prefix_length = 128; vec_validate_macip_acl_rules(rules, rule_idx); memcpy (rules[rule_idx].src_ip_addr, &src_v6address, 16); rules[rule_idx].src_ip_prefix_len = src_prefix_length; -- cgit 1.2.3-korg