Re: OpenOSPF6d does not send LSAs for passive interfaces

Previous thread: Re: 2011-Jan-01 install script bug by Theo de Raadt on Sunday, January 2, 2011 - 3:05 pm. (1 message)

Next thread: Proyectores Eposn e Infocus by DigitalNex on Monday, January 3, 2011 - 5:16 am. (1 message)
From: Patrick Coleman
Date: Sunday, January 2, 2011 - 7:28 pm

Hi,

I've found that if an interface is declared passive (or is a CARP
interface) in ospf6d.conf, ospf6d will not send LSAs for that
interface, and any associated prefixes will not be advertised. This is
contrary to the behaviour in ospfd and what I would expect.

The problem appears to be that orig_intra_lsa_rtr in rde.c assumes
that if an interface is in the down state we should not include that
interface in intra-area LSAs, which is incorrect - a passive interface
will be in the down state by definition and we still want to advertise
the attached prefix. The patch below fixes the issue for me. I'd
appreciate any comments, as I'd like to deploy this in production.

Cheers,

Patrick

-- 
http://www.labyrinthdata.net.au - WA Backup, Web and VPS Hosting


Also up at http://patrick.ld.net.au/ospf6d-fix-passive-interfaces.patch

cvs server: Diffing .
Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/rde.c,v
retrieving revision 1.50
diff -u -p -r1.50 rde.c
--- rde.c       22 Aug 2010 20:55:10 -0000      1.50
+++ rde.c       3 Jan 2011 02:23:23 -0000
@@ -22,6 +22,7 @@
 #include <sys/socket.h>
 #include <sys/queue.h>
 #include <sys/param.h>
+#include <net/if_types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <err.h>
@@ -1459,7 +1460,9 @@ orig_intra_lsa_rtr(struct area *area, st

        numprefix = 0;
        LIST_FOREACH(iface, &area->iface_list, entry) {
-               if (iface->state & IF_STA_DOWN)
+               if ((iface->state & IF_STA_DOWN) &&
+                   !((iface->media_type == IFT_CARP) ||
+                   (iface->cflags & F_IFACE_PASSIVE)))
                        continue;

                /* Broadcast links with adjacencies are handled

From: Jan Johansson
Date: Monday, January 3, 2011 - 2:27 am

Hello!

This partially fixes my problem as described in 

http://marc.info/?l=openbsd-misc&m=128931276307517&w=2

If an CARP interface is in BACKUP state the route is still
advertised which leads to assymetric routing.

Jan J

From: Patrick Coleman
Date: Tuesday, January 4, 2011 - 1:49 am

Ok, the following should fix this. It's a little more involved; here's
what's new:
- Avoid sending LSAs if the link state is down (to avoid
double-advertising CARP interfaces). OSPFd does this a little more
elegantly using metrics[1], but I wasn't able to get that to work,
perhaps I'm not understanding the protocol. Suggestions appreciated.
- Don't send LSAs if the interface is down (ifconfig carp1 down),
because that's silly
- Make the OSPF engine update the RDE about interface changes even
when the interface state does not change, so the RDE is informed when
a passive interface's link state changes (so we can then make a
decision using that data)
- Resend intra-area LSAs in the RDE when interface flags change, not
just interface state (avoids a race condition where LSAs get sent
before the OSPF engine updates the RDE with new linkstate data)

Cheers,

Patrick

[1] See ospfe.c:851 through ospfe.c:883 in ospfd.

-- 
http://www.labyrinthdata.net.au - WA Backup, Web and VPS Hosting

http://patrick.ld.net.au/ospf6d-fix-passive-interfaces-mk2.patch

Index: interface.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/interface.c,v
retrieving revision 1.15
diff -u -p -r1.15 interface.c
--- interface.c 20 Sep 2009 20:45:06 -0000  1.15
+++ interface.c 4 Jan 2011 08:44:10 -0000
@@ -145,11 +145,15 @@ if_fsm(struct iface *iface, enum iface_e
    if (iface->state != old_state) {
        orig_rtr_lsa(iface);
        orig_link_lsa(iface);
-
-       /* state change inform RDE */
-       ospfe_imsg_compose_rde(IMSG_IFINFO,
-           iface->self->peerid, 0, iface, sizeof(struct iface));
    }
+
+   /*
+    * Send interface update to RDE regardless of whether state changes - a
+    * passive interface will remain in the DOWN state but may need to have
+    * prefix LSAs sent regardless.
+    */
+   ospfe_imsg_compose_rde(IMSG_IFINFO,
+       iface->self->peerid, 0, iface, sizeof(struct iface));

    if (old_state & ...
From: Jan Johansson
Date: Tuesday, January 4, 2011 - 2:52 am

Initial testing looks good.

With your first patch:
Cisco# show ipv6 route 2001:dead:5:7357::13
IPv6 Routing Table - 23 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
       U - Per-user Static route
       I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary
       O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
       ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2
O   2001:DEAD:5:7357::/64 [110/10]
     via FE80::214:22FF:FE73:466B, GigabitEthernet2/1
     via FE80::214:22FF:FE73:44A3, GigabitEthernet2/1

Now:
Cisco# show ipv6 route 2001:dead:5:7357::13
IPv6 Routing Table - 23 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
       U - Per-user Static route
       I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary
       O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
       ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2
O   2001:DEAD:5:7357::/64 [110/10]
     via FE80::214:22FF:FE73:466B, GigabitEthernet2/1

And then lets shift the CARP:
Cisco# show ipv6 route 2001:dead:5:7357::13
IPv6 Routing Table - 23 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
       U - Per-user Static route
       I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary
       O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
       ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2
O   2001:DEAD:5:7357::/64 [110/10]
     via FE80::214:22FF:FE73:44A3, GigabitEthernet2/1

I will do some more testing.

Previous thread: Re: 2011-Jan-01 install script bug by Theo de Raadt on Sunday, January 2, 2011 - 3:05 pm. (1 message)

Next thread: Proyectores Eposn e Infocus by DigitalNex on Monday, January 3, 2011 - 5:16 am. (1 message)