]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd,lib: document the table id / instance usage 17736/head
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Thu, 23 Jan 2025 18:13:01 +0000 (15:13 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Thu, 23 Jan 2025 18:13:01 +0000 (15:13 -0300)
Document where relevant about the instance overload to table ID so users
know what to expect.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
bgpd/bgp_zebra.c
lib/zclient.c
lib/zclient.h

index 3d7481f6302194624456845e0aab4e20f02dc9fb..179404a2cebc0b81e471b63cc1c6d16f8ee9c1d2 100644 (file)
@@ -2043,6 +2043,18 @@ int bgp_redistribute_set(struct bgp *bgp, afi_t afi, int type,
        /* Return if already redistribute flag is set. */
        if (instance) {
                if (type == ZEBRA_ROUTE_TABLE_DIRECT) {
+                       /*
+                        * When redistribution type is `table-direct` the
+                        * instance means `table identification`.
+                        *
+                        * `table_id` support 32bit integers, however since
+                        * `instance` is being overloaded to `table_id` it
+                        * will only be possible to use the first 65535
+                        * entries.
+                        *
+                        * Also the ZAPI must also support `int`
+                        * (see `zebra_redistribute_add`).
+                        */
                        struct redist_table_direct table = {
                                .table_id = instance,
                                .vrf_id = bgp->vrf_id,
index 8fc9addf2f8f6bd2518d7cba719be16656cf6484..9f6542eb31e2c48eb26acfa6558a7c121ec7ad1f 100644 (file)
@@ -4774,6 +4774,16 @@ static void zclient_redistribute_table_direct(struct zclient *zclient, vrf_id_t
 void zclient_redistribute(int command, struct zclient *zclient, afi_t afi,
                          int type, unsigned short instance, vrf_id_t vrf_id)
 {
+       /*
+        * When asking for table-direct redistribution the parameter
+        * `instance` has a different meaning: it means table
+        * identification.
+        *
+        * The table identification information is stored in
+        * `zclient->mi_redist` along with the VRF identification
+        * information in a pair (different from the usual single protocol
+        * instance value).
+        */
        if (type == ZEBRA_ROUTE_TABLE_DIRECT) {
                zclient_redistribute_table_direct(zclient, vrf_id, afi, instance, command);
                return;
index 35e23ddf63221825fcf17aa7e2b386e39903918b..f3657822b841642c9b95b690ccc63eb1b0158634 100644 (file)
@@ -271,6 +271,12 @@ struct redist_proto {
 /**
  * Redistribute table direct instance data structure: keeps the VRF
  * that subscribed to the table ID.
+ *
+ * **NOTE**
+ * `table_id` is an integer because that is what the netlink interface
+ * uses for route attribute RTA_TABLE (32bit int), however the whole
+ * zclient API uses `unsigned short` (and CLI commands) so it will be
+ * limited to the range 1 to 65535.
  */
 struct redist_table_direct {
        vrf_id_t vrf_id;