From: Rainer Orth Date: Thu, 2 Oct 2003 16:53:51 +0000 (+0000) Subject: Improve RPC XID handling. X-Git-Tag: before-retrans-udp-tcp-split~80 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=31f211bf1d9c8a23d65a3f6c90bc95cf1d6da5c3;p=am-utils-6.2.git Improve RPC XID handling. * amd/rpc_fwd.c (fwd_packet, fwd_reply): Always log xid. Convert xid to/from host/network byte order. --- diff --git a/ChangeLog b/ChangeLog index b87cd9b0..dff70bd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-10-02 Rainer Orth + + Improve RPC XID handling. + + * amd/rpc_fwd.c (fwd_packet, fwd_reply): Always log xid. + Convert xid to/from host/network byte order. + 2003-10-02 Rainer Orth Use NFS V2/V3 file handles instead of mount results. diff --git a/amd/rpc_fwd.c b/amd/rpc_fwd.c index b92de8bc..37b05e2e 100644 --- a/amd/rpc_fwd.c +++ b/amd/rpc_fwd.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: rpc_fwd.c,v 1.14 2003/10/02 16:03:47 ro Exp $ + * $Id: rpc_fwd.c,v 1.15 2003/10/02 16:53:51 ro Exp $ * */ @@ -246,13 +246,13 @@ fwd_packet(int type_id, char *pkt, int len, struct sockaddr_in *fwdto, struct so */ switch (type_id & RPC_XID_MASK) { case RPC_XID_PORTMAP: - dlog("Sending PORTMAP request"); + dlog("Sending PORTMAP request %#x", type_id); break; case RPC_XID_MOUNTD: dlog("Sending MOUNTD request %#x", type_id); break; case RPC_XID_NFSPING: - dlog("Sending NFS ping"); + dlog("Sending NFS ping %#x", type_id); break; default: dlog("UNKNOWN RPC XID %#x", type_id); @@ -281,12 +281,13 @@ fwd_packet(int type_id, char *pkt, int len, struct sockaddr_in *fwdto, struct so /* * Get the original packet id */ - p->rf_oldid = *pkt_int; + p->rf_oldid = ntohl(*pkt_int); /* * Replace with newly allocated id */ - p->rf_xid = *pkt_int = type_id; + p->rf_xid = type_id; + *pkt_int = htonl(type_id); /* * The sendto may fail if, for example, the route @@ -355,6 +356,7 @@ fwd_reply(void) int len; u_int pkt[MAX_PACKET_SIZE / sizeof(u_int) + 1]; u_int *pkt_int; + u_int pkt_xid; int rc; rpc_forward *p; struct sockaddr_in src_addr; @@ -425,25 +427,26 @@ again: * Find packet reference */ pkt_int = (u_int *) pkt; + pkt_xid = ntohl(*pkt_int); - switch (*pkt_int & RPC_XID_MASK) { + switch (pkt_xid & RPC_XID_MASK) { case RPC_XID_PORTMAP: - dlog("Receiving PORTMAP reply"); + dlog("Receiving PORTMAP reply %#x", pkt_xid); break; case RPC_XID_MOUNTD: - dlog("Receiving MOUNTD reply %#x", *pkt_int); + dlog("Receiving MOUNTD reply %#x", pkt_xid); break; case RPC_XID_NFSPING: - dlog("Receiving NFS ping %#x", *pkt_int); + dlog("Receiving NFS ping %#x", pkt_xid); break; default: - dlog("UNKNOWN RPC XID"); + dlog("UNKNOWN RPC XID %#x", pkt_xid); break; } - p = fwd_locate(*pkt_int); + p = fwd_locate(pkt_xid); if (!p) { - dlog("Can't forward reply id %#x", *pkt_int); + dlog("Can't forward reply id %#x", pkt_xid); goto out; } @@ -452,7 +455,7 @@ again: * Put the original message id back * into the packet. */ - *pkt_int = p->rf_oldid; + *pkt_int = htonl(p->rf_oldid); /* * Call forwarding function