From 3fb9cd6ef456959b6eff939d5c316f6785c2dda4 Mon Sep 17 00:00:00 2001 From: hasso Date: Tue, 19 Oct 2004 19:44:43 +0000 Subject: OK. Here it is - PtP patch from Andrew J. Schorr. No problems with ospfd, ripd might need some more testing though. --- ospfd/ChangeLog | 13 +++++++++++++ ospfd/ospf_interface.c | 40 ++++++++++++++++++++++++++++++---------- ospfd/ospf_lsa.c | 2 +- ospfd/ospf_snmp.c | 2 +- ospfd/ospf_vty.c | 5 +++++ ospfd/ospfd.c | 34 ++++++++++------------------------ 6 files changed, 60 insertions(+), 36 deletions(-) (limited to 'ospfd') diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog index 914ed930..31ee303d 100644 --- a/ospfd/ChangeLog +++ b/ospfd/ChangeLog @@ -1,3 +1,16 @@ +2004-10-19 Andrew J. Schorr + + * ospf_snmp.c: (ospf_snmp_if_update) Fix logic to handle PtP links + with dedicated subnets properly. + * ospf_lsa.c: (lsa_link_ptop_set) ditto. + * ospfd.c: (ospf_network_match_iface) ditto. + (ospf_network_run) ditto. + * ospf_interface.c: (ospf_if_is_configured) ditto. + (ospf_if_lookup_by_prefix) ditto. + (ospf_if_lookup_recv_if) ditto. + * ospf_vty.c: (show_ip_ospf_interface_sub) Display the peer or + broadcast address if present. + 2004-10-13 Hasso Tepper * ospf_main.c: Unbreak compilation with ospfapi disabled. diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 277d508b..e74c375a 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -338,27 +338,45 @@ ospf_if_free (struct ospf_interface *oi) /* * check if interface with given address is configured and -* return it if yes. +* return it if yes. special treatment for PtP networks. */ struct ospf_interface * ospf_if_is_configured (struct ospf *ospf, struct in_addr *address) { struct listnode *node; struct ospf_interface *oi; - struct prefix *addr; + struct prefix_ipv4 addr; + + addr.family = AF_INET; + addr.prefix = *address; + addr.prefixlen = IPV4_MAX_PREFIXLEN; for (node = listhead (ospf->oiflist); node; nextnode (node)) if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK) { if (oi->type == OSPF_IFTYPE_POINTOPOINT) - addr = oi->connected->destination; + { + if (CONNECTED_DEST_HOST(oi->connected)) + { + /* match only destination addr, since local addr is most likely + * not unique (borrowed from another interface) */ + if (IPV4_ADDR_SAME (address, + &oi->connected->destination->u.prefix4)) + return oi; + } + else + { + /* special leniency: match if addr is anywhere on PtP subnet */ + if (prefix_match(oi->address,(struct prefix *)&addr)) + return oi; + } + } else - addr = oi->address; - - if (IPV4_ADDR_SAME (address, &addr->u.prefix4)) - return oi; + { + if (IPV4_ADDR_SAME (address, &oi->address->u.prefix4)) + return oi; + } } - return NULL; } @@ -417,7 +435,8 @@ ospf_if_lookup_by_prefix (struct ospf *ospf, struct prefix_ipv4 *p) { if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK) { - if (oi->type == OSPF_IFTYPE_POINTOPOINT) + if ((oi->type == OSPF_IFTYPE_POINTOPOINT) && + CONNECTED_DEST_HOST(oi->connected)) { prefix_copy (&ptmp, oi->connected->destination); ptmp.prefixlen = IPV4_MAX_BITLEN; @@ -454,7 +473,8 @@ ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src) if (oi->type == OSPF_IFTYPE_VIRTUALLINK) continue; - if (oi->type == OSPF_IFTYPE_POINTOPOINT) + if ((oi->type == OSPF_IFTYPE_POINTOPOINT) && + CONNECTED_DEST_HOST(oi->connected)) { if (IPV4_ADDR_SAME (&oi->connected->destination->u.prefix4, &src)) return oi; diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 3ad6ddf0..f1478a3d 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -517,7 +517,7 @@ lsa_link_ptop_set (struct stream *s, struct ospf_interface *oi) links++; } - if (oi->connected->destination != NULL) + if (CONNECTED_DEST_HOST(oi->connected)) { /* Option 1: link_type = LSA_LINK_TYPE_STUB; diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index db0aaf6e..0cf257da 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -1435,7 +1435,7 @@ ospf_snmp_if_update (struct interface *ifp) /* Lookup first IPv4 address entry. */ LIST_LOOP (ifp->connected, ifc, nn) { - if (if_is_pointopoint (ifp)) + if (CONNECTED_POINTOPOINT_HOST(ifc)) p = ifc->destination; else p = ifc->address; diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0ecb6fb4..c84da747 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2550,6 +2550,11 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, vty_out (vty, " Internet Address %s/%d,", inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); + if (oi->connected->destination) + vty_out (vty, " %s %s,", + ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"), + inet_ntoa (oi->connected->destination->u.prefix4)); + vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), VTY_NEWLINE); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 0a988e0f..054c3316 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -686,31 +686,17 @@ ospf_network_match_iface(struct connected *co, struct prefix *net) * PtP special case: network specified == iface peer addr -> ospf */ - /* For PtP, match if peer address matches network address exactly. - * This can be addr/32 or addr/p for p < 32, but the addr must match - * exactly; this is not a test for falling within the prefix. This + /* For PtP, match if peer address matches network address exactly + * in situations where the peer address is available and the prefix + * length is 32 (i.e. a dedicated subnet has not been assigned). + * This is not a test for falling within the prefix. This * test is solely for compatibility with zebra. - */ - if (if_is_pointopoint (co->ifp) && - IPV4_ADDR_SAME ( &(co->destination->u.prefix4), &(net->u.prefix4))) - return 1; - -#if 0 - /* Decline to accept PtP if dst address does not match the - * prefix. (ifdefed out because this is a workaround, not the - * desired behavior.) */ - if (if_is_pointopoint (co->ifp) && - ! prefix_match (net, co->destination)) - return 0; -#endif - - /* If the address is within the prefix, accept. Note that this - * applies to PtP as well as other types. + * + * If not PtP, accept if the address is within the prefix. */ - if (prefix_match (net, co->address)) - return 1; - - return 0; /* no match */ + return CONNECTED_POINTOPOINT_HOST(co) ? + IPV4_ADDR_SAME ( &(co->destination->u.prefix4), &(net->u.prefix4)) : + prefix_match (net, co->address); } void @@ -748,7 +734,7 @@ ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area) if (CHECK_FLAG(co->flags,ZEBRA_IFA_SECONDARY)) continue; - if (if_is_pointopoint (co->ifp)) + if (CONNECTED_POINTOPOINT_HOST(co)) addr = co->destination; else addr = co->address; -- cgit v1.2.1