Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
linux
Commits
95fda206
Commit
95fda206
authored
17 years ago
by
Linus Torvalds
Browse files
Options
Download
Email Patches
Plain Diff
Import 1.1.56
parent
f4a818e0
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
242 additions
and
253 deletions
+242
-253
Makefile
Makefile
+1
-1
drivers/block/ll_rw_blk.c
drivers/block/ll_rw_blk.c
+16
-1
drivers/char/ChangeLog
drivers/char/ChangeLog
+8
-0
drivers/char/keyboard.c
drivers/char/keyboard.c
+1
-1
drivers/char/serial.c
drivers/char/serial.c
+1
-2
fs/exec.c
fs/exec.c
+2
-6
fs/ext2/dir.c
fs/ext2/dir.c
+30
-22
fs/fcntl.c
fs/fcntl.c
+18
-1
fs/file_table.c
fs/file_table.c
+1
-0
fs/read_write.c
fs/read_write.c
+2
-0
fs/xiafs/dir.c
fs/xiafs/dir.c
+1
-1
include/linux/fs.h
include/linux/fs.h
+1
-0
include/linux/if_arp.h
include/linux/if_arp.h
+3
-0
include/linux/net.h
include/linux/net.h
+3
-0
include/linux/socket.h
include/linux/socket.h
+0
-3
kernel/ksyms.c
kernel/ksyms.c
+11
-0
kernel/sys.c
kernel/sys.c
+1
-1
net/inet/README
net/inet/README
+15
-154
net/inet/af_inet.c
net/inet/af_inet.c
+18
-1
net/inet/arp.c
net/inet/arp.c
+109
-59
No files found.
Makefile
View file @
95fda206
VERSION
=
1
PATCHLEVEL
=
1
SUBLEVEL
=
5
5
SUBLEVEL
=
5
6
ARCH
=
i386
...
...
This diff is collapsed.
Click to expand it.
drivers/block/ll_rw_blk.c
View file @
95fda206
/*
* linux/
kernel/blk_dev
/ll_rw.c
* linux/
drivers/block
/ll_rw
_blk
.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
* Copyright (C) 1994, Karl Keyte: Added support for disk statistics
*/
/*
...
...
@@ -149,6 +150,20 @@ void set_device_ro(int dev,int flag)
static
void
add_request
(
struct
blk_dev_struct
*
dev
,
struct
request
*
req
)
{
struct
request
*
tmp
;
short
disk_index
;
switch
(
MAJOR
(
req
->
dev
))
{
case
SCSI_DISK_MAJOR
:
disk_index
=
(
MINOR
(
req
->
dev
)
&
0x0070
)
>>
4
;
if
(
disk_index
<
4
)
kstat
.
dk_drive
[
disk_index
]
++
;
break
;
case
HD_MAJOR
:
case
XT_DISK_MAJOR
:
disk_index
=
(
MINOR
(
req
->
dev
)
&
0x00C0
)
>>
6
;
if
(
disk_index
<
4
)
kstat
.
dk_drive
[
disk_index
]
++
;
break
;
default:
break
;
}
req
->
next
=
NULL
;
cli
();
...
...
This diff is collapsed.
Click to expand it.
drivers/char/ChangeLog
View file @
95fda206
Tue Oct 18 10:02:43 1994 Theodore Y. Ts'o (tytso@rt-11)
* serial.c (rs_start): Removed an incorrect '!' that was
preventing transmit interrupts from being re-enabled in
rs_start(). Fortunately in most cases it would be
re-enabled elsewhere, but this still should be fixed
corectly.
Sun Oct 9 23:46:03 1994 Theodore Y. Ts'o (tytso@rt-11)
* tty_io.c (do_tty_hangup): If the tty driver flags
...
...
This diff is collapsed.
Click to expand it.
drivers/char/keyboard.c
View file @
95fda206
...
...
@@ -305,7 +305,7 @@ static void keyboard_interrupt(int int_pt_regs)
}
/* strange ... */
reply_expected
=
1
;
#if
def KBD_REPORT_ERR
#if
0
printk("keyboard reply expected - got %02x\n", scancode);
#endif
}
...
...
This diff is collapsed.
Click to expand it.
drivers/char/serial.c
View file @
95fda206
...
...
@@ -313,8 +313,7 @@ static void rs_start(struct tty_struct *tty)
return
;
save_flags
(
flags
);
cli
();
if
(
info
->
xmit_cnt
&&
!
info
->
xmit_buf
&&
!
(
info
->
IER
&
UART_IER_THRI
))
{
if
(
info
->
xmit_cnt
&&
info
->
xmit_buf
&&
!
(
info
->
IER
&
UART_IER_THRI
))
{
info
->
IER
|=
UART_IER_THRI
;
serial_out
(
info
,
UART_IER
,
info
->
IER
);
}
...
...
This diff is collapsed.
Click to expand it.
fs/exec.c
View file @
95fda206
...
...
@@ -631,12 +631,8 @@ int do_execve(char * filename, char ** argv, char ** envp, struct pt_regs * regs
bprm
.
e_uid
=
(
i
&
S_ISUID
)
?
bprm
.
inode
->
i_uid
:
current
->
euid
;
bprm
.
e_gid
=
(
i
&
S_ISGID
)
?
bprm
.
inode
->
i_gid
:
current
->
egid
;
}
if
(
current
->
euid
==
bprm
.
inode
->
i_uid
)
i
>>=
6
;
else
if
(
in_group_p
(
bprm
.
inode
->
i_gid
))
i
>>=
3
;
if
(
!
(
i
&
1
)
&&
!
((
bprm
.
inode
->
i_mode
&
0111
)
&&
suser
()))
{
if
(
!
permission
(
bprm
.
inode
,
MAY_EXEC
)
||
(
!
(
bprm
.
inode
->
i_mode
&
0111
)
&&
fsuser
()))
{
retval
=
-
EACCES
;
goto
exec_error2
;
}
...
...
This diff is collapsed.
Click to expand it.
fs/ext2/dir.c
View file @
95fda206
...
...
@@ -144,29 +144,36 @@ static int ext2_readdir (struct inode * inode, struct file * filp,
revalidate:
/* If the dir block has changed since the last call to
readdir(2), then we might be pointing to an invalid dirent
right now. Scan from the start of the block to make
sure. */
for
(
i
=
0
;
i
<
sb
->
s_blocksize
&&
i
<
offset
;
)
{
de
=
(
struct
ext2_dir_entry
*
)
(
bh
->
b_data
+
i
);
/* It's too expensive to do a full dirent test
* each time round this loop, but we do have
* to test at least that it is non-zero. A
* failure will be detected in the dirent test
* below. */
if
(
de
->
rec_len
<
EXT2_DIR_REC_LEN
(
1
))
break
;
i
+=
de
->
rec_len
;
* readdir(2), then we might be pointing to an invalid
* dirent right now. Scan from the start of the block
* to make sure. */
if
(
filp
->
f_version
!=
inode
->
i_version
)
{
for
(
i
=
0
;
i
<
sb
->
s_blocksize
&&
i
<
offset
;
)
{
de
=
(
struct
ext2_dir_entry
*
)
(
bh
->
b_data
+
i
);
/* It's too expensive to do a full
* dirent test each time round this
* loop, but we do have to test at
* least that it is non-zero. A
* failure will be detected in the
* dirent test below. */
if
(
de
->
rec_len
<
EXT2_DIR_REC_LEN
(
1
))
break
;
i
+=
de
->
rec_len
;
}
offset
=
i
;
filp
->
f_pos
=
(
filp
->
f_pos
&
~
(
sb
->
s_blocksize
-
1
))
|
offset
;
filp
->
f_version
=
inode
->
i_version
;
}
offset
=
i
;
filp
->
f_pos
=
(
filp
->
f_pos
&
~
(
sb
->
s_blocksize
-
1
))
|
offset
;
while
(
count
>
0
&&
filp
->
f_pos
<
inode
->
i_size
&&
offset
<
sb
->
s_blocksize
)
{
de
=
(
struct
ext2_dir_entry
*
)
(
bh
->
b_data
+
offset
);
if
(
!
ext2_check_dir_entry
(
"ext2_readdir"
,
inode
,
de
,
bh
,
offset
))
{
/* On error, skip the f_pos to the next block. */
/* On error, skip the f_pos to the
next block. */
filp
->
f_pos
=
(
filp
->
f_pos
&
(
sb
->
s_blocksize
-
1
))
+
sb
->
s_blocksize
;
brelse
(
bh
);
...
...
@@ -175,7 +182,8 @@ static int ext2_readdir (struct inode * inode, struct file * filp,
if
(
de
->
inode
)
{
dlen
=
ROUND_UP
(
NAME_OFFSET
(
dirent
)
+
de
->
name_len
+
1
);
/* Old libc libraries always use a count of 1. */
/* Old libc libraries always use a
count of 1. */
if
(
count
==
1
&&
!
stored
)
count
=
dlen
;
if
(
count
<
dlen
)
{
...
...
@@ -184,11 +192,11 @@ static int ext2_readdir (struct inode * inode, struct file * filp,
}
/* We might block in the next section
* if the data destination is
* currently swapped out. So, use a
* version stamp to detect whether or
* not the directory has been modified
* during the copy operation. */
* if the data destination is
* currently swapped out. So, use a
* version stamp to detect whether or
* not the directory has been modified
* during the copy operation. */
version
=
inode
->
i_version
;
i
=
de
->
name_len
;
memcpy_tofs
(
dirent
->
d_name
,
de
->
name
,
i
);
...
...
This diff is collapsed.
Click to expand it.
fs/fcntl.c
View file @
95fda206
...
...
@@ -115,7 +115,24 @@ asmlinkage int sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
*/
return
filp
->
f_owner
;
case
F_SETOWN
:
filp
->
f_owner
=
arg
;
/* XXX security implications? */
/*
* Add the security checks - AC. Without this there is a massive
* Linux security hole here - consider what happens if you do
* something like
* fcntl(0,F_SETOWN,some_root_process);
* getchar();
* and input a line!
*
* BTW: Don't try this for fun. Several Unix systems I tried this on
* fall for the trick!
*
* I had to fix this botch job as Linux kill_fasync asserts
* priv making it a free all user process killer!
*/
if
(
!
suser
()
&&
current
->
pgrp
!=
-
arg
&&
current
->
pid
!=
arg
)
return
-
EPERM
;
filp
->
f_owner
=
arg
;
if
(
S_ISSOCK
(
filp
->
f_inode
->
i_mode
))
sock_fcntl
(
filp
,
F_SETOWN
,
arg
);
return
0
;
...
...
This diff is collapsed.
Click to expand it.
fs/file_table.c
View file @
95fda206
...
...
@@ -79,6 +79,7 @@ struct file * get_empty_filp(void)
memset
(
f
,
0
,
sizeof
(
*
f
));
put_last_free
(
f
);
f
->
f_count
=
1
;
f
->
f_version
=
++
event
;
return
f
;
}
if
(
nr_files
<
NR_FILE
)
{
...
...
This diff is collapsed.
Click to expand it.
fs/read_write.c
View file @
95fda206
...
...
@@ -71,6 +71,7 @@ asmlinkage int sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
if
(
tmp
!=
file
->
f_pos
)
{
file
->
f_pos
=
tmp
;
file
->
f_reada
=
0
;
file
->
f_version
=
++
event
;
}
return
file
->
f_pos
;
}
...
...
@@ -109,6 +110,7 @@ asmlinkage int sys_llseek(unsigned int fd, unsigned long offset_high,
return
-
EINVAL
;
file
->
f_pos
=
tmp
;
file
->
f_reada
=
0
;
file
->
f_version
=
++
event
;
memcpy_tofs
(
result
,
&
file
->
f_pos
,
sizeof
(
loff_t
));
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
fs/xiafs/dir.c
View file @
95fda206
...
...
@@ -131,5 +131,5 @@ static int xiafs_readdir(struct inode * inode,
inode
->
i_atime
=
CURRENT_TIME
;
inode
->
i_dirt
=
1
;
}
return
0
;
return
ret
;
}
This diff is collapsed.
Click to expand it.
include/linux/fs.h
View file @
95fda206
...
...
@@ -233,6 +233,7 @@ struct file {
int
f_owner
;
/* pid or -pgrp where SIGIO should be sent */
struct
inode
*
f_inode
;
struct
file_operations
*
f_op
;
unsigned
long
f_version
;
void
*
private_data
;
/* needed for tty driver, and maybe others */
};
...
...
This diff is collapsed.
Click to expand it.
include/linux/if_arp.h
View file @
95fda206
...
...
@@ -52,6 +52,7 @@ struct arpreq {
struct
sockaddr
arp_pa
;
/* protocol address */
struct
sockaddr
arp_ha
;
/* hardware address */
int
arp_flags
;
/* flags */
struct
sockaddr
arp_netmask
;
/* netmask (only for proxy arps) */
};
/* ARP Flag values. */
...
...
@@ -59,6 +60,8 @@ struct arpreq {
#define ATF_PERM 0x04
/* permanent entry */
#define ATF_PUBL 0x08
/* publish entry */
#define ATF_USETRAILERS 0x10
/* has requested trailers */
#define ATF_NETMASK 0x20
/* want to use a netmask (only
for proxy entries) */
/*
* This structure defines an ethernet arp header.
...
...
This diff is collapsed.
Click to expand it.
include/linux/net.h
View file @
95fda206
...
...
@@ -77,6 +77,7 @@ struct socket {
struct
socket
*
next
;
struct
wait_queue
**
wait
;
/* ptr to place to wait on */
struct
inode
*
inode
;
struct
fasync_struct
*
fasync_list
;
/* Asynchronous wake up list */
};
#define SOCK_INODE(S) ((S)->inode)
...
...
@@ -128,7 +129,9 @@ struct net_proto {
};
extern
int
sock_awaitconn
(
struct
socket
*
mysock
,
struct
socket
*
servsock
);
extern
int
sock_wake_async
(
struct
socket
*
sock
);
extern
int
sock_register
(
int
family
,
struct
proto_ops
*
ops
);
extern
int
sock_unregister
(
int
family
);
#endif
/* __KERNEL__ */
#endif
/* _LINUX_NET_H */
This diff is collapsed.
Click to expand it.
include/linux/socket.h
View file @
95fda206
...
...
@@ -81,9 +81,6 @@ struct linger {
/* IPX options */
#define IPX_TYPE 1
/* AX.25 options */
#define AX25_WINDOW 1
/* TCP options - this way around because someone left a set in the c library includes */
#define TCP_NODELAY 1
#define TCP_MAXSEG 2
...
...
This diff is collapsed.
Click to expand it.
kernel/ksyms.c
View file @
95fda206
...
...
@@ -28,6 +28,7 @@
#include <linux/tty.h>
#include <linux/serial.h>
#ifdef CONFIG_INET
#include <linux/net.h>
#include <linux/netdevice.h>
#endif
...
...
@@ -169,6 +170,10 @@ struct symbol_table symbol_table = { 0, 0, 0, /* for stacked module support */
/* Miscellaneous access points */
X
(
si_meminfo
),
/* socket layer registration */
X
(
sock_register
),
X
(
sock_unregister
),
#ifdef CONFIG_FTAPE
/* The next labels are needed for ftape driver. */
X
(
ftape_big_buffer
),
...
...
@@ -187,6 +192,12 @@ struct symbol_table symbol_table = { 0, 0, 0, /* for stacked module support */
X
(
dev_rint
),
X
(
dev_tint
),
X
(
irq2dev_map
),
X
(
dev_add_pack
),
X
(
dev_remove_pack
),
X
(
dev_get
),
X
(
dev_ioctl
),
X
(
dev_queue_xmit
),
X
(
dev_base
),
#endif
/********************************************************
...
...
This diff is collapsed.
Click to expand it.
kernel/sys.c
View file @
95fda206
...
...
@@ -322,7 +322,7 @@ asmlinkage int sys_setreuid(uid_t ruid, uid_t euid)
if
(
ruid
!=
(
uid_t
)
-
1
||
(
euid
!=
(
uid_t
)
-
1
&&
euid
!=
old_ruid
))
current
->
suid
=
current
->
euid
;
current
->
fsuid
=
euid
;
current
->
fsuid
=
current
->
euid
;
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
net/inet/README
View file @
95fda206
Changes for 1.1.21
Changes for NET3.017
This is mostly small stuff as follows:
o accept()ed socket don't end up with an invalid sk->socket and give bogus
netstat output.
o FASYNC/SIGIO now works with sockets.
o Fixed the permissions on F_SETOWN for all. Its now as broken/working
as other systems. Really we need something like a 32bit generation
number on processes.
o ARP allows proxy for whole networks (a la cisco routers)
o TCP sendto() reports ENOTCONN in the right cases
o Removed some surplus uncommented code from tcp.c
o Fixed protocol violation during closedown in tcp.c
[Still not got the window < MSS bug fix included]
o Small bug fix in the apricot xen-ii driver code (Mark Evans)
o DE600 changes + DE620 driver (Bj0rn Eckwall)
o WWW error return bug fixed (Everyone!)
o SLIP default address is now better
o Small changes to PLIP (Niibe)
o Added PF_UNSPEC (Dominic Kubla)
o TCP fastpath for receive.
o Turbo charged tcp checksum routine (Arnt Gulbrandsen)
o PPP locking bug fixes (Florian La Roche)
To Do
o Include the HP onboard lance fixes.
o Fix Unix domain sockets.
o Fix the _SLOW_ TCP window calculation junk in tcp_data/tcp_ack.
o Make the dev_add_proto() list hashed by protocol type.
o Remove the call to dev->header_type - load it into the skbuff.
instead to avoid the extra calls and cache misses.
o Include new sk_buff skb_push() code and move toward using it.
o Fix the PI driver so pi0a can be down when pi0b is up without getting
crashes. Also fix the stuff to allow piconfig to set the parameters.
o Make AX.25 set the packet type - certainly before it hits IP.
o sk_buff building at the top level - pure kernel interfaces to the
protocol layers
o Clean up NFS, merge NFS/TCP code.
o SIGIO
o IP forwarding use of options properly (needs new sk_buff code)
o Reroute TCP retransmits if needed (needs new sk_buffs)
Changes for 1.1.20
o All read/write buffers are validated at the top level _only_
o All address structures are moved to and from user mode at the top
level. Thus you can now issue proto->bind(....) calls and related
functions such as connect from another kernel task. All thats left
to fix now is a kernel alloc_socket()/free_socket() and accompanying
proto->make_kernel(socket)
o Small fixes to address behaviour caused by the above
o Max NFS size of 16K bytes
o Added the apricot driver as a test (#'ed out in config.in)
o Fixed a missing function definition in net_init.c
o Added G4KLX ax25_router code
o Added Niibe's PLIP driver and altered it to support timer
configuration and IRQ/port setting. Added if_plip.h. Comments and
feedback appreciated on this (both to Niibe and me).
o Added AF_MAX/PF_MAX defines
o Added a note that the DE600 driver also works for a noname 'PE1200'.
o Network buffer statistics on shift-scroll_lock
o Fixed a serious race in the device driver code. This was causing odd
crashes with the Lance drivers, lockups with the ne2000 cards and
a few other 'bad' goings on. All drivers are effected. See
README.DEV if porting a driver to this revision.
If you see entries in your 'free while locked' count, those would
typically have crashed a pre 1.20 kernel.
o TCP keeps the timers above 0.2sec round-trip time because of the use of
delayed ACK's by BSD style kernels.
o Fixed a small BSD error in the return from datagram socket
recv/recvfrom() calls when data is truncated. BSD returns the true
length of the message, Linux returned the amount copied which broke
programs that did a MSG_PEEK with a small buffer and grew it if need
be (some of the AV/RTP stuff notably).
o Added TIOCINQ/OUTQ to AX.25 and IPX.
o Added driver ioctl() calls to IPX.
o Corrected the skb->len==0 in the tcp_data reset on shutdown to check
skb->copied_seq.
o IP options reflect onto SO_PRIORITY.
o When a driver is downed its ARP entries are flushed. Should solve
the occasional crash when taking out a modular driver.
o Added Donald's multicast reception while promiscuous fix for the
8390 drivers.
o Potential ARP TCP-retransmit clear race fixed. Incredibly
unlikely to occur but no doubt it will 8(.
Fixes added for 1.1.19
o Unix domain bind error code.
o skb->localroute starts cleared.
o Compiles with networking disabled
Fixes added for 1.1.18
o Dummy driver includes correctly.
o PPP fixes from A.L.
o ifslave fixes
o Small error causing nfsd to coredump fixed by Linus.
Fixes added for 1.1.17
o Charles Hedrick's fixes broken fragmentation totally. Mended.
o Contributed 'dummy' device added. Apparently some slip people want it.
o Tried to kill the memory problems with fragments by setting things
up more carefully and guarding them.
o Module fixes by Bj0rn.
o PLIP fix by Tanabe.
Fixes added for 1.1.16
o Charles Hedricks fixes to TCP.
o Small fixes all over the place.
Fixes added for 1.1.15
o Modular PLIP and 3c501 drivers. Now you -can- have multiple 3c501's
(sort of).
o Integrated new AX.25 - this will be ready for the big time in a few
releases.
Fixes added for 1.1.14
o Compiles properly on the whole 8)
o Yet more Unix /proc protection.
o Modular PLIP and 3c501 drivers. Now you -can- have multiple 3c501's
(sort of).
This fixes the following from the 1.1.12 release (see the relevant files
for the credits to authors).
o RARP compiles in properly
o Using new Tytso TTY drivers
o IP forwarding is configurable
o PC/TCP support
o AX.25 builds fine without SLIP driver (just PI)
o MTU recognized in routing table (but only by TCP currently)
o AX.25 PI driver merged into AX.25 code and kernel stubs
o UNIX /proc trap hopefully fixed
o DDI removed totally ready to use the PCMCIA people's stuff
o Unix domain lock/unlock now static (needlessly visible before)
o Split net/inet/sock.c into generic and IP components
o NFS client works correctly with 8K NFS
o Non IP builds work correctly
o Renamed inet_bh etc to net_bh to reflect true nature
o TCP handling of poor routes much improved
o TCP connect timing fixed
o Incredibly unlikely SLIP memory leak removed
o Loopback maintains IFF_LOOPBACK flag
o Johnathon Naylor(G4KLX) AX.25 changes
o Out of sync bug in lance driver fixed.
o First cut at ethernet loadable modules
o PCMCIA people have ifmap stuff. Will extend this to other drivers.
o New de600.c
o Clean up of IP layer - sorted a lot of redundant and duplicated code
out.
o Removed all the old non working debugging junk from the kernel.
o Removed all the devices the kernel used to use as a legacy from
FvK's days writing the linux networking.
o Greg Page's latest and greatest IPX fixes (including 802.2). Now
I've got the stuff to write a free Netware client too and some
volunteers to do it.
o Fixed the 1.1.12 ARP fragment bug.
This diff is collapsed.
Click to expand it.
net/inet/af_inet.c
View file @
95fda206
...
...
@@ -15,6 +15,12 @@
* Changes (see also sock.c)
*
* A.N.Kuznetsov : Socket death error in accept().
* John Richardson : Fix non blocking error in connect()
* so sockets that fail to connect
* don't return -EINPROGRESS.
* Alan Cox : Asynchronous I/O support
* Alan Cox : Keep correct socket pointer on sock structures
* when accept() ed
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -461,7 +467,10 @@ static void def_callback1(struct sock *sk)
static
void
def_callback2
(
struct
sock
*
sk
,
int
len
)
{
if
(
!
sk
->
dead
)
{
wake_up_interruptible
(
sk
->
sleep
);
sock_wake_async
(
sk
->
socket
);
}
}
...
...
@@ -875,6 +884,12 @@ static int inet_connect(struct socket *sock, struct sockaddr * uaddr,
return
(
err
);
sock
->
state
=
SS_CONNECTING
;
}
if
(
sk
->
state
>
TCP_FIN_WAIT2
&&
sock
->
state
==
SS_CONNECTING
)
{
sock
->
state
=
SS_UNCONNECTED
;
return
-
ETIMEDOUT
;
}
if
(
sk
->
state
!=
TCP_ESTABLISHED
&&
(
flags
&
O_NONBLOCK
))
return
(
-
EINPROGRESS
);
...
...
@@ -966,6 +981,7 @@ static int inet_accept(struct socket *sock, struct socket *newsock, int flags)
}
newsock
->
data
=
(
void
*
)
sk2
;
sk2
->
sleep
=
newsock
->
wait
;
sk2
->
socket
=
newsock
;
newsock
->
conn
=
NULL
;
if
(
flags
&
O_NONBLOCK
)
return
(
0
);
...
...
@@ -979,6 +995,7 @@ static int inet_accept(struct socket *sock, struct socket *newsock, int flags)
sti
();
sk1
->
pair
=
sk2
;
sk2
->
sleep
=
NULL
;
sk2
->
socket
=
NULL
;
newsock
->
data
=
NULL
;
return
(
-
ERESTARTSYS
);
}
...
...
@@ -1318,7 +1335,7 @@ void inet_proto_init(struct net_proto *pro)
int
i
;
printk
(
"
NET3 TCP/IP protocols stack v
01
6
\n
"
);
printk
(
"
Swansea University Computer Society TCP/IP for NET3.
01
7
\n
"
);
/*
* Tell SOCKET that we are alive...
...
...
This diff is collapsed.
Click to expand it.
net/inet/arp.c
View file @
95fda206
...
...
@@ -33,6 +33,8 @@
* Martin Seine : Move the arphdr structure
* to if_arp.h for compatibility
* with BSD based programs.
* Andrew Tridgell : Added ARP netmask code and
* re-arranged proxy handling
*/
#include <linux/types.h>
...
...
@@ -62,6 +64,7 @@
#include "ax25.h"
#endif
/*
* This structure defines the ARP mapping cache. As long as we make changes
* in this structure, we keep interrupts of. But normally we can copy the
...
...
@@ -75,6 +78,7 @@ struct arp_table
unsigned
long
last_used
;
/* For expiry */
unsigned
int
flags
;
/* Control status */
unsigned
long
ip
;
/* ip address of entry */
unsigned
long
mask
;
/* netmask - used for generalised proxy arps (tridge) */
unsigned
char
ha
[
MAX_ADDR_LEN
];
/* Hardware address */
unsigned
char
hlen
;
/* Length of hardware address */
unsigned
short
htype
;
/* Type of hardware in use */
...
...
@@ -122,39 +126,52 @@ struct arp_table
#define ARP_CHECK_INTERVAL (60 * HZ)
static
void
arp_check_expire
(
unsigned
long
);
/* Forward declaration. */
/* Forward declarations. */
static
void
arp_check_expire
(
unsigned
long
);
static
struct
arp_table
*
arp_lookup
(
unsigned
long
paddr
,
int
exact
);
static
struct
timer_list
arp_timer
=
{
NULL
,
NULL
,
ARP_CHECK_INTERVAL
,
0L
,
&
arp_check_expire
};
/*
* The default arp netmask is just 255.255.255.255 which means it's
* a single machine entry. Only proxy entries can have other netmasks
*
*/
#define DEF_ARP_NETMASK (~0)
/*
* The size of the hash table. Must be a power of two.
* Maybe we should remove hashing in the future for arp and concentrate
* on Patrick Schaaf's Host-Cache-Lookup...
*/
#define ARP_TABLE_SIZE 16
struct
arp_table
*
arp_tables
[
ARP_TABLE_SIZE
]
=
/* The ugly +1 here is to cater for proxy entries. They are put in their
own list for efficiency of lookup. If you don't want to find a proxy
entry then don't look in the last entry, otherwise do
*/
#define FULL_ARP_TABLE_SIZE (ARP_TABLE_SIZE+1)
struct
arp_table
*
arp_tables
[
FULL_ARP_TABLE_SIZE
]
=
{
NULL
,
};
/*
* The last bits in the IP address are used for the cache lookup.
* A special entry is used for proxy arp entries
*/
#define HASH(paddr) (htonl(paddr) & (ARP_TABLE_SIZE - 1))
/*
* Number of proxy arp entries. This is normally zero and we use it to do
* some optimizing for normal uses.
*/
static
int
proxies
=
0
;
#define PROXY_HASH ARP_TABLE_SIZE
/*
* Check if there are too old entries and remove them. If the ATF_PERM
...
...
@@ -172,7 +189,7 @@ static void arp_check_expire(unsigned long dummy)
save_flags
(
flags
);
cli
();
for
(
i
=
0
;
i
<
ARP_TABLE_SIZE
;
i
++
)
for
(
i
=
0
;
i
<
FULL_
ARP_TABLE_SIZE
;
i
++
)
{
struct
arp_table
*
entry
;
struct
arp_table
**
pentry
=
&
arp_tables
[
i
];
...
...
@@ -183,8 +200,6 @@ static void arp_check_expire(unsigned long dummy)
&&
!
(
entry
->
flags
&
ATF_PERM
))
{
*
pentry
=
entry
->
next
;
/* remove from list */
if
(
entry
->
flags
&
ATF_PUBL
)
proxies
--
;
del_timer
(
&
entry
->
timer
);
/* Paranoia */
kfree_s
(
entry
,
sizeof
(
struct
arp_table
));
}
...
...
@@ -213,9 +228,6 @@ static void arp_release_entry(struct arp_table *entry)
struct
sk_buff
*
skb
;
unsigned
long
flags
;
if
(
entry
->
flags
&
ATF_PUBL
)
proxies
--
;
save_flags
(
flags
);
cli
();
/* Release the list of `skb' pointers. */
...
...
@@ -234,7 +246,7 @@ static void arp_release_entry(struct arp_table *entry)
/*
* Purge a device from the ARP queue
*/
void
arp_device_down
(
struct
device
*
dev
)
{
int
i
;
...
...
@@ -245,7 +257,7 @@ void arp_device_down(struct device *dev)
*/
save_flags
(
flags
);
cli
();
for
(
i
=
0
;
i
<
ARP_TABLE_SIZE
;
i
++
)
for
(
i
=
0
;
i
<
FULL_
ARP_TABLE_SIZE
;
i
++
)
{
struct
arp_table
*
entry
;
struct
arp_table
**
pentry
=
&
arp_tables
[
i
];
...
...
@@ -255,8 +267,6 @@ void arp_device_down(struct device *dev)
if
(
entry
->
dev
==
dev
)
{
*
pentry
=
entry
->
next
;
/* remove from list */
if
(
entry
->
flags
&
ATF_PUBL
)
proxies
--
;
del_timer
(
&
entry
->
timer
);
/* Paranoia */
kfree_s
(
entry
,
sizeof
(
struct
arp_table
));
}
...
...
@@ -387,9 +397,16 @@ static void arp_expire_request (unsigned long arg)
* loop through everything again. Maybe hash is good enough, but
* I will look at it later.
*/
hash
=
HASH
(
entry
->
ip
);
pentry
=
&
arp_tables
[
hash
];
/* proxy entries shouldn't really time out so this is really
only here for completeness
*/
if
(
entry
->
flags
&
ATF_PUBL
)
pentry
=
&
arp_tables
[
PROXY_HASH
];
else
pentry
=
&
arp_tables
[
hash
];
while
(
*
pentry
!=
NULL
)
{
if
(
*
pentry
==
entry
)
...
...
@@ -466,12 +483,16 @@ static void arp_send_q(struct arp_table *entry, unsigned char *hw_dest)
void
arp_destroy
(
unsigned
long
ip_addr
,
int
force
)
{
int
checked_proxies
=
0
;
struct
arp_table
*
entry
;
struct
arp_table
**
pentry
;
unsigned
long
hash
=
HASH
(
ip_addr
);
cli
();
pentry
=
&
arp_tables
[
hash
];
if
(
!
*
pentry
)
/* also check proxy entries */
pentry
=
&
arp_tables
[
PROXY_HASH
];
while
((
entry
=
*
pentry
)
!=
NULL
)
{
if
(
entry
->
ip
==
ip_addr
)
...
...
@@ -485,6 +506,12 @@ void arp_destroy(unsigned long ip_addr, int force)
return
;
}
pentry
=
&
entry
->
next
;
if
(
!
checked_proxies
&&
!
*
pentry
)
{
/* ugly. we have to make sure we check proxy
entries as well */
checked_proxies
=
1
;
pentry
=
&
arp_tables
[
PROXY_HASH
];
}
}
sti
();
}
...
...
@@ -507,7 +534,7 @@ int arp_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
struct
arp_table
*
entry
;
struct
arp_table
*
proxy_entry
;
int
addr_hint
,
hlen
,
htype
;
unsigned
long
hash
,
dest_
hash
;
unsigned
long
hash
;
unsigned
char
ha
[
MAX_ADDR_LEN
];
/* So we can enable ints again. */
long
sip
,
tip
;
unsigned
char
*
sha
,
*
tha
;
...
...
@@ -546,6 +573,7 @@ int arp_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
break
;
#endif
case
ARPHRD_ETHER
:
case
ARPHRD_ARCNET
:
if
(
arp
->
ar_pro
!=
htons
(
ETH_P_IP
))
{
kfree_skb
(
skb
,
FREE_READ
);
...
...
@@ -628,22 +656,25 @@ int arp_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
* check if that someone else is one of our proxies. If it isn't,
* we can toss it.
*/
if
(
proxies
==
0
)
{
kfree_skb
(
skb
,
FREE_READ
);
return
0
;
}
dest_hash
=
HASH
(
tip
);
cli
();
for
(
proxy_entry
=
arp_tables
[
dest_hash
];
proxy_entry
;
proxy_entry
=
proxy_entry
->
next
)
for
(
proxy_entry
=
arp_tables
[
PROXY_HASH
];
proxy_entry
;
proxy_entry
=
proxy_entry
->
next
)
{
if
(
proxy_entry
->
ip
==
tip
&&
proxy_entry
->
htype
==
htype
)
break
;
/* we will respond to a proxy arp request
if the masked arp table ip matches the masked
tip. This allows a single proxy arp table
entry to be used on a gateway machine to handle
all requests for a whole network, rather than
having to use a huge number of proxy arp entries
and having to keep them uptodate.
*/
if
(
proxy_entry
->
htype
==
htype
&&
!
((
proxy_entry
->
ip
^
tip
)
&
proxy_entry
->
mask
))
break
;
}
if
(
proxy_entry
&&
(
proxy_entry
->
flags
&
ATF_PUBL
)
)
if
(
proxy_entry
)
{
memcpy
(
ha
,
proxy_entry
->
ha
,
hlen
);
sti
();
...
...
@@ -724,6 +755,7 @@ int arp_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
return
0
;
}
entry
->
mask
=
DEF_ARP_NETMASK
;
entry
->
ip
=
sip
;
entry
->
hlen
=
hlen
;
entry
->
htype
=
htype
;
...
...
@@ -774,10 +806,7 @@ int arp_find(unsigned char *haddr, unsigned long paddr, struct device *dev,
/*
* Find an entry
*/
for
(
entry
=
arp_tables
[
hash
];
entry
!=
NULL
;
entry
=
entry
->
next
)
if
(
entry
->
ip
==
paddr
)
break
;
entry
=
arp_lookup
(
paddr
,
0
);
if
(
entry
!=
NULL
)
/* It exists */
{
...
...
@@ -817,6 +846,7 @@ int arp_find(unsigned char *haddr, unsigned long paddr, struct device *dev,
GFP_ATOMIC
);
if
(
entry
!=
NULL
)
{
entry
->
mask
=
DEF_ARP_NETMASK
;
entry
->
ip
=
paddr
;
entry
->
hlen
=
dev
->
addr_len
;
entry
->
htype
=
dev
->
type
;
...
...
@@ -874,12 +904,13 @@ int arp_get_info(char *buffer, char **start, off_t offset, int length)
int
i
,
j
,
k
;
const
char
hexbuf
[]
=
"0123456789ABCDEF"
;
size
=
sprintf
(
buffer
,
"IP address HW type Flags HW address
\n
"
);
size
=
sprintf
(
buffer
,
"IP address HW type Flags HW address Mask
\n
"
);
pos
+=
size
;
len
+=
size
;
cli
();
for
(
i
=
0
;
i
<
ARP_TABLE_SIZE
;
i
++
)
for
(
i
=
0
;
i
<
FULL_
ARP_TABLE_SIZE
;
i
++
)
{
for
(
entry
=
arp_tables
[
i
];
entry
!=
NULL
;
entry
=
entry
->
next
)
{
...
...
@@ -905,11 +936,15 @@ int arp_get_info(char *buffer, char **start, off_t offset, int length)
}
#endif
size
=
sprintf
(
buffer
+
len
,
"%-17s0x%-10x0x%-10x%s
\n
"
,
"%-17s0x%-10x0x%-10x%s"
,
in_ntoa
(
entry
->
ip
),
(
unsigned
int
)
entry
->
htype
,
entry
->
flags
,
hbuffer
);
size
+=
sprintf
(
buffer
+
len
+
size
,
" %-17s
\n
"
,
entry
->
mask
==
DEF_ARP_NETMASK
?
"*"
:
in_ntoa
(
entry
->
mask
));
len
+=
size
;
pos
=
begin
+
len
;
...
...
@@ -935,17 +970,24 @@ int arp_get_info(char *buffer, char **start, off_t offset, int length)
/*
* This will find an entry in the ARP table by looking at the IP address.
* Be careful, interrupts are turned off on exit!!!
* If exact is true then only exact IP matches will be allowed
* for proxy entries, otherwise the netmask will be used
*/
static
struct
arp_table
*
arp_lookup
(
unsigned
long
paddr
)
static
struct
arp_table
*
arp_lookup
(
unsigned
long
paddr
,
int
exact
)
{
struct
arp_table
*
entry
;
unsigned
long
hash
=
HASH
(
paddr
);
cli
();
for
(
entry
=
arp_tables
[
hash
];
entry
!=
NULL
;
entry
=
entry
->
next
)
if
(
entry
->
ip
==
paddr
)
break
;
/* it's possibly a proxy entry (with a netmask) */
if
(
!
entry
)
for
(
entry
=
arp_tables
[
PROXY_HASH
];
entry
!=
NULL
;
entry
=
entry
->
next
)
if
(
exact
?
(
entry
->
ip
==
paddr
)
:
!
((
entry
->
ip
^
paddr
)
&
entry
->
mask
))
break
;
return
entry
;
}
...
...
@@ -960,7 +1002,7 @@ static int arp_req_set(struct arpreq *req)
struct
arp_table
*
entry
;
struct
sockaddr_in
*
si
;
int
htype
,
hlen
;
unsigned
long
ip
,
hash
;
unsigned
long
ip
;
struct
rtable
*
rt
;
memcpy_fromfs
(
&
r
,
req
,
sizeof
(
r
));
...
...
@@ -980,6 +1022,10 @@ static int arp_req_set(struct arpreq *req)
htype
=
ARPHRD_ETHER
;
hlen
=
ETH_ALEN
;
break
;
case
ARPHRD_ARCNET
:
htype
=
ARPHRD_ARCNET
;
hlen
=
1
;
/* length of arcnet addresses */
break
;
#ifdef CONFIG_AX25
case
ARPHRD_AX25
:
htype
=
ARPHRD_AX25
;
...
...
@@ -1010,15 +1056,12 @@ static int arp_req_set(struct arpreq *req)
* Is there an existing entry for this address?
*/
hash
=
HASH
(
ip
);
cli
();
/*
* Find the entry
*/
for
(
entry
=
arp_tables
[
hash
];
entry
!=
NULL
;
entry
=
entry
->
next
)
if
(
entry
->
ip
==
ip
)
break
;
entry
=
arp_lookup
(
ip
,
1
);
/*
* Do we need to create a new entry
...
...
@@ -1026,6 +1069,10 @@ static int arp_req_set(struct arpreq *req)
if
(
entry
==
NULL
)
{
unsigned
long
hash
=
HASH
(
ip
);
if
(
r
.
arp_flags
&
ATF_PUBL
)
hash
=
PROXY_HASH
;
entry
=
(
struct
arp_table
*
)
kmalloc
(
sizeof
(
struct
arp_table
),
GFP_ATOMIC
);
if
(
entry
==
NULL
)
...
...
@@ -1041,9 +1088,6 @@ static int arp_req_set(struct arpreq *req)
arp_tables
[
hash
]
=
entry
;
skb_queue_head_init
(
&
entry
->
skb
);
}
else
if
(
entry
->
flags
&
ATF_PUBL
)
proxies
--
;
/*
* We now have a pointer to an ARP entry. Update it!
*/
...
...
@@ -1051,8 +1095,13 @@ static int arp_req_set(struct arpreq *req)
memcpy
(
&
entry
->
ha
,
&
r
.
arp_ha
.
sa_data
,
hlen
);
entry
->
last_used
=
jiffies
;
entry
->
flags
=
r
.
arp_flags
|
ATF_COM
;
if
(
entry
->
flags
&
ATF_PUBL
)
proxies
++
;
if
((
entry
->
flags
&
ATF_PUBL
)
&&
(
entry
->
flags
&
ATF_NETMASK
))
{
si
=
(
struct
sockaddr_in
*
)
&
r
.
arp_netmask
;
entry
->
mask
=
si
->
sin_addr
.
s_addr
;
}
else
entry
->
mask
=
DEF_ARP_NETMASK
;
entry
->
dev
=
rt
->
rt_dev
;
sti
();
...
...
@@ -1084,7 +1133,8 @@ static int arp_req_get(struct arpreq *req)
*/
si
=
(
struct
sockaddr_in
*
)
&
r
.
arp_pa
;
entry
=
arp_lookup
(
si
->
sin_addr
.
s_addr
);
cli
();
entry
=
arp_lookup
(
si
->
sin_addr
.
s_addr
,
0
);
if
(
entry
==
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment