]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, zebra: carry source prefix in route_notify
authorDavid Lamparter <equinox@opensourcerouting.org>
Mon, 27 Jan 2025 19:26:32 +0000 (20:26 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 28 Jan 2025 14:40:17 +0000 (15:40 +0100)
When a daemon wants to know about its routes, make it possible to have
that work for dst-src routes.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/zclient.c
lib/zclient.h
zebra/zapi_msg.c

index 063944fd3b23f5742677e293bd4759ba9d184210..d2bd7ed0451f6473b852895e2d1899156fec9322 100644 (file)
@@ -2015,6 +2015,15 @@ bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
                              uint32_t *tableid,
                              enum zapi_route_notify_owner *note,
                              afi_t *afi, safi_t *safi)
+{
+       struct prefix dummy;
+
+       return zapi_route_notify_decode_srcdest(s, p, &dummy, tableid, note, afi, safi);
+}
+
+bool zapi_route_notify_decode_srcdest(struct stream *s, struct prefix *p, struct prefix *src_p,
+                                     uint32_t *tableid, enum zapi_route_notify_owner *note,
+                                     afi_t *afi, safi_t *safi)
 {
        uint32_t t;
        afi_t afi_val;
@@ -2025,6 +2034,9 @@ bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
        STREAM_GETC(s, p->family);
        STREAM_GETC(s, p->prefixlen);
        STREAM_GET(&p->u.prefix, s, prefix_blen(p));
+       src_p->family = p->family;
+       STREAM_GETC(s, src_p->prefixlen);
+       STREAM_GET(&src_p->u.prefix, s, prefix_blen(src_p));
        STREAM_GETL(s, t);
        STREAM_GETC(s, afi_val);
        STREAM_GETC(s, safi_val);
index 2385a8a2197b3a103b50aadedc18f64a6e049dc5..e2bf0ce69927375bfc568b0cbd8ac35b55fc43fc 100644 (file)
@@ -1144,6 +1144,9 @@ bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
                              uint32_t *tableid,
                              enum zapi_route_notify_owner *note,
                              afi_t *afi, safi_t *safi);
+bool zapi_route_notify_decode_srcdest(struct stream *s, struct prefix *p, struct prefix *src_p,
+                                     uint32_t *tableid, enum zapi_route_notify_owner *note,
+                                     afi_t *afi, safi_t *safi);
 bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
                             uint32_t *priority, uint32_t *unique, char *ifname,
                             enum zapi_rule_notify_owner *note);
index ab55998af046160ed5824bc90e42b4fa13c15ab5..8e5eeae1cc1136b932e9448990a9c7448969e3ec 100644 (file)
@@ -740,6 +740,10 @@ static int route_notify_internal(const struct route_node *rn, int type,
        struct zserv *client;
        struct stream *s;
        uint8_t blen;
+       const struct prefix *p, *src_p;
+       struct prefix src_dummy = {};
+
+       srcdest_rnode_prefixes(rn, &p, &src_p);
 
        client = zserv_find_client(type, instance);
        if (!client || !client->notify_owner) {
@@ -771,9 +775,17 @@ static int route_notify_internal(const struct route_node *rn, int type,
 
        stream_putc(s, rn->p.family);
 
-       blen = prefix_blen(&rn->p);
-       stream_putc(s, rn->p.prefixlen);
-       stream_put(s, &rn->p.u.prefix, blen);
+       blen = prefix_blen(p);
+       stream_putc(s, p->prefixlen);
+       stream_put(s, &p->u.prefix, blen);
+
+       if (!src_p) {
+               src_dummy.family = p->family;
+               src_p = &src_dummy;
+       }
+       blen = prefix_blen(src_p);
+       stream_putc(s, src_p->prefixlen);
+       stream_put(s, &src_p->u.prefix, blen);
 
        stream_putl(s, table_id);