linux-ifdef-stupidity-cleanup-20030117
[openafs.git] / src / rx / rx_packet.c
index 294316e..c759122 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <afsconfig.h>
 #ifdef KERNEL
-#include "../afs/param.h"
+#include "afs/param.h"
 #else
 #include <afs/param.h>
 #endif
@@ -18,38 +18,41 @@ RCSID("$Header$");
 
 #ifdef KERNEL
 #if defined(UKERNEL)
-#include "../afs/sysincludes.h"
-#include "../afs/afsincludes.h"
-#include "../rx/rx_kcommon.h"
-#include "../rx/rx_clock.h"
-#include "../rx/rx_queue.h"
-#include "../rx/rx_packet.h"
+#include "afs/sysincludes.h"
+#include "afsincludes.h"
+#include "rx/rx_kcommon.h"
+#include "rx/rx_clock.h"
+#include "rx/rx_queue.h"
+#include "rx/rx_packet.h"
 #else /* defined(UKERNEL) */
-#include "../h/types.h"
+#include "h/types.h"
 #ifndef AFS_LINUX20_ENV
-#include "../h/systm.h"
+#include "h/systm.h"
 #endif
 #if defined(AFS_SGI_ENV) || defined(AFS_HPUX110_ENV)
-#include "../afs/sysincludes.h"
+#include "afs/sysincludes.h"
 #endif
-#include "../h/socket.h"
+#if defined(AFS_OBSD_ENV)
+#include "h/proc.h"
+#endif
+#include "h/socket.h"
 #if !defined(AFS_SUN5_ENV) &&  !defined(AFS_LINUX20_ENV)
 #if    !defined(AFS_OSF_ENV) && !defined(AFS_AIX41_ENV)
-#include "../sys/mount.h"   /* it gets pulled in by something later anyway */
+#include "sys/mount.h"   /* it gets pulled in by something later anyway */
 #endif
-#include "../h/mbuf.h"
+#include "h/mbuf.h"
 #endif
-#include "../netinet/in.h"
-#include "../afs/afs_osi.h"
-#include "../rx/rx_kmutex.h"
-#include "../rx/rx_clock.h"
-#include "../rx/rx_queue.h"
+#include "netinet/in.h"
+#include "afs/afs_osi.h"
+#include "rx_kmutex.h"
+#include "rx/rx_clock.h"
+#include "rx/rx_queue.h"
 #ifdef AFS_SUN5_ENV
 #include <sys/sysmacros.h>
 #endif
-#include "../rx/rx_packet.h"
+#include "rx/rx_packet.h"
 #endif /* defined(UKERNEL) */
-#include "../rx/rx_globals.h"
+#include "rx/rx_globals.h"
 #else /* KERNEL */
 #include "sys/types.h"
 #include <sys/stat.h>
