]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib,zebra: add tx queuelen to interface struct
authorMark Stapp <mjs@labn.net>
Fri, 1 Sep 2023 14:06:10 +0000 (10:06 -0400)
committerMark Stapp <mjs@labn.net>
Fri, 1 Sep 2023 14:06:10 +0000 (10:06 -0400)
Add the txqlen attribute to the common interface struct. Capture
the value in zebra, and distribute it through the interface lib
module's zapi messaging.

Signed-off-by: Mark Stapp <mjs@labn.net>
lib/if.h
lib/zclient.c
zebra/if_netlink.c
zebra/interface.c
zebra/zapi_msg.c
zebra/zebra_dplane.c
zebra/zebra_dplane.h

index c6b4fd216a371252c9391c0bccab48d17c9d7373..7b4415da45d47ca76dca542bf5230a7e54689a3b 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -252,6 +252,9 @@ struct interface {
        /* Interface Speed in Mb/s */
        uint32_t speed;
 
+       /* TX queue len */
+       uint32_t txqlen;
+
        /* Interface MTU. */
        unsigned int mtu; /* IPv4 MTU */
        unsigned int
index e40725826ad5786c2a8c69586b9cc51a6bf62175..68a342982230d2d13f033a5c0b9b1d614b6b36b6 100644 (file)
@@ -2761,6 +2761,7 @@ static void zebra_interface_if_set_value(struct stream *s,
        STREAM_GETC(s, ifp->ptm_status);
        STREAM_GETL(s, ifp->metric);
        STREAM_GETL(s, ifp->speed);
+       STREAM_GETL(s, ifp->txqlen);
        STREAM_GETL(s, ifp->mtu);
        STREAM_GETL(s, ifp->mtu6);
        STREAM_GETL(s, ifp->bandwidth);
index ca0a354afdc0c7d2c452a24077b7ba8d92cd8b46..61a8c6a78a0e727f92ce1708307922f51cde016e 100644 (file)
@@ -1508,6 +1508,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        ns_id_t link_nsid = ns_id;
        ifindex_t master_infindex = IFINDEX_INTERNAL;
        uint8_t bypass = 0;
+       uint32_t txqlen = 0;
 
        frrtrace(3, frr_zebra, netlink_interface, h, ns_id, startup);
 
@@ -1586,6 +1587,9 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
                link_nsid = ns_id_get_absolute(ns_id, link_nsid);
        }
 
+       if (tb[IFLA_TXQLEN])
+               txqlen = *(uint32_t *)RTA_DATA(tb[IFLA_TXQLEN]);
+
        struct zebra_dplane_ctx *ctx = dplane_ctx_alloc();
        dplane_ctx_set_ns_id(ctx, ns_id);
        dplane_ctx_set_ifp_link_nsid(ctx, link_nsid);
@@ -1594,6 +1598,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
        dplane_ctx_set_ifname(ctx, name);
        dplane_ctx_set_ifp_startup(ctx, startup);
        dplane_ctx_set_ifp_family(ctx, ifi->ifi_family);
+       dplane_ctx_set_intf_txqlen(ctx, txqlen);
 
        /* We are interested in some AF_BRIDGE notifications. */
 #ifndef AF_BRIDGE
index 9ca330571f4dff7fd6beb0e79d5e63a759f7bf61..5c01e64e0fa2f13079a54fce3b6f83a6b109fcea 100644 (file)
@@ -2060,6 +2060,7 @@ static void zebra_if_dplane_ifp_handling(struct zebra_dplane_ctx *ctx)
                        ifp->metric = 0;
                        ifp->speed = kernel_get_speed(ifp, NULL);
                        ifp->ptm_status = ZEBRA_PTM_STATUS_UNKNOWN;
+                       ifp->txqlen = dplane_ctx_get_intf_txqlen(ctx);
 
                        /* Set interface type */
                        zebra_if_set_ziftype(ifp, zif_type, zif_slave_type);
@@ -2142,6 +2143,7 @@ static void zebra_if_dplane_ifp_handling(struct zebra_dplane_ctx *ctx)
                        set_ifindex(ifp, ifindex, zns);
                        ifp->mtu6 = ifp->mtu = mtu;
                        ifp->metric = 0;
+                       ifp->txqlen = dplane_ctx_get_intf_txqlen(ctx);
 
                        /*
                         * Update interface type - NOTE: Only slave_type can
@@ -2786,8 +2788,8 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
                return;
        }
 
-       vty_out(vty, "  index %d metric %d mtu %d speed %u ", ifp->ifindex,
-               ifp->metric, ifp->mtu, ifp->speed);
+       vty_out(vty, "  index %d metric %d mtu %d speed %u txqlen %u",
+               ifp->ifindex, ifp->metric, ifp->mtu, ifp->speed, ifp->txqlen);
        if (ifp->mtu6 != ifp->mtu)
                vty_out(vty, "mtu6 %d ", ifp->mtu6);
        vty_out(vty, "\n  flags: %s\n", if_flag_dump(ifp->flags));
@@ -3174,6 +3176,7 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp,
        if (ifp->mtu6 != ifp->mtu)
                json_object_int_add(json_if, "mtu6", ifp->mtu6);
        json_object_int_add(json_if, "speed", ifp->speed);
+       json_object_int_add(json_if, "txqlen", ifp->txqlen);
        json_object_string_add(json_if, "flags", if_flag_dump(ifp->flags));
 
        /* Hardware address. */
index f6afb006b720cc9f65d40dfcbecf85ff80f5867a..6bed6d87272cb3f4ab897a26390672d8e340b04f 100644 (file)
@@ -71,6 +71,7 @@ static void zserv_encode_interface(struct stream *s, struct interface *ifp)
        stream_putc(s, ifp->ptm_status);
        stream_putl(s, ifp->metric);
        stream_putl(s, ifp->speed);
+       stream_putl(s, ifp->txqlen);
        stream_putl(s, ifp->mtu);
        stream_putl(s, ifp->mtu6);
        stream_putl(s, ifp->bandwidth);
index 7b2f6430804f0ad643a00c88b2f73c054e7d2a7b..03d7bb88a2183b468a64a5bbe577d156beff2c4c 100644 (file)
@@ -216,6 +216,8 @@ struct dplane_intf_info {
 
        uint32_t rc_bitfield;
 
+       uint32_t txqlen;
+
        uint32_t metric;
        uint32_t flags;
 
@@ -2656,6 +2658,20 @@ void dplane_ctx_set_intf_label(struct zebra_dplane_ctx *ctx, const char *label)
        }
 }
 
