diff options
36 files changed, 230 insertions, 273 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 983c335cf..9923f9492 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1480,8 +1480,7 @@ bgp_attr_as4_path (struct bgp_attr_parser_args *args, struct aspath **as4_path) } /* Set aspath attribute flag. */ - if (as4_path) - attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS4_PATH); + attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS4_PATH); return BGP_ATTR_PARSE_PROCEED; } diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index 21e33eb1c..a61d63bb8 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -1158,16 +1158,13 @@ extcommunity_list_set (struct community_list_handler *ch, } } - if (str) - { - if (style == EXTCOMMUNITY_LIST_STANDARD) - ecom = ecommunity_str2com (str, 0, 1); - else - regex = bgp_regcomp (str); + if (style == EXTCOMMUNITY_LIST_STANDARD) + ecom = ecommunity_str2com (str, 0, 1); + else + regex = bgp_regcomp (str); - if (! ecom && ! regex) - return COMMUNITY_LIST_ERR_MALFORMED_VAL; - } + if (! ecom && ! regex) + return COMMUNITY_LIST_ERR_MALFORMED_VAL; if (ecom) ecom->str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_DISPLAY, 0); @@ -1180,8 +1177,7 @@ extcommunity_list_set (struct community_list_handler *ch, entry->config = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_COMMUNITY_LIST, 0); else if (regex) entry->config = XSTRDUP (MTYPE_COMMUNITY_LIST_CONFIG, str); - else - entry->config = NULL; + entry->u.ecom = ecom; entry->reg = regex; diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index cdddde14b..bf26fddf9 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -626,7 +626,7 @@ bgp_dump_parse_time (const char *str) return 0; total += time * 60; time = 0; - seen_h = 1; + seen_m = 1; } else return 0; diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index f9f2018db..8714820e2 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -327,22 +327,15 @@ bgp_vrf_disable (struct vrf *vrf) static void bgp_vrf_init (void) { - vrf_add_hook (VRF_NEW_HOOK, bgp_vrf_new); - vrf_add_hook (VRF_ENABLE_HOOK, bgp_vrf_enable); - vrf_add_hook (VRF_DISABLE_HOOK, bgp_vrf_disable); - vrf_add_hook (VRF_DELETE_HOOK, bgp_vrf_delete); - - vrf_init (); + vrf_init (bgp_vrf_new, + bgp_vrf_enable, + bgp_vrf_disable, + bgp_vrf_delete); } static void bgp_vrf_terminate (void) { - vrf_add_hook (VRF_NEW_HOOK, NULL); - vrf_add_hook (VRF_ENABLE_HOOK, NULL); - vrf_add_hook (VRF_DISABLE_HOOK, NULL); - vrf_add_hook (VRF_DELETE_HOOK, NULL); - vrf_terminate (); } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 85c43bac6..41966192d 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8887,6 +8887,7 @@ bgp_show_community (struct vty *vty, struct bgp *bgp, int argc, int i; char *str; int first = 0; + int ret = 0; b = buffer_new (1024); for (i = 0; i < argc; i++) @@ -8915,9 +8916,12 @@ bgp_show_community (struct vty *vty, struct bgp *bgp, int argc, return CMD_WARNING; } - return bgp_show (vty, bgp, afi, safi, - (exact ? bgp_show_type_community_exact : - bgp_show_type_community), com, 0); + ret = bgp_show (vty, bgp, afi, safi, + (exact ? bgp_show_type_community_exact : + bgp_show_type_community), com, 0); + community_free (com); + + return ret; } static int diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 967fb2ea6..1c519f099 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -94,7 +94,6 @@ struct community_list_handler *bgp_clist; unsigned int multipath_num = MULTIPATH_NUM; -static void bgp_if_init (struct bgp *bgp); static void bgp_if_finish (struct bgp *bgp); extern struct zclient *zclient; @@ -3115,10 +3114,7 @@ bgp_get (struct bgp **bgp_val, as_t *as, const char *name, vrf = bgp_vrf_lookup_by_instance_type (bgp); if (vrf) - { - bgp_vrf_link (bgp, vrf); - bgp_if_init (bgp); - } + bgp_vrf_link (bgp, vrf); } /* Register with Zebra, if needed */ @@ -7655,19 +7651,6 @@ bgp_master_init (struct thread_master *master) } /* - * Initialize interface list for instance, if needed. Invoked upon - * instance create. - */ -static void -bgp_if_init (struct bgp *bgp) -{ - if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) - return; - - vrf_iflist_create (bgp->vrf_id); -} - -/* * Free up connected routes and interfaces for a BGP instance. Invoked upon * instance delete (non-default only) or BGP exit. */ diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c index e841882c3..c2fbe29cf 100644 --- a/eigrpd/eigrp_dump.c +++ b/eigrpd/eigrp_dump.c @@ -309,10 +309,16 @@ show_ip_eigrp_topology_header (struct vty *vty, struct eigrp *eigrp) void show_ip_eigrp_prefix_entry (struct vty *vty, struct eigrp_prefix_entry *tn) { + struct list *successors = eigrp_topology_get_successor(tn); + vty_out (vty, "%-3c",(tn->state > 0) ? 'A' : 'P'); - vty_out (vty, "%s/%u, ",inet_ntoa (tn->destination_ipv4->prefix),tn->destination_ipv4->prefixlen); - vty_out (vty, "%u successors, ",eigrp_topology_get_successor(tn)->count); - vty_out (vty, "FD is %u, serno: %" PRIu64 " %s",tn->fdistance, tn->serno, VTY_NEWLINE); + + vty_out (vty, "%s/%u, ", + inet_ntoa (tn->destination_ipv4->prefix), tn->destination_ipv4->prefixlen); + vty_out (vty, "%u successors, ", successors->count); + vty_out (vty, "FD is %u, serno: %" PRIu64 " %s", tn->fdistance, tn->serno, VTY_NEWLINE); + + list_delete(successors); } void diff --git a/eigrpd/eigrp_filter.c b/eigrpd/eigrp_filter.c index 5a2755d03..df5933217 100644 --- a/eigrpd/eigrp_filter.c +++ b/eigrpd/eigrp_filter.c @@ -82,7 +82,6 @@ eigrp_distribute_update (struct distribute *dist) if (dist->list[DISTRIBUTE_V4_IN]) { alist = access_list_lookup (AFI_IP, dist->list[DISTRIBUTE_V4_IN]); - zlog_info("<DEBUG DISTRIBUTE ACL IN FOUND: %s",alist->name); if (alist) e->list[EIGRP_FILTER_IN] = alist; else @@ -96,7 +95,6 @@ eigrp_distribute_update (struct distribute *dist) /* access list OUT for whole process */ if (dist->list[DISTRIBUTE_V4_OUT]) { - zlog_info("<DEBUG DISTRIBUTE ACL OUT FOUND: %s",dist->list[DISTRIBUTE_V4_OUT]); alist = access_list_lookup (AFI_IP, dist->list[DISTRIBUTE_V4_OUT]); if (alist) e->list[EIGRP_FILTER_OUT] = alist; @@ -111,7 +109,6 @@ eigrp_distribute_update (struct distribute *dist) /* PREFIX_LIST IN for process */ if (dist->prefix[DISTRIBUTE_V4_IN]) { - zlog_info("<DEBUG DISTRIBUTE PREFIX IN FOUND: %s",dist->prefix[DISTRIBUTE_V4_IN]); plist = prefix_list_lookup (AFI_IP, dist->prefix[DISTRIBUTE_V4_IN]); if (plist) { @@ -125,7 +122,6 @@ eigrp_distribute_update (struct distribute *dist) /* PREFIX_LIST OUT for process */ if (dist->prefix[DISTRIBUTE_V4_OUT]) { - zlog_info("<DEBUG DISTRIBUTE PREFIX OUT FOUND: %s",dist->prefix[DISTRIBUTE_V4_OUT]); plist = prefix_list_lookup (AFI_IP, dist->prefix[DISTRIBUTE_V4_OUT]); if (plist) { @@ -191,8 +187,6 @@ eigrp_distribute_update (struct distribute *dist) if (ifp == NULL) return; - zlog_info("<DEBUG ACL 2"); - /*struct eigrp_if_info * info = ifp->info; ei = info->eigrp_interface;*/ struct listnode *node, *nnode; @@ -206,15 +200,9 @@ eigrp_distribute_update (struct distribute *dist) } } - if(ei == NULL) - { - zlog_info("Not Found eigrp interface %s",ifp->name); - } - /* Access-list for interface in */ if (dist->list[DISTRIBUTE_V4_IN]) { - zlog_info("<DEBUG ACL in"); alist = access_list_lookup (AFI_IP, dist->list[DISTRIBUTE_V4_IN]); if (alist){ ei->list[EIGRP_FILTER_IN] = alist; @@ -238,10 +226,7 @@ eigrp_distribute_update (struct distribute *dist) } else - { - ei->list[EIGRP_FILTER_OUT] = NULL; - zlog_info("<DEBUG ACL out else"); - } + ei->list[EIGRP_FILTER_OUT] = NULL; /* Prefix-list for interface in */ if (dist->prefix[DISTRIBUTE_V4_IN]) diff --git a/eigrpd/eigrp_hello.c b/eigrpd/eigrp_hello.c index 58a34530c..0b370219b 100644 --- a/eigrpd/eigrp_hello.c +++ b/eigrpd/eigrp_hello.c @@ -251,7 +251,8 @@ eigrp_peer_termination_decode (struct eigrp_neighbor *nbr, if(my_ip == received_ip) { zlog_info ("Neighbor %s (%s) is down: Peer Termination received", - inet_ntoa (nbr->src),ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT)); + inet_ntoa (nbr->src), + ifindex2ifname (nbr->ei->ifp->ifindex, VRF_DEFAULT)); /* set neighbor to DOWN */ nbr->state = EIGRP_NEIGHBOR_DOWN; /* delete neighbor */ @@ -363,14 +364,15 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e case EIGRP_TLV_SW_VERSION: eigrp_sw_version_decode(nbr, tlv_header); break; - case EIGRP_TLV_NEXT_MCAST_SEQ: - break; + case EIGRP_TLV_NEXT_MCAST_SEQ: + break; case EIGRP_TLV_PEER_TERMINATION: eigrp_peer_termination_decode(nbr, tlv_header); + return; break; case EIGRP_TLV_PEER_MTRLIST: - case EIGRP_TLV_PEER_TIDLIST: - break; + case EIGRP_TLV_PEER_TIDLIST: + break; default: break; } @@ -387,7 +389,8 @@ eigrp_hello_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e { /* increment statistics. */ ei->hello_in++; - eigrp_nbr_state_update(nbr); + if (nbr) + eigrp_nbr_state_update(nbr); } diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c index d7e609238..7e38a8da5 100644 --- a/eigrpd/eigrp_interface.c +++ b/eigrpd/eigrp_interface.c @@ -303,7 +303,9 @@ eigrp_if_up (struct eigrp_interface *ei) { pe = eigrp_prefix_entry_new (); pe->serno = eigrp->serno; - pe->destination_ipv4 = dest_addr; + pe->destination_ipv4 = prefix_ipv4_new (); + prefix_copy ((struct prefix *)pe->destination_ipv4, + (struct prefix *)&dest_addr); pe->af = AF_INET; pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED; diff --git a/eigrpd/eigrp_main.c b/eigrpd/eigrp_main.c index b11b5825c..08a1cb659 100644 --- a/eigrpd/eigrp_main.c +++ b/eigrpd/eigrp_main.c @@ -181,7 +181,7 @@ main (int argc, char **argv, char **envp) eigrp_om->master = frr_init(); master = eigrp_om->master; - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); /*EIGRPd init*/ eigrp_if_init (); diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c index 72f3e151d..2d02acc00 100644 --- a/eigrpd/eigrp_packet.c +++ b/eigrpd/eigrp_packet.c @@ -113,7 +113,10 @@ eigrp_make_md5_digest (struct eigrp_interface *ei, struct stream *s, u_char flag if(keychain) key = key_lookup_for_send(keychain); else - return EIGRP_AUTH_TYPE_NONE; + { + eigrp_authTLV_MD5_free(auth_TLV); + return EIGRP_AUTH_TYPE_NONE; + } memset(&ctx, 0, sizeof(ctx)); MD5Init(&ctx); @@ -234,8 +237,7 @@ eigrp_check_md5_digest (struct stream *s, } /* save neighbor's crypt_seqnum */ - if (nbr) - nbr->crypt_seqnum = authTLV->key_sequence; + nbr->crypt_seqnum = authTLV->key_sequence; return 1; } @@ -627,7 +629,7 @@ eigrp_read (struct thread *thread) struct eigrp_packet *ep; ep = eigrp_fifo_tail(nbr->retrans_queue); - if (ep != NULL) + if (ep) { if (ntohl(eigrph->ack) == ep->sequence_number) { @@ -641,7 +643,7 @@ eigrp_read (struct thread *thread) eigrp_update_send_EOT(nbr); } ep = eigrp_fifo_pop_tail(nbr->retrans_queue); - /*eigrp_packet_free(ep);*/ + eigrp_packet_free(ep); if (nbr->retrans_queue->count > 0) { eigrp_send_packet_reliably(nbr); @@ -649,7 +651,7 @@ eigrp_read (struct thread *thread) } } ep = eigrp_fifo_tail(nbr->multicast_queue); - if (ep != NULL) + if (ep) { if (ntohl(eigrph->ack) == ep->sequence_number) { diff --git a/eigrpd/eigrp_query.c b/eigrpd/eigrp_query.c index b5f4cab84..774461a09 100644 --- a/eigrpd/eigrp_query.c +++ b/eigrpd/eigrp_query.c @@ -113,16 +113,17 @@ eigrp_query_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr); /* If the destination exists (it should, but one never know)*/ if (dest != NULL) diff --git a/eigrpd/eigrp_reply.c b/eigrpd/eigrp_reply.c index fb7770ca5..e64a3d022 100644 --- a/eigrpd/eigrp_reply.c +++ b/eigrpd/eigrp_reply.c @@ -145,6 +145,8 @@ eigrp_send_reply (struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe) { eigrp_send_packet_reliably(nbr); } + + XFREE(MTYPE_EIGRP_PREFIX_ENTRY, pe2); } /*EIGRP REPLY read function*/ @@ -179,16 +181,17 @@ eigrp_reply_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4 (eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4 (eigrp->topology_table, &dest_addr); /* * Destination must exists */ @@ -211,24 +214,18 @@ eigrp_reply_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header *e plist = e->prefix[EIGRP_FILTER_IN]; alist_i = ei->list[EIGRP_FILTER_IN]; plist_i = ei->prefix[EIGRP_FILTER_IN]; - zlog_info("REPLY Receive: Filtering"); - zlog_info("REPLY RECEIVE Prefix: %s", inet_ntoa(dest_addr->prefix)); /* Check if any list fits */ - if ((alist && access_list_apply (alist, - (struct prefix *) dest_addr) == FILTER_DENY)|| - (plist && prefix_list_apply (plist, - (struct prefix *) dest_addr) == PREFIX_DENY)|| - (alist_i && access_list_apply (alist_i, - (struct prefix *) dest_addr) == FILTER_DENY)|| - (plist_i && prefix_list_apply (plist_i, - (struct prefix *) dest_addr) == PREFIX_DENY)) + if ((alist && + access_list_apply (alist, (struct prefix *)&dest_addr) == FILTER_DENY) || + (plist && + prefix_list_apply (plist, (struct prefix *)&dest_addr) == PREFIX_DENY) || + (alist_i && + access_list_apply (alist_i, (struct prefix *)&dest_addr) == FILTER_DENY) || + (plist_i && + prefix_list_apply (plist_i, (struct prefix *)&dest_addr) == PREFIX_DENY)) { - zlog_info("REPLY RECEIVE: Setting metric to max"); tlv->metric.delay = EIGRP_MAX_METRIC; - zlog_info("REPLY RECEIVE Prefix: %s", inet_ntoa(dest_addr->prefix)); - } else { - zlog_info("REPLY RECEIVE: Not setting metric"); - } + } /* * End of filtering */ diff --git a/eigrpd/eigrp_siaquery.c b/eigrpd/eigrp_siaquery.c index 3fc1aa54d..d521a57ba 100644 --- a/eigrpd/eigrp_siaquery.c +++ b/eigrpd/eigrp_siaquery.c @@ -80,16 +80,17 @@ eigrp_siaquery_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr); /* If the destination exists (it should, but one never know)*/ if (dest != NULL) @@ -161,4 +162,6 @@ eigrp_send_siaquery (struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe) eigrp_send_packet_reliably(nbr); } } + else + eigrp_packet_free(ep); } diff --git a/eigrpd/eigrp_siareply.c b/eigrpd/eigrp_siareply.c index ecce154bf..dbf451800 100644 --- a/eigrpd/eigrp_siareply.c +++ b/eigrpd/eigrp_siareply.c @@ -79,16 +79,17 @@ eigrp_siareply_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr); /* If the destination exists (it should, but one never know)*/ if (dest != NULL) @@ -160,6 +161,8 @@ eigrp_send_siareply (struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe) eigrp_send_packet_reliably(nbr); } } + else + eigrp_packet_free(ep); } diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c index b0644535d..98b2defea 100644 --- a/eigrpd/eigrp_update.c +++ b/eigrpd/eigrp_update.c @@ -290,17 +290,18 @@ eigrp_update_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header * type = stream_getw(s); if (type == EIGRP_TLV_IPv4_INT) { + struct prefix_ipv4 dest_addr; + stream_set_getp(s, s->getp - sizeof(u_int16_t)); tlv = eigrp_read_ipv4_tlv(s); /*searching if destination exists */ - struct prefix_ipv4 *dest_addr; - dest_addr = prefix_ipv4_new(); - dest_addr->prefix = tlv->destination; - dest_addr->prefixlen = tlv->prefix_length; + dest_addr.family = AFI_IP; + dest_addr.prefix = tlv->destination; + dest_addr.prefixlen = tlv->prefix_length; struct eigrp_prefix_entry *dest = - eigrp_topology_table_lookup_ipv4(eigrp->topology_table, dest_addr); + eigrp_topology_table_lookup_ipv4(eigrp->topology_table, &dest_addr); /*if exists it comes to DUAL*/ if (dest != NULL) @@ -330,7 +331,9 @@ eigrp_update_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header * /*Here comes topology information save*/ pe = eigrp_prefix_entry_new(); pe->serno = eigrp->serno; - pe->destination_ipv4 = dest_addr; + pe->destination_ipv4 = prefix_ipv4_new(); + prefix_copy((struct prefix *)pe->destination_ipv4, + (struct prefix *)&dest_addr); pe->af = AF_INET; pe->state = EIGRP_FSM_STATE_PASSIVE; pe->nt = EIGRP_TOPOLOGY_TYPE_REMOTE; @@ -352,93 +355,52 @@ eigrp_update_receive (struct eigrp *eigrp, struct ip *iph, struct eigrp_header * */ alist = ei->list[EIGRP_FILTER_IN]; - if (alist) { - zlog_info ("ALIST PROC IN: %s", alist->name); - } else { - zlog_info("ALIST je prazdny"); - } - /* Check if access-list fits */ - if (alist && access_list_apply (alist, - (struct prefix *) dest_addr) == FILTER_DENY) + if (alist && + access_list_apply (alist, (struct prefix *)&dest_addr) == FILTER_DENY) { /* If yes, set reported metric to Max */ - zlog_info("PROC IN: Nastavujem metriku na MAX"); ne->reported_metric.delay = EIGRP_MAX_METRIC; - zlog_info("PROC IN Prefix: %s", inet_ntoa(dest_addr->prefix)); } else { - zlog_info("PROC IN: NENastavujem metriku "); ne->distance = eigrp_calculate_total_metrics(eigrp, ne); } plist = e->prefix[EIGRP_FILTER_IN]; - if (plist) { - zlog_info ("PLIST PROC IN: %s", plist->name); - } else { - zlog_info("PLIST PROC IN je prazdny"); - } - /* Check if prefix-list fits */ - if (plist && prefix_list_apply (plist, - (struct prefix *) dest_addr) == PREFIX_DENY) + if (plist && + prefix_list_apply (plist, (struct prefix *)&dest_addr) == PREFIX_DENY) { /* If yes, set reported metric to Max */ - zlog_info("PLIST PROC IN: Nastavujem metriku na MAX"); ne->reported_metric.delay = EIGRP_MAX_METRIC; - zlog_info("PLIST PROC IN Prefix: %s", inet_ntoa(dest_addr->prefix)); - } else { - zlog_info("PLIST PROC IN: NENastavujem metriku "); - } + } /*Get access-list from current interface */ - zlog_info("Checking access_list on interface: %s",ei->ifp->name); alist = ei->list[EIGRP_FILTER_IN]; - if (alist) { - zlog_info ("ALIST INT IN: %s", alist->name); - } else { - zlog_info("ALIST INT IN je prazdny"); - } /* Check if access-list fits */ - if (alist && access_list_apply (alist, (struct prefix *) dest_addr) == FILTER_DENY) + if (alist && + access_list_apply (alist, (struct prefix *)&dest_addr) == FILTER_DENY) { /* If yes, set reported metric to Max */ - zlog_info("INT IN: Nastavujem metriku na MAX"); ne->reported_metric.delay = EIGRP_MAX_METRIC; - zlog_info("INT IN Prefix: %s", inet_ntoa(dest_addr->prefix)); - } else { - zlog_info("INT IN: NENastavujem metriku "); - } + } plist = ei->prefix[EIGRP_FILTER_IN]; - if (plist) { - zlog_info ("PLIST INT IN: %s", plist->name); - } else { - zlog_info("PLIST INT IN je prazdny"); - } - /* Check if prefix-list fits */ - if (plist && prefix_list_apply (plist, - (struct prefix *) dest_addr) == PREFIX_DENY) + if (plist && + prefix_list_apply (plist, (struct prefix *)&dest_addr) == PREFIX_DENY) { /* If yes, set reported metric to Max */ - zlog_info("PLIST INT IN: Nastavujem metriku na MAX"); ne->reported_metric.delay = EIGRP_MAX_METRIC; - zlog_info("PLIST INT IN Prefix: %s", inet_ntoa(dest_addr->prefix)); - } else { - zlog_info("PLIST INT IN: NENastavujem metriku "); - } + } /* * End of filtering */ ne->distance = eigrp_calculate_total_metrics(eigrp, ne); - zlog_info("<DEBUG PROC IN Distance: %x", ne->distance); - zlog_info("<DEBUG PROC IN Delay: %x", ne->total_metric.delay); - pe->fdistance = pe->distance = pe->rdistance = ne->distance; ne->prefix = pe; @@ -648,6 +610,7 @@ eigrp_update_send (struct eigrp_interface *ei) struct prefix_list *plist_i; struct eigrp *e; struct prefix_ipv4 *dest_addr; + bool packet_sent = false; u_int16_t length = EIGRP_HEADER_LEN; @@ -719,7 +682,8 @@ eigrp_update_send (struct eigrp_interface *ei) return; } - if((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) && (IF_DEF_PARAMS (ei->ifp)->auth_keychain != NULL)) + if((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) + && (IF_DEF_PARAMS (ei->ifp)->auth_keychain != NULL)) { eigrp_make_md5_digest(ei,ep->s, EIGRP_AUTH_UPDATE_FLAG); } @@ -741,6 +705,7 @@ eigrp_update_send (struct eigrp_interface *ei) { if (nbr->state == EIGRP_NEIGHBOR_UP) { + packet_sent = true; /*Put packet to retransmission queue*/ eigrp_fifo_push_head(nbr->retrans_queue, ep); @@ -750,6 +715,9 @@ eigrp_update_send (struct eigrp_interface *ei) } } } + + if (!packet_sent) + eigrp_packet_free(ep); } void diff --git a/isisd/isis_main.c b/isisd/isis_main.c index 6b761d645..58070c7f2 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -206,7 +206,7 @@ main (int argc, char **argv, char **envp) * initializations */ access_list_init(); - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); prefix_list_init(); isis_init (); isis_circuit_init (); diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index a0b021dfd..710dcd15f 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -329,7 +329,7 @@ main(int argc, char *argv[]) cmd_init(1); vty_config_lockless(); vty_init(master); - vrf_init(); + vrf_init(NULL, NULL, NULL, NULL); access_list_init(); ldp_vty_init(); ldp_zebra_init(master); diff --git a/lib/Makefile.am b/lib/Makefile.am index 0323f9ab9..a1b78d3c4 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -80,6 +80,7 @@ pkginclude_HEADERS = \ libfrr.h \ sha256.h \ frr_pthread.h \ + vrf_int.h \ # end noinst_HEADERS = \ @@ -23,6 +23,7 @@ #include "if.h" #include "vrf.h" +#include "vrf_int.h" #include "prefix.h" #include "table.h" #include "log.h" @@ -236,33 +237,6 @@ vrf_disable (struct vrf *vrf) (*vrf_master.vrf_disable_hook) (vrf); } - -/* Add a VRF hook. Please add hooks before calling vrf_init(). */ -void -vrf_add_hook (int type, int (*func)(struct vrf *)) -{ - if (debug_vrf) - zlog_debug ("%s: Add Hook %d to function %p", __PRETTY_FUNCTION__, - type, func); - - switch (type) { - case VRF_NEW_HOOK: - vrf_master.vrf_new_hook = func; - break; - case VRF_DELETE_HOOK: - vrf_master.vrf_delete_hook = func; - break; - case VRF_ENABLE_HOOK: - vrf_master.vrf_enable_hook = func; - break; - case VRF_DISABLE_HOOK: - vrf_master.vrf_disable_hook = func; - break; - default: - break; - } -} - vrf_id_t vrf_name_to_id (const char *name) { @@ -308,24 +282,6 @@ vrf_iflist_get (vrf_id_t vrf_id) return vrf->iflist; } -/* Create the interface list for the specified VRF, if needed. */ -void -vrf_iflist_create (vrf_id_t vrf_id) -{ - struct vrf * vrf = vrf_lookup_by_id (vrf_id); - if (vrf && !vrf->iflist) - if_init (&vrf->iflist); -} - -/* Free the interface list of the specified VRF. */ -void -vrf_iflist_terminate (vrf_id_t vrf_id) -{ - struct vrf * vrf = vrf_lookup_by_id (vrf_id); - if (vrf && vrf->iflist) - if_terminate (&vrf->iflist); -} - /* * VRF bit-map */ @@ -423,13 +379,21 @@ vrf_bitmap_check (vrf_bitmap_t bmap, vrf_id_t vrf_id) /* Initialize VRF module. */ void -vrf_init (void) +vrf_init (int (*create)(struct vrf *), + int (*enable)(struct vrf *), + int (*disable)(struct vrf *), + int (*delete)(struct vrf *)) { struct vrf *default_vrf; if (debug_vrf) zlog_debug ("%s: Initializing VRF subsystem", __PRETTY_FUNCTION__); + vrf_master.vrf_new_hook = create; + vrf_master.vrf_enable_hook = enable; + vrf_master.vrf_disable_hook = disable; + vrf_master.vrf_delete_hook = delete; + /* The default VRF always exists. */ default_vrf = vrf_get (VRF_DEFAULT, VRF_DEFAULT_NAME); if (!default_vrf) @@ -56,15 +56,6 @@ enum { #define VRF_CMD_HELP_STR "Specify the VRF\nThe VRF name\n" #define VRF_ALL_CMD_HELP_STR "Specify the VRF\nAll VRFs\n" -/* - * VRF hooks - */ - -#define VRF_NEW_HOOK 0 /* a new VRF is just created */ -#define VRF_DELETE_HOOK 1 /* a VRF is to be deleted */ -#define VRF_ENABLE_HOOK 2 /* a VRF is ready to use */ -#define VRF_DISABLE_HOOK 3 /* a VRF is to be unusable */ - struct vrf { RB_ENTRY(vrf) id_entry, name_entry; @@ -97,21 +88,9 @@ DECLARE_QOBJ_TYPE(vrf) extern struct vrf_id_head vrfs_by_id; extern struct vrf_name_head vrfs_by_name; -/* - * Add a specific hook to VRF module. - * @param1: hook type - * @param2: the callback function - * - param 1: the VRF ID - * - param 2: the address of the user data pointer (the user data - * can be stored in or freed from there) - */ -extern void vrf_add_hook (int, int (*)(struct vrf *)); - extern struct vrf *vrf_lookup_by_id (vrf_id_t); extern struct vrf *vrf_lookup_by_name (const char *); extern struct vrf *vrf_get (vrf_id_t, const char *); -extern void vrf_delete (struct vrf *); -extern int vrf_enable (struct vrf *); extern vrf_id_t vrf_name_to_id (const char *); #define VRF_GET_ID(V,NAME) \ @@ -147,10 +126,6 @@ extern void *vrf_info_lookup (vrf_id_t); extern struct list *vrf_iflist (vrf_id_t); /* Get the interface list of the specified VRF. Create one if not find. */ extern struct list *vrf_iflist_get (vrf_id_t); -/* Create the interface list for the specified VRF, if needed. */ -extern void vrf_iflist_create (vrf_id_t vrf_id); -/* Free the interface list of the specified VRF. */ -extern void vrf_iflist_terminate (vrf_id_t vrf_id); /* * VRF bit-map: maintaining flags, one bit per VRF ID @@ -167,9 +142,31 @@ extern int vrf_bitmap_check (vrf_bitmap_t, vrf_id_t); /* * VRF initializer/destructor + * + * create -> Called back when a new VRF is created. This + * can be either through these 3 options: + * 1) CLI mentions a vrf before OS knows about it + * 2) OS calls zebra and we create the vrf from OS + * callback + * 3) zebra calls individual protocols to notify + * about the new vrf + * + * enable -> Called back when a VRF is actually usable from + * an OS perspective ( 2 and 3 above ) + * + * disable -> Called back when a VRF is being deleted from + * the system ( 2 and 3 ) above + * + * delete -> Called back when a vrf is being deleted from + * the system ( 2 and 3 ) above. + */ +extern void vrf_init (int (*create)(struct vrf *), + int (*enable)(struct vrf *), + int (*disable)(struct vrf *), + int (*delete)(struct vrf *)); +/* + * Call vrf_terminate when the protocol is being shutdown */ -/* Please add hooks before calling vrf_init(). */ -extern void vrf_init (void); extern void vrf_terminate (void); extern void vrf_cmd_init (int (*writefunc)(struct vty *vty)); diff --git a/lib/vrf_int.h b/lib/vrf_int.h new file mode 100644 index 000000000..f0301b767 --- /dev/null +++ b/lib/vrf_int.h @@ -0,0 +1,56 @@ +/* + * VRF Internal Header + * Copyright (C) 2017 Cumulus Networks, Inc. + * Donald Sharp + * + * This file is part of FRR. + * + * FRR is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FRR is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FRR; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ +#ifndef __LIB_VRF_PRIVATE_H__ +#define __LIB_VRF_PRIVATE_H__ + +#include "vrf.h" + +/* + * These functions should only be called by: + * zebra/if_netlink.c -> The interface from OS into Zebra + * lib/zclient.c -> The interface from Zebra to each daemon + * + * Why you ask? Well because these are the turn on/off + * functions and the only place we can really turn a + * vrf on properly is in the call up from the os -> zebra + * and the pass through of this informatoin from zebra -> protocols + */ + +/* + * vrf_enable + * + * Given a newly running vrf enable it to be used + * by interested routing protocols + */ +extern int vrf_enable (struct vrf *); + +/* + * vrf_delete + * + * Given a vrf that is being deleted, delete it + * from interested parties + */ +extern void vrf_delete (struct vrf *); + +#endif + diff --git a/lib/zclient.c b/lib/zclient.c index 650a37503..9823bc8d9 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -25,6 +25,8 @@ #include "stream.h" #include "buffer.h" #include "network.h" +#include "vrf.h" +#include "vrf_int.h" #include "if.h" #include "log.h" #include "thread.h" diff --git a/nhrpd/nhrp_main.c b/nhrpd/nhrp_main.c index a44ce35bb..7c5d80336 100644 --- a/nhrpd/nhrp_main.c +++ b/nhrpd/nhrp_main.c @@ -129,7 +129,7 @@ int main(int argc, char **argv) /* Library inits. */ master = frr_init(); nhrp_interface_init(); - vrf_init(); + vrf_init(NULL, NULL, NULL, NULL); resolver_init(); /* Run with elevated capabilities, as for all netlink activity diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index baecf7981..f69c1e1bc 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -221,7 +221,7 @@ main (int argc, char *argv[], char *envp[]) /* thread master */ master = frr_init (); - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); access_list_init (); prefix_list_init (); diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index a56272356..6cd6d0272 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -206,7 +206,7 @@ main (int argc, char **argv) /* Library inits. */ debug_init (); - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); access_list_init (); prefix_list_init (); diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 84bbedad4..f36a9b3cb 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -60,7 +60,6 @@ pim_if_init (void) for (i = 0; i < MAXVIFS; i++) pim_iface_vif_index[i] = 0; - vrf_iflist_create(VRF_DEFAULT); pim_ifchannel_list = list_new(); pim_ifchannel_list->cmp = (int (*)(void *, void *))pim_ifchannel_compare; } diff --git a/pimd/pimd.c b/pimd/pimd.c index 8b6fa6714..8aab5d2ef 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -140,22 +140,15 @@ pim_vrf_disable (struct vrf *vrf) void pim_vrf_init (void) { - vrf_add_hook (VRF_NEW_HOOK, pim_vrf_new); - vrf_add_hook (VRF_ENABLE_HOOK, pim_vrf_enable); - vrf_add_hook (VRF_DISABLE_HOOK, pim_vrf_disable); - vrf_add_hook (VRF_DELETE_HOOK, pim_vrf_delete); - - vrf_init (); + vrf_init (pim_vrf_new, + pim_vrf_enable, + pim_vrf_disable, + pim_vrf_delete); } static void pim_vrf_terminate (void) { - vrf_add_hook (VRF_NEW_HOOK, NULL); - vrf_add_hook (VRF_ENABLE_HOOK, NULL); - vrf_add_hook (VRF_DISABLE_HOOK, NULL); - vrf_add_hook (VRF_DELETE_HOOK, NULL); - vrf_terminate (); } diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 0958800d8..38c287594 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -177,7 +177,7 @@ main (int argc, char **argv) /* Library initialization. */ keychain_init (); - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); /* RIP related initialization. */ rip_init (); diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index ef4ab8552..e51781714 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -177,7 +177,7 @@ main (int argc, char **argv) master = frr_init (); /* Library inits. */ - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); /* RIPngd inits. */ ripng_init (); diff --git a/tests/bgpd/test_capability.c b/tests/bgpd/test_capability.c index 395001bc6..1e3a5be4e 100644 --- a/tests/bgpd/test_capability.c +++ b/tests/bgpd/test_capability.c @@ -650,7 +650,7 @@ main (void) qobj_init (); master = thread_master_create (); bgp_master_init (master); - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); bgp_option_set (BGP_OPT_NO_LISTEN); if (fileno (stdout) >= 0) diff --git a/tests/bgpd/test_mp_attr.c b/tests/bgpd/test_mp_attr.c index 1995c1702..e323748e9 100644 --- a/tests/bgpd/test_mp_attr.c +++ b/tests/bgpd/test_mp_attr.c @@ -750,7 +750,7 @@ main (void) qobj_init (); master = thread_master_create (); bgp_master_init (master); - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); bgp_option_set (BGP_OPT_NO_LISTEN); bgp_attr_init (); diff --git a/tests/bgpd/test_mpath.c b/tests/bgpd/test_mpath.c index 79e607f49..affebbafe 100644 --- a/tests/bgpd/test_mpath.c +++ b/tests/bgpd/test_mpath.c @@ -379,7 +379,7 @@ global_test_init (void) master = thread_master_create (); zclient = zclient_new(master); bgp_master_init (master); - vrf_init (); + vrf_init (NULL, NULL, NULL, NULL); bgp_option_set (BGP_OPT_NO_LISTEN); if (fileno (stdout) >= 0) diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index f123dab96..edfb564a6 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -37,6 +37,7 @@ #include "privs.h" #include "nexthop.h" #include "vrf.h" +#include "vrf_int.h" #include "mpls.h" #include "vty.h" diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 28512c49f..94e250618 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -535,11 +535,10 @@ vrf_config_write (struct vty *vty) void zebra_vrf_init (void) { - vrf_add_hook (VRF_NEW_HOOK, zebra_vrf_new); - vrf_add_hook (VRF_ENABLE_HOOK, zebra_vrf_enable); - vrf_add_hook (VRF_DISABLE_HOOK, zebra_vrf_disable); - vrf_add_hook (VRF_DELETE_HOOK, zebra_vrf_delete); + vrf_init (zebra_vrf_new, + zebra_vrf_enable, + zebra_vrf_disable, + zebra_vrf_delete); - vrf_init (); vrf_cmd_init (vrf_config_write); } |