]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Allow fpm_listener to reject all routes
authorDonald Sharp <sharpd@nvidia.com>
Wed, 19 Mar 2025 16:22:04 +0000 (12:22 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 19 Mar 2025 17:43:47 +0000 (13:43 -0400)
Now usage of `-r -f` with fpm_listener now causes all
routes to be rejected.

r1# sharp install routes 10.0.0.0 nexthop 192.168.44.5 5
r1# show ip route
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
D>o 10.0.0.0/32 [150/0] via 192.168.44.5, r1-eth0, weight 1, 00:00:02
D>o 10.0.0.1/32 [150/0] via 192.168.44.5, r1-eth0, weight 1, 00:00:02
D>o 10.0.0.2/32 [150/0] via 192.168.44.5, r1-eth0, weight 1, 00:00:02
D>o 10.0.0.3/32 [150/0] via 192.168.44.5, r1-eth0, weight 1, 00:00:02
D>o 10.0.0.4/32 [150/0] via 192.168.44.5, r1-eth0, weight 1, 00:00:02
C>* 192.168.44.0/24 is directly connected, r1-eth0, weight 1, 00:00:37
L>* 192.168.44.1/32 is directly connected, r1-eth0, weight 1, 00:00:37
r1#

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/fpm_listener.c

index 43ca6e47b887750f1400f5c67bb39b44fa3f060d..00c3c3e6f509c30ced917b8e6ee270a096592afb 100644 (file)
@@ -43,6 +43,7 @@ struct glob {
        int server_sock;
        int sock;
        bool reflect;
+       bool reflect_fail_all;
        bool dump_hex;
        FILE *output_file;
 };
@@ -711,10 +712,14 @@ static void parse_netlink_msg(char *buf, size_t buf_len, fpm_msg_hdr_t *fpm)
 
                        if (glob->reflect && hdr->nlmsg_type == RTM_NEWROUTE &&
                            ctx->rtmsg->rtm_protocol > RTPROT_STATIC) {
-                               fprintf(glob->output_file, "  Route %s(%u) reflecting back\n",
+                               fprintf(glob->output_file, "  Route %s(%u) reflecting back as %s\n",
                                        netlink_prot_to_s(ctx->rtmsg->rtm_protocol),
-                                       ctx->rtmsg->rtm_protocol);
-                               ctx->rtmsg->rtm_flags |= RTM_F_OFFLOAD;
+                                       ctx->rtmsg->rtm_protocol,
+                                       glob->reflect_fail_all ? "Offload Failed" : "Offloaded");
+                               if (glob->reflect_fail_all)
+                                       ctx->rtmsg->rtm_flags |= RTM_F_OFFLOAD_FAILED;
+                               else
+                                       ctx->rtmsg->rtm_flags |= RTM_F_OFFLOAD;
                                write(glob->sock, fpm, fpm_msg_len(fpm));
                        }
                        break;
@@ -772,11 +777,14 @@ int main(int argc, char **argv)
        memset(glob, 0, sizeof(*glob));
        glob->output_file = stdout;
 
-       while ((r = getopt(argc, argv, "rdvo:")) != -1) {
+       while ((r = getopt(argc, argv, "rfdvo:")) != -1) {
                switch (r) {
                case 'r':
                        glob->reflect = true;
                        break;
+               case 'f':
+                       glob->reflect_fail_all = true;
+                       break;
                case 'd':
                        fork_daemon = true;
                        break;