diff options
| -rw-r--r-- | bgpd/bgp_vty.c | 12 | ||||
| -rw-r--r-- | bgpd/rfapi/rfapi_ap.c | 2 | ||||
| -rw-r--r-- | bgpd/rfapi/vnc_zebra.c | 2 | ||||
| -rw-r--r-- | ldpd/ldp_vty_conf.c | 7 | ||||
| -rw-r--r-- | ldpd/packet.c | 16 | ||||
| -rw-r--r-- | lib/command.c | 25 | ||||
| -rw-r--r-- | lib/command.h | 1 | ||||
| -rw-r--r-- | lib/csv.c | 18 | ||||
| -rw-r--r-- | lib/plist.c | 5 | ||||
| -rw-r--r-- | lib/prefix.c | 14 | ||||
| -rw-r--r-- | lib/prefix.h | 1 | ||||
| -rw-r--r-- | lib/routemap.c | 32 | ||||
| -rw-r--r-- | pimd/pim_cmd.c | 21 | ||||
| -rw-r--r-- | zebra/zebra_ptm.c | 8 | ||||
| -rw-r--r-- | zebra/zebra_static.c | 35 |
15 files changed, 79 insertions, 120 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 51839b784b..01d1768691 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7337,6 +7337,10 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (use_json) json_neigh = json_object_new_object(); + memset (dn_flag, '\0', sizeof (dn_flag)); + if (!p->conf_if && peer_dynamic_neighbor (p)) + dn_flag[0] = '*'; + if (!use_json) { if (p->conf_if) /* Configured interface name. */ @@ -7344,13 +7348,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js BGP_PEER_SU_UNSPEC(p) ? "None" : sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); else /* Configured IP address. */ - { - memset(dn_flag, '\0', sizeof(dn_flag)); - if (peer_dynamic_neighbor(p)) - dn_flag[0] = '*'; - - vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); - } + vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); } if (use_json) diff --git a/bgpd/rfapi/rfapi_ap.c b/bgpd/rfapi/rfapi_ap.c index 5cc1dd7815..68292c26b1 100644 --- a/bgpd/rfapi/rfapi_ap.c +++ b/bgpd/rfapi/rfapi_ap.c @@ -169,7 +169,7 @@ void rfapiApReadvertiseAll (struct bgp *bgp, struct rfapi_descriptor *rfd) { struct rfapi_adb *adb; - void *cursor; + void *cursor = NULL; int rc; for (rc = diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index 85baa13301..23b6e9dbb4 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -546,6 +546,7 @@ vnc_zebra_route_msg ( api.nexthop_num = nhp_count; api.nexthop = nhp_ary; api.ifindex_num = 0; + api.instance = 0; if (BGP_DEBUG (zebra, ZEBRA)) { @@ -580,6 +581,7 @@ vnc_zebra_route_msg ( SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); api.ifindex_num = 1; api.ifindex = &ifindex; + api.instance = 0; if (BGP_DEBUG (zebra, ZEBRA)) { diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 792f8c8d1b..4d1af62146 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -487,8 +487,10 @@ ldp_vty_address_family(struct vty *vty, struct vty_arg *args[]) } else if (strcmp(af_str, "ipv6") == 0) { af = AF_INET6; af_conf = &vty_conf->ipv6; - } else + } else { + ldp_clear_config(vty_conf); return (CMD_WARNING); + } if (disable) { af_conf->flags &= ~F_LDPD_AF_ENABLED; @@ -919,7 +921,8 @@ ldp_vty_interface(struct vty *vty, struct vty_arg *args[]) if (!ia->enabled) { ia->enabled = 1; ldp_reload_ref(vty_conf, (void **)&iface); - } + } else + ldp_clear_config(vty_conf); } switch (af) { diff --git a/ldpd/packet.c b/ldpd/packet.c index be5ed8072b..b085cac055 100644 --- a/ldpd/packet.c +++ b/ldpd/packet.c @@ -686,8 +686,8 @@ struct tcp_conn * tcp_new(int fd, struct nbr *nbr) { struct tcp_conn *tcp; - struct sockaddr_storage src; - socklen_t len = sizeof(src); + struct sockaddr_storage ss; + socklen_t len = sizeof(ss); if ((tcp = calloc(1, sizeof(*tcp))) == NULL) fatal(__func__); @@ -703,10 +703,14 @@ tcp_new(int fd, struct nbr *nbr) tcp->nbr = nbr; } - getsockname(fd, (struct sockaddr *)&src, &len); - sa2addr((struct sockaddr *)&src, NULL, NULL, &tcp->lport); - getpeername(fd, (struct sockaddr *)&src, &len); - sa2addr((struct sockaddr *)&src, NULL, NULL, &tcp->rport); + if (getsockname(fd, (struct sockaddr *)&ss, &len) != 0) + log_warn("%s: getsockname", __func__); + else + sa2addr((struct sockaddr *)&ss, NULL, NULL, &tcp->lport); + if (getpeername(fd, (struct sockaddr *)&ss, &len) != 0) + log_warn("%s: getpeername", __func__); + else + sa2addr((struct sockaddr *)&ss, NULL, NULL, &tcp->rport); return (tcp); } diff --git a/lib/command.c b/lib/command.c index 510699f91b..6467fb7185 100644 --- a/lib/command.c +++ b/lib/command.c @@ -294,27 +294,6 @@ cmd_free_strvec (vector v) vector_free (v); } -char * -cmd_concat_strvec (vector v) -{ - size_t strsize = 0; - for (unsigned int i = 0; i < vector_active (v); i++) - if (vector_slot (v, i)) - strsize += strlen ((char *) vector_slot (v, i)) + 1; - - if (strsize == 0) - return XSTRDUP (MTYPE_TMP, ""); - - char *concatenated = calloc (sizeof (char), strsize); - for (unsigned int i = 0; i < vector_active (v); i++) - { - strlcat (concatenated, (char *) vector_slot (v, i), strsize); - strlcat (concatenated, " ", strsize); - } - - return concatenated; -} - /* Return prompt character of specified node. */ const char * cmd_prompt (enum node_type node) @@ -720,6 +699,8 @@ cmd_complete_command (vector vline, struct vty *vty, int *status) vector_free (comps); comps = NULL; } + else if (initial_comps) + vector_free (initial_comps); // comps should always be null here assert (!comps); @@ -805,6 +786,8 @@ cmd_execute_command_real (vector vline, // if matcher error, return corresponding CMD_ERR if (MATCHER_ERROR(status)) { + if (argv_list) + list_delete (argv_list); switch (status) { case MATCHER_INCOMPLETE: diff --git a/lib/command.h b/lib/command.h index 8986703708..04bba9e412 100644 --- a/lib/command.h +++ b/lib/command.h @@ -410,7 +410,6 @@ extern int argv_find (struct cmd_token **argv, int argc, const char *text, int * extern vector cmd_make_strvec (const char *); extern void cmd_free_strvec (vector); -extern char *cmd_concat_strvec (vector); extern vector cmd_describe_command (vector, struct vty *, int *status); extern char **cmd_complete_command (vector, struct vty *, int *status); extern const char *cmd_prompt (enum node_type); @@ -239,6 +239,9 @@ csv_encode (csv_t *csv, rec = malloc(sizeof(csv_record_t)); if (!rec) { log_error("record malloc failed\n"); + if (!buf) + free(str); + va_end(list); return (NULL); } csv_init_record(rec); @@ -255,6 +258,7 @@ csv_encode (csv_t *csv, if (!fld) { log_error("fld malloc failed\n"); csv_remove_record(csv, rec); + va_end(list); return (NULL); } if (tempc < (count - 1)) { @@ -518,7 +522,7 @@ csv_concat_record (csv_t *csv, curr = (char *)calloc(1, csv->buflen); if (!curr) { log_error("field str malloc failed\n"); - return (NULL); + goto out_rec; } rec->record = curr; @@ -526,7 +530,7 @@ csv_concat_record (csv_t *csv, ret = strstr(rec1->record, "\n"); if (!ret) { log_error("rec1 str not properly formatted\n"); - return (NULL); + goto out_curr; } snprintf(curr, (int)(ret - rec1->record + 1), "%s", rec1->record); @@ -535,7 +539,7 @@ csv_concat_record (csv_t *csv, ret = strstr(rec2->record, "\n"); if (!ret) { log_error("rec2 str not properly formatted\n"); - return (NULL); + goto out_curr; } snprintf((curr+strlen(curr)), (int)(ret - rec2->record + 1), "%s", @@ -556,6 +560,12 @@ csv_concat_record (csv_t *csv, csv_insert_record(csv, rec); return rec; + +out_curr: + free(curr); +out_rec: + free(rec); + return NULL; } void @@ -569,6 +579,8 @@ csv_decode (csv_t *csv, char *inbuf) pos = strpbrk(buf, "\n"); while (pos != NULL) { rec = calloc(1, sizeof(csv_record_t)); + if (!rec) + return; csv_init_record(rec); TAILQ_INSERT_TAIL(&(csv->records), rec, next_record); csv->num_recs++; diff --git a/lib/plist.c b/lib/plist.c index 41cae020de..4539d82972 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -557,10 +557,11 @@ prefix_list_entry_delete (struct prefix_list *plist, struct prefix_list_entry *pentry, int update_list) { - prefix_list_trie_del (plist, pentry); - if (plist == NULL || pentry == NULL) return; + + prefix_list_trie_del (plist, pentry); + if (pentry->prev) pentry->prev->next = pentry->next; else diff --git a/lib/prefix.c b/lib/prefix.c index 8289593781..bc1c681058 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -723,20 +723,6 @@ apply_mask_ipv6 (struct prefix_ipv6 *p) } void -str2in6_addr (const char *str, struct in6_addr *addr) -{ - int i; - unsigned int x; - - /* %x must point to unsinged int */ - for (i = 0; i < 16; i++) - { - sscanf (str + (i * 2), "%02x", &x); - addr->s6_addr[i] = x & 0xff; - } -} - -void apply_mask (struct prefix *p) { switch (p->family) diff --git a/lib/prefix.h b/lib/prefix.h index 45e6368463..eb69e98f04 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -281,7 +281,6 @@ extern void apply_mask_ipv6 (struct prefix_ipv6 *); extern int ip6_masklen (struct in6_addr); extern void masklen2ip6 (const int, struct in6_addr *); -extern void str2in6_addr (const char *, struct in6_addr *); extern const char *inet6_ntoa (struct in6_addr); static inline int ipv6_martian (struct in6_addr *addr) diff --git a/lib/routemap.c b/lib/routemap.c index 49b3039838..39d9a5d375 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -800,29 +800,29 @@ route_map_free_map (struct route_map *map) struct route_map_list *list; struct route_map_index *index; + if (map == NULL) + return; + while ((index = map->head) != NULL) route_map_index_delete (index, 0); list = &route_map_master; - if (map != NULL) - { - QOBJ_UNREG (map); + QOBJ_UNREG (map); - if (map->next) - map->next->prev = map->prev; - else - list->tail = map->prev; + if (map->next) + map->next->prev = map->prev; + else + list->tail = map->prev; - if (map->prev) - map->prev->next = map->next; - else - list->head = map->next; + if (map->prev) + map->prev->next = map->next; + else + list->head = map->next; - hash_release(route_map_master_hash, map); - XFREE (MTYPE_ROUTE_MAP_NAME, map->name); - XFREE (MTYPE_ROUTE_MAP, map); - } + hash_release(route_map_master_hash, map); + XFREE (MTYPE_ROUTE_MAP_NAME, map->name); + XFREE (MTYPE_ROUTE_MAP, map); } /* Route map delete from list. */ @@ -1053,7 +1053,7 @@ vty_show_route_map (struct vty *vty, const char *name) { if (zlog_default) vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]); - if (zlog_default->instance) + if (zlog_default && zlog_default->instance) vty_out (vty, " %d", zlog_default->instance); vty_out (vty, ": 'route-map %s' not found%s", name, VTY_NEWLINE); return CMD_SUCCESS; diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 7f276b22ce..ae23499d97 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -2876,6 +2876,13 @@ static void show_mroute(struct vty *vty, u_char uj) json_object *json_ifp_out = NULL; int found_oif = 0; int first = 1; + char grp_str[INET_ADDRSTRLEN]; + char src_str[INET_ADDRSTRLEN]; + char in_ifname[INTERFACE_NAMSIZ+1]; + char out_ifname[INTERFACE_NAMSIZ+1]; + int oif_vif_index; + struct interface *ifp_in; + char proto[100]; if (uj) { json = json_object_new_object(); @@ -2888,13 +2895,6 @@ static void show_mroute(struct vty *vty, u_char uj) /* print list of PIM and IGMP routes */ for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) { - char grp_str[INET_ADDRSTRLEN]; - char src_str[INET_ADDRSTRLEN]; - char in_ifname[16]; - char out_ifname[16]; - int oif_vif_index; - char proto[100]; - struct interface *ifp_in; found_oif = 0; first = 1; if (!c_oil->installed && !uj) @@ -3034,13 +3034,6 @@ static void show_mroute(struct vty *vty, u_char uj) /* Print list of static routes */ for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) { - char grp_str[INET_ADDRSTRLEN]; - char src_str[INET_ADDRSTRLEN]; - char in_ifname[INTERFACE_NAMSIZ+1]; - char out_ifname[INTERFACE_NAMSIZ+1]; - int oif_vif_index; - struct interface *ifp_in; - char proto[100]; first = 1; if (!s_route->c_oil.installed) diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 446eb4953b..bc924842d4 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -388,7 +388,13 @@ zebra_ptm_socket_init (void) if (sock < 0) return -1; if (set_nonblocking(sock) < 0) - return -1; + { + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug ("%s: Unable to set socket non blocking[%s]", + __PRETTY_FUNCTION__, safe_strerror (errno)); + close (sock); + return -1; + } /* Make server socket. */ memset (&addr, 0, sizeof (struct sockaddr_un)); diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index 1302f1cd39..4628d11091 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -198,31 +198,8 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, } static int -static_nexthop_label_same (struct nexthop *nexthop, - struct static_nh_label *snh_label) -{ - int i; - - if ((snh_label->num_labels == 0 && nexthop->nh_label) || - (snh_label->num_labels != 0 && !nexthop->nh_label)) - return 0; - - if (snh_label->num_labels != 0) - if (snh_label->num_labels != nexthop->nh_label->num_labels) - return 0; - - for (i = 0; i < snh_label->num_labels; i++) - if (snh_label->label[i] != nexthop->nh_label->label[i]) - return 0; - - return 1; -} - -static int static_nexthop_same (struct nexthop *nexthop, struct static_route *si) { - int gw_match = 0; - if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE && si->type == STATIC_BLACKHOLE) return 1; @@ -230,26 +207,22 @@ static_nexthop_same (struct nexthop *nexthop, struct static_route *si) if (nexthop->type == NEXTHOP_TYPE_IPV4 && si->type == STATIC_IPV4_GATEWAY && IPV4_ADDR_SAME (&nexthop->gate.ipv4, &si->addr.ipv4)) - gw_match = 1; + return 1; else if (nexthop->type == NEXTHOP_TYPE_IFINDEX && si->type == STATIC_IFINDEX && nexthop->ifindex == si->ifindex) - gw_match = 1; + return 1; else if (nexthop->type == NEXTHOP_TYPE_IPV6 && si->type == STATIC_IPV6_GATEWAY && IPV6_ADDR_SAME (&nexthop->gate.ipv6, &si->addr.ipv6)) - gw_match = 1; + return 1; else if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX && si->type == STATIC_IPV6_GATEWAY_IFINDEX && IPV6_ADDR_SAME (&nexthop->gate.ipv6, &si->addr.ipv6) && nexthop->ifindex == si->ifindex) - gw_match = 1; + return 1; - if (!gw_match) return 0; - - /* Check match on label(s), if any */ - return static_nexthop_label_same (nexthop, &si->snh_label); } /* Uninstall static route from RIB. */ |
