From 5be3d4cc59ea955cff35ef962fd908e1147eea99 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Thu, 15 Jul 2021 08:11:38 +0000 Subject: acl: Fix the CLI to accept IPv6 prefixes Type: fix DBGvpp# set acl-plugin acl src 1::1/128 dst 2::/64 DBGvpp# sh acl-plugin acl acl-index 0 count 1 tag {cli} 0: ipv4 permit src 1.1.1.1/32 dst 1.1.1.2/32 proto 0 sport 0-65535 dport 0-65535 acl-index 1 count 1 tag {cli} 0: ipv6 permit src 1::1/128 dst 2::/64 proto 0 sport 0-65535 dport 0-65535 Signed-off-by: Neale Ranns Change-Id: Ibb8e20dd4ec2792f423a61eefe7398175e45a577 --- src/plugins/acl/acl.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c index dcca2a2c9ba..e8b5877ab21 100644 --- a/src/plugins/acl/acl.c +++ b/src/plugins/acl/acl.c @@ -2837,8 +2837,7 @@ acl_set_aclplugin_acl_fn (vlib_main_t * vm, u32 port2 = 0; u32 action = 0; u32 tcpflags, tcpmask; - u32 src_prefix_length = 0, dst_prefix_length = 0; - ip46_address_t src, dst; + ip_prefix_t src, dst; u8 *tag = 0; if (!unformat_user (input, unformat_line_input, line_input)) @@ -2870,25 +2869,15 @@ acl_set_aclplugin_acl_fn (vlib_main_t * vm, vec_validate_acl_rules (rules, rule_idx); rules[rule_idx].is_permit = action; } - else if (unformat (line_input, "src %U/%d", - unformat_ip46_address, &src, IP46_TYPE_ANY, - &src_prefix_length)) + else if (unformat (line_input, "src %U", unformat_ip_prefix, &src)) { vec_validate_acl_rules (rules, rule_idx); - ip_address_encode (&src, IP46_TYPE_ANY, - &rules[rule_idx].src_prefix.address); - rules[rule_idx].src_prefix.address.af = ADDRESS_IP4; - rules[rule_idx].src_prefix.len = src_prefix_length; + ip_prefix_encode2 (&src, &rules[rule_idx].src_prefix); } - else if (unformat (line_input, "dst %U/%d", - unformat_ip46_address, &dst, IP46_TYPE_ANY, - &dst_prefix_length)) + else if (unformat (line_input, "dst %U", unformat_ip_prefix, &dst)) { vec_validate_acl_rules (rules, rule_idx); - ip_address_encode (&dst, IP46_TYPE_ANY, - &rules[rule_idx].dst_prefix.address); - rules[rule_idx].dst_prefix.address.af = ADDRESS_IP4; - rules[rule_idx].dst_prefix.len = dst_prefix_length; + ip_prefix_encode2 (&dst, &rules[rule_idx].dst_prefix); } else if (unformat (line_input, "sport %d-%d", &port1, &port2)) { -- cgit 1.2.3-korg