+void dplane_ctx_set_intf_txqlen(struct zebra_dplane_ctx *ctx, uint32_t txqlen)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       ctx->u.intf.txqlen = txqlen;
+}
+
+uint32_t dplane_ctx_get_intf_txqlen(const struct zebra_dplane_ctx *ctx)
+{
+       DPLANE_CTX_VALID(ctx);
+
+       return ctx->u.intf.txqlen;
+}
+
 /* Accessors for MAC information */
 vlanid_t dplane_ctx_mac_get_vlan(const struct zebra_dplane_ctx *ctx)
 {
index c006522e01770c3f8aebc6531bacd9c2fc01e5d0..4d4a17bbaeba0c58cffcdcccabad6628f399f5fe 100644 (file)
@@ -672,6 +672,8 @@ void dplane_ctx_set_intf_dest(struct zebra_dplane_ctx *ctx,
 bool dplane_ctx_intf_has_label(const struct zebra_dplane_ctx *ctx);
 const char *dplane_ctx_get_intf_label(const struct zebra_dplane_ctx *ctx);
 void dplane_ctx_set_intf_label(struct zebra_dplane_ctx *ctx, const char *label);
+void dplane_ctx_set_intf_txqlen(struct zebra_dplane_ctx *ctx, uint32_t txqlen);
+uint32_t dplane_ctx_get_intf_txqlen(const struct zebra_dplane_ctx *ctx);
 
 /* Accessors for MAC information */
 vlanid_t dplane_ctx_mac_get_vlan(const struct zebra_dplane_ctx *ctx);