]> git.proxmox.com Git - mirror_frr.git/blobdiff - nhrpd/nhrp_route.c
*: auto-convert to SPDX License IDs
[mirror_frr.git] / nhrpd / nhrp_route.c
index ee8db277d9a9a69b24966831af3b53ebf6da5605..bf7ba5f650bb8d93f3e0cb2b1010af436e5c2030 100644 (file)
@@ -1,10 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* NHRP routing functions
  * Copyright (c) 2014-2015 Timo Teräs
- *
- * This file is free software: you may copy, redistribute and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -139,7 +135,17 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
                /* Regular route, so these are announced
                 * to other routing daemons */
                break;
-       default:
+       case NHRP_CACHE_INVALID:
+       case NHRP_CACHE_INCOMPLETE:
+               /*
+                * I cannot believe that we want to set a FIB_OVERRIDE
+                * for invalid state or incomplete.  But this matches
+                * the original code.  Someone will probably notice
+                * the problem eventually
+                */
+       case NHRP_CACHE_CACHED:
+       case NHRP_CACHE_LOCAL:
+       case NHRP_CACHE_NUM_TYPES:
                SET_FLAG(api.flags, ZEBRA_FLAG_FIB_OVERRIDE);
                break;
        }
@@ -366,21 +372,25 @@ static void nhrp_zebra_connected(struct zclient *zclient)
        nhrp_zebra_register_neigh(VRF_DEFAULT, AFI_IP6, true);
 }
 
+static zclient_handler *const nhrp_handlers[] = {
+       [ZEBRA_INTERFACE_ADDRESS_ADD] = nhrp_interface_address_add,
+       [ZEBRA_INTERFACE_ADDRESS_DELETE] = nhrp_interface_address_delete,
+       [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = nhrp_route_read,
+       [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = nhrp_route_read,
+       [ZEBRA_NHRP_NEIGH_ADDED] = nhrp_neighbor_operation,
+       [ZEBRA_NHRP_NEIGH_REMOVED] = nhrp_neighbor_operation,
+       [ZEBRA_NHRP_NEIGH_GET] = nhrp_neighbor_operation,
+       [ZEBRA_GRE_UPDATE] = nhrp_gre_update,
+};
+
 void nhrp_zebra_init(void)
 {
        zebra_rib[AFI_IP] = route_table_init();
        zebra_rib[AFI_IP6] = route_table_init();
 
-       zclient = zclient_new(master, &zclient_options_default);
+       zclient = zclient_new(master, &zclient_options_default, nhrp_handlers,
+                             array_size(nhrp_handlers));
        zclient->zebra_connected = nhrp_zebra_connected;
-       zclient->interface_address_add = nhrp_interface_address_add;
-       zclient->interface_address_delete = nhrp_interface_address_delete;
-       zclient->redistribute_route_add = nhrp_route_read;
-       zclient->redistribute_route_del = nhrp_route_read;
-       zclient->neighbor_added = nhrp_neighbor_operation;
-       zclient->neighbor_removed = nhrp_neighbor_operation;
-       zclient->neighbor_get = nhrp_neighbor_operation;
-       zclient->gre_update = nhrp_gre_update;
        zclient_init(zclient, ZEBRA_ROUTE_NHRP, 0, &nhrpd_privs);
 }
 
@@ -404,9 +414,7 @@ void nhrp_send_zebra_configure_arp(struct interface *ifp, int family)
        }
        s = zclient->obuf;
        stream_reset(s);
-       zclient_create_header(s,
-                             ZEBRA_CONFIGURE_ARP,
-                             ifp->vrf_id);
+       zclient_create_header(s, ZEBRA_CONFIGURE_ARP, ifp->vrf->vrf_id);
        stream_putc(s, family);
        stream_putl(s, ifp->ifindex);
        stream_putw_at(s, 0, stream_get_endp(s));
@@ -429,9 +437,7 @@ void nhrp_send_zebra_gre_source_set(struct interface *ifp,
        }
        s = zclient->obuf;
        stream_reset(s);
-       zclient_create_header(s,
-                             ZEBRA_GRE_SOURCE_SET,
-                             ifp->vrf_id);
+       zclient_create_header(s, ZEBRA_GRE_SOURCE_SET, ifp->vrf->vrf_id);
        stream_putl(s, ifp->ifindex);
        stream_putl(s, link_idx);
        stream_putl(s, link_vrf_id);
@@ -452,7 +458,8 @@ void nhrp_send_zebra_nbr(union sockunion *in,
        stream_reset(s);
        zclient_neigh_ip_encode(s, out ? ZEBRA_NEIGH_IP_ADD :
                                ZEBRA_NEIGH_IP_DEL, in, out,
-                               ifp);
+                               ifp, out ? ZEBRA_NEIGH_STATE_REACHABLE
+                               : ZEBRA_NEIGH_STATE_FAILED);
        stream_putw_at(s, 0, stream_get_endp(s));
        zclient_send_message(zclient);
 }
@@ -475,7 +482,7 @@ void nhrp_zebra_terminate(void)
        route_table_finish(zebra_rib[AFI_IP6]);
 }
 
-void nhrp_gre_update(ZAPI_CALLBACK_ARGS)
+int nhrp_gre_update(ZAPI_CALLBACK_ARGS)
 {
        struct stream *s;
        struct nhrp_gre_info gre_info, *val;
@@ -484,7 +491,7 @@ void nhrp_gre_update(ZAPI_CALLBACK_ARGS)
        /* result */
        s = zclient->ibuf;
        if (vrf_id != VRF_DEFAULT)
-               return;
+               return 0;
 
        /* read GRE information */
        STREAM_GETL(s, gre_info.ifindex);
@@ -515,7 +522,9 @@ void nhrp_gre_update(ZAPI_CALLBACK_ARGS)
               ifp ? ifp->name : "<none>", gre_info.ifindex, vrf_id);
        if (ifp)
                nhrp_interface_update_nbma(ifp, val);
-       return;
+       return 0;
+
 stream_failure:
        zlog_err("%s(): error reading response ..", __func__);
+       return -1;
 }