summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPavel Kotucek <pkotucek@cisco.com>2017-08-16 15:45:37 +0200
committerOle Trøan <otroan@employees.org>2017-08-18 12:34:43 +0000
commitf77e913549bbe08c09431e2f7d4bea61e4027fea (patch)
treeb6c4b89f1ffa75b6847f4f2e7ccc6983aaf1f5ed /src
parent71bb05454c97cc18e3c95127b54385c52e4c57c2 (diff)
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 <pkotucek@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/acl/acl_test.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c
index 704906a9e4e..2b5175852e4 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;
235'>235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
# Copyright (c) 2015 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
AUTOMAKE_OPTIONS = foreign subdir-objects

AM_CPPFLAGS = -Wall @VEC64@ # -Werror

if WITH_UNIX
  lib_LTLIBRARIES = libvppinfra.la
endif

lib_LIBRARIES =

TESTS =

if ENABLE_TESTS
TESTS  +=  test_bihash_template \
	   test_elog \
	   test_elf \
	   test_fifo \
	   test_format \
	   test_hash \
	   test_heap \
	   test_longjmp \
	   test_macros \
	   test_md5 \
	   test_mheap \
	   test_pfhash \
	   test_phash \
	   test_pool_iterate \
	   test_qhash \
	   test_random \
	   test_random_isaac \
	   test_serialize \
	   test_slist \
	   test_socket \
	   test_time \
	   test_timing_wheel \
	   test_vec \
	   test_zvec 
endif

noinst_PROGRAMS = $(TESTS)
check_PROGRAMS	= $(TESTS)

test_bihash_template_SOURCES = vppinfra/test_bihash_template.c
test_elog_SOURCES = vppinfra/test_elog.c
test_elf_SOURCES = vppinfra/test_elf.c
test_fifo_SOURCES = vppinfra/test_fifo.c
test_format_SOURCES = vppinfra/test_format.c
test_hash_SOURCES = vppinfra/test_hash.c
test_heap_SOURCES = vppinfra/test_heap.c
test_longjmp_SOURCES = vppinfra/test_longjmp.c
test_macros_SOURCES = vppinfra/test_macros.c
test_md5_SOURCES = vppinfra/test_md5.c
test_mheap_SOURCES = vppinfra/test_mheap.c
test_pfhash_SOURCES = vppinfra/test_pfhash.c
test_phash_SOURCES = vppinfra/test_phash.c
test_pool_iterate_SOURCES = vppinfra/test_pool_iterate.c
test_qhash_SOURCES = vppinfra/test_qhash.c
test_random_SOURCES = vppinfra/test_random.c
test_random_isaac_SOURCES = vppinfra/test_random_isaac.c
test_serialize_SOURCES = vppinfra/test_serialize.c
test_slist_SOURCES = vppinfra/test_slist.c
test_socket_SOURCES = vppinfra/test_socket.c
test_time_SOURCES = vppinfra/test_time.c
test_timing_wheel_SOURCES = vppinfra/test_timing_wheel.c
test_vec_SOURCES = vppinfra/test_vec.c
test_zvec_SOURCES = vppinfra/test_zvec.c

# All unit tests use ASSERT for failure
# So we'll need -DDEBUG to enable ASSERTs
test_bihash_template_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_elog_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_elf_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_fifo_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_format_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_hash_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_heap_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_longjmp_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_macros_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_md5_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_mheap_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_pfhash_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_phash_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_pool_iterate_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_qhash_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_random_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_random_isaac_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_socket_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_serialize_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_slist_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_time_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_timing_wheel_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
test_vec_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG
test_zvec_CPPFLAGS =	$(AM_CPPFLAGS) -DCLIB_DEBUG

test_bihash_template_LDADD =	libvppinfra.la
test_elog_LDADD =	libvppinfra.la
test_elf_LDADD =	libvppinfra.la
test_fifo_LDADD =	libvppinfra.la
test_format_LDADD =	libvppinfra.la
test_hash_LDADD =	libvppinfra.la
test_heap_LDADD =	libvppinfra.la
test_longjmp_LDADD =	libvppinfra.la
test_macros_LDADD =	libvppinfra.la
test_md5_LDADD =	libvppinfra.la
test_mheap_LDADD =	libvppinfra.la
test_pfhash_LDADD =	libvppinfra.la
test_phash_LDADD =	libvppinfra.la
test_pool_iterate_LDADD =	libvppinfra.la
test_qhash_LDADD =	libvppinfra.la
test_random_LDADD =	libvppinfra.la
test_random_isaac_LDADD =	libvppinfra.la
test_serialize_LDADD =	libvppinfra.la
test_slist_LDADD =	libvppinfra.la
test_socket_LDADD =	libvppinfra.la
test_time_LDADD =	libvppinfra.la -lm
test_timing_wheel_LDADD =	libvppinfra.la -lm
test_vec_LDADD =	libvppinfra.la
test_zvec_LDADD =	libvppinfra.la

