>
> > > > Other packets are sent to the neighbor IP address, which is a slight
> > > > diversion from RFC 2328, but should not cause any problems.
> > >
> > > But a stricter router may reject OSPF msg over an ptp links if
> > > they aren't addressed to AllSPFRouters.
> >
> > I just noticed you impl. a PTMP I/F type, nice :)
>
> I updated to new nexhp calc. patch to match your latest
> changes. I hope you like it.

Did some more spf improvements. Lets see if you like these too:

>From ebb34c0fea546fbade7c72455253c84467d05c7c Mon Sep 17 00:00:00 2001
From: Joakim Tjernlund <joakim.tjernl...@transmode.se>
Date: Mon, 27 Dec 2010 19:26:15 +0100
Subject: [PATCH] ospf: Improve calc_next_hop()

Using the new ospf_pos_to_ifa(), calc_next_hop() can be cleaned up
and improved further.

Signed-off-by: Joakim Tjernlund <joakim.tjernl...@transmode.se>
---
 proto/ospf/rt.c |   49 +++++++++++++++++++++++++------------------------
 1 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c
index 84fea16..d851616 100644
--- a/proto/ospf/rt.c
+++ b/proto/ospf/rt.c
@@ -1350,37 +1350,38 @@ calc_next_hop(struct ospf_area *oa, struct 
top_hash_entry *en,
   if (inherit_nexthops(pn))
     return pn;

-  /*
+  /*
    * There are three cases:
    * 1) en is a local network (and par is root)
    * 2) en is a ptp or ptmp neighbor (and par is root)
    * 3) en is a bcast or nbma neighbor (and par is local network)
    */

-  /* The first case - local network */
-  if ((en->lsa.type == LSA_T_NET) && (par == oa->rt))
-  {
-    ifa = ospf_pos_to_ifa(oa, pos);
-    if (!ifa)
-        return NULL;
+  if (par == oa->rt) { /* par is root ? */
+      if (rtl->type == LSART_VLNK) /* en->lsa.type == LSA_T_RT needed ? */
+         return new_nexthop(po, IPA_NONE, NULL, 0); /* No iface ? */

-    return new_nexthop(po, IPA_NONE, ifa->iface, ifa->ecmp_weight);
-  }
+      ifa = ospf_pos_to_ifa(oa, pos);
+      if (!ifa)
+         goto bad;

-  /* The second case - ptp or ptmp neighbor */
-  if ((en->lsa.type == LSA_T_RT) && (par == oa->rt))
-  {
-    if (rtl->type == LSART_VLNK)
-      return new_nexthop(po, IPA_NONE, NULL, 0);
-    ifa = ospf_pos_to_ifa(oa, pos);
-    if (!ifa)
-        return NULL;
-    {
-        struct ospf_neighbor *m = find_neigh(ifa, rid);
-        if (m && (m->state == NEIGHBOR_FULL))
-             return new_nexthop(po, m->ip, ifa->iface, ifa->ecmp_weight);
-    }
-    return NULL;
+      /* The first case - local network */
+      if (en->lsa.type == LSA_T_NET)
+         return new_nexthop(po, IPA_NONE, ifa->iface, ifa->ecmp_weight);
+
+      /* The second case - ptp or ptmp neighbor */
+      if (en->lsa.type == LSA_T_RT)
+      {
+         if (ifa->type == OSPF_IT_PTP)
+             return new_nexthop(po, ifa->addr->opposite, ifa->iface,
+                                ifa->ecmp_weight);
+         else { /* must be PTMP */
+             struct ospf_neighbor *m = find_neigh(ifa, rid);
+             if (m && (m->state == NEIGHBOR_FULL))
+                 return new_nexthop(po, m->ip, ifa->iface, ifa->ecmp_weight);
+         }
+      }
+      goto bad;
   }

   /* The third case - bcast or nbma neighbor */
@@ -1396,7 +1397,7 @@ calc_next_hop(struct ospf_area *oa, struct top_hash_entry 
*en,
      * already computed in link_back().
      */
     if (ipa_zero(en->lb))
-      goto bad;
+      return NULL; /* This is not "bad", may happen intermittent. */

     return new_nexthop(po, en->lb, pn->iface, pn->weight);

--
1.7.2.5

Reply via email to