summaryrefslogtreecommitdiff
path: root/proto/ospf/iface.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2020-05-26 18:21:43 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2020-05-26 18:21:43 +0200
commitc1632ad0f39f7221d649a9e469cacc38105528e2 (patch)
tree02567e33e3d6c06954ef35cd65aceb19e18b2c3a /proto/ospf/iface.c
parent1ca7665fa4a9858a6d4c591ccff5b61e5e6aed13 (diff)
OSPF: Fix handling of unnumbered PtPs
This issue has a long history. In 2012, we changed data field for unnumbered PtP links from iface id (specified by RFC) to IP address based on reports of bugs in Quagga that required it, and we used out-of-band information to distinquish unnumberred PtPs with the same local IP address. Then with OSPF graceful restart implementation, we found that we can no longer use out-of-band information, and we need to use only LSAdb info for routing table calculation, but i forgot to finish handling of this case, so multiple unnumbered PtPs with the same local IP addresses were broken. Considering that even recent Mikrotik RouterOS has broken next hop calculation that depends on IP address in PtP link data field, we cannot just switch back to the iface id for unnumbered PtP links. The patch makes two changes: First, it goes back to use out-of-band (position) info for distinguishing local interfaces in SPF when graceful restart is not enabled, while still uses LSAdb-only approach for SPF calculation when graceful restart is enabled. Second, it adds OSPF interface option 'ptp address', which controls whether IP address or iface id is used in data field. It is enabled by default except for unnumbered PtP links with enabled graceful restart. Thanks to Kenth Eriksson for the bugreport and Joakim Tjernlund for suggestions.
Diffstat (limited to 'proto/ospf/iface.c')
-rw-r--r--proto/ospf/iface.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index d58747c6..666140b5 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -602,6 +602,11 @@ ospf_iface_new(struct ospf_area *oa, struct ifa *addr, struct ospf_iface_patt *i
if (ip->ptp_netmask < 2)
ifa->ptp_netmask = ip->ptp_netmask;
+ /* For compatibility, we may use ptp_address even for unnumbered links */
+ ifa->ptp_address = !(addr->flags & IA_PEER) || (p->gr_mode != OSPF_GR_ABLE);
+ if (ip->ptp_address < 2)
+ ifa->ptp_address = ip->ptp_address;
+
ifa->drip = ifa->bdrip = ospf_is_v2(p) ? IPA_NONE4 : IPA_NONE6;
ifa->type = ospf_iface_classify(ip->type, addr);
@@ -1004,6 +1009,29 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
ospf_notify_link_lsa(ifa);
}
+ /* PtP netmask */
+ int new_ptp_netmask = (new->ptp_netmask < 2) ? new->ptp_netmask :
+ !(ifa->addr->flags & IA_PEER);
+ if (ifa->ptp_netmask != new_ptp_netmask)
+ {
+ OSPF_TRACE(D_EVENTS, "Changing PtP netmask option of %s from %d to %d",
+ ifname, ifa->ptp_netmask, new_ptp_netmask);
+ ifa->ptp_netmask = new_ptp_netmask;
+ }
+
+ /* PtP address */
+ int new_ptp_address = (new->ptp_address < 2) ? new->ptp_address :
+ (!(ifa->addr->flags & IA_PEER) || (p->gr_mode != OSPF_GR_ABLE));
+ if (ifa->ptp_address != new_ptp_address)
+ {
+ /* Keep it silent for implicit changes */
+ if (new->ptp_address < 2)
+ OSPF_TRACE(D_EVENTS, "Changing PtP address option of %s from %d to %d",
+ ifname, ifa->ptp_address, new_ptp_address);
+
+ ifa->ptp_address = new_ptp_address;
+ }
+
/* BFD */
if (ifa->bfd != new->bfd)
{