]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
OSPF: Packets on PtP networks should be always sent to AllSPFRouters
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Sun, 9 May 2021 13:16:13 +0000 (15:16 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Sun, 9 May 2021 13:26:13 +0000 (15:26 +0200)
As specified in RFC 2328 8.1: "On physical point-to-point networks,
the IP destination is always set to the address AllSPFRouters."

Note that this likely break setups with multiple neighbors on a network
configured as PtP, which worked before. These should be configured as
PtMP.

Thanks to Senthil Kumar Nagappan for the original patch and to Joakim
Tjernlund for suggestions.

proto/ospf/dbdes.c
proto/ospf/lsack.c
proto/ospf/lsreq.c
proto/ospf/lsupd.c
proto/ospf/ospf.h
proto/ospf/packet.c

index 5a5f76f8858615045c3304d0b2b83ba185d7f4b4..6d33bf8e05b11403980ebc2f3b65489ca3365b54 100644 (file)
@@ -194,7 +194,7 @@ ospf_do_send_dbdes(struct ospf_proto *p, struct ospf_neighbor *n)
   OSPF_PACKET(ospf_dump_dbdes, n->ldd_buffer,
              "DBDES packet sent to nbr %R on %s", n->rid, ifa->ifname);
   sk_set_tbuf(ifa->sk, n->ldd_buffer);
-  ospf_send_to(ifa, n->ip);
+  ospf_send_to_nbr(ifa, n);
   sk_set_tbuf(ifa->sk, NULL);
 }
 
index 1654953f72931f57caf1af4e9dbb0eff6bd3b5c3..4eec536dc4a6a616de170da184cdbe0e9c67d29d 100644 (file)
@@ -110,7 +110,7 @@ ospf_send_lsack_(struct ospf_proto *p, struct ospf_neighbor *n, int queue)
   if (queue == ACKL_DIRECT)
   {
     OSPF_PACKET(ospf_dump_lsack, pkt, "LSACK packet sent to nbr %R on %s", n->rid, ifa->ifname);
-    ospf_send_to(ifa, n->ip);
+    ospf_send_to_nbr(ifa, n);
   }
   else
   {
index 45af7533c39a6a5279a9402f6fca1636a3f59d66..05c0e039de1b8865e39efcfddab90742fd5d74de 100644 (file)
@@ -89,7 +89,7 @@ ospf_send_lsreq(struct ospf_proto *p, struct ospf_neighbor *n)
   pkt->length = htons(length);
 
   OSPF_PACKET(ospf_dump_lsreq, pkt, "LSREQ packet sent to nbr %R on %s", n->rid, ifa->ifname);
-  ospf_send_to(ifa, n->ip);
+  ospf_send_to_nbr(ifa, n);
 }
 
 
index 66017a2e28407b0d422dcc4652215aba502a182d..54c4a0696df33506a13212d3b53119764a08b575 100644 (file)
@@ -420,7 +420,7 @@ ospf_send_lsupd(struct ospf_proto *p, struct top_hash_entry **lsa_list, uint lsa
     OSPF_PACKET(ospf_dump_lsupd, ospf_tx_buffer(ifa),
                "LSUPD packet sent to nbr %R on %s", n->rid, ifa->ifname);
 
-    ospf_send_to(ifa, n->ip);
+    ospf_send_to_nbr(ifa, n);
   }
 
   return i;
index aa7d937e9b9a113b7d0289e2cd11a43eb33780df..fd2347e5539e494f25e5826b3d97fbe9f57d832b 100644 (file)
@@ -1058,6 +1058,9 @@ void ospf_verr_hook(sock *sk, int err);
 void ospf_send_to(struct ospf_iface *ifa, ip_addr ip);
 void ospf_send_to_iface(struct ospf_iface *ifa);
 
+static inline void ospf_send_to_nbr(struct ospf_iface *ifa, struct ospf_neighbor *n)
+{ ospf_send_to(ifa, (ifa->type == OSPF_IT_PTP) ? ifa->all_routers :  n->ip); }
+
 static inline void ospf_send_to_all(struct ospf_iface *ifa)
 { ospf_send_to(ifa, ifa->all_routers); }
 
index 1f471d7933a68c4f849b2a5b8099286d6266aca7..15242318563616d8f85d26078af9ba83e2c5fec7 100644 (file)
@@ -695,6 +695,14 @@ ospf_send_to_adjacent(struct ospf_iface *ifa)
 void
 ospf_send_to_iface(struct ospf_iface *ifa)
 {
+  /*
+   * Send packet to (relevant) neighbors on iface
+   *
+   * On broadcast networks, destination is either AllSPFRouters, or AllDRouters.
+   * On PtP networks, destination is always AllSPFRouters. On non-broadcast
+   * networks, packets are sent as unicast to every adjacent neighbor.
+   */
+
   if (ifa->type == OSPF_IT_BCAST)
   {
     if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
@@ -702,6 +710,8 @@ ospf_send_to_iface(struct ospf_iface *ifa)
     else
       ospf_send_to_designated(ifa);
   }
+  else if (ifa->type == OSPF_IT_PTP)
+    ospf_send_to_all(ifa);
   else /* Non-broadcast */
     ospf_send_to_adjacent(ifa);
 }