On Wed, Aug 17, 2011 at 09:39:03PM +0100, Alex Bligh wrote:
>
>
> --On 17 August 2011 22:50:06 +0200 Ondrej Zajicek 
> <santi...@crfreenet.org> wrote:
>
>>> Using the device protocol, I can mask out all the interfaces
>>> bar these autogenerated ones because I give them a name with a
>>> constant prefix.
>>
>> Perhaps the direct protocol (to filter generated device routes)?
>
> Sorry, I meant the direct protocol. I didn't even realise you
> could export from the device protocol.

It is not a real route export, just some specific option to filter
interfaces. But it is probably better to forget about this option
:-)

> However, this doesn't pick up situations where the interface
> itself is unnumbered, with just a static route pointing out of
> it (for /32 numbering), which is my issue. The static route
> is inserted by a separate call to "ip route" (by me), and
> looks like this:
>  ip route add 4.4.4.4/32 proto SOMEPROTO nexthop dev evrr-000001
>
> Even though it has a "dev" next-hop, it isn't a device route
> in bird terms, and only the kernel (bird) protocol sees it, as far as
> I can tell.

In my terms it is a device route, but it is not a route related to iface
address prefix (so it is not a route generated by 'direct' protocol)
prefix.


BTW, you can add this as an interface address using something like:

ip a a SOME_LOCAL_ADDR peer 4.4.4.4/32 dev evrr-000001

(where SOME_LOCAL_ADDR can be shared for all such ifaces)


BTW2, For now, your requirement to filter out routes based on  protocol
could be easily done by modifying the source, there is already similar
hack in BIRD code (see [*]), if you modify it (see attached patch), it
will be applied on all routes and blocks import of routes with RTPROT_BOOT.

[*] 
http://www.mail-archive.com/bird-users@atrey.karlin.mff.cuni.cz/msg01039.html


-- 
Elen sila lumenn' omentielvo

Ondrej 'SanTiago' Zajicek (email: santi...@crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
diff --git a/sysdep/linux/netlink/netlink.c b/sysdep/linux/netlink/netlink.c
index 0830097..b9466d3 100644
--- a/sysdep/linux/netlink/netlink.c
+++ b/sysdep/linux/netlink/netlink.c
@@ -797,6 +797,9 @@ nl_parse_route(struct nlmsghdr *h, int scan)
     .cast = RTC_UNICAST
   };
 
+  if (i->rtm_protocol == RTPROT_BOOT)
+    src = KRT_SRC_KERNEL;
+
   switch (i->rtm_type)
     {
     case RTN_UNICAST:
@@ -856,9 +859,6 @@ nl_parse_route(struct nlmsghdr *h, int scan)
 	   * behavior in IPv4. Anyway, users should use RTPROT_STATIC
 	   * for their 'alien' routes.
 	   */
-
-	  if (i->rtm_protocol == RTPROT_BOOT)
-	    src = KRT_SRC_KERNEL;
 	}
 
       break;

Reply via email to