char afs_rootVolumeName[64] = "";
struct afs_icl_set *afs_iclSetp = (struct afs_icl_set *)0;
struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set *)0;
+afs_uint32 rx_bindhost;
#if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
kmutex_t afs_global_lock;
/* start RX */
rx_extraPackets = AFS_NRXPACKETS; /* smaller # of packets */
- code = rx_Init(htons(7001));
+ code = rx_InitHost(rx_bindhost, htons(7001));
if (code) {
printf("AFS: RX failed to initialize %d).\n", code);
return code;
cacheNumEntries : 1));
} else if (parm == AFSOP_ADVISEADDR) {
/* pass in the host address to the rx package */
+ int rxbind = 0;
afs_int32 count = parm2;
afs_int32 *buffer =
afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
int i;
+ /* Bind, but only if there's only one address configured */
+ if ( count & 0x80000000) {
+ count &= ~0x80000000;
+ if (count == 1)
+ rxbind=1;
+ }
+
if (count > AFS_MAX_INTERFACE_ADDR) {
code = ENOMEM;
count = AFS_MAX_INTERFACE_ADDR;
}
afs_uuid_create(&afs_cb_interface.uuid);
rxi_setaddr(buffer[0]);
+ if (rxbind)
+ rx_bindhost = buffer[0];
+ else
+ rx_bindhost = htonl(INADDR_ANY);
+
afs_osi_Free(buffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
afs_osi_Free(maskbuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
afs_osi_Free(mtubuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR);
/*
* Global configuration variables.
*/
+afs_int32 enable_rxbind = 0;
afs_int32 afs_shutdown = 0;
afs_int32 cacheBlocks; /*Num blocks in the cache */
afs_int32 cacheFiles = 1000; /*Optimal # of files in workstation cache */
/* -backuptree */
enable_backuptree = 1;
}
+ if (as->parms[31].items) {
+ /* -rxbind */
+ enable_rxbind = 1;
+ }
+
/*
* Pull out all the configuration info for the workstation's AFS cache and
* the cellular community we're willing to let our users see.
parseNetFiles(addrbuf, maskbuf, mtubuf, MAXIPADDRS, reason,
AFSDIR_CLIENT_NETINFO_FILEPATH,
AFSDIR_CLIENT_NETRESTRICT_FILEPATH);
- if (code > 0)
+ if (code > 0) {
+ if (enable_rxbind)
+ code = code | 0x80000000;
call_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf);
- else
+ } else
printf("ADVISEADDR: Error in specifying interface addresses:%s\n",
reason);
}
cmd_AddParm(ts, "-nomount", CMD_FLAG, CMD_OPTIONAL, "Do not mount AFS");
cmd_AddParm(ts, "-backuptree", CMD_FLAG, CMD_OPTIONAL,
"Prefer backup volumes for mointpoints in backup volumes");
+ cmd_AddParm(ts, "-rxbind", CMD_FLAG, CMD_OPTIONAL, "Bind the Rx socket (one interface only)");
return (cmd_Dispatch(argc, argv));
}
long eparm[4];
struct afsprocdata syscall_data;
int fd = open(PROC_SYSCALL_FNAME,O_RDWR);
-
+ if (fd < 0)
+ fd = open(PROC_SYSCALL_ARLA_FNAME,O_RDWR);
eparm[0] = param4;
eparm[1] = param5;
eparm[2] = param6;
* open and bind RX socket
*/
struct osi_socket *
-rxk_NewSocket(short aport)
+rxk_NewSocketHost(afs_uint32 ahost, short aport)
{
struct socket *sockp;
struct sockaddr_in myaddr;
/* Bind socket */
myaddr.sin_family = AF_INET;
- myaddr.sin_addr.s_addr = htonl(INADDR_ANY);
+ myaddr.sin_addr.s_addr = ahost;
myaddr.sin_port = aport;
code =
sockp->ops->bind(sockp, (struct sockaddr *)&myaddr, sizeof(myaddr));
return (struct osi_socket *)sockp;
}
+struct osi_socket *
+rxk_NewSocket(short aport)
+{
+ return rxk_NewSocketHost(htonl(INADDR_ANY), aport);
+}
/* free socket allocated by osi_NetSocket */
int
/* Allocate a new socket at specified port in network byte order. */
struct osi_socket *
-rxk_NewSocket(short aport)
+rxk_NewSocketHost(afs_uint32 ahost, short aport)
{
vnode_t *accessvp;
struct sonode *so;
addr.sin_family = AF_INET;
addr.sin_port = aport;
- addr.sin_addr.s_addr = INADDR_ANY;
+ addr.sin_addr.s_addr = ahost; /* I wonder what the odds are on
+ needing to unbyteswap this */
error = sockfs_sobind(so, (struct sockaddr *)&addr, sizeof(addr), 0, 0);
if (error != 0) {
return NULL;
return (struct osi_socket *)so;
}
+struct osi_socket *
+rxk_NewSocket(short aport)
+{
+ return rxk_NewSocketHost(htonl(INADDR_ANY), aport);
+}
+
int
osi_FreeSocket(register struct osi_socket *asocket)
{
/* Allocate a new socket at specified port in network byte order. */
struct osi_socket *
-rxk_NewSocket(short aport)
+rxk_NewSocketHost(afs_uint32 ahost, short aport)
{
TIUSER *udp_tiptr;
struct t_bind *reqp, *rspp;
myaddrp = (struct sockaddr_in *)reqp->addr.buf;
myaddrp->sin_family = AF_INET;
myaddrp->sin_port = aport;
- myaddrp->sin_addr.s_addr = INADDR_ANY; /* XXX Was 0 XXX */
+ myaddrp->sin_addr.s_addr = ahost; /* byteswap? */
code = t_kbind(udp_tiptr, reqp, rspp);
if (code) {
return (struct osi_socket *)udp_tiptr;
}
+struct osi_socket *
+rxk_NewSocket(short aport)
+{
+ return rxk_NewSocketHost(htonl(INADDR_ANY), aport);
+}
int
osi_FreeSocket(register struct osi_socket *asocket)
* we start the receiver threads.
*/
struct osi_socket *
-rxk_NewSocket(short aport)
+rxk_NewSocketHost(afs_uint32 ahost, short aport)
{
struct usr_socket *usockp;
return (struct osi_socket *)usockp;
}
+struct osi_socket *
+rxk_NewSocket(short aport)
+{
+ return rxk_NewSocketHost(htonl(INADDR_ANY), aport);
+}
+
/*
* This routine is called from rxk_Listener. By this time rx_port
* is set to 7001 and rx_socket points to the socket buffer
#define UNLOCK_RX_INIT
#endif
-int
-rx_Init(u_int port)
+int
+rx_InitHost(u_int host, u_int port)
{
#ifdef KERNEL
osi_timeval_t tv;
/* Allocate and initialize a socket for client and perhaps server
* connections. */
- rx_socket = rxi_GetUDPSocket((u_short) port);
+ rx_socket = rxi_GetHostUDPSocket(host, (u_short) port);
if (rx_socket == OSI_NULLSOCKET) {
UNLOCK_RX_INIT return RX_ADDRINUSE;
}
UNLOCK_RX_INIT return tmp_status;
}
+int rx_Init(u_int port)
+{
+ return rx_InitHost(htonl(INADDR_ANY), port);
+}
+
/* called with unincremented nRequestsRunning to see if it is OK to start
* a new thread in this service. Could be "no" for two reasons: over the
* max quota, or would prevent others from reaching their min quota.
if (socket == OSI_NULLSOCKET) {
/* If we don't already have a socket (from another
* service on same port) get a new one */
- socket = rxi_GetUDPSocket(port);
+ socket = rxi_GetHostUDPSocket(htonl(INADDR_ANY), port);
if (socket == OSI_NULLSOCKET) {
AFS_RXGUNLOCK();
USERPRI;
#ifndef KERNEL
typedef void (*rx_destructor_t) (void *);
int rx_KeyCreate(rx_destructor_t);
+osi_socket rxi_GetHostUDPSocket(u_int host, u_short port);
osi_socket rxi_GetUDPSocket(u_short port);
#endif /* KERNEL */
int (*rxk_GetPacketProc) (char **ahandle, int asize);
#endif
+struct osi_socket *rxk_NewSocketHost(afs_uint32 ahost, short aport);
extern struct interfaceAddr afs_cb_interface;
rxk_ports_t rxk_ports;
}
osi_socket
-rxi_GetUDPSocket(u_short port)
+rxi_GetHostUDPSocket(u_int host, u_short port)
{
struct osi_socket *sockp;
- sockp = (struct osi_socket *)rxk_NewSocket(port);
+ sockp = (struct osi_socket *)rxk_NewSocketHost(host, port);
if (sockp == (struct osi_socket *)0)
return OSI_NULLSOCKET;
rxk_AddPort(port, (char *)sockp);
return (osi_socket) sockp;
}
+osi_socket
+rxi_GetUDPSocket(u_short port)
+{
+ return rxi_GetHostUDPSocket(htonl(INADDR_ANY), port);
+}
void
osi_Panic(msg, a1, a2, a3)
* in network byte order.
*/
struct osi_socket *
-rxk_NewSocket(short aport)
+rxk_NewSocketHost(afs_uint32 ahost, short aport)
{
register afs_int32 code;
struct socket *newSocket;
memset(&myaddr, 0, sizeof myaddr);
myaddr.sin_family = AF_INET;
myaddr.sin_port = aport;
- myaddr.sin_addr.s_addr = 0;
+ myaddr.sin_addr.s_addr = ahost;
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
myaddr.sin_len = sizeof(myaddr);
#endif
return (struct osi_socket *)0;
}
+struct osi_socket *
+rxk_NewSocket(short aport)
+{
+ return rxk_NewSocketHost(0, aport);
+}
/* free socket allocated by rxk_NewSocket */
int
extern int rxk_DelPort(u_short aport);
extern void rxk_shutdownPorts(void);
extern osi_socket rxi_GetUDPSocket(u_short port);
+extern osi_socket rxi_GetHostUDPSocket(u_int host, u_short port);
extern void osi_Panic();
extern int osi_utoa(char *buf, size_t len, unsigned long val);
extern void rxi_InitPeerParams(register struct rx_peer *pp);
* failure. Port must be in network byte order.
*/
osi_socket
-rxi_GetUDPSocket(u_short port)
+rxi_GetHostUDPSocket(u_int ahost, u_short port)
{
int binds, code = 0;
osi_socket socketFd = OSI_NULLSOCKET;
goto error;
}
- taddr.sin_addr.s_addr = INADDR_ANY;
+ taddr.sin_addr.s_addr = ahost;
taddr.sin_family = AF_INET;
taddr.sin_port = (u_short) port;
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
return OSI_NULLSOCKET;
}
+osi_socket
+rxi_GetUDPSocket(u_short port)
+{
+ return rxi_GetHostUDPSocket(htonl(INADDR_ANY), port);
+}
+
void
osi_Panic(char *msg, int a1, int a2, int a3)
{