Merge branch 'frr/pull/152' ("Lib fixes")

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-02-07 15:48:46 +01:00
commit fa02c492fa
11 changed files with 80 additions and 110 deletions

View File

@ -1335,25 +1335,9 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str,
return CMD_SUCCESS; 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, DEFUN (access_list_exact,
access_list_exact_cmd, 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" "Add an access list entry\n"
"IP zebra access-list name\n" "IP zebra access-list name\n"
"Specify packets to reject\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" "Prefix to match. e.g. 10.0.0.0/8\n"
"Exact match of the prefixes\n") "Exact match of the prefixes\n")
{ {
int idx;
int exact = 0;
int idx_word = 1; int idx_word = 1;
int idx_permit_deny = 2; int idx_permit_deny = 2;
int idx_ipv4_prefixlen = 3; 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, 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); 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, DEFUN (no_access_list_exact,
no_access_list_exact_cmd, 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 NO_STR
"Add an access list entry\n" "Add an access list entry\n"
"IP zebra access-list name\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" "Prefix to match. e.g. 10.0.0.0/8\n"
"Exact match of the prefixes\n") "Exact match of the prefixes\n")
{ {
int idx;
int exact = 0;
int idx_word = 2; int idx_word = 2;
int idx_permit_deny = 3; int idx_permit_deny = 3;
int idx_ipv4_prefixlen = 4; 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, DEFUN (no_access_list_any,
@ -1527,26 +1510,9 @@ DEFUN (no_access_list_remark_comment,
return no_access_list_remark (self, vty, argc, argv); 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, DEFUN (ipv6_access_list_exact,
ipv6_access_list_exact_cmd, 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 IPV6_STR
"Add an access list entry\n" "Add an access list entry\n"
"IPv6 zebra access-list\n" "IPv6 zebra access-list\n"
@ -1555,10 +1521,18 @@ DEFUN (ipv6_access_list_exact,
"IPv6 prefix\n" "IPv6 prefix\n"
"Exact match of the prefixes\n") "Exact match of the prefixes\n")
{ {
int idx = 0; int idx;
char *alname = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; int exact = 0;
char *prefix = argv_find (argv, argc, "X:X::X:X/M", &idx) ? argv[idx]->arg : NULL; int idx_word = 2;
return filter_set_zebra (vty, alname, argv[3]->text, AFI_IP6, prefix, 1, 1); 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, 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); 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, DEFUN (no_ipv6_access_list_exact,
no_ipv6_access_list_exact_cmd, 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 NO_STR
IPV6_STR IPV6_STR
"Add an access list entry\n" "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" "Prefix to match. e.g. 3ffe:506::/32\n"
"Exact match of the prefixes\n") "Exact match of the prefixes\n")
{ {
int idx;
int exact = 0;
int idx_word = 3; int idx_word = 3;
int idx_permit_deny = 4; int idx_permit_deny = 4;
int idx_ipv6_prefixlen = 5; 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, 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); install_element (ENABLE_NODE, &show_ip_access_list_name_cmd);
/* Zebra access-list */ /* Zebra access-list */
install_element (CONFIG_NODE, &access_list_cmd);
install_element (CONFIG_NODE, &access_list_exact_cmd); install_element (CONFIG_NODE, &access_list_exact_cmd);
install_element (CONFIG_NODE, &access_list_any_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_exact_cmd);
install_element (CONFIG_NODE, &no_access_list_any_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_cmd);
install_element (ENABLE_NODE, &show_ipv6_access_list_name_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_exact_cmd);
install_element (CONFIG_NODE, &ipv6_access_list_any_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_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_any_cmd);
install_element (CONFIG_NODE, &no_ipv6_access_list_all_cmd); install_element (CONFIG_NODE, &no_ipv6_access_list_all_cmd);

View File

@ -374,7 +374,7 @@ if_lookup_exact_address_vrf (void *src, int family, vrf_id_t vrf_id)
} }
else if (family == AF_INET6) 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; return ifp;
} }
} }

