[quagga-users 15031] Re: zebra, linux, blackhole route

Matthias Ferdinand <mf-5+/[email protected]> Thu, 14 Nov 2019 15:23:36 +0100
Newsgroups gmane.network.quagga.user
Message-ID <20191114142336.GE26017@xoff>
> Question: can zebra correctly handle special routes like blackhole, 
> defined directly in the linux console?

Hello,

I never had a use case for this so I never stumbled upon that, but
apparently blackhole routes received via netlink are simply ignored, as
they are not of type RTN_UNICAST:

zebra/rt_netlink.c:
    909 
    910 /* Routing information change from the kernel. */
    911 static int
    912 netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
...
    948 
=>  949   if (rtm->rtm_type != RTN_UNICAST)
=>  950     {
=>  951       return 0;
=>  952     }
...
   1233 
   1234   return 0;
   1235 }


If I understand the code correctly, with the kernel socket interface as
used on BSD, blackhole routes are not ignored:

zebra/kernel_socket.c:
    871 
    872 void
    873 rtm_read (struct rt_msghdr *rtm)
    874 {
...
    915   /* This is a reject or blackhole route */
    916   if (flags & RTF_REJECT)
    917     SET_FLAG (zebra_flags, ZEBRA_FLAG_REJECT);
    918   if (flags & RTF_BLACKHOLE)
    919     SET_FLAG (zebra_flags, ZEBRA_FLAG_BLACKHOLE);
...
   1060     }
   1061 #endif /* HAVE_IPV6 */
   1062 }



It might be as simple as adding a RTN_BLACKHOLE case to
netlink_route_change(), i.e. not ignore it and to do
SET_FLAG (zebra_flags, ZEBRA_FLAG_BLACKHOLE).
But I am not sure I understand all the implications of blackhole routes
in the quagga code.


Regards
Matthias Ferdinand