diff options
| -rw-r--r-- | bgpd/bgp_route.c | 70 | ||||
| -rw-r--r-- | bgpd/bgp_vty.c | 4 | ||||
| -rw-r--r-- | isisd/isis_circuit.c | 15 | ||||
| -rw-r--r-- | lib/compiler.h | 1 | ||||
| -rw-r--r-- | lib/filter.c | 3 | ||||
| -rw-r--r-- | lib/module.c | 2 | ||||
| -rw-r--r-- | lib/vrf.c | 5 | ||||
| -rw-r--r-- | pimd/pim_cmd.c | 18 | ||||
| -rw-r--r-- | pimd/pim_ifchannel.c | 5 | ||||
| -rw-r--r-- | pimd/pim_igmp.c | 3 | ||||
| -rw-r--r-- | pimd/pim_nht.c | 173 | ||||
| -rw-r--r-- | pimd/pim_nht.h | 8 | ||||
| -rw-r--r-- | pimd/pim_rp.c | 21 | ||||
| -rw-r--r-- | pimd/pim_rpf.c | 22 | ||||
| -rw-r--r-- | pimd/pim_zebra.c | 12 | ||||
| -rw-r--r-- | zebra/if_netlink.c | 2 | ||||
| -rw-r--r-- | zebra/main.c | 21 | ||||
| -rw-r--r-- | zebra/zebra_netns_notify.c | 1 | ||||
| -rw-r--r-- | zebra/zebra_ptm.c | 36 | ||||
| -rw-r--r-- | zebra/zebra_vty.c | 2 | ||||
| -rw-r--r-- | zebra/zserv.c | 16 |
21 files changed, 223 insertions, 217 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 795bd15613..f10f7425c6 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8163,7 +8163,7 @@ static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, const char *regstr, afi_t afi, safi_t safi, enum bgp_show_type type); static int bgp_show_community(struct vty *vty, struct bgp *bgp, const char *comstr, int exact, afi_t afi, - safi_t safi); + safi_t safi, uint8_t use_json); static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, @@ -9038,7 +9038,6 @@ DEFUN (show_ip_bgp, |prefix-list WORD\ |filter-list WORD\ |statistics\ - |community <AA:NN|local-AS|no-advertise|no-export|graceful-shutdown> [exact-match]\ |community-list <(1-500)|WORD> [exact-match]\ |A.B.C.D/M longer-prefixes\ |X:X::X:X/M longer-prefixes\ @@ -9058,13 +9057,6 @@ DEFUN (show_ip_bgp, "Display routes conforming to the filter-list\n" "Regular expression access list name\n" "BGP RIB advertisement statistics\n" - "Display routes matching the communities\n" - COMMUNITY_AANN_STR - "Do not send outside local AS (well-known community)\n" - "Do not advertise to any peer (well-known community)\n" - "Do not export to next AS (well-known community)\n" - "Graceful shutdown (well-known community)\n" - "Exact match of the communities\n" "Display routes matching the community-list\n" "community-list number\n" "community-list name\n" @@ -9079,7 +9071,6 @@ DEFUN (show_ip_bgp, int exact_match = 0; struct bgp *bgp = NULL; int idx = 0; - int idx_community_type = 0; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, &bgp); @@ -9106,24 +9097,6 @@ DEFUN (show_ip_bgp, return bgp_show_route_map(vty, bgp, argv[idx + 1]->arg, afi, safi, bgp_show_type_route_map); - if (argv_find(argv, argc, "community", &idx)) { - /* show a specific community */ - if (argv_find(argv, argc, "local-AS", &idx_community_type) - || argv_find(argv, argc, "no-advertise", - &idx_community_type) - || argv_find(argv, argc, "no-export", &idx_community_type) - || argv_find(argv, argc, "graceful-shutdown", - &idx_community_type) - || argv_find(argv, argc, "AA:NN", &idx_community_type)) { - - if (argv_find(argv, argc, "exact-match", &idx)) - exact_match = 1; - return bgp_show_community(vty, bgp, - argv[idx_community_type]->arg, - exact_match, afi, safi); - } - } - if (argv_find(argv, argc, "community-list", &idx)) { const char *clist_number_or_name = argv[++idx]->arg; if (++idx < argc && strmatch(argv[idx]->text, "exact-match")) @@ -9148,7 +9121,7 @@ DEFUN (show_ip_bgp_json, [<\ cidr-only\ |dampening <flap-statistics|dampened-paths>\ - |community \ + |community [<AA:NN|local-AS|no-advertise|no-export|graceful-shutdown>] [exact-match]\ >] [json]", SHOW_STR IP_STR @@ -9161,6 +9134,12 @@ DEFUN (show_ip_bgp_json, "Display flap statistics of routes\n" "Display paths suppressed due to dampening\n" "Display routes matching the communities\n" + COMMUNITY_AANN_STR + "Do not send outside local AS (well-known community)\n" + "Do not advertise to any peer (well-known community)\n" + "Do not export to next AS (well-known community)\n" + "Graceful shutdown (well-known community)\n" + "Exact match of the communities\n" JSON_STR) { afi_t afi = AFI_IP6; @@ -9168,6 +9147,8 @@ DEFUN (show_ip_bgp_json, enum bgp_show_type sh_type = bgp_show_type_normal; struct bgp *bgp = NULL; int idx = 0; + int idx_community_type = 0; + int exact_match = 0; bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi, &bgp); @@ -9193,10 +9174,31 @@ DEFUN (show_ip_bgp_json, } if (argv_find(argv, argc, "community", &idx)) { - /* show all communities */ - return bgp_show(vty, bgp, afi, safi, - bgp_show_type_community_all, NULL, uj); + + /* show a specific community */ + if (argv_find(argv, argc, "local-AS", &idx_community_type) || + argv_find(argv, argc, "no-advertise", + &idx_community_type) || + argv_find(argv, argc, "no-export", + &idx_community_type) || + argv_find(argv, argc, "graceful-shutdown", + &idx_community_type) || + argv_find(argv, argc, "AA:NN", &idx_community_type)) { + if (argv_find(argv, argc, "exact-match", &idx)) + exact_match = 1; + + return (bgp_show_community(vty, bgp, + argv[idx_community_type]->arg, + exact_match, afi, safi, uj)); + } else { + + /* show all communities */ + return (bgp_show(vty, bgp, afi, safi, + bgp_show_type_community_all, NULL, + uj)); + } } + return bgp_show(vty, bgp, afi, safi, sh_type, NULL, uj); } @@ -9403,7 +9405,7 @@ static int bgp_show_route_map(struct vty *vty, struct bgp *bgp, static int bgp_show_community(struct vty *vty, struct bgp *bgp, const char *comstr, int exact, afi_t afi, - safi_t safi) + safi_t safi, uint8_t use_json) { struct community *com; int ret = 0; @@ -9417,7 +9419,7 @@ static int bgp_show_community(struct vty *vty, struct bgp *bgp, ret = bgp_show(vty, bgp, afi, safi, (exact ? bgp_show_type_community_exact : bgp_show_type_community), - com, 0); + com, use_json); community_free(com); return ret; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index e9d9a846af..2acf39a699 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9115,6 +9115,10 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, json_object_string_add( json_neigh, "remoteRouterId", inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); + json_object_string_add( + json_neigh, "localRouterId", + inet_ntop(AF_INET, &bgp->router_id, buf1, + sizeof(buf1))); /* Confederation */ if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index f8df33d3ee..d51f31ff37 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -638,7 +638,7 @@ int isis_circuit_up(struct isis_circuit *circuit) thread_add_timer(master, isis_run_dr_l2, circuit, 2 * circuit->hello_interval[1], &circuit->u.bc.t_run_dr[1]); - } else { + } else if (circuit->circ_type == CIRCUIT_T_P2P) { /* initializing the hello send threads * for a ptp IF */ @@ -682,9 +682,6 @@ int isis_circuit_up(struct isis_circuit *circuit) void isis_circuit_down(struct isis_circuit *circuit) { - if (circuit->state != C_STATE_UP) - return; - /* Clear the flags for all the lsps of the circuit. */ isis_circuit_update_all_srmflags(circuit, 0); @@ -756,10 +753,12 @@ void isis_circuit_down(struct isis_circuit *circuit) } /* send one gratuitous hello to spead up convergence */ - if (circuit->is_type & IS_LEVEL_1) - send_hello(circuit, IS_LEVEL_1); - if (circuit->is_type & IS_LEVEL_2) - send_hello(circuit, IS_LEVEL_2); + if (circuit->state == C_STATE_UP) { + if (circuit->is_type & IS_LEVEL_1) + send_hello(circuit, IS_LEVEL_1); + if (circuit->is_type & IS_LEVEL_2) + send_hello(circuit, IS_LEVEL_2); + } circuit->upadjcount[0] = 0; circuit->upadjcount[1] = 0; diff --git a/lib/compiler.h b/lib/compiler.h index 773a52e742..b19c33f65e 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -76,6 +76,7 @@ #else #define CPP_WARN(text) +#define CPP_NOTICE(text) #endif #endif /* _FRR_COMPILER_H */ diff --git a/lib/filter.c b/lib/filter.c index 5f391aa767..670c65374a 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -549,8 +549,7 @@ static int vty_access_list_remark_unset(struct vty *vty, afi_t afi, access->remark = NULL; } - if (access->head == NULL && access->tail == NULL - && access->remark == NULL) + if (access->head == NULL && access->tail == NULL) access_list_delete(access); return CMD_SUCCESS; diff --git a/lib/module.c b/lib/module.c index 0c85364003..7d5671290b 100644 --- a/lib/module.c +++ b/lib/module.c @@ -85,7 +85,7 @@ struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, char *err, *args++ = '\0'; if (!strchr(name, '/')) { - if (!handle && execname) { + if (execname) { snprintf(fullpath, sizeof(fullpath), "%s/%s_%s.so", dir, execname, name); handle = dlopen(fullpath, RTLD_NOW | RTLD_GLOBAL); @@ -628,7 +628,7 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname, } if (vrf->ns_ctxt != NULL) { ns = (struct ns *)vrf->ns_ctxt; - if (ns && 0 != strcmp(ns->name, pathname)) { + if (!strcmp(ns->name, pathname)) { if (vty) vty_out(vty, "VRF %u already configured with NETNS %s\n", @@ -661,8 +661,7 @@ int vrf_netns_handler_create(struct vty *vty, struct vrf *vrf, char *pathname, ns->vrf_ctxt = (void *)vrf; vrf->ns_ctxt = (void *)ns; /* update VRF netns NAME */ - if (vrf) - strlcpy(vrf->data.l.netns_name, basename(pathname), NS_NAMSIZ); + strlcpy(vrf->data.l.netns_name, basename(pathname), NS_NAMSIZ); if (!ns_enable(ns, vrf_update_vrf_id)) { if (vty) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index ae2daf40aa..460bbfeae7 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -4252,7 +4252,7 @@ DEFUN (show_ip_pim_nexthop_lookup, "Source/RP address\n" "Multicast Group address\n") { - struct pim_nexthop_cache pnc; + struct pim_nexthop_cache *pnc = NULL; struct prefix nht_p; int result = 0; struct in_addr src_addr, grp_addr; @@ -4264,6 +4264,7 @@ DEFUN (show_ip_pim_nexthop_lookup, char grp_str[PREFIX_STRLEN]; int idx = 2; struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); + struct pim_rpf rpf; if (!vrf) return CMD_WARNING; @@ -4301,7 +4302,6 @@ DEFUN (show_ip_pim_nexthop_lookup, grp_addr)) return CMD_SUCCESS; - memset(&pnc, 0, sizeof(struct pim_nexthop_cache)); nht_p.family = AF_INET; nht_p.prefixlen = IPV4_MAX_BITLEN; nht_p.u.prefix4 = vif_source; @@ -4310,12 +4310,18 @@ DEFUN (show_ip_pim_nexthop_lookup, grp.u.prefix4 = grp_addr; memset(&nexthop, 0, sizeof(nexthop)); - if (pim_find_or_track_nexthop(vrf->info, &nht_p, NULL, NULL, &pnc)) - result = pim_ecmp_nexthop_search(vrf->info, &pnc, &nexthop, + memset(&rpf, 0, sizeof(struct pim_rpf)); + rpf.rpf_addr.family = AF_INET; + rpf.rpf_addr.prefixlen = IPV4_MAX_BITLEN; + rpf.rpf_addr.u.prefix4 = vif_source; + + pnc = pim_nexthop_cache_find(vrf->info, &rpf); + if (pnc) + result = pim_ecmp_nexthop_search(vrf->info, pnc, &nexthop, &nht_p, &grp, 0); else - result = pim_ecmp_nexthop_lookup(vrf->info, &nexthop, - vif_source, &nht_p, &grp, 0); + result = pim_ecmp_nexthop_lookup(vrf->info, &nexthop, &nht_p, + &grp, 0); if (!result) { vty_out(vty, diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index e82a7589b7..eb3307589e 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -136,9 +136,8 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch) mask = PIM_OIF_FLAG_PROTO_IGMP; /* SGRpt entry could have empty oil */ - if (ch->upstream->channel_oil) - pim_channel_del_oif(ch->upstream->channel_oil, - ch->interface, mask); + pim_channel_del_oif(ch->upstream->channel_oil, ch->interface, + mask); /* * Do we have any S,G's that are inheriting? * Nuke from on high too. diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 42bdd80ce2..b46f1b5e9d 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -909,10 +909,9 @@ static int pim_igmp_read(struct thread *t) socklen_t fromlen = sizeof(from); socklen_t tolen = sizeof(to); ifindex_t ifindex = -1; - int cont = 1; int len; - while (cont) { + while (1) { len = pim_socket_recvfromto(igmp->fd, buf, sizeof(buf), &from, &fromlen, &to, &tolen, &ifindex); if (len < 0) { diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index ac49373da0..78152b266f 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -418,12 +418,14 @@ int pim_ecmp_nexthop_search(struct pim_instance *pim, struct pim_nexthop *nexthop, struct prefix *src, struct prefix *grp, int neighbor_needed) { - struct pim_neighbor *nbr = NULL; + struct pim_neighbor *nbrs[MULTIPATH_NUM], *nbr; + struct interface *ifps[MULTIPATH_NUM]; struct nexthop *nh_node = NULL; ifindex_t first_ifindex; struct interface *ifp = NULL; uint32_t hash_val = 0, mod_val = 0; uint8_t nh_iter = 0, found = 0; + uint32_t i, num_nbrs = 0; if (!pnc || !pnc->nexthop_num || !nexthop) return 0; @@ -487,16 +489,41 @@ int pim_ecmp_nexthop_search(struct pim_instance *pim, } } } + + /* + * Look up all interfaces and neighbors, + * store for later usage + */ + for (nh_node = pnc->nexthop, i = 0; nh_node; + nh_node = nh_node->next, i++) { + ifps[i] = if_lookup_by_index(nh_node->ifindex, pim->vrf_id); + if (ifps[i]) { + nbrs[i] = pim_neighbor_find(ifps[i], + nh_node->gate.ipv4); + if (nbrs[i] || pim_if_connected_to_source(ifps[i], + + src->u.prefix4)) + num_nbrs++; + } + } if (pim->ecmp_enable) { + uint32_t consider = pnc->nexthop_num; + + if (neighbor_needed && num_nbrs < consider) + consider = num_nbrs; + + if (consider == 0) + return 0; + // PIM ECMP flag is enable then choose ECMP path. hash_val = pim_compute_ecmp_hash(src, grp); - mod_val = hash_val % pnc->nexthop_num; + mod_val = hash_val % consider; } for (nh_node = pnc->nexthop; nh_node && (found == 0); nh_node = nh_node->next) { first_ifindex = nh_node->ifindex; - ifp = if_lookup_by_index(first_ifindex, pim->vrf_id); + ifp = ifps[nh_iter]; if (!ifp) { if (PIM_DEBUG_PIM_NHT) { char addr_str[INET_ADDRSTRLEN]; @@ -532,7 +559,7 @@ int pim_ecmp_nexthop_search(struct pim_instance *pim, if (neighbor_needed && !pim_if_connected_to_source(ifp, src->u.prefix4)) { - nbr = pim_neighbor_find(ifp, nh_node->gate.ipv4); + nbr = nbrs[nh_iter]; if (!nbr && !if_is_loopback(ifp)) { if (PIM_DEBUG_PIM_NHT) zlog_debug( @@ -767,22 +794,23 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient, } int pim_ecmp_nexthop_lookup(struct pim_instance *pim, - struct pim_nexthop *nexthop, struct in_addr addr, - struct prefix *src, struct prefix *grp, - int neighbor_needed) + struct pim_nexthop *nexthop, struct prefix *src, + struct prefix *grp, int neighbor_needed) { struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM]; - struct pim_neighbor *nbr = NULL; + struct pim_neighbor *nbrs[MULTIPATH_NUM], *nbr = NULL; int num_ifindex; - struct interface *ifp; + struct interface *ifps[MULTIPATH_NUM], *ifp; int first_ifindex; int found = 0; uint8_t i = 0; uint32_t hash_val = 0, mod_val = 0; + uint32_t num_nbrs = 0; + char addr_str[PREFIX_STRLEN]; if (PIM_DEBUG_PIM_NHT) { - char addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); + pim_inet4_dump("<addr?>", src->u.prefix4, addr_str, + sizeof(addr_str)); zlog_debug("%s: Looking up: %s(%s), last lookup time: %lld", __PRETTY_FUNCTION__, addr_str, pim->vrf->name, nexthop->last_lookup_time); @@ -790,44 +818,63 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, memset(nexthop_tab, 0, sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM); - num_ifindex = zclient_lookup_nexthop(pim, nexthop_tab, MULTIPATH_NUM, - addr, PIM_NEXTHOP_LOOKUP_MAX); + num_ifindex = + zclient_lookup_nexthop(pim, nexthop_tab, MULTIPATH_NUM, + src->u.prefix4, PIM_NEXTHOP_LOOKUP_MAX); if (num_ifindex < 1) { - if (PIM_DEBUG_PIM_NHT) { - char addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<addr?>", addr, addr_str, - sizeof(addr_str)); + if (PIM_DEBUG_PIM_NHT) zlog_warn( "%s: could not find nexthop ifindex for address %s(%s)", __PRETTY_FUNCTION__, addr_str, pim->vrf->name); - } return 0; } + /* + * Look up all interfaces and neighbors, + * store for later usage + */ + for (i = 0; i < num_ifindex; i++) { + ifps[i] = if_lookup_by_index(nexthop_tab[i].ifindex, + pim->vrf_id); + if (ifps[i]) { + nbrs[i] = pim_neighbor_find( + ifps[i], nexthop_tab[i].nexthop_addr.u.prefix4); + if (nbrs[i] + || pim_if_connected_to_source(ifps[i], + src->u.prefix4)) + num_nbrs++; + } + } + // If PIM ECMP enable then choose ECMP path. if (pim->ecmp_enable) { + uint32_t consider = num_ifindex; + + if (neighbor_needed && num_nbrs < consider) + consider = num_nbrs; + + if (consider == 0) + return 0; + hash_val = pim_compute_ecmp_hash(src, grp); - mod_val = hash_val % num_ifindex; + mod_val = hash_val % consider; if (PIM_DEBUG_PIM_NHT_DETAIL) zlog_debug("%s: hash_val %u mod_val %u", __PRETTY_FUNCTION__, hash_val, mod_val); } + i = 0; while (!found && (i < num_ifindex)) { first_ifindex = nexthop_tab[i].ifindex; - ifp = if_lookup_by_index(first_ifindex, pim->vrf_id); + ifp = ifps[i]; if (!ifp) { - if (PIM_DEBUG_PIM_NHT) { - char addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<addr?>", addr, addr_str, - sizeof(addr_str)); + if (PIM_DEBUG_PIM_NHT) zlog_debug( "%s %s: could not find interface for ifindex %d (address %s(%s))", __FILE__, __PRETTY_FUNCTION__, first_ifindex, addr_str, pim->vrf->name); - } if (i == mod_val) mod_val++; i++; @@ -835,24 +882,20 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, } if (!ifp->info) { - if (PIM_DEBUG_PIM_NHT) { - char addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<addr?>", addr, addr_str, - sizeof(addr_str)); + if (PIM_DEBUG_PIM_NHT) zlog_debug( "%s: multicast not enabled on input interface %s(%s) (ifindex=%d, RPF for source %s)", __PRETTY_FUNCTION__, ifp->name, pim->vrf->name, first_ifindex, addr_str); - } if (i == mod_val) mod_val++; i++; continue; } - if (neighbor_needed && !pim_if_connected_to_source(ifp, addr)) { - nbr = pim_neighbor_find( - ifp, nexthop_tab[i].nexthop_addr.u.prefix4); + if (neighbor_needed + && !pim_if_connected_to_source(ifp, src->u.prefix4)) { + nbr = nbrs[i]; if (PIM_DEBUG_PIM_NHT_DETAIL) zlog_debug("ifp name: %s(%s), pim nbr: %p", ifp->name, pim->vrf->name, nbr); @@ -860,16 +903,11 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, if (i == mod_val) mod_val++; i++; - if (PIM_DEBUG_PIM_NHT) { - char addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<addr?>", addr, - addr_str, - sizeof(addr_str)); + if (PIM_DEBUG_PIM_NHT) zlog_debug( "%s: NBR not found on input interface %s(%s) (RPF for source %s)", __PRETTY_FUNCTION__, ifp->name, pim->vrf->name, addr_str); - } continue; } } @@ -877,12 +915,10 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, if (i == mod_val) { if (PIM_DEBUG_PIM_NHT) { char nexthop_str[PREFIX_STRLEN]; - char addr_str[INET_ADDRSTRLEN]; + pim_addr_dump("<nexthop?>", &nexthop_tab[i].nexthop_addr, nexthop_str, sizeof(nexthop_str)); - pim_inet4_dump("<addr?>", addr, addr_str, - sizeof(addr_str)); zlog_debug( "%s: found nhop %s for addr %s interface %s(%s) metric %d dist %d", __PRETTY_FUNCTION__, nexthop_str, @@ -898,7 +934,7 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, nexthop_tab[i].protocol_distance; nexthop->mrib_route_metric = nexthop_tab[i].route_metric; - nexthop->last_lookup = addr; + nexthop->last_lookup = src->u.prefix4; nexthop->last_lookup_time = pim_time_monotonic_usec(); nexthop->nbr = nbr; found = 1; @@ -913,59 +949,36 @@ int pim_ecmp_nexthop_lookup(struct pim_instance *pim, } int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim, - struct in_addr addr, struct prefix *src, - struct prefix *grp) + struct prefix *src, struct prefix *grp) { - struct pim_zlookup_nexthop nexthop_tab[MULTIPATH_NUM]; - int num_ifindex; + struct pim_nexthop nhop; int vif_index; - ifindex_t first_ifindex; - uint32_t hash_val = 0, mod_val = 0; + ifindex_t ifindex; + char addr_str[PREFIX_STRLEN]; - memset(nexthop_tab, 0, - sizeof(struct pim_zlookup_nexthop) * MULTIPATH_NUM); - num_ifindex = zclient_lookup_nexthop(pim, nexthop_tab, MULTIPATH_NUM, - addr, PIM_NEXTHOP_LOOKUP_MAX); - if (num_ifindex < 1) { - if (PIM_DEBUG_PIM_NHT) { - char addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<addr?>", addr, addr_str, - sizeof(addr_str)); + if (PIM_DEBUG_PIM_NHT) + pim_inet4_dump("<addr?>", src->u.prefix4, addr_str, + sizeof(addr_str)); + if (!pim_ecmp_nexthop_lookup(pim, &nhop, src, grp, 0)) { + if (PIM_DEBUG_PIM_NHT) zlog_debug( "%s: could not find nexthop ifindex for address %s(%s)", __PRETTY_FUNCTION__, addr_str, pim->vrf->name); - } return -1; } - // If PIM ECMP enable then choose ECMP path. - if (pim->ecmp_enable) { - hash_val = pim_compute_ecmp_hash(src, grp); - mod_val = hash_val % num_ifindex; - if (PIM_DEBUG_PIM_NHT_DETAIL) - zlog_debug("%s: hash_val %u mod_val %u", - __PRETTY_FUNCTION__, hash_val, mod_val); - } - - first_ifindex = nexthop_tab[mod_val].ifindex; - - if (PIM_DEBUG_PIM_NHT) { - char addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<ifaddr?>", addr, addr_str, sizeof(addr_str)); + ifindex = nhop.interface->ifindex; + if (PIM_DEBUG_PIM_NHT) zlog_debug( "%s: found nexthop ifindex=%d (interface %s(%s)) for address %s", - __PRETTY_FUNCTION__, first_ifindex, - ifindex2ifname(first_ifindex, pim->vrf_id), + __PRETTY_FUNCTION__, ifindex, + ifindex2ifname(ifindex, pim->vrf_id), pim->vrf->name, addr_str); - } - vif_index = pim_if_find_vifindex_by_ifindex(pim, first_ifindex); + vif_index = pim_if_find_vifindex_by_ifindex(pim, ifindex); if (vif_index < 0) { if (PIM_DEBUG_PIM_NHT) { - char addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("<addr?>", addr, addr_str, - sizeof(addr_str)); zlog_debug( "%s: low vif_index=%d(%s) < 1 nexthop for address %s", __PRETTY_FUNCTION__, vif_index, pim->vrf->name, diff --git a/pimd/pim_nht.h b/pimd/pim_nht.h index 77e25dcd70..796fbf9731 100644 --- a/pimd/pim_nht.h +++ b/pimd/pim_nht.h @@ -61,13 +61,11 @@ int pim_ecmp_nexthop_search(struct pim_instance *pim, struct pim_nexthop *nexthop, struct prefix *src, struct prefix *grp, int neighbor_needed); int pim_ecmp_nexthop_lookup(struct pim_instance *pim, - struct pim_nexthop *nexthop, struct in_addr addr, - struct prefix *src, struct prefix *grp, - int neighbor_needed); + struct pim_nexthop *nexthop, struct prefix *src, + struct prefix *grp, int neighbor_needed); void pim_sendmsg_zebra_rnh(struct pim_instance *pim, struct zclient *zclient, struct pim_nexthop_cache *pnc, int command); void pim_resolve_upstream_nh(struct pim_instance *pim, struct prefix *nht_p); int pim_ecmp_fib_lookup_if_vif_index(struct pim_instance *pim, - struct in_addr addr, struct prefix *src, - struct prefix *grp); + struct prefix *src, struct prefix *grp); #endif diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 7e053d2aa0..cc39b09043 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -477,10 +477,9 @@ int pim_rp_new(struct pim_instance *pim, const char *rp, &rp_all->group, 1)) return PIM_RP_NO_PATH; } else { - if (pim_nexthop_lookup( + if (!pim_ecmp_nexthop_lookup( pim, &rp_all->rp.source_nexthop, - rp_all->rp.rpf_addr.u.prefix4, 1) - != 0) + &nht_p, &rp_all->group, 1)) return PIM_RP_NO_PATH; } pim_rp_check_interfaces(pim, rp_all); @@ -556,9 +555,8 @@ int pim_rp_new(struct pim_instance *pim, const char *rp, &nht_p, &rp_info->group, 1)) return PIM_RP_NO_PATH; } else { - if (pim_nexthop_lookup(pim, &rp_info->rp.source_nexthop, - rp_info->rp.rpf_addr.u.prefix4, 1) - != 0) + if (!pim_ecmp_nexthop_lookup(pim, &rp_info->rp.source_nexthop, + &nht_p, &rp_info->group, 1)) return PIM_RP_NO_PATH; } @@ -687,9 +685,9 @@ void pim_rp_setup(struct pim_instance *pim) "%s: NHT Local Nexthop not found for RP %s ", __PRETTY_FUNCTION__, buf); } - if (pim_nexthop_lookup( - pim, &rp_info->rp.source_nexthop, - rp_info->rp.rpf_addr.u.prefix4, 1) < 0) + if (!pim_ecmp_nexthop_lookup(pim, + &rp_info->rp.source_nexthop, + &nht_p, &rp_info->group, 1)) if (PIM_DEBUG_PIM_NHT_RP) zlog_debug( "Unable to lookup nexthop for rp specified"); @@ -854,8 +852,9 @@ struct pim_rpf *pim_rp_g(struct pim_instance *pim, struct in_addr group) __PRETTY_FUNCTION__, buf, buf1); } pim_rpf_set_refresh_time(pim); - pim_nexthop_lookup(pim, &rp_info->rp.source_nexthop, - rp_info->rp.rpf_addr.u.prefix4, 1); + pim_ecmp_nexthop_lookup(pim, + &rp_info->rp.source_nexthop, + &nht_p, &rp_info->group, 1); } return (&rp_info->rp); } diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index da14e8b3eb..b02102c8fd 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -203,6 +203,7 @@ enum pim_rpf_result pim_rpf_update(struct pim_instance *pim, struct prefix nht_p; struct pim_nexthop_cache pnc; struct prefix src, grp; + bool neigh_needed = true; saved.source_nexthop = rpf->source_nexthop; saved.rpf_addr = rpf->rpf_addr; @@ -226,23 +227,20 @@ enum pim_rpf_result pim_rpf_update(struct pim_instance *pim, grp.prefixlen = IPV4_MAX_BITLEN; grp.u.prefix4 = up->sg.grp; memset(&pnc, 0, sizeof(struct pim_nexthop_cache)); + + if ((up->sg.src.s_addr == INADDR_ANY && I_am_RP(pim, up->sg.grp)) || + PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) + neigh_needed = FALSE; if (pim_find_or_track_nexthop(pim, &nht_p, up, NULL, &pnc)) { if (pnc.nexthop_num) { - if (!pim_ecmp_nexthop_search( - pim, &pnc, &up->rpf.source_nexthop, &src, - &grp, - !PIM_UPSTREAM_FLAG_TEST_FHR(up->flags) - && !PIM_UPSTREAM_FLAG_TEST_SRC_IGMP( - up->flags))) + if (!pim_ecmp_nexthop_search(pim, &pnc, + &up->rpf.source_nexthop, + &src, &grp, neigh_needed)) return PIM_RPF_FAILURE; } } else { - if (!pim_ecmp_nexthop_lookup( - pim, &rpf->source_nexthop, up->upstream_addr, &src, - &grp, - !PIM_UPSTREAM_FLAG_TEST_FHR(up->flags) - && !PIM_UPSTREAM_FLAG_TEST_SRC_IGMP( - up->flags))) + if (!pim_ecmp_nexthop_lookup(pim, &rpf->source_nexthop, &src, + &grp, neigh_needed)) return PIM_RPF_FAILURE; } diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index a58dfcdd5f..38a29b72af 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -561,7 +561,7 @@ void pim_scan_individual_oil(struct channel_oil *c_oil, int in_vif_index) __PRETTY_FUNCTION__, source_str, group_str); } input_iface_vif_index = pim_ecmp_fib_lookup_if_vif_index( - c_oil->pim, vif_source, &src, &grp); + c_oil->pim, &src, &grp); } if (input_iface_vif_index < 1) { @@ -953,8 +953,8 @@ void igmp_source_forward_start(struct pim_instance *pim, } } else input_iface_vif_index = - pim_ecmp_fib_lookup_if_vif_index( - pim, vif_source, &src, &grp); + pim_ecmp_fib_lookup_if_vif_index(pim, &src, + &grp); if (PIM_DEBUG_ZEBRA) { char buf2[INET_ADDRSTRLEN]; @@ -1153,7 +1153,7 @@ void pim_forward_start(struct pim_ifchannel *ch) /* Register addr with Zebra NHT */ nht_p.family = AF_INET; nht_p.prefixlen = IPV4_MAX_BITLEN; - nht_p.u.prefix4.s_addr = up->upstream_addr.s_addr; + nht_p.u.prefix4 = up->upstream_addr; grp.family = AF_INET; grp.prefixlen = IPV4_MAX_BITLEN; grp.u.prefix4 = up->sg.grp; @@ -1204,8 +1204,8 @@ void pim_forward_start(struct pim_ifchannel *ch) } } else input_iface_vif_index = - pim_ecmp_fib_lookup_if_vif_index( - pim, up->upstream_addr, &src, &grp); + pim_ecmp_fib_lookup_if_vif_index(pim, &src, + &grp); if (input_iface_vif_index < 1) { if (PIM_DEBUG_PIM_TRACE) { diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 5c84219418..8f6e31cfa8 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -986,7 +986,7 @@ int netlink_interface_addr(struct nlmsghdr *h, ns_id_t ns_id, int startup) if (tb[IFA_LABEL]) label = (char *)RTA_DATA(tb[IFA_LABEL]); - if (ifp && label && strcmp(ifp->name, label) == 0) + if (label && strcmp(ifp->name, label) == 0) label = NULL; /* Register interface address to the interface. */ diff --git a/zebra/main.c b/zebra/main.c index c5246999fa..3e44a41707 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -236,15 +236,15 @@ int main(int argc, char **argv) " -z, --socket Set path of zebra socket\n" " -e, --ecmp Specify ECMP to use.\n" " -l, --label_socket Socket to external label manager\n" - " -k, --keep_kernel Don't delete old routes which installed by zebra.\n" + " -k, --keep_kernel Don't delete old routes which were installed by zebra.\n" " -r, --retain When program terminates, retain added route by zebra.\n" #ifdef HAVE_NETLINK - " -n, --vrfwnetns Set VRF with NetNS\n" + " -n, --vrfwnetns Use NetNS as VRF backend\n" " -s, --nl-bufsize Set netlink receive buffer size\n" " --v6-rr-semantics Use v6 RR semantics\n" #endif /* HAVE_NETLINK */ #if defined(HANDLE_ZAPI_FUZZING) - " -c <file> Bypass normal startup use this file for tetsting of zapi" + " -c <file> Bypass normal startup and use this file for testing of zapi" #endif ); @@ -349,13 +349,6 @@ int main(int argc, char **argv) /* For debug purpose. */ /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ -#if defined(HANDLE_ZAPI_FUZZING) - if (fuzzing) { - zserv_read_file(fuzzing); - exit(0); - } -#endif - /* Process the configuration file. Among other configuration * directives we can meet those installing static routes. Such * requests will not be executed immediately, but queued in @@ -391,6 +384,14 @@ int main(int argc, char **argv) /* RNH init */ zebra_rnh_init(); +#if defined(HANDLE_ZAPI_FUZZING) + if (fuzzing) { + zserv_read_file(fuzzing); + exit(0); + } +#endif + + frr_run(zebrad.master); /* Not reached... */ diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c index 60b72298a1..2dd686fd0d 100644 --- a/zebra/zebra_netns_notify.c +++ b/zebra/zebra_netns_notify.c @@ -105,6 +105,7 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name) if (ret != CMD_SUCCESS) { zlog_warn("NS notify : failed to create NS %s", netnspath); ns_map_nsid_with_external(ns_id, false); + vrf_delete(vrf); return; } zlog_info("NS notify : created VRF %s NS %s", name, netnspath); diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 8c23bf34cf..5975c4058b 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -615,7 +615,7 @@ static int zebra_ptm_handle_msg_cb(void *arg, void *in_ctxt) int zebra_ptm_sock_read(struct thread *thread) { - int sock, done = 0; + int sock; int rc; errno = 0; @@ -625,28 +625,24 @@ int zebra_ptm_sock_read(struct thread *thread) return -1; /* PTM communicates in CSV format */ - while (!done) { + do { rc = ptm_lib_process_msg(ptm_hdl, sock, ptm_cb.in_data, ZEBRA_PTM_MAX_SOCKBUF, NULL); - if (rc <= 0) - break; - } + } while (rc > 0); - if (rc <= 0) { - if (((rc == 0) && !errno) - || (errno && (errno != EWOULDBLOCK) && (errno != EAGAIN))) { - zlog_warn("%s routing socket error: %s(%d) bytes %d", - __func__, safe_strerror(errno), errno, rc); - - close(ptm_cb.ptm_sock); - ptm_cb.ptm_sock = -1; - zebra_ptm_reset_status(0); - ptm_cb.t_timer = NULL; - thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, - ptm_cb.reconnect_time, - &ptm_cb.t_timer); - return (-1); - } + if (((rc == 0) && !errno) + || (errno && (errno != EWOULDBLOCK) && (errno != EAGAIN))) { + zlog_warn("%s routing socket error: %s(%d) bytes %d", + __func__, safe_strerror(errno), errno, rc); + + close(ptm_cb.ptm_sock); + ptm_cb.ptm_sock = -1; + zebra_ptm_reset_status(0); + ptm_cb.t_timer = NULL; + thread_add_timer(zebrad.master, zebra_ptm_connect, NULL, + ptm_cb.reconnect_time, + &ptm_cb.t_timer); + return (-1); } ptm_cb.t_read = NULL; diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 55c4f6e916..8a37e1df22 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1651,7 +1651,7 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf, json = json_object_new_object(); /* Show all routes. */ - for (rn = route_top(table); rn; rn = route_next(rn)) { + for (rn = route_top(table); rn; rn = srcdest_route_next(rn)) { dest = rib_dest_from_rnode(rn); RNODE_FOREACH_RE (rn, re) { diff --git a/zebra/zserv.c b/zebra/zserv.c index b08da9cebd..4c90757d70 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -640,7 +640,7 @@ static int zserv_handle_client_close(struct thread *thread) * sock * client's socket file descriptor */ -static void zserv_client_create(int sock) +static struct zserv *zserv_client_create(int sock) { struct zserv *client; int i; @@ -696,6 +696,8 @@ static void zserv_client_create(int sock) /* start pthread */ frr_pthread_run(client->pthread, NULL); + + return client; } /* @@ -1025,20 +1027,10 @@ void zserv_read_file(char *input) struct zserv *client = NULL; struct thread t; - zserv_client_create(-1); - - frr_pthread_stop(client->pthread, NULL); - frr_pthread_destroy(client->pthread); - client->pthread = NULL; - - t.arg = client; - fd = open(input, O_RDONLY | O_NONBLOCK); t.u.fd = fd; - zserv_read(&t); - - close(fd); + zserv_client_create(fd); } #endif |
