Re: Better ASR support in ospfd

2015-11-17 Thread Stuart Henderson
On 2015/11/15 21:47, Claudio Jeker wrote:
> On Mon, Oct 26, 2015 at 04:40:12PM +0100, Claudio Jeker wrote:
> > ospfd has some issues with self-originated networks and building summary
> > entries for those in case the router is an ABR (area border router).
> > This diff should hopefully fix all of the troubles. It changes a bit the
> > way we do nexthop calculation in the SPF/rib calculation to make sure we
> > handle self-originated networks correctly. As a side-effect it should also
> > remove the behaviour where ospfd added a OSPF route for all those
> > self-originated routes. Also the way we track active areas is changed to
> > be actually the way it should be.
> > 
> > Please test this on all ospfd setups and check for issues.
> 
> I guess nobody is using ospfd anymore. Anyway here is an updated diff that
> fixes an issue with stub networks announced by routers connected via a P2P
> link. I'm running this on our ABR router at work now and plan to commit
> this in the next days.

No regressions with this, but I flattened my areas 2 years ago (I was using
'stub redistribute default' but switched over to carrying defaults in BGP
instead) so I don't have ABRs any more.

I didn't spot any problems from reading, OK with me.



Re: Better ASR support in ospfd

2015-11-15 Thread Claudio Jeker
On Mon, Oct 26, 2015 at 04:40:12PM +0100, Claudio Jeker wrote:
> ospfd has some issues with self-originated networks and building summary
> entries for those in case the router is an ABR (area border router).
> This diff should hopefully fix all of the troubles. It changes a bit the
> way we do nexthop calculation in the SPF/rib calculation to make sure we
> handle self-originated networks correctly. As a side-effect it should also
> remove the behaviour where ospfd added a OSPF route for all those
> self-originated routes. Also the way we track active areas is changed to
> be actually the way it should be.
> 
> Please test this on all ospfd setups and check for issues.

I guess nobody is using ospfd anymore. Anyway here is an updated diff that
fixes an issue with stub networks announced by routers connected via a P2P
link. I'm running this on our ABR router at work now and plan to commit
this in the next days.

-- 
:wq Claudio

Index: area.c
===
RCS file: /cvs/src/usr.sbin/ospfd/area.c,v
retrieving revision 1.9
diff -u -p -r1.9 area.c
--- area.c  7 Jan 2009 21:16:36 -   1.9
+++ area.c  23 Oct 2015 14:22:24 -
@@ -94,19 +94,24 @@ area_find(struct ospfd_conf *conf, struc
 }
 
 void
-area_track(struct area *area, int state)
+area_track(struct area *area)
 {
-   int old = area->active;
+   int old = area->active;
+   struct iface*iface;
 
-   if (state & NBR_STA_FULL)
-   area->active++;
-   else if (area->active == 0)
-   fatalx("area_track: area already inactive");
-   else
-   area->active--;
+   area->active = 0;
+   LIST_FOREACH(iface, >iface_list, entry) {
+   if (iface->state & IF_STA_DOWN)
+   continue;
+   area->active = 1;
+   break;
+   }
 
-   if (area->active == 0 || old == 0)
+   if (area->active != old) {
+   ospfe_imsg_compose_rde(IMSG_AREA_CHANGE, area->id.s_addr, 0,
+   >active, sizeof(area->active));
ospfe_demote_area(area, old == 0);
+   }
 }
 
 int
@@ -116,7 +121,7 @@ area_border_router(struct ospfd_conf *co
int  active = 0;
 
LIST_FOREACH(area, >area_list, entry)
-   if (area->active > 0)
+   if (area->active)
active++;
 
return (active > 1);
Index: interface.c
===
RCS file: /cvs/src/usr.sbin/ospfd/interface.c,v
retrieving revision 1.79
diff -u -p -r1.79 interface.c
--- interface.c 27 Sep 2015 17:31:50 -  1.79
+++ interface.c 23 Oct 2015 14:22:24 -
@@ -136,8 +136,10 @@ if_fsm(struct iface *iface, enum iface_e
if (new_state != 0)
iface->state = new_state;
 
-   if (iface->state != old_state)
+   if (iface->state != old_state) {
+   area_track(iface->area);
orig_rtr_lsa(iface->area);
+   }
 
if (old_state & (IF_STA_MULTI | IF_STA_POINTTOPOINT) &&
(iface->state & (IF_STA_MULTI | IF_STA_POINTTOPOINT)) == 0)
Index: neighbor.c
===
RCS file: /cvs/src/usr.sbin/ospfd/neighbor.c,v
retrieving revision 1.46
diff -u -p -r1.46 neighbor.c
--- neighbor.c  17 Jan 2013 10:07:56 -  1.46
+++ neighbor.c  23 Oct 2015 14:22:24 -
@@ -204,7 +204,6 @@ nbr_fsm(struct nbr *nbr, enum nbr_event 
 * neighbor changed from/to FULL
 * originate new rtr and net LSA
 */
-   area_track(nbr->iface->area, nbr->state);
orig_rtr_lsa(nbr->iface->area);
if (nbr->iface->state & IF_STA_DR)
orig_net_lsa(nbr->iface);
Index: ospfd.h
===
RCS file: /cvs/src/usr.sbin/ospfd/ospfd.h,v
retrieving revision 1.92
diff -u -p -r1.92 ospfd.h
--- ospfd.h 27 Sep 2015 17:31:50 -  1.92
+++ ospfd.h 26 Oct 2015 13:37:36 -
@@ -104,6 +104,7 @@ enum imsg_type {
IMSG_NEIGHBOR_CAPA,
IMSG_NETWORK_ADD,
IMSG_NETWORK_DEL,
+   IMSG_AREA_CHANGE,
IMSG_DD,
IMSG_DD_END,
IMSG_DD_BADLSA,
@@ -499,6 +500,7 @@ struct ctl_rt {
enum dst_typed_type;
u_int8_t flags;
u_int8_t prefixlen;
+   u_int8_t connected;
 };
 
 struct ctl_sum {
@@ -530,7 +532,7 @@ struct demote_msg {
 struct area*area_new(void);
 int area_del(struct area *);
 struct area*area_find(struct ospfd_conf *, struct in_addr);
-voidarea_track(struct area *, int);
+voidarea_track(struct area *);
 int area_border_router(struct ospfd_conf *);
 u_int8_t

Re: Better ASR support in ospfd

2015-11-15 Thread Theo de Raadt
> On Mon, Oct 26, 2015 at 04:40:12PM +0100, Claudio Jeker wrote:
> > ospfd has some issues with self-originated networks and building summary
> > entries for those in case the router is an ABR (area border router).
> > This diff should hopefully fix all of the troubles. It changes a bit the
> > way we do nexthop calculation in the SPF/rib calculation to make sure we
> > handle self-originated networks correctly. As a side-effect it should also
> > remove the behaviour where ospfd added a OSPF route for all those
> > self-originated routes. Also the way we track active areas is changed to
> > be actually the way it should be.
> > 
> > Please test this on all ospfd setups and check for issues.
> 
> I guess nobody is using ospfd anymore.

yup, we should remove it.