[717] in linux-net channel archive
UDP fixes
daemon@ATHENA.MIT.EDU (Superman)
Tue Jul 18 18:29:17 1995
Date: Mon, 17 Jul 95 23:08 BST
From: root@thunder.swansea.linux.org.uk (Superman)
To: linux-net3@www.linux.org.uk, linux-net@vger.rutgers.edu,
torvalds@linux.helsinki.fi
These patches when coupled with the mount side patches (appended) allow NFS with
multihoming, like 4.2/4.3BSD as opposed to the normal Linux/4.4BSD behaviour. I've
used Jon Peatfields patches of the two sets I got as his are backward compatible.
Alan
--- net/ipv4/udp.c~ Tue Jul 18 00:38:21 1995
+++ net/ipv4/udp.c Tue Jul 18 00:38:21 1995
@@ -47,6 +47,7 @@
* Alan Cox : Route cache
* Alan Cox : Checksum precompute is bogus is some lame
* software is padding its udp frames in IP!
+ * Jon Peatfield : Minor efficientcy fix to sendto().
*
*
* This program is free software; you can redistribute it and/or
@@ -301,10 +302,9 @@
{
if (addr_len < sizeof(sin))
return(-EINVAL);
- memcpy(&sin,usin,sizeof(sin));
- if (sin.sin_family && sin.sin_family != AF_INET)
+ if (usin->sin_family && usin->sin_family != AF_INET)
return(-EINVAL);
- if (sin.sin_port == 0)
+ if (usin->sin_port == 0)
return(-EINVAL);
}
else
@@ -314,6 +314,7 @@
sin.sin_family = AF_INET;
sin.sin_port = sk->dummy_th.dest;
sin.sin_addr.s_addr = sk->daddr;
+ usin = &sin;
}
/*
@@ -321,16 +322,16 @@
* broadcasting of data.
*/
- if(sin.sin_addr.s_addr==INADDR_ANY)
- sin.sin_addr.s_addr=ip_my_addr();
+ if(usin->sin_addr.s_addr==INADDR_ANY)
+ usin->sin_addr.s_addr=ip_my_addr();
- if(!sk->broadcast && ip_chk_addr(sin.sin_addr.s_addr)==IS_BROADCAST)
+ if(!sk->broadcast && ip_chk_addr(usin->sin_addr.s_addr)==IS_BROADCAST)
return -EACCES; /* Must turn broadcast on first */
sk->inuse = 1;
/* Send the packet. */
- tmp = udp_send(sk, &sin, from, len, flags);
+ tmp = udp_send(sk, usin, from, len, flags);
/* The datagram has been sent off. Release the socket. */
release_sock(sk);
--- fs/nfs/inode.c.orig Mon Jun 12 14:49:41 1995
+++ fs/nfs/inode.c Tue Jul 18 00:39:13 1995
@@ -7,6 +7,10 @@
*
* Modularised by Alan Cox <Alan.Cox@linux.org>, while hacking some
* experimental NFS changes. Modularisation taken straight from SYS5 fs.
+ *
+ * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts.
+ * J.S.Peatfield@damtp.cam.ac.uk
+ *
*/
#ifdef MODULE
@@ -76,6 +80,7 @@
struct nfs_server *server;
unsigned int fd;
struct file *filp;
+
dev_t dev = sb->s_dev;
MOD_INC_USE_COUNT;
@@ -104,6 +109,7 @@
}
filp->f_count++;
lock_super(sb);
+
sb->s_blocksize = 1024; /* XXX */
sb->s_blocksize_bits = 10;
sb->s_magic = NFS_SUPER_MAGIC;
@@ -131,6 +137,31 @@
server->acdirmin = data->acdirmin*HZ;
server->acdirmax = data->acdirmax*HZ;
strcpy(server->hostname, data->hostname);
+
+ /* Start of JSP NFS patch */
+ /* Check if passed address in data->addr */
+ if (data->addr.sin_addr.s_addr == INADDR_ANY) { /* No address passed */
+ if (((struct sockaddr_in *)(&server->toaddr))->sin_addr.s_addr == INADDR_ANY) {
+ printk("NFS: Error passed unconnected socket and no address\n") ;
+ return NULL ;
+ } else {
+ /* Need access to socket internals JSP */
+ struct socket *sock;
+ int dummylen ;
+
+ /* printk("NFS: using socket address\n") ;*/
+
+ sock = &((filp->f_inode)->u.socket_i);
+
+ /* extract the other end of the socket into server->toaddr */
+ sock->ops->getname(sock, &(server->toaddr), &dummylen, 1) ;
+ }
+ } else {
+ /* printk("NFS: coppying passed addr to server->toaddr\n") ;*/
+ memcpy((char *)&(server->toaddr),(char *)(&data->addr),sizeof(server->toaddr));
+ }
+ /* End of JSP NFS patch */
+
sb->u.nfs_sb.s_root = data->root;
unlock_super(sb);
if (!(sb->s_mounted = nfs_fhget(sb, &data->root, NULL))) {
--- fs/nfs/sock.c.orig Tue Feb 7 09:43:23 1995
+++ fs/nfs/sock.c Tue Jul 18 00:39:13 1995
@@ -102,7 +102,10 @@
fs = get_fs();
set_fs(get_ds());
for (n = 0, timeout = init_timeout; ; n++, timeout <<= 1) {
- result = sock->ops->send(sock, (void *) start, len, 0, 0);
+ /* JSP 1995-07-01 Use sendto() not send() to cope with multi-homed hosts
+ as we have set the socket to have INADDR_ANY as it's desination */
+ result = sock->ops->sendto(sock, (void *) start, len, 0, 0,
+ &(server->toaddr), sizeof((server->toaddr))) ;
if (result < 0) {
printk("nfs_rpc_call: send error = %d\n", result);
break;
--- include/linux/nfs_fs_sb.h.orig Wed Dec 1 12:44:15 1993
+++ include/linux/nfs_fs_sb.h Tue Jul 18 00:39:13 1995
@@ -5,6 +5,7 @@
struct nfs_server {
struct file *file;
+ struct sockaddr toaddr ; /* Added for change to NFS code to use sendto() 1995-06-02 JSP */
int lock;
struct wait_queue *wait;
int flags;
-----------------------------
From: Jon Peatfield <J.S.Peatfield@damtp.cam.ac.uk>
Status: RO
Here are the patches for the kernel, mount (from linux-util 2.4), and
amd (upl-102). The patches kernel will work with the old mount and
amd etc but with the old behavour. The new mount/amd need the patched
kernel to work.
--mount-2.4-patch--
*** mount/nfsmount.c.orig Sun Mar 12 01:39:58 1995
--- mount/nfsmount.c Thu Jul 6 14:48:52 1995
***************
*** 387,396 ****
printf("using port %d for nfs deamon\n", port);
#endif
server_addr.sin_port = htons(port);
! if (connect(fsock, (struct sockaddr *) &server_addr,
! sizeof (server_addr)) < 0) {
! perror("nfs connect");
! goto fail;
}
/* prepare data structure for kernel */
--- 387,398 ----
printf("using port %d for nfs deamon\n", port);
#endif
server_addr.sin_port = htons(port);
! if (tcp) {
! if (connect(fsock, (struct sockaddr *) &server_addr,
! sizeof (server_addr)) < 0) {
! perror("nfs connect");
! goto fail;
! }
}
/* prepare data structure for kernel */
--mount-2.4-patch--
--amd-upl-102-patch--
*** amd/nfs_start.c.orig Sun Nov 6 03:28:13 1994
--- amd/nfs_start.c Tue Jun 13 09:44:28 1995
***************
*** 98,104 ****
static char *max_mem = 0;
int next_fd = dup(0);
! #ifdef __hpux
extern void *sbrk P((int));
#else
extern caddr_t sbrk P((int));
--- 98,104 ----
static char *max_mem = 0;
int next_fd = dup(0);
! #if defined(__hpux) || defined(__linux)
extern void *sbrk P((int));
#else
extern caddr_t sbrk P((int));
*** config/mount_linux.c.orig Sun Nov 6 03:28:41 1994
--- config/mount_linux.c Thu Jul 6 14:51:51 1995
***************
*** 121,126 ****
--- 121,127 ----
char *extra_opts = NULL;
char *tmp_opts = NULL;
char *sub_type = NULL;
+ int tcp = 0 ;
int noauto = 0;
int errorcode;
***************
*** 136,148 ****
if (!mnt_data->timeo) mnt_data->timeo=7;
if (!mnt_data->retrans) mnt_data->retrans=3;
! /* These are the only two reliable values currently */
! if (!mnt_data->rsize) mnt_data->rsize=1024;
! if (!mnt_data->wsize) mnt_data->wsize=1024;
if (((mnt_data->fd=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))< 0 )||
(bindresvport(mnt_data->fd, 0) < 0) ||
! (connect(mnt_data->fd, (struct sockaddr *) &mnt_data->addr,
! sizeof (mnt_data->addr)) < 0)) {
perror("Can't create socket for kernel");
errorcode=1;
goto fail;
--- 137,148 ----
if (!mnt_data->timeo) mnt_data->timeo=7;
if (!mnt_data->retrans) mnt_data->retrans=3;
! if (!mnt_data->rsize) mnt_data->rsize=8192;
! if (!mnt_data->wsize) mnt_data->wsize=8192;
if (((mnt_data->fd=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))< 0 )||
(bindresvport(mnt_data->fd, 0) < 0) ||
! (tcp && connect(mnt_data->fd, (struct sockaddr *) &mnt_data->addr,
! sizeof (mnt_data->addr)) < 0)) {
perror("Can't create socket for kernel");
errorcode=1;
goto fail;
*** config/Makefile.linux.orig Sun Nov 6 03:28:36 1994
--- config/Makefile.linux Tue Jun 13 09:42:19 1995
***************
*** 52,58 ****
YACC=bison -y
LEX=flex
! HAS_NIS_MAPS = # -DHAS_NIS_MAPS -DHAS_NIS_RELOAD # not on linux (yet)
# The following syntax only works with GNU's make - which all linux users have.
# Linux can lose the segment padding to page boundaries for these binaries.
--- 52,58 ----
YACC=bison -y
LEX=flex
! HAS_NIS_MAPS = -DHAS_NIS_MAPS -DHAS_NIS_RELOAD # not on linux (yet)
# The following syntax only works with GNU's make - which all linux users have.
# Linux can lose the segment padding to page boundaries for these binaries.
*** config/Makefile.local.linux.orig Mon Feb 27 23:04:49 1995
--- config/Makefile.local.linux Thu Jul 6 14:53:25 1995
***************
*** 4,8 ****
#DEBUG = -g -DDEBUG -pipe -DINFORM_MOUNTD -DNEW_TOPLVL_READDIR -DNEW_DEFAULTS -DDEBUG_PRINT -DBROKEN_YP_ALL
#DEBUG = -g -DDEBUG -pipe -DHAS_PLOCK -DINFORM_MOUNTD
#DEBUG = -g -DDEBUG -pipe -DINFORM_MOUNTD -DNEW_TOPLVL_READDIR -DNEW_DEFAULTS -DDEBUG_PRINT
! DEBUG = -g -DDEBUG -pipe -DINFORM_MOUNTD -DNEW_TOPLVL_READDIR -DNEW_DEFAULTS
ETC = /usr/etc
--- 4,10 ----
#DEBUG = -g -DDEBUG -pipe -DINFORM_MOUNTD -DNEW_TOPLVL_READDIR -DNEW_DEFAULTS -DDEBUG_PRINT -DBROKEN_YP_ALL
#DEBUG = -g -DDEBUG -pipe -DHAS_PLOCK -DINFORM_MOUNTD
#DEBUG = -g -DDEBUG -pipe -DINFORM_MOUNTD -DNEW_TOPLVL_READDIR -DNEW_DEFAULTS -DDEBUG_PRINT
! #DEBUG = -g -DDEBUG -pipe -DINFORM_MOUNTD -DNEW_TOPLVL_READDIR -DNEW_DEFAULTS
! #DEBUG = -DDEBUG -pipe -DINFORM_MOUNTD -DNEW_TOPLVL_READDIR -DNEW_DEFAULTS -DBROKEN_YP_ALL
! DEBUG = -DDEBUG -pipe -DINFORM_MOUNTD -DBROKEN_YP_ALL
ETC = /usr/etc
--amd-upl-102-patch--
I'm hoping that this fix might make it into 1.2.12 (or 13) rather than
having to wait for 1.3.9 etc...) so that the utilities can catch up...
-- Jon