]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Move protodown_r_bit to a better spot
authorDonald Sharp <sharpd@nvidia.com>
Thu, 27 Apr 2023 11:37:58 +0000 (07:37 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 5 Jul 2023 15:49:36 +0000 (11:49 -0400)
Since we are moving some code handling out of the dataplane
and into zebra proper, lets move the protodown r bit as well.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/if_netlink.c
zebra/if_netlink.h
zebra/zebra_router.c
zebra/zebra_router.h
zebra/zebra_vrf.c

index cea47b4c30afa30480184919b01497d2c14cc69b..6178b8e16df66e9595e011ca168a52d62d0c983f 100644 (file)
@@ -63,7 +63,6 @@
 #include "zebra/zebra_trace.h"
 
 extern struct zebra_privs_t zserv_privs;
-uint8_t frr_protodown_r_bit = FRR_PROTODOWN_REASON_DEFAULT_BIT;
 
 /* Note: on netlink systems, there should be a 1-to-1 mapping between interface
    names and ifindex values. */
@@ -920,9 +919,7 @@ static int netlink_bridge_interface(struct nlmsghdr *h, int len, ns_id_t ns_id,
 
 static bool is_if_protodown_reason_only_frr(uint32_t rc_bitfield)
 {
-       /* This shouldn't be possible */
-       assert(frr_protodown_r_bit < 32);
-       return (rc_bitfield == (((uint32_t)1) << frr_protodown_r_bit));
+       return (rc_bitfield == (((uint32_t)1) << if_netlink_get_frr_protodown_r_bit()));
 }
 
 /*
@@ -2393,9 +2390,10 @@ ssize_t netlink_intf_msg_encode(uint16_t cmd,
                return -1;
 
        nl_attr_put32(&req->n, buflen, IFLA_PROTO_DOWN_REASON_MASK,
-                     (1 << frr_protodown_r_bit));
+                     (1 << if_netlink_get_frr_protodown_r_bit()));
        nl_attr_put32(&req->n, buflen, IFLA_PROTO_DOWN_REASON_VALUE,
-                     ((int)pd_reason_val) << frr_protodown_r_bit);
+                     ((int)pd_reason_val)
+                             << if_netlink_get_frr_protodown_r_bit());
 
        nl_attr_nest_end(&req->n, nest_protodown_reason);
 
@@ -2420,37 +2418,6 @@ void interface_list(struct zebra_ns *zns)
        interface_addr_lookup_netlink(zns);
 }
 
-void if_netlink_set_frr_protodown_r_bit(uint8_t bit)
-{
-       if (IS_ZEBRA_DEBUG_KERNEL)
-               zlog_debug(
-                       "Protodown reason bit index changed: bit-index %u -> bit-index %u",
-                       frr_protodown_r_bit, bit);
-
-       frr_protodown_r_bit = bit;
-}
-
-void if_netlink_unset_frr_protodown_r_bit(void)
-{
-       if (IS_ZEBRA_DEBUG_KERNEL)
-               zlog_debug(
-                       "Protodown reason bit index changed: bit-index %u -> bit-index %u",
-                       frr_protodown_r_bit, FRR_PROTODOWN_REASON_DEFAULT_BIT);
-
-       frr_protodown_r_bit = FRR_PROTODOWN_REASON_DEFAULT_BIT;
-}
-
-
-bool if_netlink_frr_protodown_r_bit_is_set(void)
-{
-       return (frr_protodown_r_bit != FRR_PROTODOWN_REASON_DEFAULT_BIT);
-}
-
-uint8_t if_netlink_get_frr_protodown_r_bit(void)
-{
-       return frr_protodown_r_bit;
-}
-
 /**
  * netlink_request_tunneldump() - Request all tunnels from the linux kernel
  *
index ede6224188a1b88a183929059b84b65e3a516878..9b31906a17dab0ce5d7449184be71dd9eb1578f6 100644 (file)
@@ -42,17 +42,6 @@ extern int netlink_tunneldump_read(struct zebra_ns *zns);
 extern enum netlink_msg_status
 netlink_put_intf_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
 
-#define FRR_PROTODOWN_REASON_DEFAULT_BIT 7
-/* Protodown bit setter/getter
- *
- * Allow users to change the bit if it conflicts with another
- * on their system.
- */
-extern void if_netlink_set_frr_protodown_r_bit(uint8_t bit);
-extern void if_netlink_unset_frr_protodown_r_bit(void);
-extern bool if_netlink_frr_protodown_r_bit_is_set(void);
-extern uint8_t if_netlink_get_frr_protodown_r_bit(void);
-
 #ifdef __cplusplus
 }
 #endif
index a4772879139bcfc3261519466d2b81e70eeea77e..1b3e31ee423242eb9d0c75080815b20efc483886 100644 (file)
@@ -259,6 +259,8 @@ void zebra_router_init(bool asic_offload, bool notify_on_ack)
 {
        zrouter.sequence_num = 0;
 
+       zrouter.protodown_r_bit = FRR_PROTODOWN_REASON_DEFAULT_BIT;
+
        zrouter.allow_delete = false;
 
        zrouter.packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS;
index d81c7df589938c14ca2e416f7ff90f6c5e116896..a7f0f135f91a5d471cba6efbbddd05a36bc3e230 100644 (file)
@@ -228,6 +228,8 @@ struct zebra_router {
 
        /* Should we allow non FRR processes to delete our routes */
        bool allow_delete;
+
+       uint8_t protodown_r_bit;
 };
 
 #define GRACEFUL_RESTART_TIME 60
@@ -286,6 +288,32 @@ static inline bool zebra_router_in_shutdown(void)
        return atomic_load_explicit(&zrouter.in_shutdown, memory_order_relaxed);
 }
 
+#define FRR_PROTODOWN_REASON_DEFAULT_BIT 7
+/* Protodown bit setter/getter
+ *
+ * Allow users to change the bit if it conflicts with another
+ * on their system.
+ */
+static inline void if_netlink_set_frr_protodown_r_bit(uint8_t bit)
+{
+       zrouter.protodown_r_bit = bit;
+}
+
+static inline void if_netlink_unset_frr_protodown_r_bit(void)
+{
+       zrouter.protodown_r_bit = FRR_PROTODOWN_REASON_DEFAULT_BIT;
+}
+
+static inline bool if_netlink_frr_protodown_r_bit_is_set(void)
+{
+       return (zrouter.protodown_r_bit != FRR_PROTODOWN_REASON_DEFAULT_BIT);
+}
+
+static inline uint8_t if_netlink_get_frr_protodown_r_bit(void)
+{
+       return zrouter.protodown_r_bit;
+}
+
 /* zebra_northbound.c */
 extern const struct frr_yang_module_info frr_zebra_info;
 
index 74b9d106cdc38b052fb079fc7dbee70a8686ca53..b246d445dafaf745a698d322e67c676a3fb92e6a 100644 (file)
@@ -377,7 +377,7 @@ struct zebra_vrf *zebra_vrf_alloc(struct vrf *vrf)
 }
 
 /*
-Pending: create an efficient table_id (in a tree/hash) based lookup)
+ * Pending: create an efficient table_id (in a tree/hash) based lookup)
  */
 vrf_id_t zebra_vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id)
 {