summaryrefslogtreecommitdiff
path: root/ripd
diff options
context:
space:
mode:
authorAndrew J. Schorr <ajschorr@alumni.princeton.edu>2006-12-12 19:18:21 +0000
committerAndrew J. Schorr <ajschorr@alumni.princeton.edu>2006-12-12 19:18:21 +0000
commite4529636b77124285cca96a62799d0ff6a7addeb (patch)
treea8a50de7413833d5277ed7309248e03719e9efd3 /ripd
parent43cd33a44e010f818633b7f144b5a0be352b41e7 (diff)
[PtP over ethernet] New peer flag allows much more addressing flexibility
2006-12-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating whether a peer address has been configured. Comment now shows the new interpretation of the destination addr: if ZEBRA_IFA_PEER is set, then it must contain the destination address, otherwise it may contain the broadcast address or be NULL. (CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete macros that were specific to IPv4 and not fully general. (CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag. (CONNECTED_PREFIX) New macro giving the prefix to insert into the RIB: if CONNECTED_PEER, then use the destination (peer) address, else use the address field. (CONNECTED_ID) New macro to come up with an identifying address for the struct connected. * if.c: (if_lookup_address, connected_lookup_address) Streamline logic with new CONNECTED_PREFIX macro. * prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros for better performance than the general prefix_copy function. * zclient.c: (zebra_interface_address_read) For non-null destination addresses, set prefixlen to equal the address prefixlen. This is needed to get the new CONNECTED_PREFIX macro to work properly. * connected.c: (connected_up_ipv4, connected_down_ipv4, connected_up_ipv6, connected_down_ipv6) Simplify logic using the new CONNECTED_PREFIX macro. (connected_add_ipv4) Set prefixlen in destination addresses (required by the CONNECTED_PREFIX macro). Use CONNECTED_PEER macro instead of testing for IFF_POINTOPOINT. Delete invalid warning message. Warn about cases where the ZEBRA_IFA_PEER is set but no destination address has been supplied (and turn off the flag). (connected_add_ipv6) Add new flags argument so callers may set the ZEBRA_IFA_PEER flag. If peer/broadcast address satisfies IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning. Set prefixlen in destination address so CONNECTED_PREFIX will work. * connected.h: (connected_add_ipv6) Add new flags argument so callers may set the ZEBRA_IFA_PEER flag. * interface.c: (connected_dump_vty) Use CONNECTED_PEER macro to decide whether the destination address is a peer or broadcast address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT). * if_ioctl.c: (if_getaddrs) Instead of setting a peer address only when the IFF_POINTOPOINT is set, we now accept a peer address whenever it is available and not the same as the local address. Otherwise (no peer address assigned), we check for a broadcast address (regardless of the IFF_BROADCAST flag). And must now pass a flags value of ZEBRA_IFA_PEER to connected_add_ipv4 when a peer address is assigned. The same new logic is used with the IPv6 code as well (and we pass the new flags argument to connected_add_ipv6). (if_get_addr) Do not bother to check IFF_POINTOPOINT: just issue the SIOCGIFDSTADDR ioctl and see if we get back a peer address not matching the local address (and set the ZEBRA_IFA_PEER in that case). If there's no peer address, try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set. * if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl without bothering to check the IFF_POINTOPOINT flag. And if no peer address was found, just try the SIOCGLIFBRDADDR ioctl without checking the IFF_BROADCAST flag. Call connected_add_ipv4 and connected_add_ipv6 with appropriate flags. * if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to connected_add_ipv6. * kernel_socket.c: (ifam_read) Must pass new flags argument to connected_add_ipv6. * rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2 to determine local and possible peer address (so there's no longer a test for IFF_POINTOPOINT). Set ZEBRA_IFA_PEER flag appropriately. Pass new flags argument to connected_add_ipv6. (netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast to determine whether the connected destination address is a broadcast address. * bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete) Simplify logic by using new CONNECTED_PREFIX macro. * ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix, ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX macro. * ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX macro, both options collapse into the same code. * ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new CONNECTED_ID macro. (ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX macro. * ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro instead of testing the IFF_POINTOPOINT flag. * ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro instead of testing with if_is_pointopoint. And add commented-out code to implement alternative (in my opinion) more elegant behavior that has no special-case treatment for PtP addresses. (ospf_network_run) Use new CONNECTED_ID macro to simplify logic. * rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID macro to simplify logic. (rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does not give a useful result if prefixlen is 32 (we require a peer address in such cases). * ripd.c: (rip_update_interface) Fix same bug as above.
Diffstat (limited to 'ripd')
-rw-r--r--ripd/ChangeLog9
-rw-r--r--ripd/rip_interface.c15
-rw-r--r--ripd/ripd.c13
3 files changed, 23 insertions, 14 deletions
diff --git a/ripd/ChangeLog b/ripd/ChangeLog
index 68813f14..ba13a595 100644
--- a/ripd/ChangeLog
+++ b/ripd/ChangeLog
@@ -1,3 +1,12 @@
+2006-12-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID
+ macro to simplify logic.
+ (rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does
+ not give a useful result if prefixlen is 32 (we require a peer
+ address in such cases).
+ * ripd.c: (rip_update_interface) Fix same bug as above.
+
2006-09-11 Paul Jakma <paul.jakma@sun.com>
* ripd.c: (rip_read) remove gratuitous use of mid-function
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index a5b12db6..c8a1a84f 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -141,16 +141,10 @@ void
rip_interface_multicast_set (int sock, struct connected *connected)
{
struct in_addr addr;
- struct prefix_ipv4 *p;
assert (connected != NULL);
- if (if_is_pointopoint(connected->ifp) && CONNECTED_DEST_HOST(connected))
- p = (struct prefix_ipv4 *) connected->destination;
- else
- p = (struct prefix_ipv4 *) connected->address;
-
- addr = p->prefix;
+ addr = CONNECTED_ID(connected)->u.prefix4;
if (setsockopt_multicast_ipv4 (sock, IP_MULTICAST_IF, addr, 0,
connected->ifp->ifindex) < 0)
@@ -197,13 +191,16 @@ rip_request_interface_send (struct interface *ifp, u_char version)
memset (&to, 0, sizeof (struct sockaddr_in));
to.sin_port = htons (RIP_PORT_DEFAULT);
if (connected->destination)
- /* use specified broadcast or point-to-point destination addr */
+ /* use specified broadcast or peer destination addr */
to.sin_addr = connected->destination->u.prefix4;
- else
+ else if (connected->address->prefixlen < IPV4_MAX_PREFIXLEN)
/* calculate the appropriate broadcast address */
to.sin_addr.s_addr =
ipv4_broadcast_addr(connected->address->u.prefix4.s_addr,
connected->address->prefixlen);
+ else
+ /* do not know where to send the packet */
+ continue;
if (IS_RIP_DEBUG_EVENT)
zlog_debug ("SEND request to %s", inet_ntoa (to.sin_addr));
diff --git a/ripd/ripd.c b/ripd/ripd.c
index a1630f6c..afa49fd6 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -2449,19 +2449,22 @@ rip_update_interface (struct connected *ifc, u_char version, int route_type)
/* Destination address and port setting. */
memset (&to, 0, sizeof (struct sockaddr_in));
if (ifc->destination)
- /* use specified broadcast or point-to-point destination addr */
+ /* use specified broadcast or peer destination addr */
to.sin_addr = ifc->destination->u.prefix4;
- else
+ else if (ifc->address->prefixlen < IPV4_MAX_PREFIXLEN)
/* calculate the appropriate broadcast address */
to.sin_addr.s_addr =
ipv4_broadcast_addr(ifc->address->u.prefix4.s_addr,
ifc->address->prefixlen);
+ else
+ /* do not know where to send the packet */
+ return;
to.sin_port = htons (RIP_PORT_DEFAULT);
if (IS_RIP_DEBUG_EVENT)
- zlog_debug ("%s announce to %s on %s",
- if_is_pointopoint (ifc->ifp) ? "unicast" : "broadcast",
- inet_ntoa (to.sin_addr), ifc->ifp->name);
+ zlog_debug("%s announce to %s on %s",
+ CONNECTED_PEER(ifc) ? "unicast" : "broadcast",
+ inet_ntoa (to.sin_addr), ifc->ifp->name);
rip_output_process (ifc, &to, route_type, version);
}