View File

@ -458,7 +458,7 @@ ptm_lib_register(char *client_name,
hdl = calloc(1, sizeof(*hdl)); hdl = calloc(1, sizeof(*hdl));
if (hdl) { if (hdl) {
strcpy(hdl->client_name, client_name); strncpy(hdl->client_name, client_name, PTMLIB_MAXNAMELEN - 1);
hdl->cmd_cb = cmd_cb; hdl->cmd_cb = cmd_cb;
hdl->notify_cb = notify_cb; hdl->notify_cb = notify_cb;
hdl->response_cb = response_cb; hdl->response_cb = response_cb;

View File

@ -719,7 +719,7 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
#else #else
if (FD_ISSET (fd, fdset)) 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; return NULL;
} }

View File

@ -2230,7 +2230,7 @@ void
vty_close (struct vty *vty) vty_close (struct vty *vty)
{ {
int i; int i;
bool was_stdio; bool was_stdio = false;
/* Cancel threads.*/ /* Cancel threads.*/
if (vty->t_read) if (vty->t_read)

View File

@ -1146,11 +1146,15 @@ struct interface *
zebra_interface_link_params_read (struct stream *s) zebra_interface_link_params_read (struct stream *s)
{ {
struct if_link_params *iflp; 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); 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", zlog_err ("%s: unknown ifindex %u, shouldn't happen",
__func__, ifindex); __func__, ifindex);

View File

@ -1374,8 +1374,8 @@ pim_show_state(struct vty *vty, const char *src_or_group, const char *group, u_c
for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) { for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) {
char grp_str[INET_ADDRSTRLEN]; char grp_str[INET_ADDRSTRLEN];
char src_str[INET_ADDRSTRLEN]; char src_str[INET_ADDRSTRLEN];
char in_ifname[16]; char in_ifname[INTERFACE_NAMSIZ+1];
char out_ifname[16]; char out_ifname[INTERFACE_NAMSIZ+1];
int oif_vif_index; int oif_vif_index;
struct interface *ifp_in; struct interface *ifp_in;
first_oif = 1; first_oif = 1;
@ -3036,8 +3036,8 @@ static void show_mroute(struct vty *vty, u_char uj)
for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) { for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
char grp_str[INET_ADDRSTRLEN]; char grp_str[INET_ADDRSTRLEN];
char src_str[INET_ADDRSTRLEN]; char src_str[INET_ADDRSTRLEN];
char in_ifname[16]; char in_ifname[INTERFACE_NAMSIZ+1];
char out_ifname[16]; char out_ifname[INTERFACE_NAMSIZ+1];
int oif_vif_index; int oif_vif_index;
struct interface *ifp_in; struct interface *ifp_in;
char proto[100]; char proto[100];
@ -4871,7 +4871,7 @@ DEFUN (debug_pim_packets,
DEBUG_PIM_J_P_PACKETS_STR DEBUG_PIM_J_P_PACKETS_STR
DEBUG_PIM_PIM_REG_PACKETS_STR) DEBUG_PIM_PIM_REG_PACKETS_STR)
{ {
int idx; int idx = 0;
if (argv_find (argv, argc, "hello", &idx)) if (argv_find (argv, argc, "hello", &idx))
{ {
PIM_DO_DEBUG_PIM_HELLO; PIM_DO_DEBUG_PIM_HELLO;

View File

@ -132,6 +132,7 @@ pim_register_stop_recv (uint8_t *buf, int buf_size)
upstream->join_state = PIM_UPSTREAM_PRUNE; upstream->join_state = PIM_UPSTREAM_PRUNE;
pim_channel_del_oif (upstream->channel_oil, pim_regiface, PIM_OIF_FLAG_PROTO_PIM); pim_channel_del_oif (upstream->channel_oil, pim_regiface, PIM_OIF_FLAG_PROTO_PIM);
pim_upstream_start_register_stop_timer (upstream, 0); pim_upstream_start_register_stop_timer (upstream, 0);
break;
case PIM_UPSTREAM_JOIN_PENDING: case PIM_UPSTREAM_JOIN_PENDING:
upstream->join_state = PIM_UPSTREAM_PRUNE; upstream->join_state = PIM_UPSTREAM_PRUNE;
pim_upstream_start_register_stop_timer (upstream, 0); pim_upstream_start_register_stop_timer (upstream, 0);
@ -152,10 +153,9 @@ pim_register_send (const uint8_t *buf, int buf_size, struct in_addr src, struct
if (PIM_DEBUG_PIM_REG) if (PIM_DEBUG_PIM_REG)
{ {
char rp_str[INET_ADDRSTRLEN];
strcpy (rp_str, inet_ntoa (rpg->rpf_addr.u.prefix4));
zlog_debug ("Sending %s %sRegister Packet to %s", zlog_debug ("Sending %s %sRegister Packet to %s",
up->sg_str, null_register ? "NULL " : "", rp_str); up->sg_str, null_register ? "NULL " : "",
inet_ntoa (rpg->rpf_addr.u.prefix4));
} }
ifp = rpg->source_nexthop.interface; ifp = rpg->source_nexthop.interface;

View File

@ -139,6 +139,7 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char lo
ret = pim_socket_bind (fd, ifp); ret = pim_socket_bind (fd, ifp);
if (ret) if (ret)
{ {
close (fd);
zlog_warn("Could not set fd: %d for interface: %s to device", zlog_warn("Could not set fd: %d for interface: %s to device",
fd, ifp->name); fd, ifp->name);
return PIM_SOCK_ERR_BIND; return PIM_SOCK_ERR_BIND;

View File

@ -585,24 +585,26 @@ rip_if_down(struct interface *ifp)
struct list *list = NULL; struct list *list = NULL;
struct listnode *listnode = NULL, *nextnode = NULL; struct listnode *listnode = NULL, *nextnode = NULL;
if (rip) if (rip)
for (rp = route_top (rip->table); rp; rp = route_next (rp)) {
if ((list = rp->info) != NULL) for (rp = route_top (rip->table); rp; rp = route_next (rp))
for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo)) if ((list = rp->info) != NULL)
if (rinfo->ifindex == ifp->ifindex) for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo))
rip_ecmp_delete (rinfo); if (rinfo->ifindex == ifp->ifindex)
rip_ecmp_delete (rinfo);
ri = ifp->info; ri = ifp->info;
if (ri->running) if (ri->running)
{ {
if (IS_RIP_DEBUG_EVENT) if (IS_RIP_DEBUG_EVENT)
zlog_debug ("turn off %s", ifp->name); zlog_debug ("turn off %s", ifp->name);
/* Leave from multicast group. */ /* Leave from multicast group. */
rip_multicast_leave (ifp, rip->sock); rip_multicast_leave (ifp, rip->sock);
ri->running = 0; ri->running = 0;
} }
}
return 0; return 0;
} }

View File

@ -92,6 +92,7 @@ zserv_flush_data(struct thread *thread)
zlog_warn("%s: buffer_flush_available failed on zserv client fd %d, " zlog_warn("%s: buffer_flush_available failed on zserv client fd %d, "
"closing", __func__, client->sock); "closing", __func__, client->sock);
zebra_client_close(client); zebra_client_close(client);
client = NULL;
break; break;
case BUFFER_PENDING: case BUFFER_PENDING:
client->t_write = thread_add_write(zebrad.master, zserv_flush_data, client->t_write = thread_add_write(zebrad.master, zserv_flush_data,
@ -101,7 +102,8 @@ zserv_flush_data(struct thread *thread)
break; break;
} }
client->last_write_time = monotime(NULL); if (client)
client->last_write_time = monotime(NULL);
return 0; return 0;
} }