@@ -916,7 +919,7 @@ struct rx_packet *rxi_SplitJumboPacket(register struct rx_packet *p, afs_int32 h
 
 #ifndef KERNEL
 /* Send a udp datagram */
-int osi_NetSend(osi_socket socket, char *addr, struct iovec *dvec, int nvecs, 
+int osi_NetSend(osi_socket socket, void *addr, struct iovec *dvec, int nvecs, 
        int length, int istack)
 {
     struct msghdr msg;
@@ -932,7 +935,7 @@ int osi_NetSend(osi_socket socket, char *addr, struct iovec *dvec, int nvecs,
     return 0;
 }
 #elif !defined(UKERNEL)
-/* osi_NetSend is defined in afs/afs_osinet.c
+/*
  * message receipt is done in rxk_input or rx_put.
  */
 
@@ -1431,14 +1434,15 @@ static void rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket,
 }
 
 /* Send the packet to appropriate destination for the specified
- * connection.  The header is first encoded and placed in the packet.
+ * call.  The header is first encoded and placed in the packet.
  */
-void rxi_SendPacket(struct rx_connection * conn, struct rx_packet *p,
-                   int istack)
+void rxi_SendPacket(struct rx_call * call, struct rx_connection * conn,
+                   struct rx_packet *p, int istack)
 {
 #if defined(KERNEL)
     int waslocked;
 #endif
+    int code;
     struct sockaddr_in addr;
     register struct rx_peer *peer = conn->peer;
     osi_socket socket;
@@ -1446,6 +1450,7 @@ void rxi_SendPacket(struct rx_connection * conn, struct rx_packet *p,
     char deliveryType = 'S';
 #endif
     /* The address we're sending the packet to */
+    memset(&addr, 0, sizeof (addr));
     addr.sin_family = AF_INET;
     addr.sin_port = peer->port;
     addr.sin_addr.s_addr = peer->host;
@@ -1510,14 +1515,24 @@ void rxi_SendPacket(struct rx_connection * conn, struct rx_packet *p,
        waslocked = ISAFS_GLOCK();
        if (waslocked) AFS_GUNLOCK();
 #endif
-       if (osi_NetSend(socket, &addr, p->wirevec, p->niovecs, 
-                       p->length+RX_HEADER_SIZE, istack)){
+       if ((code = osi_NetSend(socket, &addr, p->wirevec, p->niovecs, 
+                               p->length+RX_HEADER_SIZE, istack)) != 0) {
          /* send failed, so let's hurry up the resend, eh? */
          MUTEX_ENTER(&rx_stats_mutex);
          rx_stats.netSendFailures++;      
          MUTEX_EXIT(&rx_stats_mutex);
          p->retryTime = p->timeSent;  /* resend it very soon */
          clock_Addmsec(&(p->retryTime), 10 + (((afs_uint32) p->backoff) << 8));
+
+#if defined(KERNEL) && defined(AFS_LINUX20_ENV)
+         /* Linux is nice -- it can tell us right away that we cannot
+          * reach this recipient by returning an ENETUNREACH error
+          * code.  So, when this happens let's "down" the host NOW so
+          * we don't sit around waiting for this host to timeout later.
+          */
+         if (call && code == -ENETUNREACH)
+           call->lastReceiveTime = 0;
+#endif
        }
 #ifdef KERNEL
        if (waslocked) AFS_GLOCK();
@@ -1542,8 +1557,8 @@ void rxi_SendPacket(struct rx_connection * conn, struct rx_packet *p,
 /* Send a list of packets to appropriate destination for the specified
  * connection.  The headers are first encoded and placed in the packets.
  */
-void rxi_SendPacketList(struct rx_connection * conn, struct rx_packet **list,
-       int len, int istack)
+void rxi_SendPacketList(struct rx_call * call, struct rx_connection * conn,
+                       struct rx_packet **list, int len, int istack)
 {
 #if     defined(AFS_SUN5_ENV) && defined(KERNEL)
     int waslocked;
@@ -1553,7 +1568,7 @@ void rxi_SendPacketList(struct rx_connection * conn, struct rx_packet **list,
     osi_socket socket;
     struct rx_packet *p = NULL;
     struct iovec wirevec[RX_MAXIOVECS];
-    int i, length;
+    int i, length, code;
     afs_uint32 serial;
     afs_uint32 temp;
     struct rx_jumboHeader *jp;
@@ -1673,7 +1688,7 @@ void rxi_SendPacketList(struct rx_connection * conn, struct rx_packet **list,
        waslocked = ISAFS_GLOCK();
        if (!istack && waslocked) AFS_GUNLOCK();
 #endif
-       if (osi_NetSend(socket, &addr, &wirevec[0], len+1, length, istack)){
+       if ((code = osi_NetSend(socket, &addr, &wirevec[0], len+1, length, istack)) != 0){
          /* send failed, so let's hurry up the resend, eh? */
          MUTEX_ENTER(&rx_stats_mutex);
          rx_stats.netSendFailures++;      
@@ -1683,6 +1698,15 @@ void rxi_SendPacketList(struct rx_connection * conn, struct rx_packet **list,
            p->retryTime = p->timeSent;  /* resend it very soon */
            clock_Addmsec(&(p->retryTime), 10 + (((afs_uint32) p->backoff) << 8));
          }
+#if defined(KERNEL) && defined(AFS_LINUX20_ENV)
+         /* Linux is nice -- it can tell us right away that we cannot
+          * reach this recipient by returning an ENETUNREACH error
+          * code.  So, when this happens let's "down" the host NOW so
+          * we don't sit around waiting for this host to timeout later.
+          */
+         if (call && code == -ENETUNREACH)
+           call->lastReceiveTime = 0;
+#endif
        }
 #if    defined(AFS_SUN5_ENV) && defined(KERNEL)
        if (!istack && waslocked) AFS_GLOCK();
@@ -1769,7 +1793,7 @@ struct rx_packet *rxi_SendSpecial(register struct rx_call *call,
     }
 
     if (call) rxi_Send(call, p, istack);
-    else rxi_SendPacket(conn, p, istack);
+    else rxi_SendPacket((struct rx_call *)0, conn, p, istack);
     if (saven) {  /* means we truncated the packet above.  We probably don't  */
       /* really need to do this, but it seems safer this way, given that  */
       /* sneaky optionalPacket... */