Mailing List Archive

zebra, linux, blackhole route
Hello.
I try to use quagga-1.2.4 on ArchLinux (linux kernel-5.3.10,
iproute2-5.3.0) and get a problem: zebra does not import special routes
like "blackhole" from the Linux kernel, but zebra itself can install and
remove them .
For example, if I add a route to the Linux console:
ip r add blackhole 192.0.2.0/24

then if you look at the routes in zebra, then this route will not be
shown there:
dell_zebra# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel, N - NHRP,
> - selected route, * - FIB route

K * 0.0.0.0/0 via 192.168.74.254, br0 inactive, src 192.168.74.34
C>* 127.0.0.0/8 is directly connected, lo
C>* 192.168.72.0/31 is directly connected, ipip0
C>* 192.168.74.0/24 is directly connected, br0
K>* 192.168.74.254/32 is directly connected, br0

zebra, however, receives a message about adding a route through a
netlink socket when I add a route; strace utility output:

recvmsg(6, {msg_name={sa_family=AF_NETLINK, nl_pid=0,
nl_groups=0x000040}, msg_namelen=12, msg_iov=[.{iov_base={{len=44,
type=RTM_NEWROUTE, flags=NLM_F_EXCL|NLM_F_CREATE, seq=1573711432,
pid=20978}, {rtm_family=AF_INET, rtm_dst_len=24, rtm_src_len=0,
rtm_tos=0, rtm_table=RT_TABLE_MAIN, rtm_protocol=RTPROT_BOOT,
rtm_scope=RT_SCOPE_UNIVERSE, rtm_type=RTN_BLACKHOLE, rtm_flags=0},
[{{nla_len=8, nla_type=RTA_TABLE}, RT_TABLE_MAIN}, {{nla_len=8,
nla_type=RTA_DST}, inet_addr("192.0.2.0")}]}, iov_len=8192}],
msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 44

Question: can zebra correctly handle special routes like blackhole,
defined directly in the linux console?

Thank you.
_______________________________________________
Quagga-users mailing list
Quagga-users@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-users
Re: zebra, linux, blackhole route [ In reply to ]
> 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
_______________________________________________
Quagga-users mailing list
Quagga-users@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-users
Re: zebra, linux, blackhole route [ In reply to ]
On 14/11/2019 06:26, quagga-user wrote:
> For example, if I add a route to the Linux console:
> ip r add blackhole 192.0.2.0/24


Is there a reason for not just using quagga to add the blackhole route?


Tim

_______________________________________________
Quagga-users mailing list
Quagga-users@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-users
Re: zebra, linux, blackhole route [ In reply to ]
> they are not of type RTN_UNICAST:
>
> zebra/rt_netlink.c:
Thanks a lot, the problem is clear. Thank you for the very detailed answer!

> 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.
I tried to look into the source code, but my knowledge of the internal
quagga logic is almost zero, and I have not written a patch yet.
_______________________________________________
Quagga-users mailing list
Quagga-users@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-users