]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib, zebra: complete the ndm flags on zclient api
authorPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 25 Aug 2021 09:46:42 +0000 (11:46 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 26 Aug 2021 07:19:42 +0000 (09:19 +0200)
Insist on the fact that zclient neighbor state flags are
mapped over netlink state flags. List all the defines
currently known on kernel, and create a netlink API to
convert netlink values to zclient values. The function is
simplified as it is a 1-1 match.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
lib/zclient.h
zebra/rt_netlink.c

index d24f06b778fae7e0aeb54909bfc88211c0eb4add..71187ccae73cb497b95f7c90da116154898d5f19 100644 (file)
@@ -856,9 +856,18 @@ extern struct zclient_options zclient_options_default;
  * ip_in is the underlay IP, ip_out is the tunnel dest
  * index stands for the index of the interface
  * ndm state stands for the NDM value in netlink
+ * (see linux/neighbour.h)
  */
+#define ZEBRA_NEIGH_STATE_INCOMPLETE (0x01)
 #define ZEBRA_NEIGH_STATE_REACHABLE (0x02)
-#define ZEBRA_NEIGH_STATE_FAILED    (0x20)
+#define ZEBRA_NEIGH_STATE_STALE (0x04)
+#define ZEBRA_NEIGH_STATE_DELAY (0x08)
+#define ZEBRA_NEIGH_STATE_PROBE (0x10)
+#define ZEBRA_NEIGH_STATE_FAILED (0x20)
+#define ZEBRA_NEIGH_STATE_NOARP (0x40)
+#define ZEBRA_NEIGH_STATE_PERMANENT (0x80)
+#define ZEBRA_NEIGH_STATE_NONE (0x00)
+
 struct zapi_neigh_ip {
        int cmd;
        struct ipaddr ip_in;
index 48ccf91ec7d23bf954f8892c8e8633efa610356c..a8b4b54d290eb8b8a3bc89d13261d6bb16ae3758 100644 (file)
@@ -3658,6 +3658,15 @@ static void netlink_handle_5549(struct ndmsg *ndm, struct zebra_if *zif,
 #define NUD_LOCAL_ACTIVE                                                 \
        (NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE)
 
+static int netlink_nbr_entry_state_to_zclient(int nbr_state)
+{
+       /* an exact match is done between
+        * - netlink neighbor state values: NDM_XXX (see in linux/neighbour.h)
+        * - zclient neighbor state values: ZEBRA_NEIGH_STATE_XXX
+        *  (see in lib/zclient.h)
+        */
+       return nbr_state;
+}
 static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
 {
        struct ndmsg *ndm;
@@ -3747,8 +3756,10 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
                               &mac, l2_len);
                } else
                        sockunion_family(&link_layer_ipv4) = AF_UNSPEC;
-               zsend_nhrp_neighbor_notify(cmd, ifp, &ip, ndm->ndm_state,
-                                          &link_layer_ipv4);
+               zsend_nhrp_neighbor_notify(
+                       cmd, ifp, &ip,
+                       netlink_nbr_entry_state_to_zclient(ndm->ndm_state),
+                       &link_layer_ipv4);
        }
 
        if (h->nlmsg_type == RTM_GETNEIGH)