]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pbrd: use `zclient->nexthop_update`
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 29 Nov 2022 11:09:45 +0000 (12:09 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 20 Nov 2023 10:24:28 +0000 (11:24 +0100)
Have the library decode the nexthop.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
pbrd/pbr_zebra.c

index d47a308ac8470ae6f7b29c5975ad79dfaa3be9f3..44ccbde0e101c8dca68050ef337c601822d4d0de 100644 (file)
@@ -364,38 +364,30 @@ void route_delete(struct pbr_nexthop_group_cache *pnhgc, afi_t afi)
        }
 }
 
-static int pbr_zebra_nexthop_update(ZAPI_CALLBACK_ARGS)
+static void pbr_zebra_nexthop_update(struct vrf *vrf, struct prefix *matched,
+                                    struct zapi_route *nhr)
 {
-       struct zapi_route nhr;
-       struct prefix matched;
        uint32_t i;
 
-       if (!zapi_nexthop_update_decode(zclient->ibuf, &matched, &nhr)) {
-               zlog_err("Failure to decode Nexthop update message");
-               return 0;
-       }
-
        if (DEBUG_MODE_CHECK(&pbr_dbg_zebra, DEBUG_MODE_ALL)) {
-
                DEBUGD(&pbr_dbg_zebra,
                       "%s: Received Nexthop update: %pFX against %pFX",
-                      __func__, &matched, &nhr.prefix);
+                      __func__, matched, &nhr->prefix);
 
                DEBUGD(&pbr_dbg_zebra, "%s:   (Nexthops(%u)", __func__,
-                      nhr.nexthop_num);
+                      nhr->nexthop_num);
 
-               for (i = 0; i < nhr.nexthop_num; i++) {
+               for (i = 0; i < nhr->nexthop_num; i++) {
                        DEBUGD(&pbr_dbg_zebra,
                               "%s:     Type: %d: vrf: %d, ifindex: %d gate: %pI4",
-                              __func__, nhr.nexthops[i].type,
-                              nhr.nexthops[i].vrf_id, nhr.nexthops[i].ifindex,
-                              &nhr.nexthops[i].gate.ipv4);
+                              __func__, nhr->nexthops[i].type,
+                              nhr->nexthops[i].vrf_id, nhr->nexthops[i].ifindex,
+                              &nhr->nexthops[i].gate.ipv4);
                }
        }
 
-       nhr.prefix = matched;
-       pbr_nht_nexthop_update(&nhr);
-       return 1;
+       nhr->prefix = *matched;
+       pbr_nht_nexthop_update(nhr);
 }
 
 extern struct zebra_privs_t pbr_privs;
@@ -405,7 +397,6 @@ static zclient_handler *const pbr_handlers[] = {
        [ZEBRA_INTERFACE_ADDRESS_DELETE] = interface_address_delete,
        [ZEBRA_ROUTE_NOTIFY_OWNER] = route_notify_owner,
        [ZEBRA_RULE_NOTIFY_OWNER] = rule_notify_owner,
-       [ZEBRA_NEXTHOP_UPDATE] = pbr_zebra_nexthop_update,
 };
 
 void pbr_zebra_init(void)
@@ -417,6 +408,7 @@ void pbr_zebra_init(void)
 
        zclient_init(zclient, ZEBRA_ROUTE_PBR, 0, &pbr_privs);
        zclient->zebra_connected = zebra_connected;
+       zclient->nexthop_update = pbr_zebra_nexthop_update;
 }
 
 void pbr_zebra_destroy(void)