From b9d92881f5d45601c4268d99baec8835068b73c2 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Fri, 28 Apr 2006 16:22:36 +0000 Subject: [ripd] Fix logic to send updates on all connected addresses. 2006-04-28 Andrew J. Schorr * ripd.c: (rip_update_process) Try to fix the logic for sending an updated on each connected network. The new code will attempt to send the update on each connected network, whereas the previous code seemed to be attempting to avoid sending more than one RIPv1 update on a given interface, but was coded incorrectly. The actual effect of the old code was to send an update only on the first connected address in the cases where the interface is not multicast, or RIPv2 is not being used. --- ripd/ripd.c | 48 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index c8aa5221..e91adb84 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2498,42 +2498,28 @@ rip_update_process (int route_type) if (ri->running) { + /* + * If there is no version configuration in the interface, + * use rip's version setting. + */ + int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? + rip->version_send : ri->ri_send); + if (IS_RIP_DEBUG_EVENT) - { - if (ifp->name) - zlog_debug ("SEND UPDATE to %s ifindex %d", - ifp->name, ifp->ifindex); - else - zlog_debug ("SEND UPDATE to _unknown_ ifindex %d", - ifp->ifindex); - } + zlog_debug("SEND UPDATE to %s ifindex %d", + (ifp->name ? ifp->name : "_unknown_"), ifp->ifindex); /* send update on each connected network */ for (ALL_LIST_ELEMENTS (ifp->connected, ifnode, ifnnode, connected)) { - struct prefix_ipv4 *ifaddr; - int done = 0; - /* - * If there is no version configuration in the interface, - * use rip's version setting. - */ - int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? - rip->version_send : ri->ri_send); - - ifaddr = (struct prefix_ipv4 *) connected->address; - - if (ifaddr->family != AF_INET) - continue; - - if ((vsend & RIPv1) && !done) - rip_update_interface (connected, RIPv1, route_type); - if ((vsend & RIPv2) && if_is_multicast(ifp)) - rip_update_interface (connected, RIPv2, route_type); - done = 1; - if (!(vsend & RIPv2) || !if_is_multicast(ifp)) - break; - - } + if (connected->address->family == AF_INET) + { + if (vsend & RIPv1) + rip_update_interface (connected, RIPv1, route_type); + if ((vsend & RIPv2) && if_is_multicast(ifp)) + rip_update_interface (connected, RIPv2, route_type); + } + } } } -- cgit v1.2.3 From 15a2b089ced3f1e956659e9ca88af45d1c48272c Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 4 May 2006 07:36:34 +0000 Subject: [ripd] bugs #261, #262: Fix RIPv1 info-leak and unauthenticated route updates 2006-05-04 Paul Jakma * (general) Fixes for bugs #261 and 262. Thanks to Konstantin V. Gavrilenko for the problem reports, testing of a series of proposed patches and comment on the proposed changes in behaviour. * rip_interface.c: (ip_rip_authentication_mode_cmd) Parse all of the command before making any changes to configured state. * ripd.c: (rip_read) RIP version control should be absolute and always apply, fixes bug #261 by allowing RIPv1 to be disabled. Fix bug #262: If authentication is enabled, then unauthenticated packets should not be accepted. We do however make an exception for RIPv1 REQUEST packets, to which we will reply as RIPv1 can now be disabled fully, to allow ripd to still provide routing /information/ to simple devices. --- ripd/ripd.c | 205 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 103 insertions(+), 102 deletions(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index e91adb84..518e4861 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -1936,35 +1936,29 @@ rip_read (struct thread *t) return -1; } - /* RIP Version check. */ - if (packet->command == RIP_RESPONSE) + /* RIP Version check. RFC2453, 4.6 and 5.1 */ + int vrecv = ((ri->ri_receive == RI_RIP_UNSPEC) ? + rip->version_recv : ri->ri_receive); + if ((packet->version == RIPv1) && !(vrecv & RIPv1)) { - int vrecv = ((ri->ri_receive == RI_RIP_UNSPEC) ? - rip->version_recv : ri->ri_receive); - if (packet->version == RIPv1) - if (! (vrecv & RIPv1)) - { - if (IS_RIP_DEBUG_PACKET) - zlog_debug (" packet's v%d doesn't fit to if version spec", - packet->version); - rip_peer_bad_packet (&from); - return -1; - } - if (packet->version == RIPv2) - if (! (vrecv & RIPv2)) - { - if (IS_RIP_DEBUG_PACKET) - zlog_debug (" packet's v%d doesn't fit to if version spec", - packet->version); - rip_peer_bad_packet (&from); - return -1; - } + if (IS_RIP_DEBUG_PACKET) + zlog_debug (" packet's v%d doesn't fit to if version spec", + packet->version); + rip_peer_bad_packet (&from); + return -1; } - + if ((packet->version == RIPv2) && !(vrecv & RIPv2)) + { + if (IS_RIP_DEBUG_PACKET) + zlog_debug (" packet's v%d doesn't fit to if version spec", + packet->version); + rip_peer_bad_packet (&from); + return -1; + } + /* RFC2453 5.2 If the router is not configured to authenticate RIP-2 messages, then RIP-1 and unauthenticated RIP-2 messages will be accepted; authenticated RIP-2 messages shall be discarded. */ - if ((ri->auth_type == RIP_NO_AUTH) && rtenum && (packet->version == RIPv2) @@ -1976,94 +1970,101 @@ rip_read (struct thread *t) rip_peer_bad_packet (&from); return -1; } - - /* If the router is configured to authenticate RIP-2 messages, then + + /* RFC: + If the router is configured to authenticate RIP-2 messages, then RIP-1 messages and RIP-2 messages which pass authentication testing shall be accepted; unauthenticated and failed authentication RIP-2 messages shall be discarded. For maximum security, RIP-1 messages should be ignored when authentication is in use (see section 4.1); otherwise, the routing information from authenticated messages will be propagated by RIP-1 routers in an - unauthenticated manner. */ - - if ((ri->auth_type == RIP_AUTH_SIMPLE_PASSWORD - || ri->auth_type == RIP_AUTH_MD5) && rtenum) + unauthenticated manner. + */ + /* We make an exception for RIPv1 REQUEST packets, to which we'll + * always reply regardless of authentication settings, because: + * + * - if there other authorised routers on-link, the REQUESTor can + * passively obtain the routing updates anyway + * - if there are no other authorised routers on-link, RIP can + * easily be disabled for the link to prevent giving out information + * on state of this routers RIP routing table.. + * + * I.e. if RIPv1 has any place anymore these days, it's as a very + * simple way to distribute routing information (e.g. to embedded + * hosts / appliances) and the ability to give out RIPv1 + * routing-information freely, while still requiring RIPv2 + * authentication for any RESPONSEs might be vaguely useful. + */ + if (ri->auth_type != RIP_NO_AUTH + && packet->version == RIPv1) { - /* We follow maximum security. */ - if (packet->version == RIPv1 - && packet->rte->family == htons(RIP_FAMILY_AUTH)) - { - if (IS_RIP_DEBUG_PACKET) - zlog_debug - ("packet RIPv%d is dropped because authentication enabled", - packet->version); + /* Discard RIPv1 messages other than REQUESTs */ + if (packet->command != RIP_REQUEST) + { + if (IS_RIP_DEBUG_PACKET) + zlog_debug ("RIPv1" " dropped because authentication enabled"); + rip_peer_bad_packet (&from); + return -1; + } + } + else if (ri->auth_type != RIP_NO_AUTH) + { + const char *auth_desc; + + if (rtenum == 0) + { + /* There definitely is no authentication in the packet. */ + if (IS_RIP_DEBUG_PACKET) + zlog_debug ("RIPv2 authentication failed: no auth RTE in packet"); + rip_peer_bad_packet (&from); + return -1; + } + + /* First RTE must be an Authentication Family RTE */ + if (packet->rte->family != htons(RIP_FAMILY_AUTH)) + { + if (IS_RIP_DEBUG_PACKET) + zlog_debug ("RIPv2" " dropped because authentication enabled"); rip_peer_bad_packet (&from); return -1; - } - + } + /* Check RIPv2 authentication. */ - if (packet->version == RIPv2) - { - if (packet->rte->family == htons(RIP_FAMILY_AUTH)) - { - if (packet->rte->tag == htons(RIP_AUTH_SIMPLE_PASSWORD)) - { - ret = rip_auth_simple_password (packet->rte, &from, ifp); - if (! ret) - { - if (IS_RIP_DEBUG_EVENT) - zlog_debug - ("RIPv2 simple password authentication failed"); - rip_peer_bad_packet (&from); - return -1; - } - else - { - if (IS_RIP_DEBUG_EVENT) - zlog_debug - ("RIPv2 simple password authentication success"); - } - } - else if (packet->rte->tag == htons(RIP_AUTH_MD5)) - { - ret = rip_auth_md5 (packet, &from, len, ifp); - if (! ret) - { - if (IS_RIP_DEBUG_EVENT) - zlog_debug ("RIPv2 MD5 authentication failed"); - rip_peer_bad_packet (&from); - return -1; - } - else - { - if (IS_RIP_DEBUG_EVENT) - zlog_debug ("RIPv2 MD5 authentication success"); - } - /* Reset RIP packet length to trim MD5 data. */ - len = ret; - } - else - { - if (IS_RIP_DEBUG_EVENT) - zlog_debug ("Unknown authentication type %d", - ntohs (packet->rte->tag)); - rip_peer_bad_packet (&from); - return -1; - } - } - else - { - /* There is no authentication in the packet. */ - if (ri->auth_str || ri->key_chain) - { - if (IS_RIP_DEBUG_EVENT) - zlog_debug - ("RIPv2 authentication failed: no authentication in packet"); - rip_peer_bad_packet (&from); - return -1; - } - } - } + switch (ntohs(packet->rte->tag)) + { + case RIP_AUTH_SIMPLE_PASSWORD: + auth_desc = "simple"; + ret = rip_auth_simple_password (packet->rte, &from, ifp); + break; + + case RIP_AUTH_MD5: + auth_desc = "MD5"; + ret = rip_auth_md5 (packet, &from, len, ifp); + /* Reset RIP packet length to trim MD5 data. */ + len = ret; + break; + + default: + ret = 0; + auth_desc = "unknown type"; + if (IS_RIP_DEBUG_PACKET) + zlog_debug ("RIPv2 Unknown authentication type %d", + ntohs (packet->rte->tag)); + } + + if (ret) + { + if (IS_RIP_DEBUG_PACKET) + zlog_debug ("RIPv2 %s authentication success", auth_desc); + } + else + { + if (IS_RIP_DEBUG_PACKET) + zlog_debug ("RIPv2 %s authentication failure", auth_desc); + rip_peer_bad_packet (&from); + return -1; + } } /* Process each command. */ -- cgit v1.2.3 From 3e557ae1ea7693d91b6df42c2529952d6a349911 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Mon, 11 Sep 2006 02:10:40 +0000 Subject: [ripd] bug #278: remove gratuitous use of mid-function declaration 2006-09-11 Paul Jakma * ripd.c: (rip_read) remove gratuitous use of mid-function declaration of vrecv, bug #278. --- ripd/ripd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index 518e4861..a1630f6c 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -1818,6 +1818,7 @@ rip_read (struct thread *t) struct rip_packet *packet; struct sockaddr_in from; int len; + int vrecv; socklen_t fromlen; struct interface *ifp; struct connected *ifc; @@ -1937,8 +1938,8 @@ rip_read (struct thread *t) } /* RIP Version check. RFC2453, 4.6 and 5.1 */ - int vrecv = ((ri->ri_receive == RI_RIP_UNSPEC) ? - rip->version_recv : ri->ri_receive); + vrecv = ((ri->ri_receive == RI_RIP_UNSPEC) ? + rip->version_recv : ri->ri_receive); if ((packet->version == RIPv1) && !(vrecv & RIPv1)) { if (IS_RIP_DEBUG_PACKET) -- cgit v1.2.3 From e4529636b77124285cca96a62799d0ff6a7addeb Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 12 Dec 2006 19:18:21 +0000 Subject: [PtP over ethernet] New peer flag allows much more addressing flexibility 2006-12-12 Andrew J. Schorr * 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. --- ripd/ripd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ripd/ripd.c') 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); } -- cgit v1.2.3 From a4c648281dfdc45687580ea2d20884b5d7dbdc8d Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Wed, 21 Mar 2007 18:57:38 +0000 Subject: [ripd] Fix "show ip rip status" display of time until next update 2007-03-21 Andrew J. Schorr * ripd.c: (show_ip_rip_status) Use new thread_timer_remain_second function instead of rip_next_thread_timer to display the time until next update properly. (rip_next_thread_timer) Remove obsolete function. --- ripd/ripd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index afa49fd6..f656073a 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3500,17 +3500,6 @@ DEFUN (show_ip_rip, return CMD_SUCCESS; } -/* Return next event time. */ -static int -rip_next_thread_timer (struct thread *thread) -{ - struct timeval timer_now; - - gettimeofday (&timer_now, NULL); - - return thread->u.sands.tv_sec - timer_now.tv_sec; -} - /* Vincent: formerly, it was show_ip_protocols_rip: "show ip protocols" */ DEFUN (show_ip_rip_status, show_ip_rip_status_cmd, @@ -3533,8 +3522,8 @@ DEFUN (show_ip_rip_status, vty_out (vty, "Routing Protocol is \"rip\"%s", VTY_NEWLINE); vty_out (vty, " Sending updates every %ld seconds with +/-50%%,", rip->update_time); - vty_out (vty, " next due in %d seconds%s", - rip_next_thread_timer (rip->t_update), + vty_out (vty, " next due in %lu seconds%s", + thread_timer_remain_second(rip->t_update), VTY_NEWLINE); vty_out (vty, " Timeout after %ld seconds,", rip->timeout_time); vty_out (vty, " garbage collect after %ld seconds%s", rip->garbage_time, -- cgit v1.2.3 From a1fdf9479637642ae3de0ee6ef5c0958d6e687d8 Mon Sep 17 00:00:00 2001 From: Vincent Jardin Date: Wed, 11 Apr 2007 15:12:05 +0000 Subject: Fix the display of route timeout in "show ip rip". (Use thread_timer_remain_second) --- ripd/ripd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index f656073a..fb5b1777 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3389,14 +3389,14 @@ rip_vty_out_uptime (struct vty *vty, struct rip_info *rinfo) if ((thread = rinfo->t_timeout) != NULL) { - clock = thread->u.sands.tv_sec - timer_now.tv_sec; + clock = thread_timer_remain_second (thread); tm = gmtime (&clock); strftime (timebuf, TIME_BUF, "%M:%S", tm); vty_out (vty, "%5s", timebuf); } else if ((thread = rinfo->t_garbage_collect) != NULL) { - clock = thread->u.sands.tv_sec - timer_now.tv_sec; + clock = thread_timer_remain_second (thread); tm = gmtime (&clock); strftime (timebuf, TIME_BUF, "%M:%S", tm); vty_out (vty, "%5s", timebuf); -- cgit v1.2.3 From 33672eddf14c5b619fc38975d4c1f2888189cbc8 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Fri, 27 Apr 2007 18:03:11 +0000 Subject: [ripd, ripngd] Remove useless code in rip_vty_out_uptime function 2007-04-27 Andrew J. Schorr * ripd/ripd.c: (rip_vty_out_uptime) Remove unused variable timer_now. * ripngd/ripngd.c: (ripng_vty_out_uptime) Remove unused variable timer_now. --- ripd/ripd.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index fb5b1777..7c463d50 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3378,15 +3378,12 @@ DEFUN (no_rip_distance_source_access_list, static void rip_vty_out_uptime (struct vty *vty, struct rip_info *rinfo) { - struct timeval timer_now; time_t clock; struct tm *tm; #define TIME_BUF 25 char timebuf [TIME_BUF]; struct thread *thread; - gettimeofday (&timer_now, NULL); - if ((thread = rinfo->t_timeout) != NULL) { clock = thread_timer_remain_second (thread); -- cgit v1.2.3 From 6f0e3f6e17687eb25b7b77c4fdc8324837d4700f Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 10 May 2007 02:38:51 +0000 Subject: [autoconf] bugs 162,303,178: Fix 'present but can not be compiled' warnings 2007-05-09 Paul Jakma * configure.ac: sys/conf.h depends on sys/param.h, at least on FBSD 6.2. (bug #363) Should check for in_pktinfo for IRDP 2006-05-27 Paul Jakma * configure.ac: General cleanup of header and type checks, introducing an internal define, QUAGGA_INCLUDES, to build up a list of stuff to include so as to avoid 'present but cant be compiled' warnings. Misc additional checks of things missing according to autoscan. Add LIBM, for bgpd's use of libm, so as to avoid burdening LIBS, and all the binaries, with libm linkage. Remove the bad practice of using m4 changequote(), just quote the []'s in the case statements properly. This should fix bugs 162, 303 and 178. * */*.{c,h}: Update all HAVE_* to the standard autoconf namespaced HAVE_* defines. I.e. HAVE_SA_LEN -> HAVE_STRUCT_SOCKADDR_SA_LEN, * bgpd/Makefile.am: Add LIBM to bgpd's LDADD, for pow(). --- ripd/ripd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index 7c463d50..75ac2159 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -1352,9 +1352,9 @@ rip_create_socket (struct sockaddr_in *from) { addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; -#ifdef HAVE_SINLEN +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN addr.sin_len = sizeof (struct sockaddr_in); -#endif /* HAVE_SINLEN */ +#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ } else { memcpy(&addr, from, sizeof(addr)); } @@ -1457,9 +1457,9 @@ rip_send_packet (u_char * buf, int size, struct sockaddr_in *to, /* Make destination address. */ memset (&sin, 0, sizeof (struct sockaddr_in)); sin.sin_family = AF_INET; -#ifdef HAVE_SIN_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sin.sin_len = sizeof (struct sockaddr_in); -#endif /* HAVE_SIN_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ /* When destination is specified, use it's port and address. */ if (to) @@ -1479,9 +1479,9 @@ rip_send_packet (u_char * buf, int size, struct sockaddr_in *to, from.sin_family = AF_INET; from.sin_port = htons (RIP_PORT_DEFAULT); from.sin_addr = ifc->address->u.prefix4; -#ifdef HAVE_SIN_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN from.sin_len = sizeof (struct sockaddr_in); -#endif /* HAVE_SIN_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ /* * we have to open a new socket for each packet because this -- cgit v1.2.3 From ce6ab03a273beb903731621153722511910ebbe5 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 13 Mar 2008 03:28:13 +0000 Subject: [ripd] remove unnecessary 0 entries from struct message's 2008-03-13 Paul Jakma * ripd.c/rip_interface.c: Remove 0 entries from rip_msg ri_version_msg struct message's, not needed with recent fixes to mes_lookup. --- ripd/ripd.c | 1 - 1 file changed, 1 deletion(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index 75ac2159..c5e42705 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -84,7 +84,6 @@ struct message rip_msg[] = {RIP_TRACEOFF, "TRACEOFF"}, {RIP_POLL, "POLL"}, {RIP_POLL_ENTRY, "POLL ENTRY"}, - {0, NULL} }; /* Utility function to set boradcast option to the socket. */ -- cgit v1.2.3 From fa93b16208c2e7ffb09bd5bf72fb1a70a1ad8f73 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 29 May 2008 19:03:08 +0000 Subject: [ripd] Fix mistaken empty string test 2008-05-29 Stephen Hemminger * ripd.c: (rip_auth_md5) fix bogus empty string test --- ripd/ripd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index c5e42705..62d8691c 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -926,7 +926,7 @@ rip_auth_md5 (struct rip_packet *packet, struct sockaddr_in *from, else if (ri->auth_str) strncpy (auth_str, ri->auth_str, RIP_AUTH_MD5_SIZE); - if (! auth_str) + if (auth_str[0] == 0) return 0; /* MD5 digest authentication. */ -- cgit v1.2.3 From 1423c809cc4ddc2e013ba6264c49a11e5719c6f2 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 14 Aug 2008 17:59:25 +0100 Subject: [lib] mes_lookup string lookup table argument should be marked const 2008-08-14 Stephen Hemminger * lib/log.{c,h}: struct message argument should point to const * */*.c: adjust to suit, Signed-off-by: Paul Jakma --- ripd/ripd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ripd/ripd.c') diff --git a/ripd/ripd.c b/ripd/ripd.c index 62d8691c..2525679c 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -76,7 +76,7 @@ enum }; /* RIP command strings. */ -struct message rip_msg[] = +static const struct message rip_msg[] = { {RIP_REQUEST, "REQUEST"}, {RIP_RESPONSE, "RESPONSE"}, @@ -84,6 +84,7 @@ struct message rip_msg[] = {RIP_TRACEOFF, "TRACEOFF"}, {RIP_POLL, "POLL"}, {RIP_POLL_ENTRY, "POLL ENTRY"}, + {0, NULL}, }; /* Utility function to set boradcast option to the socket. */ @@ -3508,7 +3509,7 @@ DEFUN (show_ip_rip_status, struct listnode *node; struct interface *ifp; struct rip_interface *ri; - extern struct message ri_version_msg[]; + extern const struct message ri_version_msg[]; const char *send_version; const char *receive_version; -- cgit v1.2.3