summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/filter.c123
-rw-r--r--lib/if.c2
-rw-r--r--lib/ptm_lib.c2
-rw-r--r--lib/thread.c2
-rw-r--r--lib/vty.c2
-rw-r--r--lib/zclient.c8
6 files changed, 52 insertions, 87 deletions
diff --git a/lib/filter.c b/lib/filter.c
index 46e0bbe804..2b9ba87137 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -1335,25 +1335,9 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
return CMD_SUCCESS;
}
-/* Zebra access-list */
-DEFUN (access_list,
- access_list_cmd,
- "access-list WORD <deny|permit> A.B.C.D/M",
- "Add an access list entry\n"
- "IP zebra access-list name\n"
- "Specify packets to reject\n"
- "Specify packets to forward\n"
- "Prefix to match. e.g. 10.0.0.0/8\n")
-{
- int idx_word = 1;
- int idx_permit_deny = 2;
- int idx_ipv4_prefixlen = 3;
- return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 0, 1);
-}
-
DEFUN (access_list_exact,
access_list_exact_cmd,
- "access-list WORD <deny|permit> A.B.C.D/M exact-match",
+ "access-list WORD <deny|permit> A.B.C.D/M [exact-match]",
"Add an access list entry\n"
"IP zebra access-list name\n"
"Specify packets to reject\n"
@@ -1361,10 +1345,18 @@ DEFUN (access_list_exact,
"Prefix to match. e.g. 10.0.0.0/8\n"
"Exact match of the prefixes\n")
{
+ int idx;
+ int exact = 0;
int idx_word = 1;
int idx_permit_deny = 2;
int idx_ipv4_prefixlen = 3;
- return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 1, 1);
+ idx = idx_ipv4_prefixlen;
+
+ if (argv_find (argv, argc, "exact-match", &idx))
+ exact = 1;
+
+ return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg,
+ AFI_IP, argv[idx_ipv4_prefixlen]->arg, exact, 1);
}
DEFUN (access_list_any,
@@ -1381,25 +1373,9 @@ DEFUN (access_list_any,
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, "0.0.0.0/0", 0, 1);
}
-DEFUN (no_access_list,
- no_access_list_cmd,
- "no access-list WORD <deny|permit> A.B.C.D/M",
- NO_STR
- "Add an access list entry\n"
- "IP zebra access-list name\n"
- "Specify packets to reject\n"
- "Specify packets to forward\n"
- "Prefix to match. e.g. 10.0.0.0/8\n")
-{
- int idx_word = 2;
- int idx_permit_deny = 3;
- int idx_ipv4_prefixlen = 4;
- return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 0, 0);
-}
-
DEFUN (no_access_list_exact,
no_access_list_exact_cmd,
- "no access-list WORD <deny|permit> A.B.C.D/M exact-match",
+ "no access-list WORD <deny|permit> A.B.C.D/M [exact-match]",
NO_STR
"Add an access list entry\n"
"IP zebra access-list name\n"
@@ -1408,10 +1384,17 @@ DEFUN (no_access_list_exact,
"Prefix to match. e.g. 10.0.0.0/8\n"
"Exact match of the prefixes\n")
{
+ int idx;
+ int exact = 0;
int idx_word = 2;
int idx_permit_deny = 3;
int idx_ipv4_prefixlen = 4;
- return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, 1, 0);
+ idx = idx_ipv4_prefixlen;
+
+ if (argv_find (argv, argc, "exact-match", &idx))
+ exact = 1;
+
+ return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP, argv[idx_ipv4_prefixlen]->arg, exact, 0);
}
DEFUN (no_access_list_any,
@@ -1526,27 +1509,10 @@ DEFUN (no_access_list_remark_comment,
{
return no_access_list_remark (self, vty, argc, argv);
}
-
-
-DEFUN (ipv6_access_list,
- ipv6_access_list_cmd,
- "ipv6 access-list WORD <deny|permit> X:X::X:X/M",
- IPV6_STR
- "Add an access list entry\n"
- "IPv6 zebra access-list\n"
- "Specify packets to reject\n"
- "Specify packets to forward\n"
- "IPv6 prefix\n")
-{
- int idx = 0;
- char *alname = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
- char *prefix = argv_find (argv, argc, "X:X::X:X/M", &idx) ? argv[idx]->arg : NULL;
- return filter_set_zebra (vty, alname, argv[3]->text, AFI_IP6, prefix, 0, 1);
-}
DEFUN (ipv6_access_list_exact,
ipv6_access_list_exact_cmd,
- "ipv6 access-list WORD <deny|permit> X:X::X:X/M exact-match",
+ "ipv6 access-list WORD <deny|permit> X:X::X:X/M [exact-match]",
IPV6_STR
"Add an access list entry\n"
"IPv6 zebra access-list\n"
@@ -1555,10 +1521,18 @@ DEFUN (ipv6_access_list_exact,
"IPv6 prefix\n"
"Exact match of the prefixes\n")
{
- int idx = 0;
- char *alname = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
- char *prefix = argv_find (argv, argc, "X:X::X:X/M", &idx) ? argv[idx]->arg : NULL;
- return filter_set_zebra (vty, alname, argv[3]->text, AFI_IP6, prefix, 1, 1);
+ int idx;
+ int exact = 0;
+ int idx_word = 2;
+ int idx_allow = 3;
+ int idx_addr = 4;
+ idx = idx_addr;
+
+ if (argv_find (argv, argc, "exact-match", &idx))
+ exact = 1;
+
+ return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_allow]->text,
+ AFI_IP6, argv[idx_addr]->arg, exact, 1);
}
DEFUN (ipv6_access_list_any,
@@ -1576,26 +1550,9 @@ DEFUN (ipv6_access_list_any,
return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, "::/0", 0, 1);
}
-DEFUN (no_ipv6_access_list,
- no_ipv6_access_list_cmd,
- "no ipv6 access-list WORD <deny|permit> X:X::X:X/M",
- NO_STR
- IPV6_STR
- "Add an access list entry\n"
- "IPv6 zebra access-list\n"
- "Specify packets to reject\n"
- "Specify packets to forward\n"
- "Prefix to match. e.g. 3ffe:506::/32\n")
-{
- int idx_word = 3;
- int idx_permit_deny = 4;
- int idx_ipv6_prefixlen = 5;
- return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, argv[idx_ipv6_prefixlen]->arg, 0, 0);
-}
-
DEFUN (no_ipv6_access_list_exact,
no_ipv6_access_list_exact_cmd,
- "no ipv6 access-list WORD <deny|permit> X:X::X:X/M exact-match",
+ "no ipv6 access-list WORD <deny|permit> X:X::X:X/M [exact-match]",
NO_STR
IPV6_STR
"Add an access list entry\n"
@@ -1605,10 +1562,18 @@ DEFUN (no_ipv6_access_list_exact,
"Prefix to match. e.g. 3ffe:506::/32\n"
"Exact match of the prefixes\n")
{
+ int idx;
+ int exact = 0;
int idx_word = 3;
int idx_permit_deny = 4;
int idx_ipv6_prefixlen = 5;
- return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg, AFI_IP6, argv[idx_ipv6_prefixlen]->arg, 1, 0);
+ idx = idx_ipv6_prefixlen;
+
+ if (argv_find (argv, argc, "exact-match", &idx))
+ exact = 1;
+
+ return filter_set_zebra (vty, argv[idx_word]->arg, argv[idx_permit_deny]->arg,
+ AFI_IP6, argv[idx_ipv6_prefixlen]->arg, exact, 0);
}
DEFUN (no_ipv6_access_list_any,
@@ -2059,10 +2024,8 @@ access_list_init_ipv4 (void)
install_element (ENABLE_NODE, &show_ip_access_list_name_cmd);
/* Zebra access-list */
- install_element (CONFIG_NODE, &access_list_cmd);
install_element (CONFIG_NODE, &access_list_exact_cmd);
install_element (CONFIG_NODE, &access_list_any_cmd);
- install_element (CONFIG_NODE, &no_access_list_cmd);
install_element (CONFIG_NODE, &no_access_list_exact_cmd);
install_element (CONFIG_NODE, &no_access_list_any_cmd);
@@ -2152,11 +2115,9 @@ access_list_init_ipv6 (void)
install_element (ENABLE_NODE, &show_ipv6_access_list_cmd);
install_element (ENABLE_NODE, &show_ipv6_access_list_name_cmd);
- install_element (CONFIG_NODE, &ipv6_access_list_cmd);
install_element (CONFIG_NODE, &ipv6_access_list_exact_cmd);
install_element (CONFIG_NODE, &ipv6_access_list_any_cmd);
install_element (CONFIG_NODE, &no_ipv6_access_list_exact_cmd);
- install_element (CONFIG_NODE, &no_ipv6_access_list_cmd);
install_element (CONFIG_NODE, &no_ipv6_access_list_any_cmd);
install_element (CONFIG_NODE, &no_ipv6_access_list_all_cmd);
diff --git a/lib/if.c b/lib/if.c
index 20f792b8f8..6ee84e126c 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -374,7 +374,7 @@ if_lookup_exact_address_vrf (void *src, int family, vrf_id_t vrf_id)
}
else if (family == AF_INET6)
{
- if (IPV6_ADDR_SAME (&p->u.prefix4, (struct in6_addr *)src))
+ if (IPV6_ADDR_SAME (&p->u.prefix6, (struct in6_addr *)src))
return ifp;
}
}
diff --git a/lib/ptm_lib.c b/lib/ptm_lib.c
index 0666797fad..a93d7b8476 100644
--- a/lib/ptm_lib.c
+++ b/lib/ptm_lib.c
@@ -458,7 +458,7 @@ ptm_lib_register(char *client_name,
hdl = calloc(1, sizeof(*hdl));
if (hdl) {
- strcpy(hdl->client_name, client_name);
+ strncpy(hdl->client_name, client_name, PTMLIB_MAXNAMELEN - 1);
hdl->cmd_cb = cmd_cb;
hdl->notify_cb = notify_cb;
hdl->response_cb = response_cb;
diff --git a/lib/thread.c b/lib/thread.c
index de7066bb82..28245d11a2 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -719,7 +719,7 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
#else
if (FD_ISSET (fd, fdset))
{
- zlog (NULL, LOG_WARNING, "There is already %s fd [%d]", (dir = THREAD_READ) ? "read" : "write", fd);
+ zlog (NULL, LOG_WARNING, "There is already %s fd [%d]", (dir == THREAD_READ) ? "read" : "write", fd);
return NULL;
}
diff --git a/lib/vty.c b/lib/vty.c
index b6f493b6c9..2660ca3251 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2230,7 +2230,7 @@ void
vty_close (struct vty *vty)
{
int i;
- bool was_stdio;
+ bool was_stdio = false;
/* Cancel threads.*/
if (vty->t_read)
diff --git a/lib/zclient.c b/lib/zclient.c
index 92662fd70f..cea4b098fc 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -1146,11 +1146,15 @@ struct interface *
zebra_interface_link_params_read (struct stream *s)
{
struct if_link_params *iflp;
- uint32_t ifindex = stream_getl (s);
+ ifindex_t ifindex;
+
+ assert (s);
+
+ ifindex = stream_getl (s);
struct interface *ifp = if_lookup_by_index (ifindex);
- if (ifp == NULL || s == NULL)
+ if (ifp == NULL)
{
zlog_err ("%s: unknown ifindex %u, shouldn't happen",
__func__, ifindex);