test_bihash_template_LDFLAGS = -static
test_elog_LDFLAGS = -static
test_elf_LDFLAGS = -static
test_fifo_LDFLAGS = -static
test_format_LDFLAGS = -static
test_hash_LDFLAGS = -static
test_heap_LDFLAGS = -static
test_longjmp_LDFLAGS = -static
test_macros_LDFLAGS = -static
test_md5_LDFLAGS = -static
test_mheap_LDFLAGS = -static
test_pfhash_LDFLAGS = -static
test_phash_LDFLAGS = -static
test_pool_iterate_LDFLAGS = -static
test_qhash_LDFLAGS = -static
test_random_LDFLAGS = -static
test_random_isaac_LDFLAGS = -static
test_serialize_LDFLAGS = -static
test_slist_LDFLAGS = -static
test_socket_LDFLAGS = -static
test_time_LDFLAGS = -static
test_timing_wheel_LDFLAGS = -static
test_vec_LDFLAGS = -static
test_zvec_LDFLAGS = -static

# noinst_PROGRAMS += test_vhash
# test_vhash_SOURCES = vppinfra/test_vhash.c vppinfra/vhash.c
# test_vhash_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG
# test_vhash_LDADD = libvppinfra.la
# test_vhash_LDFLAGS = -static

nobase_include_HEADERS = \
  vppinfra/asm_mips.h \
  vppinfra/asm_x86.h \
  vppinfra/bihash_8_8.h \
  vppinfra/bihash_24_8.h \
  vppinfra/bihash_template.h \
  vppinfra/bihash_template.c \
  vppinfra/bitmap.h \
  vppinfra/bitops.h \
  vppinfra/byte_order.h \
  vppinfra/cache.h \
  vppinfra/clib.h \
  vppinfra/cpu.h \
  vppinfra/elf.h \
  vppinfra/elf_clib.h \
  vppinfra/elog.h \
  vppinfra/fheap.h \
  vppinfra/error.h \
  vppinfra/error_bootstrap.h \
  vppinfra/fifo.h \
  vppinfra/format.h \
  vppinfra/graph.h \
  vppinfra/hash.h \
  vppinfra/heap.h \
  vppinfra/longjmp.h \
  vppinfra/macros.h \
  vppinfra/math.h \
  vppinfra/md5.h \
  vppinfra/mem.h \
  vppinfra/memcpy_sse3.h \
  vppinfra/memcpy_avx.h \
  vppinfra/mhash.h \
  vppinfra/mheap.h \
  vppinfra/mheap_bootstrap.h \
  vppinfra/os.h \
  vppinfra/pfhash.h \
  vppinfra/phash.h \
  vppinfra/pipeline.h \
  vppinfra/pool.h \
  vppinfra/qhash.h \
  vppinfra/random.h \
  vppinfra/random_buffer.h \
  vppinfra/random_isaac.h \
  vppinfra/serialize.h \
  vppinfra/slist.h \
  vppinfra/smp.h \
  vppinfra/smp_fifo.h \
  vppinfra/socket.h \
  vppinfra/sparse_vec.h \
  vppinfra/string.h \
  vppinfra/time.h \
  vppinfra/timing_wheel.h \
  vppinfra/timer.h \
  vppinfra/types.h \
  vppinfra/unix.h \
  vppinfra/vec.h \
  vppinfra/vec_bootstrap.h \
  vppinfra/vector.h \
  vppinfra/vector_altivec.h \
  vppinfra/vector_funcs.h \
  vppinfra/vector_iwmmxt.h \
  vppinfra/vector_sse2.h \
  vppinfra/valgrind.h \
  vppinfra/vm_unix.h \
  vppinfra/xxhash.h \
  vppinfra/xy.h \
  vppinfra/zvec.h

CLIB_CORE = \
  vppinfra/asm_x86.c \
  vppinfra/backtrace.c \
  vppinfra/cpu.c \
  vppinfra/elf.c \
  vppinfra/elog.c \
  vppinfra/error.c \
  vppinfra/fifo.c \
  vppinfra/fheap.c \
  vppinfra/format.c \
  vppinfra/graph.c \
  vppinfra/hash.c \
  vppinfra/heap.c \
  vppinfra/longjmp.S \
  vppinfra/macros.c \
  vppinfra/mhash.c \
  vppinfra/mheap.c \
  vppinfra/md5.c \
  vppinfra/mem_mheap.c \
  vppinfra/pfhash.c \
  vppinfra/phash.c \
  vppinfra/qhash.c \
  vppinfra/random.c \
  vppinfra/random_buffer.c \
  vppinfra/random_isaac.c \
  vppinfra/serialize.c \
  vppinfra/slist.c \
  vppinfra/smp.c \
  vppinfra/smp_fifo.c \
  vppinfra/std-formats.c \
  vppinfra/string.c \
  vppinfra/time.c \
  vppinfra/timing_wheel.c \
  vppinfra/unformat.c \
  vppinfra/vec.c \
  vppinfra/vector.c \
  vppinfra/zvec.c

# Core plus Unix additions
libvppinfra_la_SOURCES =			\
  $(CLIB_CORE)					\
  vppinfra/elf_clib.c				\
  vppinfra/socket.c				\
  vppinfra/timer.c				\
  vppinfra/unix-formats.c			\
  vppinfra/unix-misc.c

bin_PROGRAMS = elftool

elftool_SOURCES = tools/elftool.c
elftool_CPPFLAGS = -Wall
elftool_LDADD = libvppinfra.la -lpthread -lrt -lm