? quagga-0.96.2 ? bgpd/rserver-todo.txt Index: bgpd/bgp_nexthop.c =================================================================== RCS file: /var/cvsroot/quagga/bgpd/bgp_nexthop.c,v retrieving revision 1.3 diff -u -w -b -r1.3 bgp_nexthop.c --- bgpd/bgp_nexthop.c 28 Apr 2003 17:11:02 -0000 1.3 +++ bgpd/bgp_nexthop.c 29 Sep 2003 19:51:03 -0000 @@ -663,7 +663,7 @@ p.family = AF_INET; p.prefixlen = addr->prefixlen; - if (ifc_pointopoint (ifc)) + if (if_is_pointopoint (ifp)) p.u.prefix4 = dest->u.prefix4; else p.u.prefix4 = addr->u.prefix4; @@ -694,7 +694,7 @@ p.family = AF_INET6; p.prefixlen = addr->prefixlen; - if (ifc_pointopoint (ifc)) + if (if_is_pointopoint (ifp)) p.u.prefix6 = dest->u.prefix6; else p.u.prefix6 = addr->u.prefix6; @@ -748,7 +748,7 @@ p.family = AF_INET; p.prefixlen = addr->prefixlen; - if (ifc_pointopoint (ifc)) + if (if_is_pointopoint (ifp)) p.u.prefix4 = dest->u.prefix4; else p.u.prefix4 = addr->u.prefix4; @@ -779,7 +779,7 @@ p.family = AF_INET6; p.prefixlen = addr->prefixlen; - if (ifc_pointopoint (ifc)) + if (if_is_pointopoint (ifp)) p.u.prefix6 = dest->u.prefix6; else p.u.prefix6 = addr->u.prefix6; Index: lib/if.c =================================================================== RCS file: /var/cvsroot/quagga/lib/if.c,v retrieving revision 1.12 diff -u -w -b -r1.12 if.c --- lib/if.c 23 Sep 2003 23:46:01 -0000 1.12 +++ lib/if.c 29 Sep 2003 19:51:03 -0000 @@ -245,13 +245,11 @@ listnode node; struct prefix addr; struct prefix best; - struct prefix peer; listnode cnode; struct interface *ifp; struct prefix *p; struct connected *c; struct interface *match; - int prefixlen; /* Zero structures - get rid of rubbish from stack */ memset(&addr, 0, sizeof(addr)); @@ -270,24 +268,34 @@ for (cnode = listhead (ifp->connected); cnode; nextnode (cnode)) { c = getdata (cnode); - p = c->address; - if (p->family == AF_INET) + if (if_is_pointopoint (ifp)) { - prefixlen = p->prefixlen; + p = c->address; - if (if_is_pointopoint (ifp) || - prefixlen >= IPV4_MAX_PREFIXLEN - 1) + if (p && p->family == AF_INET) { - peer = *c->destination; - peer.prefixlen = prefixlen; - p = &peer; +#ifdef OLD_RIB /* PTP links are conventionally identified + by the address of the far end - MAG */ + if (IPV4_ADDR_SAME (&p->u.prefix4, &src)) + return ifp; +#endif + p = c->destination; + if (p && IPV4_ADDR_SAME (&p->u.prefix4, &src)) + return ifp; } + } + else + { + p = c->address; - if (prefix_match (p, &addr) && prefixlen > best.prefixlen) + if (p->family == AF_INET) + { + if (prefix_match (p, &addr) && p->prefixlen > best.prefixlen) { best = *p; match = ifp; + } } } } Index: ospfd/ospf_snmp.c =================================================================== RCS file: /var/cvsroot/quagga/ospfd/ospf_snmp.c,v retrieving revision 1.6 diff -u -w -b -r1.6 ospf_snmp.c --- ospfd/ospf_snmp.c 19 Jun 2003 01:21:07 -0000 1.6 +++ ospfd/ospf_snmp.c 29 Sep 2003 19:51:04 -0000 @@ -1440,7 +1440,7 @@ /* Lookup first IPv4 address entry. */ LIST_LOOP (ifp->connected, ifc, nn) { - if (ifc_pointopoint (ifc)) + if (if_is_pointopoint (ifp)) p = ifc->destination; else p = ifc->address; Index: ospfd/ospfd.c =================================================================== RCS file: /var/cvsroot/quagga/ospfd/ospfd.c,v retrieving revision 1.15 diff -u -w -b -r1.15 ospfd.c --- ospfd/ospfd.c 27 Aug 2003 06:45:32 -0000 1.15 +++ ospfd/ospfd.c 29 Sep 2003 19:51:05 -0000 @@ -714,7 +714,7 @@ * PtP special case: network specified == iface peer addr -> ospf */ return ( - ((ifc_pointopoint (co) && + ((if_is_pointopoint (co) && IPV4_ADDR_SAME ( &(co->destination->u.prefix4), &(net->u.prefix4))) || prefix_match (net, co->address)) ? 1 : 0 @@ -756,7 +756,7 @@ if (CHECK_FLAG(co->flags,ZEBRA_IFA_SECONDARY)) continue; - if (ifc_pointopoint (co)) + if (if_is_pointopoint (co)) addr = co->destination; else addr = co->address; Index: ripd/rip_interface.c =================================================================== RCS file: /var/cvsroot/quagga/ripd/rip_interface.c,v retrieving revision 1.11 diff -u -w -b -r1.11 rip_interface.c --- ripd/rip_interface.c 23 Sep 2003 23:41:50 -0000 1.11 +++ ripd/rip_interface.c 29 Sep 2003 19:51:06 -0000 @@ -396,6 +396,106 @@ return count; } + + + + +/* Does this address belongs to me ? */ +int +if_check_address (struct in_addr addr) +{ + listnode node; + + for (node = listhead (iflist); node; nextnode (node)) + { + listnode cnode; + struct interface *ifp; + + ifp = getdata (node); + + for (cnode = listhead (ifp->connected); cnode; nextnode (cnode)) + { + struct connected *connected; + struct prefix_ipv4 *p; + + connected = getdata (cnode); + p = (struct prefix_ipv4 *) connected->address; + + if (p->family != AF_INET) + continue; + + if (IPV4_ADDR_CMP (&p->prefix, &addr) == 0) + return 1; + } + } + return 0; +} + +/* is this address from a valid neighbor? (RFC2453 - Sec. 3.9.2) */ +int +if_valid_neighbor (struct in_addr addr) +{ + listnode node; + struct connected *connected = NULL; + struct prefix_ipv4 *p; + + for (node = listhead (iflist); node; nextnode (node)) + { + listnode cnode; + struct interface *ifp; + + ifp = getdata (node); + + for (cnode = listhead (ifp->connected); cnode; nextnode (cnode)) + { + struct prefix *pxn = NULL; /* Prefix of the neighbor */ + struct prefix *pxc = NULL; /* Prefix of the connected network */ + + connected = getdata (cnode); + + if (if_is_pointopoint (ifp)) + { + p = (struct prefix_ipv4 *) connected->address; + + if (p && p->family == AF_INET) + { + if (IPV4_ADDR_SAME (&p->prefix, &addr)) + return 1; + + p = (struct prefix_ipv4 *) connected->destination; + if (p && IPV4_ADDR_SAME (&p->prefix, &addr)) + return 1; + } + } + else + { + p = (struct prefix_ipv4 *) connected->address; + + if (p->family != AF_INET) + continue; + + pxn = prefix_new(); + pxn->family = AF_INET; + pxn->prefixlen = 32; + pxn->u.prefix4 = addr; + + pxc = prefix_new(); + prefix_copy(pxc, (struct prefix *) p); + apply_mask(pxc); + + if (prefix_match (pxc, pxn)) + { + prefix_free (pxn); + prefix_free (pxc); + return 1; + } + prefix_free(pxc); + prefix_free(pxn); + } + } + } + return 0; +} /* Inteface link down message processing. */ int Index: ripd/ripd.c =================================================================== RCS file: /var/cvsroot/quagga/ripd/ripd.c,v retrieving revision 1.9 diff -u -w -b -r1.9 ripd.c --- ripd/ripd.c 8 Jun 2003 21:22:18 -0000 1.9 +++ ripd/ripd.c 29 Sep 2003 19:51:07 -0000 @@ -1017,7 +1017,7 @@ /* The datagram's IPv4 source address should be checked to see whether the datagram is from a valid neighbor; the source of the datagram must be on a directly connected network */ - if (if_lookup_address (from->sin_addr) == NULL) + if (! if_valid_neighbor (from->sin_addr)) { zlog_info ("This datagram doesn't came from a valid neighbor: %s", inet_ntoa (from->sin_addr)); @@ -1602,7 +1602,7 @@ } /* Check is this packet comming from myself? */ - if (if_lookup_exact_address (from.sin_addr)) + if (if_check_address (from.sin_addr)) { if (IS_RIP_DEBUG_PACKET) zlog_warn ("ignore packet comes from myself"); Index: ripd/ripd.h =================================================================== RCS file: /var/cvsroot/quagga/ripd/ripd.h,v retrieving revision 1.6 diff -u -w -b -r1.6 ripd.h --- ripd/ripd.h 7 Jun 2003 01:10:00 -0000 1.6 +++ ripd/ripd.h 29 Sep 2003 19:51:07 -0000 @@ -374,6 +374,8 @@ void rip_zclient_start (); void rip_zclient_reset (); void rip_offset_init (); +int if_check_address (struct in_addr addr); +int if_valid_neighbor (struct in_addr addr); int rip_request_send (struct sockaddr_in *, struct interface *, u_char); int rip_neighbor_lookup (struct sockaddr_in *); Index: zebra/connected.c =================================================================== RCS file: /var/cvsroot/quagga/zebra/connected.c,v retrieving revision 1.5 diff -u -w -b -r1.5 connected.c --- zebra/connected.c 25 May 2003 21:05:46 -0000 1.5 +++ zebra/connected.c 29 Sep 2003 19:51:08 -0000 @@ -69,7 +69,7 @@ p.prefixlen = addr->prefixlen; /* Point-to-point check. */ - if (ifc_pointopoint (ifc) && dest) + if (if_is_pointopoint (ifc) && dest) p.prefix = dest->prefix; else p.prefix = addr->prefix; @@ -163,7 +163,7 @@ p.prefixlen = addr->prefixlen; /* Point-to-point check. */ - if (dest && ifc_pointopoint (ifc)) + if (dest && if_is_pointopoint (ifc)) p.prefix = dest->prefix; else p.prefix = addr->prefix; @@ -250,7 +250,7 @@ p.family = AF_INET6; p.prefixlen = addr->prefixlen; - if (ifc_pointopoint (ifc) && dest) + if (if_is_pointopoint (ifp) && dest) { if (IN6_IS_ADDR_UNSPECIFIED (&dest->prefix)) p.prefix = addr->prefix; @@ -343,7 +343,7 @@ p.family = AF_INET6; p.prefixlen = addr->prefixlen; - if (ifc_pointopoint (ifc) && dest) + if (if_is_pointopoint (ifp) && dest) { if (IN6_IS_ADDR_UNSPECIFIED (&dest->prefix)) p.prefix = addr->prefix; Index: zebra/rt_netlink.c =================================================================== RCS file: /var/cvsroot/quagga/zebra/rt_netlink.c,v retrieving revision 1.14 diff -u -w -b -r1.14 rt_netlink.c --- zebra/rt_netlink.c 15 Jul 2003 12:52:22 -0000 1.14 +++ zebra/rt_netlink.c 29 Sep 2003 19:51:08 -0000 @@ -487,7 +487,6 @@ void *broad = NULL; u_char flags = 0; char *label = NULL; - int peeronly = 0; ifa = NLMSG_DATA (h); @@ -540,38 +539,39 @@ zlog_info (" IFA_LABEL %s", RTA_DATA (tb[IFA_LABEL])); } - /* peer or broadcast network? */ - if (ifa->ifa_family == AF_INET) - peeronly = if_is_pointopoint (ifp) || - ifa->ifa_prefixlen >= IPV4_MAX_PREFIXLEN - 1; -#ifdef HAVE_IPV6 - if (ifa->ifa_family == AF_INET6) + if (tb[IFA_ADDRESS] == NULL) + tb[IFA_ADDRESS] = tb[IFA_LOCAL]; + + if (ifp->flags & IFF_POINTOPOINT) + { + if (tb[IFA_LOCAL]) { - peeronly = if_is_pointopoint (ifp) || - ifa->ifa_prefixlen >= IPV6_MAX_PREFIXLEN - 1; + addr = RTA_DATA (tb[IFA_LOCAL]); + if (tb[IFA_ADDRESS]) + broad = RTA_DATA (tb[IFA_ADDRESS]); + else + broad = NULL; } -#endif /* HAVE_IPV6 */ - if (!(tb[IFA_LOCAL] && tb[IFA_ADDRESS])) + else { - /* FIXME: IPv6 Appears to have only IFA_ADDRESS */ - peeronly = 0; + if (tb[IFA_ADDRESS]) + addr = RTA_DATA (tb[IFA_ADDRESS]); + else + addr = NULL; } - - /* network. prefixlen applies to IFA_ADDRESS rather than IFA_LOCAL */ - if (tb[IFA_ADDRESS] && !peeronly) + } + else + { + if (tb[IFA_ADDRESS]) addr = RTA_DATA (tb[IFA_ADDRESS]); - else if (tb[IFA_LOCAL]) - addr = RTA_DATA (tb[IFA_LOCAL]); else addr = NULL; - /* broadcast/peer */ if (tb[IFA_BROADCAST]) broad = RTA_DATA (tb[IFA_BROADCAST]); - else if (tb[IFA_ADDRESS] && peeronly) - broad = RTA_DATA (tb[IFA_ADDRESS]); /* peer address specified */ else broad = NULL; + } /* Flags. */ if (ifa->ifa_flags & IFA_F_SECONDARY)