@@ -28,6 +28,7 @@
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/xprtsock.h>
+#include "sunrpc.h"
#ifdef RPC_DEBUG
# define RPCDBG_FACILITY RPCDBG_BIND
@@ -292,11 +293,13 @@ out:
}
static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr,
- size_t salen, int proto, u32 version)
+ size_t salen, int proto, u32 version,
+ struct sockaddr *srcaddr)
{
struct rpc_create_args args = {
.net = &init_net,
.protocol = proto,
+ .saddress = srcaddr,
.address = srvaddr,
.addrsize = salen,
.servername = hostname,
@@ -601,11 +604,32 @@ void rpcb_getport_async(struct rpc_task *task)
struct rpc_task *child;
struct sockaddr_storage addr;
struct sockaddr *sap = (struct sockaddr *)&addr;
+ struct sockaddr_storage srcaddr;
+ struct sockaddr *srcaddra = NULL;
size_t salen;
int status;
+ struct sock_xprt *sxprt;
clnt = rpcb_find_transport_owner(task->tk_client);
xprt = clnt->cl_xprt;
+ sxprt = container_of(xprt, struct sock_xprt, xprt);
+
+ /* We just want to bind to the IP, not the port */
+ memset(&srcaddr, 0, sizeof(srcaddr));
+ srcaddr.ss_family = sxprt->srcaddr.ss_family;
+ if (sxprt->srcaddr.ss_family == AF_INET) {
+ struct sockaddr_in *si = (struct sockaddr_in *)(&srcaddr);
+ struct sockaddr_in *si2;
+ si2 = (struct sockaddr_in *)(&sxprt->srcaddr);
+ si->sin_addr.s_addr = si2->sin_addr.s_addr;
+ srcaddra = (struct sockaddr *)(&srcaddr);
+ } else if (sxprt->srcaddr.ss_family == AF_INET6) {
+ struct sockaddr_in6 *si = (struct sockaddr_in6 *)(&srcaddr);
+ struct sockaddr_in6 *si2;
+ si2 = (struct sockaddr_in6 *)(&sxprt->srcaddr);
+ memcpy(&si->sin6_addr, &si2->sin6_addr, sizeof(si2->sin6_addr));
+ srcaddra = (struct sockaddr *)(&srcaddr);
+ }
dprintk("RPC: %5u %s(%s, %u, %u, %d)\n",
task->tk_pid, __func__,
@@ -660,7 +684,7 @@ void rpcb_getport_async(struct rpc_task *task)
task->tk_pid, __func__, bind_version);
rpcb_clnt = rpcb_create(clnt->cl_server, sap, salen, xprt->prot,
- bind_version);
+ bind_version, srcaddra);
if (IS_ERR(rpcb_clnt)) {
status = PTR_ERR(rpcb_clnt);
dprintk("RPC: %5u %s: rpcb_create failed, error %ld\n",
@@ -37,6 +37,51 @@ struct rpc_buffer {
char data[];
};
+struct sock_xprt {
+ struct rpc_xprt xprt;
+
+ /*
+ * Network layer
+ */
+ struct socket *sock;
+ struct sock *inet;
+
+ /*
+ * State of TCP reply receive
+ */
+ __be32 tcp_fraghdr,
+ tcp_xid,
+ tcp_calldir;
+
+ u32 tcp_offset,
+ tcp_reclen;
+
+ unsigned long tcp_copied,
+ tcp_flags;
+
+ /*
+ * Connection of transports
+ */
+ struct delayed_work connect_worker;
+ struct sockaddr_storage srcaddr;
+ unsigned short srcport;
+
+ /*
+ * UDP socket buffer size parameters
+ */
+ size_t rcvsize,
+ sndsize;
+
+ /*
+ * Saved socket callback addresses
+ */
+ void (*old_data_ready)(struct sock *, int);
+ void (*old_state_change)(struct sock *);
+ void (*old_write_space)(struct sock *);
+ void (*old_error_report)(struct sock *);
+};
+
+
static inline int rpc_reply_expected(struct rpc_task *task)
{
return (task->tk_msg.rpc_proc != NULL) &&
@@ -202,49 +202,6 @@ static inline void xs_pktdump(char *msg, u32 *packet, unsigned int count)
}
#endif
-struct sock_xprt {
- struct rpc_xprt xprt;
-
- /*
- * Network layer
- */
- struct socket * sock;
- struct sock * inet;
-
- /*
- * State of TCP reply receive
- */
- __be32 tcp_fraghdr,
- tcp_xid,
- tcp_calldir;
-
- u32 tcp_offset,
- tcp_reclen;
-
- unsigned long tcp_copied,
- tcp_flags;
-
- /*
- * Connection of transports
- */
- struct delayed_work connect_worker;
- struct sockaddr_storage srcaddr;
- unsigned short srcport;
-
- /*
- * UDP socket buffer size parameters
- */
- size_t rcvsize,
- sndsize;
-
- /*
- * Saved socket callback addresses
- */
- void (*old_data_ready)(struct sock *, int);
- void (*old_state_change)(struct sock *);
- void (*old_write_space)(struct sock *);
- void (*old_error_report)(struct sock *);
-};
/*
* TCP receive state flags