summaryrefslogtreecommitdiff
path: root/zebra/zebra_mpls.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-03-27 15:21:15 -0400
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-03-27 15:21:15 -0400
commit42732e05a9a97a18f496eb559a77062a1b4b420e (patch)
tree03c8b87c2b26cb43b7b241f5ab0db6583c4b5a30 /zebra/zebra_mpls.c
parent056d8355967b372566a98432f07e4cff66ab17b0 (diff)
parent2d6e6d36d7e847b997f29097268dc529bd154d10 (diff)
Merge branch 'master' into stylechecker
Diffstat (limited to 'zebra/zebra_mpls.c')
-rw-r--r--zebra/zebra_mpls.c90
1 files changed, 50 insertions, 40 deletions
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index ec80081a46..8375d45d2f 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -182,7 +182,7 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label,
* the label advertised by the recursive nexthop (plus we don't have the
* logic yet to push multiple labels).
*/
- for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) {
+ for (nexthop = re->ng.nexthop; nexthop; nexthop = nexthop->next) {
/* Skip inactive and recursive entries. */
if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
continue;
@@ -411,8 +411,8 @@ static int fec_change_update_lsp(struct zebra_vrf *zvrf, zebra_fec_t *fec,
afi_t afi;
/* Uninstall label forwarding entry, if previously installed. */
- if (old_label != MPLS_INVALID_LABEL &&
- old_label != MPLS_LABEL_IMPLICIT_NULL)
+ if (old_label != MPLS_INVALID_LABEL
+ && old_label != MPLS_LABEL_IMPLICIT_NULL)
lsp_uninstall(zvrf, old_label);
/* Install label forwarding entry corr. to new label, if needed. */
@@ -455,8 +455,7 @@ static int fec_send(zebra_fec_t *fec, struct zserv *client)
rn = fec->rn;
/* Get output stream. */
- s = client->obuf;
- stream_reset(s);
+ s = stream_new(ZEBRA_MAX_PACKET_SIZ);
zclient_create_header(s, ZEBRA_FEC_UPDATE, VRF_DEFAULT);
@@ -464,7 +463,7 @@ static int fec_send(zebra_fec_t *fec, struct zserv *client)
stream_put_prefix(s, &rn->p);
stream_putl(s, fec->label);
stream_putw_at(s, 0, stream_get_endp(s));
- return zebra_server_send_message(client);
+ return zebra_server_send_message(client, s);
}
/*
@@ -637,7 +636,7 @@ static int nhlfe_nexthop_active_ipv4(zebra_nhlfe_t *nhlfe,
|| !CHECK_FLAG(match->flags, ZEBRA_FLAG_SELECTED))
continue;
- for (match_nh = match->nexthop; match_nh;
+ for (match_nh = match->ng.nexthop; match_nh;
match_nh = match_nh->next) {
if (match->type == ZEBRA_ROUTE_CONNECT
|| nexthop->ifindex == match_nh->ifindex) {
@@ -688,10 +687,10 @@ static int nhlfe_nexthop_active_ipv6(zebra_nhlfe_t *nhlfe,
break;
}
- if (!match || !match->nexthop)
+ if (!match || !match->ng.nexthop)
return 0;
- nexthop->ifindex = match->nexthop->ifindex;
+ nexthop->ifindex = match->ng.nexthop->ifindex;
return 1;
}
@@ -937,16 +936,16 @@ static wq_item_status lsp_process(struct work_queue *wq, void *data)
* Any NHLFE that was installed but is not
* selected now needs to have its flags updated.
*/
- for (nhlfe = lsp->nhlfe_list;
- nhlfe; nhlfe = nhlfe->next) {
+ for (nhlfe = lsp->nhlfe_list; nhlfe;
+ nhlfe = nhlfe->next) {
nexthop = nhlfe->nexthop;
if (!nexthop)
continue;
if (CHECK_FLAG(nhlfe->flags,
- NHLFE_FLAG_INSTALLED) &&
- !CHECK_FLAG(nhlfe->flags,
- NHLFE_FLAG_SELECTED)) {
+ NHLFE_FLAG_INSTALLED)
+ && !CHECK_FLAG(nhlfe->flags,
+ NHLFE_FLAG_SELECTED)) {
UNSET_FLAG(nhlfe->flags,
NHLFE_FLAG_INSTALLED);
UNSET_FLAG(nexthop->flags,
@@ -1398,9 +1397,9 @@ static void nhlfe_print(zebra_nhlfe_t *nhlfe, struct vty *vty)
default:
break;
}
- vty_out(vty, "%s", CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED)
- ? " (installed)"
- : "");
+ vty_out(vty, "%s",
+ CHECK_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED) ? " (installed)"
+ : "");
vty_out(vty, "\n");
}
@@ -1688,8 +1687,7 @@ static int mpls_processq_init(struct zebra_t *zebra)
/* Public functions */
-void kernel_lsp_pass_fail(zebra_lsp_t *lsp,
- enum southbound_results res)
+void kernel_lsp_pass_fail(zebra_lsp_t *lsp, enum southbound_results res)
{
struct nexthop *nexthop;
zebra_nhlfe_t *nhlfe;
@@ -2256,6 +2254,19 @@ void zebra_mpls_print_fec(struct vty *vty, struct zebra_vrf *zvrf,
fec_print(rn->info, vty);
}
+static bool mpls_ftn_update_nexthop(int add, struct nexthop *nexthop,
+ enum lsp_types_t type, mpls_label_t label)
+{
+ if (add && nexthop->nh_label_type == ZEBRA_LSP_NONE)
+ nexthop_add_labels(nexthop, type, 1, &label);
+ else if (!add && nexthop->nh_label_type == type)
+ nexthop_del_labels(nexthop);
+ else
+ return false;
+
+ return true;
+}
+
/*
* Install/uninstall a FEC-To-NHLFE (FTN) binding.
*/
@@ -2268,6 +2279,7 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
struct route_node *rn;
struct route_entry *re;
struct nexthop *nexthop;
+ bool found;
/* Lookup table. */
table = zebra_vrf_table(family2afi(prefix->family), SAFI_UNICAST,
@@ -2287,7 +2299,8 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
if (re == NULL)
return -1;
- for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) {
+ found = false;
+ for (nexthop = re->ng.nexthop; nexthop; nexthop = nexthop->next) {
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX:
@@ -2299,7 +2312,11 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX
&& nexthop->ifindex != ifindex)
continue;
- goto found;
+ if (!mpls_ftn_update_nexthop(add, nexthop, type,
+ out_label))
+ return 0;
+ found = true;
+ break;
case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX:
if (gtype != NEXTHOP_TYPE_IPV6
@@ -2310,21 +2327,18 @@ int mpls_ftn_update(int add, struct zebra_vrf *zvrf, enum lsp_types_t type,
if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX
&& nexthop->ifindex != ifindex)
continue;
- goto found;
+ if (!mpls_ftn_update_nexthop(add, nexthop, type,
+ out_label))
+ return 0;
+ found = true;
+ break;
default:
break;
}
}
- /* nexthop not found */
- return -1;
-found:
- if (add && nexthop->nh_label_type == ZEBRA_LSP_NONE)
- nexthop_add_labels(nexthop, type, 1, &out_label);
- else if (!add && nexthop->nh_label_type == type)
- nexthop_del_labels(nexthop);
- else
- return 0;
+ if (!found)
+ return -1;
SET_FLAG(re->status, ROUTE_ENTRY_CHANGED);
SET_FLAG(re->status, ROUTE_ENTRY_LABELS_CHANGED);
@@ -2505,7 +2519,7 @@ void mpls_ldp_ftn_uninstall_all(struct zebra_vrf *zvrf, int afi)
for (rn = route_top(table); rn; rn = route_next(rn)) {
update = 0;
RNODE_FOREACH_RE (rn, re) {
- for (nexthop = re->nexthop; nexthop;
+ for (nexthop = re->ng.nexthop; nexthop;
nexthop = nexthop->next) {
if (nexthop->nh_label_type != ZEBRA_LSP_LDP)
continue;
@@ -2793,8 +2807,7 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
nexthop = nhlfe->nexthop;
switch (nexthop->type) {
- case NEXTHOP_TYPE_IFINDEX:
- {
+ case NEXTHOP_TYPE_IFINDEX: {
struct interface *ifp;
ifp = if_lookup_by_index(
@@ -2955,12 +2968,9 @@ void zebra_mpls_init_tables(struct zebra_vrf *zvrf)
{
if (!zvrf)
return;
- zvrf->slsp_table = hash_create(label_hash,
- label_cmp,
- "ZEBRA SLSP table");
- zvrf->lsp_table = hash_create(label_hash,
- label_cmp,
- "ZEBRA LSP table");
+ zvrf->slsp_table =
+ hash_create(label_hash, label_cmp, "ZEBRA SLSP table");
+ zvrf->lsp_table = hash_create(label_hash, label_cmp, "ZEBRA LSP table");
zvrf->fec_table[AFI_IP] = route_table_init();
zvrf->fec_table[AFI_IP6] = route_table_init();
zvrf->mpls_flags = 0;