From 05b15adcc25c530c20e90ef03412f0ca1c155c03 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 12 Jun 2017 09:53:21 -0700 Subject: [PATCH 01/12] ospfd: ospf bandwidth handling if bandwidth is not set from Zebra use speed as bandwidth for ospf route. Testing Done: Verfied over bond which has aggregated speed of all member interfaces, cost is reflected in ospf route and ip route. Manually changed interface bandwidth which replaces speed as bw, instead uses cli entered value as bw, verifid output of ospf route and ip route. Signed-off-by: Chirag Shah --- ospfd/ospf_interface.c | 7 ++++++- ospfd/ospf_vty.c | 5 +++-- ospfd/ospf_zebra.c | 12 +++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 137df16a05..2c270c5ca2 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -59,7 +59,12 @@ ospf_if_get_output_cost (struct ospf_interface *oi) u_int32_t cost; u_int32_t bw, refbw; - bw = oi->ifp->bandwidth ? oi->ifp->bandwidth : OSPF_DEFAULT_BANDWIDTH; + if (oi->ifp->bandwidth) + bw = oi->ifp->bandwidth; + if (!oi->ifp->bandwidth && oi->ifp->speed) + bw = oi->ifp->speed; + else + bw = OSPF_DEFAULT_BANDWIDTH; refbw = oi->ospf->ref_bandwidth; /* A specifed ip ospf cost overrides a calculated one. */ diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0eb3aa6a8a..7e8c5ce2ce 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3252,6 +3252,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface int is_up; struct ospf_neighbor *nbr; struct route_node *rn; + uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed; /* Is interface up? */ if (use_json) @@ -3264,7 +3265,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex); json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu); - json_object_int_add(json_interface_sub, "bandwidthMbit", ifp->bandwidth); + json_object_int_add(json_interface_sub, "bandwidthMbit", bandwidth); json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags)); } else @@ -3272,7 +3273,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface vty_out (vty, "%s is %s%s", ifp->name, ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s", - ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), + ifp->ifindex, ifp->mtu, bandwidth, if_flag_dump(ifp->flags), VTY_NEWLINE); } diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index abb6db0347..eb6b09c88c 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -188,16 +188,10 @@ ospf_interface_state_up (int command, struct zclient *zclient, zebra_interface_if_set_value (zclient->ibuf, ifp); if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) - zlog_debug ("Zebra: Interface[%s] state update.", ifp->name); + zlog_debug ("Zebra: Interface[%s] state udpate speed change %u -> %u bw change %d -> %d.", + ifp->name, if_tmp.speed, ifp->speed, if_tmp.bandwidth, ifp->bandwidth); - if (if_tmp.bandwidth != ifp->bandwidth) - { - if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) - zlog_debug ("Zebra: Interface[%s] bandwidth change %d -> %d.", - ifp->name, if_tmp.bandwidth, ifp->bandwidth); - - ospf_if_recalculate_output_cost (ifp); - } + ospf_if_recalculate_output_cost (ifp); if (if_tmp.mtu != ifp->mtu) { From 3eb7a8495e6d2304de1bd6c34bb8f83949b2d8ca Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 12 Jun 2017 13:17:28 -0700 Subject: [PATCH 02/12] ospfd: ospf bandwidth handling Handle proper indent and insert missing not statement. Signed-off-by: Chirag Shah --- ospfd/ospf_interface.c | 4 +--- ospfd/ospf_zebra.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 2c270c5ca2..85f294966c 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -59,12 +59,10 @@ ospf_if_get_output_cost (struct ospf_interface *oi) u_int32_t cost; u_int32_t bw, refbw; - if (oi->ifp->bandwidth) - bw = oi->ifp->bandwidth; if (!oi->ifp->bandwidth && oi->ifp->speed) bw = oi->ifp->speed; else - bw = OSPF_DEFAULT_BANDWIDTH; + bw = oi->ifp->bandwidth ? oi->ifp->bandwidth : OSPF_DEFAULT_BANDWIDTH; refbw = oi->ospf->ref_bandwidth; /* A specifed ip ospf cost overrides a calculated one. */ diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index eb6b09c88c..d0747e1ad0 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -189,7 +189,7 @@ ospf_interface_state_up (int command, struct zclient *zclient, if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) zlog_debug ("Zebra: Interface[%s] state udpate speed change %u -> %u bw change %d -> %d.", - ifp->name, if_tmp.speed, ifp->speed, if_tmp.bandwidth, ifp->bandwidth); + ifp->name, if_tmp.speed, ifp->speed, if_tmp.bandwidth, ifp->bandwidth); ospf_if_recalculate_output_cost (ifp); From 0e3451e5cf761d877f5b99f8ac8acad0236dd4ab Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 13 Jun 2017 10:32:24 -0300 Subject: [PATCH 03/12] ldpd: fix issues with dual-stack adjacencies Handling configuration changes from single-stack mode to dual-stack mode (and vice-versa) is tricky. This patch attempts to solve all issues that might happen on such circumstances. Signed-off-by: Renato Westphal --- ldpd/adjacency.c | 22 ++++++---------------- ldpd/hello.c | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index 3ec57f1589..89314aa2c3 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -109,17 +109,19 @@ adj_new(struct in_addr lsr_id, struct hello_source *source, return (adj); } -static void -adj_del_single(struct adj *adj) +void +adj_del(struct adj *adj, uint32_t notif_status) { + struct nbr *nbr = adj->nbr; + log_debug("%s: lsr-id %s, %s (%s)", __func__, inet_ntoa(adj->lsr_id), log_hello_src(&adj->source), af_name(adj_get_af(adj))); adj_stop_itimer(adj); RB_REMOVE(global_adj_head, &global.adj_tree, adj); - if (adj->nbr) - RB_REMOVE(nbr_adj_head, &adj->nbr->adj_tree, adj); + if (nbr) + RB_REMOVE(nbr_adj_head, &nbr->adj_tree, adj); switch (adj->source.type) { case HELLO_LINK: RB_REMOVE(ia_adj_head, &adj->source.link.ia->adj_tree, adj); @@ -130,15 +132,6 @@ adj_del_single(struct adj *adj) } free(adj); -} - -void -adj_del(struct adj *adj, uint32_t notif_status) -{ - struct nbr *nbr = adj->nbr; - struct adj *atmp; - - adj_del_single(adj); /* * If the neighbor still exists but none of its remaining @@ -146,8 +139,6 @@ adj_del(struct adj *adj, uint32_t notif_status) * then delete it. */ if (nbr && nbr_adj_count(nbr, nbr->af) == 0) { - RB_FOREACH_SAFE(adj, nbr_adj_head, &nbr->adj_tree, atmp) - adj_del_single(adj); session_shutdown(nbr, notif_status, 0, 0); nbr_del(nbr); } @@ -194,7 +185,6 @@ adj_itimer(struct thread *thread) tnbr_del(leconf, adj->source.target); return (0); } - adj->source.target->adj = NULL; } adj_del(adj, S_HOLDTIME_EXP); diff --git a/ldpd/hello.c b/ldpd/hello.c index dd67f68f70..d17e80008e 100644 --- a/ldpd/hello.c +++ b/ldpd/hello.c @@ -214,6 +214,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af, __func__, inet_ntoa(lsr_id)); return; } + ds_tlv = (tlvs_rcvd & F_HELLO_TLV_RCVD_DS) ? 1 : 0; /* implicit transport address */ if (!(tlvs_rcvd & F_HELLO_TLV_RCVD_ADDR)) @@ -291,11 +292,21 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af, source.link.src_addr = *src; } + debug_hello_recv("%s lsr-id %s transport-address %s holdtime %u%s", + log_hello_src(&source), inet_ntoa(lsr_id), log_addr(af, &trans_addr), + holdtime, (ds_tlv) ? " (dual stack TLV present)" : ""); + adj = adj_find(lsr_id, &source); + if (adj && adj->ds_tlv != ds_tlv) { + /* + * Transient condition, ignore packet and wait until adjacency + * times out. + */ + return; + } nbr = nbr_find_ldpid(lsr_id.s_addr); /* check dual-stack tlv */ - ds_tlv = (tlvs_rcvd & F_HELLO_TLV_RCVD_DS) ? 1 : 0; if (ds_tlv && trans_pref != leconf->trans_pref) { /* * RFC 7552 - Section 6.1.1: @@ -420,10 +431,6 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af, else adj_stop_itimer(adj); - debug_hello_recv("%s lsr-id %s transport-address %s holdtime %u%s", - log_hello_src(&source), inet_ntoa(lsr_id), log_addr(af, &trans_addr), - holdtime, (ds_tlv) ? " (dual stack TLV present)" : ""); - if (nbr && nbr->state == NBR_STA_PRESENT && !nbr_pending_idtimer(nbr) && nbr_session_active_role(nbr) && !nbr_pending_connect(nbr)) nbr_establish_connection(nbr); From 2664233e71d9f24cca30f065a76bfc2b455015de Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Wed, 14 Jun 2017 09:23:36 +0200 Subject: [PATCH 04/12] zebra: pass srcdest information also when creating blackhole routes Signed-off-by: Christian Franke --- zebra/zebra_vty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 1708138d83..9d7c763c46 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2423,10 +2423,10 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, return CMD_WARNING; } if (add_cmd) - static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, NULL, NULL, ifindex, ifname, + static_add_route (AFI_IP6, SAFI_UNICAST, type, &p, src_p, NULL, ifindex, ifname, ZEBRA_FLAG_BLACKHOLE, tag, distance, zvrf, &snh_label); else - static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, NULL, NULL, ifindex, tag, + static_delete_route (AFI_IP6, SAFI_UNICAST, type, &p, src_p, NULL, ifindex, tag, distance, zvrf, &snh_label); return CMD_SUCCESS; } From 59b28c452343c7ef29c15b77bbb4c45899c73773 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Wed, 14 Jun 2017 09:23:40 +0200 Subject: [PATCH 05/12] zebra: fix ipv6 route command description strings Signed-off-by: Christian Franke --- zebra/zebra_vty.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 9d7c763c46..a8bee3cf50 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2510,7 +2510,6 @@ DEFUN (ipv6_route, "IPv6 gateway address\n" "IPv6 gateway interface name\n" "Null interface\n" - "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" @@ -2559,7 +2558,6 @@ DEFUN (ipv6_route_flags, "IPv6 gateway interface name\n" "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n" - "Silently discard pkts when matched\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" From 6196c77a4f4facc2f6df34cdf2ce02f3d5f5083c Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 14 Jun 2017 14:06:01 +0000 Subject: [PATCH 06/12] zebra: fix divide-by-zero x % 0 = FPE Signed-off-by: Quentin Young --- zebra/irdp_interface.c | 31 +++++++++++-------------------- zebra/irdp_main.c | 3 ++- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index 5cabe7e62f..6ea14b3058 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -476,18 +476,14 @@ DEFUN (ip_irdp_minadvertinterval, zi=ifp->info; irdp=&zi->irdp; - if( (unsigned) atoi(argv[idx_number]->arg) <= irdp->MaxAdvertInterval) { + if((unsigned) atoi(argv[idx_number]->arg) < irdp->MaxAdvertInterval) { irdp->MinAdvertInterval = atoi(argv[idx_number]->arg); - return CMD_SUCCESS; } - - vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s", - VTY_NEWLINE); - - vty_out (vty, "Please correct!%s", - VTY_NEWLINE); - return CMD_WARNING; + else { + vty_out (vty, "%% MinAdvertInterval must be less than MaxAdvertInterval"); + return CMD_WARNING; + } } DEFUN (ip_irdp_maxadvertinterval, @@ -506,19 +502,14 @@ DEFUN (ip_irdp_maxadvertinterval, zi=ifp->info; irdp=&zi->irdp; - - if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[idx_number]->arg) ) { - irdp->MaxAdvertInterval = atoi(argv[idx_number]->arg); - + if(irdp->MinAdvertInterval < (unsigned) atoi(argv[idx_number]->arg)) { + irdp->MaxAdvertInterval = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } - - vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s", - VTY_NEWLINE); - - vty_out (vty, "Please correct!%s", - VTY_NEWLINE); - return CMD_WARNING; + else { + vty_out (vty, "%% MaxAdvertInterval must be greater than MinAdvertInterval"); + return CMD_WARNING; + } } /* DEFUN needs to be fixed for negative ranages... diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index 7fa4ad4cbe..8f1647c9db 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -234,7 +234,8 @@ int irdp_send_thread(struct thread *t_advert) } tmp = irdp->MaxAdvertInterval-irdp->MinAdvertInterval; - timer = (random () % tmp ) + 1; + assert (tmp > 0); + timer = (random () % tmp) + 1; timer = irdp->MinAdvertInterval + timer; if(irdp->irdp_sent < MAX_INITIAL_ADVERTISEMENTS && From 87c64b029ddaf72f13173b96a54ab7c8536c98f8 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Wed, 14 Jun 2017 13:30:08 -0700 Subject: [PATCH 07/12] ospfd: correct typo in zebra trace added comment around which bw value used. Signed-off-by: Chirag Shah --- ospfd/ospf_interface.c | 3 +++ ospfd/ospf_zebra.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 85f294966c..0075506ccd 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -59,6 +59,9 @@ ospf_if_get_output_cost (struct ospf_interface *oi) u_int32_t cost; u_int32_t bw, refbw; + /* ifp speed and bw can be 0 in some platforms, use ospf default bw + if bw is configured under interface it would be used. + */ if (!oi->ifp->bandwidth && oi->ifp->speed) bw = oi->ifp->speed; else diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index d0747e1ad0..d2dd0cf367 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -188,7 +188,7 @@ ospf_interface_state_up (int command, struct zclient *zclient, zebra_interface_if_set_value (zclient->ibuf, ifp); if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) - zlog_debug ("Zebra: Interface[%s] state udpate speed change %u -> %u bw change %d -> %d.", + zlog_debug ("Zebra: Interface[%s] state update speed %u -> %u, bw %d -> %d", ifp->name, if_tmp.speed, ifp->speed, if_tmp.bandwidth, ifp->bandwidth); ospf_if_recalculate_output_cost (ifp); From 11e2897282839b66f7566b056c14b2558d2df354 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 16 Jun 2017 16:18:54 +0000 Subject: [PATCH 08/12] zebra: more dbzing Revert to the previous <= restrictions, improve error messages, fix the divide by zero. Signed-off-by: Quentin Young --- zebra/irdp_interface.c | 10 ++++++---- zebra/irdp_main.c | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c index 6ea14b3058..407738d80f 100644 --- a/zebra/irdp_interface.c +++ b/zebra/irdp_interface.c @@ -476,12 +476,13 @@ DEFUN (ip_irdp_minadvertinterval, zi=ifp->info; irdp=&zi->irdp; - if((unsigned) atoi(argv[idx_number]->arg) < irdp->MaxAdvertInterval) { + if((unsigned) atoi(argv[idx_number]->arg) <= irdp->MaxAdvertInterval) { irdp->MinAdvertInterval = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } else { - vty_out (vty, "%% MinAdvertInterval must be less than MaxAdvertInterval"); + vty_out (vty, "%% MinAdvertInterval must be less than or equal to " + "MaxAdvertInterval%s", VTY_NEWLINE); return CMD_WARNING; } } @@ -502,12 +503,13 @@ DEFUN (ip_irdp_maxadvertinterval, zi=ifp->info; irdp=&zi->irdp; - if(irdp->MinAdvertInterval < (unsigned) atoi(argv[idx_number]->arg)) { + if(irdp->MinAdvertInterval <= (unsigned) atoi(argv[idx_number]->arg)) { irdp->MaxAdvertInterval = atoi(argv[idx_number]->arg); return CMD_SUCCESS; } else { - vty_out (vty, "%% MaxAdvertInterval must be greater than MinAdvertInterval"); + vty_out (vty, "%% MaxAdvertInterval must be greater than or equal to " + "MinAdvertInterval%s", VTY_NEWLINE); return CMD_WARNING; } } diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c index 8f1647c9db..6965dca3e4 100644 --- a/zebra/irdp_main.c +++ b/zebra/irdp_main.c @@ -234,8 +234,7 @@ int irdp_send_thread(struct thread *t_advert) } tmp = irdp->MaxAdvertInterval-irdp->MinAdvertInterval; - assert (tmp > 0); - timer = (random () % tmp) + 1; + timer = random () % (tmp + 1); timer = irdp->MinAdvertInterval + timer; if(irdp->irdp_sent < MAX_INITIAL_ADVERTISEMENTS && From b59fee54db24d8d56ab87c9ea08bfa7055aeed74 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 20 Jun 2017 22:46:41 +0200 Subject: [PATCH 09/12] isisd: fix formatting in metrics when showing database --- isisd/isis_lsp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index f633a8fb78..f7ed23aa30 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -915,7 +915,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.is_neighs, lnode, is_neigh)) { lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0); - vty_out (vty, " Metric : %-8d IS : %s%s", + vty_out (vty, " Metric : %-8" PRIu8 " IS : %s%s", is_neigh->metrics.metric_default, LSPid, VTY_NEWLINE); } @@ -928,7 +928,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) sizeof (ipv4_reach_prefix)); memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), sizeof (ipv4_reach_mask)); - vty_out (vty, " Metric : %-8d IPv4-Internal : %s %s%s", + vty_out (vty, " Metric : %-8" PRIu8 " IPv4-Internal : %s %s%s", ipv4_reach->metrics.metric_default, ipv4_reach_prefix, ipv4_reach_mask, VTY_NEWLINE); } @@ -942,7 +942,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) sizeof (ipv4_reach_prefix)); memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), sizeof (ipv4_reach_mask)); - vty_out (vty, " Metric : %-8d IPv4-External : %s %s%s", + vty_out (vty, " Metric : %-8" PRIu8 " IPv4-External : %s %s%s", ipv4_reach->metrics.metric_default, ipv4_reach_prefix, ipv4_reach_mask, VTY_NEWLINE); } @@ -957,11 +957,11 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) inet_ntop (AF_INET6, &in6, (char *)buff, BUFSIZ); if ((ipv6_reach->control_info & CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL) - vty_out (vty, " Metric : %-8d IPv6-Internal : %s/%d%s", + vty_out (vty, " Metric : %-8" PRIu32 " IPv6-Internal : %s/%d%s", ntohl (ipv6_reach->metric), buff, ipv6_reach->prefix_len, VTY_NEWLINE); else - vty_out (vty, " Metric : %-8d IPv6-External : %s/%d%s", + vty_out (vty, " Metric : %-8" PRIu32 " IPv6-External : %s/%d%s", ntohl (ipv6_reach->metric), buff, ipv6_reach->prefix_len, VTY_NEWLINE); } @@ -971,7 +971,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.te_is_neighs, lnode, te_is_neigh)) { lspid_print (te_is_neigh->neigh_id, LSPid, dynhost, 0); - vty_out (vty, " Metric : %-8d IS-Extended : %s%s", + vty_out (vty, " Metric : %-8u IS-Extended : %s%s", GET_TE_METRIC(te_is_neigh), LSPid, VTY_NEWLINE); if (IS_MPLS_TE(isisMplsTE)) mpls_te_print_detail(vty, te_is_neigh); @@ -983,7 +983,7 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) te_ipv4_reach)) { /* FIXME: There should be better way to output this stuff. */ - vty_out (vty, " Metric : %-8d IPv4-Extended : %s/%d%s", + vty_out (vty, " Metric : %-8" PRIu32 " IPv4-Extended : %s/%d%s", ntohl (te_ipv4_reach->te_metric), inet_ntoa (newprefix2inaddr (&te_ipv4_reach->prefix_start, te_ipv4_reach->control)), From 113b1946e39ea0a1e61335b56ff8cafb94934835 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 20 Jun 2017 22:47:54 +0200 Subject: [PATCH 10/12] isisd: adjust redist functionality to current zapi --- isisd/isis_redist.c | 41 ++++++++++++++++++++++++++++------------- isisd/isis_zebra.c | 26 +++++++++++++++++++++----- isisd/isis_zebra.h | 4 ++-- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index bdf90aaa1e..abc4003fe1 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -55,6 +55,18 @@ redist_protocol(int family) return 0; } +static afi_t +afi_for_redist_protocol(int protocol) +{ + if (protocol == 0) + return AFI_IP; + if (protocol == 1) + return AFI_IP6; + + assert(!"Unknown redist protocol!"); + return AFI_IP; +} + static int is_default(struct prefix *p) { @@ -387,7 +399,7 @@ isis_redist_update_zebra_subscriptions(struct isis *isis) int level; int protocol; - char do_subscribe[ZEBRA_ROUTE_MAX + 1]; + char do_subscribe[REDIST_PROTOCOL_COUNT][ZEBRA_ROUTE_MAX + 1]; memset(do_subscribe, 0, sizeof(do_subscribe)); @@ -396,20 +408,23 @@ isis_redist_update_zebra_subscriptions(struct isis *isis) for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++) for (level = 0; level < ISIS_LEVELS; level++) if (area->redist_settings[protocol][type][level].redist) - do_subscribe[type] = 1; + do_subscribe[protocol][type] = 1; - for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++) - { - /* This field is actually controlling transmission of the IS-IS - * routes to Zebra and has nothing to do with redistribution, - * so skip it. */ - if (type == ZEBRA_ROUTE_ISIS) - continue; + for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++) + for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++) + { + /* This field is actually controlling transmission of the IS-IS + * routes to Zebra and has nothing to do with redistribution, + * so skip it. */ + if (type == ZEBRA_ROUTE_ISIS) + continue; - if (do_subscribe[type]) - isis_zebra_redistribute_set(type); - else - isis_zebra_redistribute_unset(type); + afi_t afi = afi_for_redist_protocol(protocol); + + if (do_subscribe[protocol][type]) + isis_zebra_redistribute_set(afi, type); + else + isis_zebra_redistribute_unset(afi, type); } } diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index e7bd99c3e8..79bc752e5f 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -602,6 +602,7 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient, struct stream *stream; struct zapi_ipv6 api; struct prefix_ipv6 p; + struct prefix src_p; struct prefix *p_generic = (struct prefix*)&p; struct in6_addr nexthop; unsigned long ifindex __attribute__((unused)); @@ -613,6 +614,7 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient, ifindex = 0; api.type = stream_getc(stream); + api.instance = stream_getw(stream); api.flags = stream_getl(stream); api.message = stream_getc(stream); @@ -620,6 +622,18 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient, p.prefixlen = stream_getc(stream); stream_get(&p.prefix, stream, PSIZE(p.prefixlen)); + memset(&src_p, 0, sizeof (struct prefix)); + src_p.family = AF_INET6; + if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) + { + src_p.prefixlen = stream_getc(stream); + stream_get(&src_p.u.prefix6, stream, PSIZE (src_p.prefixlen)); + } + + if (src_p.prefixlen) + /* we completely ignore srcdest routes for now. */ + return 0; + if (CHECK_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP)) { api.nexthop_num = stream_getc(stream); /* this is always 1 */ @@ -634,6 +648,8 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient, api.distance = stream_getc(stream); if (CHECK_FLAG(api.message, ZAPI_MESSAGE_METRIC)) api.metric = stream_getl(stream); + if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG)) + api.tag = stream_getl(stream); /* * Avoid advertising a false default reachability. (A default @@ -644,7 +660,7 @@ isis_zebra_read_ipv6 (int command, struct zclient *zclient, if (p.prefixlen == 0 && api.type == ZEBRA_ROUTE_ISIS) command = ZEBRA_IPV6_ROUTE_DELETE; - if (command == ZEBRA_IPV6_ROUTE_ADD) + if (command == ZEBRA_REDISTRIBUTE_IPV6_ADD) isis_redist_add(api.type, p_generic, api.distance, api.metric); else isis_redist_delete(api.type, p_generic); @@ -659,21 +675,21 @@ isis_distribute_list_update (int routetype) } void -isis_zebra_redistribute_set(int type) +isis_zebra_redistribute_set(afi_t afi, int type) { if (type == DEFAULT_ROUTE) zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient, VRF_DEFAULT); else - zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT); + zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, 0, VRF_DEFAULT); } void -isis_zebra_redistribute_unset(int type) +isis_zebra_redistribute_unset(afi_t afi, int type) { if (type == DEFAULT_ROUTE) zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient, VRF_DEFAULT); else - zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT); + zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, 0, VRF_DEFAULT); } static void diff --git a/isisd/isis_zebra.h b/isisd/isis_zebra.h index 217e3d48cd..69759a627c 100644 --- a/isisd/isis_zebra.h +++ b/isisd/isis_zebra.h @@ -28,7 +28,7 @@ void isis_zebra_init(struct thread_master *); void isis_zebra_route_update (struct prefix *prefix, struct isis_route_info *route_info); int isis_distribute_list_update (int routetype); -void isis_zebra_redistribute_set(int type); -void isis_zebra_redistribute_unset(int type); +void isis_zebra_redistribute_set(afi_t afi, int type); +void isis_zebra_redistribute_unset(afi_t afi, int type); #endif /* _ZEBRA_ISIS_ZEBRA_H */ From e4220cb4f32958e40968790ce7b063d39b27ba99 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 20 Jun 2017 22:48:36 +0200 Subject: [PATCH 11/12] isisd: fix memtype counting issue --- isisd/isis_redist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index abc4003fe1..5520ad15ce 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -189,7 +189,7 @@ isis_redist_uninstall(struct isis_area *area, int level, struct prefix *p) if (!er_node->info) return; - XFREE(MTYPE_ISIS, er_node->info); + XFREE(MTYPE_ISIS_EXT_INFO, er_node->info); route_unlock_node(er_node); lsp_regenerate_schedule(area, level, 0); } @@ -372,7 +372,7 @@ isis_redist_delete(int type, struct prefix *p) isis_redist_uninstall(area, level, p); } - XFREE(MTYPE_ISIS, ei_node->info); + XFREE(MTYPE_ISIS_EXT_INFO, ei_node->info); route_unlock_node(ei_node); } @@ -520,7 +520,7 @@ isis_redist_unset(struct isis_area *area, int level, continue; } - XFREE(MTYPE_ISIS, rn->info); + XFREE(MTYPE_ISIS_EXT_INFO, rn->info); route_unlock_node(rn); } From cd35442a89aed9bee3c98153c0d37c7c31b3a134 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 20 Jun 2017 22:49:37 +0200 Subject: [PATCH 12/12] isisd: fix to adhere to new cli api --- isisd/isis_redist.c | 56 +++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 5520ad15ce..1c9fbb89dd 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -555,7 +555,7 @@ isis_redist_area_finish(struct isis_area *area) DEFUN (isis_redistribute, isis_redistribute_cmd, - "redistribute " FRR_REDIST_STR_ISISD " []", + "redistribute " FRR_REDIST_STR_ISISD " []", REDIST_STR "Redistribute IPv4 routes\n" "Redistribute IPv6 routes\n" @@ -604,19 +604,26 @@ DEFUN (isis_redistribute, return CMD_WARNING; } - if (strmatch(argv[idx_metric_rmap]->text, "metric")) - { - char *endp; - metric = strtoul(argv[idx_metric_rmap + 1]->arg, &endp, 10); - routemap = NULL; + metric = 0xffffffff; + routemap = NULL; - if (argv[idx_metric_rmap]->arg[0] == '\0' || *endp != '\0') - return CMD_WARNING; - } - else + if (argc > idx_metric_rmap + 1) { - routemap = argv[idx_metric_rmap + 1]->arg; - metric = 0xffffffff; + if (argv[idx_metric_rmap + 1]->arg[0] == '\0') + return CMD_WARNING; + + if (strmatch(argv[idx_metric_rmap]->text, "metric")) + { + char *endp; + metric = strtoul(argv[idx_metric_rmap + 1]->arg, &endp, 10); + + if (*endp != '\0') + return CMD_WARNING; + } + else + { + routemap = argv[idx_metric_rmap + 1]->arg; + } } isis_redist_set(area, level, family, type, metric, routemap, 0); @@ -625,7 +632,7 @@ DEFUN (isis_redistribute, DEFUN (no_isis_redistribute, no_isis_redistribute_cmd, - "no redistribute " FRR_REDIST_STR_ISISD " ", + "no redistribute " FRR_REDIST_STR_ISISD " ", NO_STR REDIST_STR "Redistribute IPv4 routes\n" @@ -663,7 +670,7 @@ DEFUN (no_isis_redistribute, DEFUN (isis_default_originate, isis_default_originate_cmd, - "default-information originate []", + "default-information originate [always] []", "Control distribution of default information\n" "Distribute a default route\n" "Distribute default route for IPv4\n" @@ -678,6 +685,7 @@ DEFUN (isis_default_originate, { int idx_afi = 2; int idx_level = 3; + int idx_always = 4; int idx_metric_rmap = 4; VTY_DECLVAR_CONTEXT (isis_area, area); int family; @@ -698,15 +706,19 @@ DEFUN (isis_default_originate, return CMD_WARNING; } - if (argc > 4) - { - if (strmatch (argv[idx_metric_rmap]->text, "always")) + if (argc > idx_always && strmatch (argv[idx_always]->text, "always")) + { originate_type = DEFAULT_ORIGINATE_ALWAYS; - else if (strmatch(argv[idx_metric_rmap]->text, "metric")) - metric = strtoul(argv[idx_metric_rmap + 1]->arg, NULL, 10); - else - routemap = argv[idx_metric_rmap + 1]->arg; - } + idx_metric_rmap++; + } + + if (argc > idx_metric_rmap) + { + if (strmatch(argv[idx_metric_rmap]->text, "metric")) + metric = strtoul(argv[idx_metric_rmap + 1]->arg, NULL, 10); + else + routemap = argv[idx_metric_rmap + 1]->arg; + } if (family == AF_INET6 && originate_type != DEFAULT_ORIGINATE_ALWAYS) {