Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
8549ccb7
Commit
8549ccb7
authored
Jul 18, 2002
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Manual content merge with Rusty's ISO struct initializers patch.
parents
eb1f4c38
1d086a5d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
304 additions
and
247 deletions
+304
-247
net/appletalk/aarp.c
net/appletalk/aarp.c
+126
-105
net/appletalk/ddp.c
net/appletalk/ddp.c
+130
-128
net/appletalk/sysctl_net_atalk.c
net/appletalk/sysctl_net_atalk.c
+48
-14
No files found.
net/appletalk/aarp.c
View file @
8549ccb7
...
...
@@ -66,17 +66,29 @@ int sysctl_aarp_retransmit_limit = AARP_RETRANSMIT_LIMIT;
int
sysctl_aarp_resolve_time
=
AARP_RESOLVE_TIME
;
/* Lists of aarp entries */
/**
* struct aarp_entry - AARP entry
* @last_sent - Last time we xmitted the aarp request
* @packet_queue - Queue of frames wait for resolution
* @status - Used for proxy AARP
* expires_at - Entry expiry time
* target_addr - DDP Address
* dev - Device to use
* hwaddr - Physical i/f address of target/router
* xmit_count - When this hits 10 we give up
* next - Next entry in chain
*/
struct
aarp_entry
{
/* These first two are only used for unresolved entries */
unsigned
long
last_sent
;
/* Last time we xmitted the aarp request */
struct
sk_buff_head
packet_queue
;
/* Queue of frames wait for resolution */
int
status
;
/* Used for proxy AARP */
unsigned
long
expires_at
;
/* Entry expiry time */
struct
at_addr
target_addr
;
/* DDP Address */
struct
net_device
*
dev
;
/* Device to use */
char
hwaddr
[
6
];
/* Physical i/f address of target/router */
unsigned
short
xmit_count
;
/* When this hits 10 we give up */
struct
aarp_entry
*
next
;
/* Next entry in chain */
unsigned
long
last_sent
;
struct
sk_buff_head
packet_queue
;
int
status
;
unsigned
long
expires_at
;
struct
at_addr
target_addr
;
struct
net_device
*
dev
;
char
hwaddr
[
6
];
unsigned
short
xmit_count
;
struct
aarp_entry
*
next
;
};
/* Hashed list of resolved, unresolved and proxy entries */
...
...
@@ -371,7 +383,7 @@ static int aarp_device_event(struct notifier_block *this, unsigned long event,
static
struct
aarp_entry
*
aarp_alloc
(
void
)
{
struct
aarp_entry
*
a
=
kmalloc
(
sizeof
(
struct
aarp_entry
),
GFP_ATOMIC
);
struct
aarp_entry
*
a
=
kmalloc
(
sizeof
(
*
a
),
GFP_ATOMIC
);
if
(
a
)
skb_queue_head_init
(
&
a
->
packet_queue
);
...
...
@@ -462,7 +474,7 @@ void aarp_probe_network(struct atalk_iface *atif)
/* Defer 1/10th */
current
->
state
=
TASK_INTERRUPTIBLE
;
schedule_timeout
(
HZ
/
10
);
schedule_timeout
(
HZ
/
10
);
if
(
atif
->
status
&
ATIF_PROBE_FAIL
)
break
;
...
...
@@ -472,7 +484,7 @@ void aarp_probe_network(struct atalk_iface *atif)
int
aarp_proxy_probe_network
(
struct
atalk_iface
*
atif
,
struct
at_addr
*
sa
)
{
int
hash
,
retval
=
1
;
int
hash
,
retval
=
-
EPROTONOSUPPORT
;
struct
aarp_entry
*
entry
;
unsigned
int
count
;
...
...
@@ -480,19 +492,18 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa)
* we don't currently support LocalTalk or PPP for proxy AARP;
* if someone wants to try and add it, have fun
*/
if
(
atif
->
dev
->
type
==
ARPHRD_LOCALTLK
)
return
-
EPROTONOSUPPORT
;
if
(
atif
->
dev
->
type
==
ARPHRD_PPP
)
return
-
EPROTONOSUPPORT
;
if
(
atif
->
dev
->
type
==
ARPHRD_LOCALTLK
||
atif
->
dev
->
type
==
ARPHRD_PPP
)
goto
out
;
/*
* create a new AARP entry with the flags set to be published --
* we need this one to hang around even if it's in use
*/
entry
=
aarp_alloc
();
retval
=
-
ENOMEM
;
if
(
!
entry
)
return
-
ENOMEM
;
goto
out
;
entry
->
expires_at
=
-
1
;
entry
->
status
=
ATIF_PROBE
;
...
...
@@ -512,7 +523,7 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa)
/* Defer 1/10th */
current
->
state
=
TASK_INTERRUPTIBLE
;
spin_unlock_bh
(
&
aarp_lock
);
schedule_timeout
(
HZ
/
10
);
schedule_timeout
(
HZ
/
10
);
spin_lock_bh
(
&
aarp_lock
);
if
(
entry
->
status
&
ATIF_PROBE_FAIL
)
...
...
@@ -522,10 +533,13 @@ int aarp_proxy_probe_network(struct atalk_iface *atif, struct at_addr *sa)
if
(
entry
->
status
&
ATIF_PROBE_FAIL
)
{
entry
->
expires_at
=
jiffies
-
1
;
/* free the entry */
retval
=
-
EADDRINUSE
;
/* return network full */
}
else
/* clear the probing flag */
}
else
{
/* clear the probing flag */
entry
->
status
&=
~
ATIF_PROBE
;
retval
=
1
;
}
spin_unlock_bh
(
&
aarp_lock
);
out:
return
retval
;
}
...
...
@@ -613,8 +627,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
a
=
__aarp_find_entry
(
unresolved
[
hash
],
dev
,
sa
);
if
(
a
)
{
/* Queue onto the unresolved queue */
skb_queue_tail
(
&
a
->
packet_queue
,
skb
);
spin_unlock_bh
(
&
aarp_lock
);
return
0
;
goto
out_unlock
;
}
/* Allocate a new entry */
...
...
@@ -647,12 +660,14 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
mod_timer
(
&
aarp_timer
,
jiffies
+
sysctl_aarp_tick_time
);
/* Now finally, it is safe to drop the lock. */
out_unlock:
spin_unlock_bh
(
&
aarp_lock
);
/* Tell the ddp layer we have taken over for this frame. */
return
0
;
sendit:
if
(
skb
->
sk
)
sendit:
if
(
skb
->
sk
)
skb
->
priority
=
skb
->
sk
->
priority
;
dev_queue_xmit
(
skb
);
return
1
;
...
...
@@ -834,9 +849,12 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
break
;
}
unlock:
spin_unlock_bh
(
&
aarp_lock
);
out1:
ret
=
1
;
out0:
kfree_skb
(
skb
);
unlock:
spin_unlock_bh
(
&
aarp_lock
);
out1:
ret
=
1
;
out0:
kfree_skb
(
skb
);
return
ret
;
}
...
...
@@ -880,81 +898,84 @@ static int aarp_get_info(char *buffer, char **start, off_t offset, int length)
{
/* we should dump all our AARP entries */
struct
aarp_entry
*
entry
;
int
len
,
ct
;
len
=
sprintf
(
buffer
,
"%-10.10s %-10.10s%-18.18s%12.12s%12.12s xmit_count status
\n
"
,
"address"
,
"device"
,
"hw addr"
,
"last_sent"
,
"expires"
);
int
ct
,
len
=
sprintf
(
buffer
,
"%-10.10s %-10.10s%-18.18s%12.12s%12.12s "
"xmit_count status
\n
"
,
"address"
,
"device"
,
"hw addr"
,
"last_sent
"
,
"expires"
);
spin_lock_bh
(
&
aarp_lock
);
for
(
ct
=
0
;
ct
<
AARP_HASH_SIZE
;
ct
++
)
{
for
(
entry
=
resolved
[
ct
];
entry
;
entry
=
entry
->
next
)
{
len
+=
sprintf
(
buffer
+
len
,
"%6u:%-3u "
,
len
+=
sprintf
(
buffer
+
len
,
"%6u:%-3u "
,
(
unsigned
int
)
ntohs
(
entry
->
target_addr
.
s_net
),
(
unsigned
int
)(
entry
->
target_addr
.
s_node
));
len
+=
sprintf
(
buffer
+
len
,
"%-10.10s"
,
len
+=
sprintf
(
buffer
+
len
,
"%-10.10s"
,
entry
->
dev
->
name
);
len
+=
sprintf
(
buffer
+
len
,
"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
,
len
+=
sprintf
(
buffer
+
len
,
"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
,
(
int
)(
entry
->
hwaddr
[
0
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
1
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
2
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
3
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
4
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
5
]
&
0x000000FF
));
len
+=
sprintf
(
buffer
+
len
,
"%12lu ""%12lu "
,
len
+=
sprintf
(
buffer
+
len
,
"%12lu ""%12lu "
,
(
unsigned
long
)
entry
->
last_sent
,
(
unsigned
long
)
entry
->
expires_at
);
len
+=
sprintf
(
buffer
+
len
,
"%10u"
,
len
+=
sprintf
(
buffer
+
len
,
"%10u"
,
(
unsigned
int
)
entry
->
xmit_count
);
len
+=
sprintf
(
buffer
+
len
,
" resolved
\n
"
);
len
+=
sprintf
(
buffer
+
len
,
" resolved
\n
"
);
}
}
for
(
ct
=
0
;
ct
<
AARP_HASH_SIZE
;
ct
++
)
{
for
(
entry
=
unresolved
[
ct
];
entry
;
entry
=
entry
->
next
)
{
len
+=
sprintf
(
buffer
+
len
,
"%6u:%-3u "
,
len
+=
sprintf
(
buffer
+
len
,
"%6u:%-3u "
,
(
unsigned
int
)
ntohs
(
entry
->
target_addr
.
s_net
),
(
unsigned
int
)(
entry
->
target_addr
.
s_node
));
len
+=
sprintf
(
buffer
+
len
,
"%-10.10s"
,
len
+=
sprintf
(
buffer
+
len
,
"%-10.10s"
,
entry
->
dev
->
name
);
len
+=
sprintf
(
buffer
+
len
,
"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
,
len
+=
sprintf
(
buffer
+
len
,
"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
,
(
int
)(
entry
->
hwaddr
[
0
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
1
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
2
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
3
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
4
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
5
]
&
0x000000FF
));
len
+=
sprintf
(
buffer
+
len
,
"%12lu ""%12lu "
,
len
+=
sprintf
(
buffer
+
len
,
"%12lu ""%12lu "
,
(
unsigned
long
)
entry
->
last_sent
,
(
unsigned
long
)
entry
->
expires_at
);
len
+=
sprintf
(
buffer
+
len
,
"%10u"
,
len
+=
sprintf
(
buffer
+
len
,
"%10u"
,
(
unsigned
int
)
entry
->
xmit_count
);
len
+=
sprintf
(
buffer
+
len
,
" unresolved
\n
"
);
len
+=
sprintf
(
buffer
+
len
,
" unresolved
\n
"
);
}
}
for
(
ct
=
0
;
ct
<
AARP_HASH_SIZE
;
ct
++
)
{
for
(
entry
=
proxies
[
ct
];
entry
;
entry
=
entry
->
next
)
{
len
+=
sprintf
(
buffer
+
len
,
"%6u:%-3u "
,
len
+=
sprintf
(
buffer
+
len
,
"%6u:%-3u "
,
(
unsigned
int
)
ntohs
(
entry
->
target_addr
.
s_net
),
(
unsigned
int
)(
entry
->
target_addr
.
s_node
));
len
+=
sprintf
(
buffer
+
len
,
"%-10.10s"
,
len
+=
sprintf
(
buffer
+
len
,
"%-10.10s"
,
entry
->
dev
->
name
);
len
+=
sprintf
(
buffer
+
len
,
"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
,
len
+=
sprintf
(
buffer
+
len
,
"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
,
(
int
)(
entry
->
hwaddr
[
0
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
1
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
2
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
3
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
4
]
&
0x000000FF
),
(
int
)(
entry
->
hwaddr
[
5
]
&
0x000000FF
));
len
+=
sprintf
(
buffer
+
len
,
"%12lu ""%12lu "
,
len
+=
sprintf
(
buffer
+
len
,
"%12lu ""%12lu "
,
(
unsigned
long
)
entry
->
last_sent
,
(
unsigned
long
)
entry
->
expires_at
);
len
+=
sprintf
(
buffer
+
len
,
"%10u"
,
len
+=
sprintf
(
buffer
+
len
,
"%10u"
,
(
unsigned
int
)
entry
->
xmit_count
);
len
+=
sprintf
(
buffer
+
len
,
" proxy
\n
"
);
len
+=
sprintf
(
buffer
+
len
,
" proxy
\n
"
);
}
}
...
...
net/appletalk/ddp.c
View file @
8549ccb7
...
...
@@ -99,13 +99,6 @@ extern int aarp_proxy_probe_network(struct atalk_iface *atif,
struct
at_addr
*
sa
);
extern
void
aarp_proxy_remove
(
struct
net_device
*
dev
,
struct
at_addr
*
sa
);
#undef APPLETALK_DEBUG
#ifdef APPLETALK_DEBUG
#define DPRINT(x) print(x)
#else
#define DPRINT(x)
#endif
/* APPLETALK_DEBUG */
#ifdef CONFIG_SYSCTL
extern
inline
void
atalk_register_sysctl
(
void
);
extern
inline
void
atalk_unregister_sysctl
(
void
);
...
...
@@ -182,10 +175,13 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to,
return
s
;
}
/*
* Try to find a socket matching ADDR in the socket list,
* if found then return it. If not, insert SK into the
* socket list.
/**
* atalk_find_or_insert_socket - Try to find a socket matching ADDR
* @sk - socket to insert in the list if it is not there already
* @sat - address to search for
*
* Try to find a socket matching ADDR in the socket list, if found then return
* it. If not, insert SK into the socket list.
*
* This entire operation must execute atomically.
*/
...
...
@@ -219,7 +215,7 @@ static struct sock *atalk_find_or_insert_socket(struct sock *sk,
static
void
atalk_destroy_timer
(
unsigned
long
data
)
{
struct
sock
*
sk
=
(
struct
sock
*
)
data
;
struct
sock
*
sk
=
(
struct
sock
*
)
data
;
if
(
!
atomic_read
(
&
sk
->
wmem_alloc
)
&&
!
atomic_read
(
&
sk
->
rmem_alloc
)
&&
sk
->
dead
)
{
...
...
@@ -263,16 +259,16 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length)
for
(
s
=
atalk_sockets
;
s
;
s
=
s
->
next
)
{
struct
atalk_sock
*
at
=
at_sk
(
s
);
len
+=
sprintf
(
buffer
+
len
,
"%02X "
,
s
->
type
);
len
+=
sprintf
(
buffer
+
len
,
"%04X:%02X:%02X "
,
len
+=
sprintf
(
buffer
+
len
,
"%02X "
,
s
->
type
);
len
+=
sprintf
(
buffer
+
len
,
"%04X:%02X:%02X "
,
ntohs
(
at
->
src_net
),
at
->
src_node
,
at
->
src_port
);
len
+=
sprintf
(
buffer
+
len
,
"%04X:%02X:%02X "
,
len
+=
sprintf
(
buffer
+
len
,
"%04X:%02X:%02X "
,
ntohs
(
at
->
dest_net
),
at
->
dest_node
,
at
->
dest_port
);
len
+=
sprintf
(
buffer
+
len
,
"%08X:%08X "
,
len
+=
sprintf
(
buffer
+
len
,
"%08X:%08X "
,
atomic_read
(
&
s
->
wmem_alloc
),
atomic_read
(
&
s
->
rmem_alloc
));
len
+=
sprintf
(
buffer
+
len
,
"%02X %d
\n
"
,
s
->
state
,
len
+=
sprintf
(
buffer
+
len
,
"%02X %d
\n
"
,
s
->
state
,
SOCK_INODE
(
s
->
socket
)
->
i_uid
);
/* Are we still dumping unwanted data then discard the record */
...
...
@@ -287,7 +283,7 @@ static int atalk_get_info(char *buffer, char **start, off_t offset, int length)
}
spin_unlock_bh
(
&
atalk_sockets_lock
);
/* The data in question runs from begin to begin
+
len */
/* The data in question runs from begin to begin
+
len */
*
start
=
buffer
+
offset
-
begin
;
/* Start of wanted data */
len
-=
offset
-
begin
;
/* Remove unwanted header data from length */
if
(
len
>
length
)
...
...
@@ -338,10 +334,13 @@ static void atif_drop_device(struct net_device *dev)
static
struct
atalk_iface
*
atif_add_device
(
struct
net_device
*
dev
,
struct
at_addr
*
sa
)
{
struct
atalk_iface
*
iface
=
kmalloc
(
sizeof
(
*
iface
),
GFP_KERNEL
);
struct
atalk_iface
*
iface
;
MOD_INC_USE_COUNT
;
iface
=
kmalloc
(
sizeof
(
*
iface
),
GFP_KERNEL
);
if
(
!
iface
)
return
NULL
;
goto
out_mem
;
iface
->
dev
=
dev
;
dev
->
atalk_ptr
=
iface
;
...
...
@@ -352,9 +351,11 @@ static struct atalk_iface *atif_add_device(struct net_device *dev,
iface
->
next
=
atalk_iface_list
;
atalk_iface_list
=
iface
;
spin_unlock_bh
(
&
atalk_iface_lock
);
MOD_INC_USE_COUNT
;
out:
return
iface
;
out_mem:
MOD_DEC_USE_COUNT
;
goto
out
;
}
/* Perform phase 2 AARP probing on our tentative address */
...
...
@@ -381,7 +382,7 @@ static int atif_probe_device(struct atalk_iface *atif)
/* Sweep the available nodes from a given start */
atif
->
address
.
s_net
=
htons
(
probe_net
);
for
(
nodect
=
0
;
nodect
<
256
;
nodect
++
)
{
atif
->
address
.
s_node
=
(
(
nodect
+
probe_node
)
&
0xFF
)
;
atif
->
address
.
s_node
=
(
nodect
+
probe_node
)
&
0xFF
;
if
(
atif
->
address
.
s_node
>
0
&&
atif
->
address
.
s_node
<
254
)
{
/* Probe a proposed address */
...
...
@@ -430,7 +431,7 @@ static int atif_proxy_probe_device(struct atalk_iface *atif,
/* Sweep the available nodes from a given start */
proxy_addr
->
s_net
=
htons
(
probe_net
);
for
(
nodect
=
0
;
nodect
<
256
;
nodect
++
)
{
proxy_addr
->
s_node
=
(
(
nodect
+
probe_node
)
&
0xFF
)
;
proxy_addr
->
s_node
=
(
nodect
+
probe_node
)
&
0xFF
;
if
(
proxy_addr
->
s_node
>
0
&&
proxy_addr
->
s_node
<
254
)
{
/* Tell AARP to probe a proposed address */
...
...
@@ -482,7 +483,8 @@ static struct at_addr *atalk_find_primary(void)
retval
=
&
atalk_iface_list
->
address
;
else
retval
=
NULL
;
out:
spin_unlock_bh
(
&
atalk_iface_lock
);
out:
spin_unlock_bh
(
&
atalk_iface_lock
);
return
retval
;
}
...
...
@@ -577,7 +579,8 @@ static struct atalk_route *atrtr_find(struct at_addr *target)
r
=
&
atrtr_default
;
else
/* No route can be found */
r
=
NULL
;
out:
read_unlock_bh
(
&
atalk_router_lock
);
out:
read_unlock_bh
(
&
atalk_router_lock
);
return
r
;
}
...
...
@@ -612,7 +615,7 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
struct
sockaddr_at
*
ga
=
(
struct
sockaddr_at
*
)
&
r
->
rt_gateway
;
struct
atalk_route
*
rt
;
struct
atalk_iface
*
iface
,
*
riface
;
int
retval
;
int
retval
=
-
EINVAL
;
/*
* Fixme: Raise/Lower a routing change semaphore for these
...
...
@@ -620,11 +623,9 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
*/
/* Validate the request */
if
(
ta
->
sat_family
!=
AF_APPLETALK
)
return
-
EINVAL
;
if
(
!
devhint
&&
ga
->
sat_family
!=
AF_APPLETALK
)
return
-
EINVAL
;
if
(
ta
->
sat_family
!=
AF_APPLETALK
||
(
!
devhint
&&
ga
->
sat_family
!=
AF_APPLETALK
))
goto
out
;
/* Now walk the routing table and make our decisions */
write_lock_bh
(
&
atalk_router_lock
);
...
...
@@ -660,13 +661,13 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
retval
=
-
ENETUNREACH
;
if
(
!
riface
)
goto
out
;
goto
out
_unlock
;
devhint
=
riface
->
dev
;
}
if
(
!
rt
)
{
rt
=
kmalloc
(
sizeof
(
struct
atalk_route
),
GFP_ATOMIC
);
rt
=
kmalloc
(
sizeof
(
*
rt
),
GFP_ATOMIC
);
retval
=
-
ENOBUFS
;
if
(
!
rt
)
...
...
@@ -683,7 +684,9 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
rt
->
gateway
=
ga
->
sat_addr
;
retval
=
0
;
out:
write_unlock_bh
(
&
atalk_router_lock
);
out_unlock:
write_unlock_bh
(
&
atalk_router_lock
);
out:
return
retval
;
}
...
...
@@ -706,7 +709,8 @@ static int atrtr_delete(struct at_addr * addr)
r
=
&
tmp
->
next
;
}
retval
=
-
ENOENT
;
out:
write_unlock_bh
(
&
atalk_router_lock
);
out:
write_unlock_bh
(
&
atalk_router_lock
);
return
retval
;
}
...
...
@@ -750,7 +754,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event,
{
if
(
event
==
NETDEV_DOWN
)
/* Discard any use of this */
atalk_dev_down
(
(
struct
net_device
*
)
ptr
);
atalk_dev_down
(
ptr
);
return
NOTIFY_DONE
;
}
...
...
@@ -759,7 +763,7 @@ static int ddp_device_event(struct notifier_block *this, unsigned long event,
/* Device configuration ioctl calls */
static
int
atif_ioctl
(
int
cmd
,
void
*
arg
)
{
static
char
aarp_mcast
[
6
]
=
{
0x09
,
0x00
,
0x00
,
0xFF
,
0xFF
,
0xFF
};
static
char
aarp_mcast
[
6
]
=
{
0x09
,
0x00
,
0x00
,
0xFF
,
0xFF
,
0xFF
};
struct
ifreq
atreq
;
struct
netrange
*
nr
;
struct
sockaddr_at
*
sa
;
...
...
@@ -777,7 +781,7 @@ static int atif_ioctl(int cmd, void *arg)
if
(
!
dev
)
return
-
ENODEV
;
sa
=
(
struct
sockaddr_at
*
)
&
atreq
.
ifr_addr
;
sa
=
(
struct
sockaddr_at
*
)
&
atreq
.
ifr_addr
;
atif
=
atalk_find_dev
(
dev
);
switch
(
cmd
)
{
...
...
@@ -792,7 +796,7 @@ static int atif_ioctl(int cmd, void *arg)
dev
->
type
!=
ARPHRD_PPP
)
return
-
EPROTONOSUPPORT
;
nr
=
(
struct
netrange
*
)
&
sa
->
sat_zero
[
0
];
nr
=
(
struct
netrange
*
)
&
sa
->
sat_zero
[
0
];
add_route
=
1
;
/*
...
...
@@ -846,11 +850,11 @@ static int atif_ioctl(int cmd, void *arg)
}
/* Hey it worked - add the direct routes */
sa
=
(
struct
sockaddr_at
*
)
&
rtdef
.
rt_gateway
;
sa
=
(
struct
sockaddr_at
*
)
&
rtdef
.
rt_gateway
;
sa
->
sat_family
=
AF_APPLETALK
;
sa
->
sat_addr
.
s_net
=
atif
->
address
.
s_net
;
sa
->
sat_addr
.
s_node
=
atif
->
address
.
s_node
;
sa
=
(
struct
sockaddr_at
*
)
&
rtdef
.
rt_dst
;
sa
=
(
struct
sockaddr_at
*
)
&
rtdef
.
rt_dst
;
rtdef
.
rt_flags
=
RTF_UP
;
sa
->
sat_family
=
AF_APPLETALK
;
sa
->
sat_addr
.
s_node
=
ATADDR_ANYNODE
;
...
...
@@ -932,7 +936,7 @@ static int atif_ioctl(int cmd, void *arg)
if
(
!
atif
)
return
-
EADDRNOTAVAIL
;
nr
=
(
struct
netrange
*
)
&
(
atif
->
nets
);
nr
=
(
struct
netrange
*
)
&
(
atif
->
nets
);
/*
* Phase 1 is fine on Localtalk but we don't do
* Ethertalk phase 1. Anyone wanting to add it go ahead.
...
...
@@ -1016,7 +1020,7 @@ static int atalk_if_get_info(char *buffer, char **start, off_t offset,
spin_lock_bh
(
&
atalk_iface_lock
);
for
(
iface
=
atalk_iface_list
;
iface
;
iface
=
iface
->
next
)
{
len
+=
sprintf
(
buffer
+
len
,
"%-16s %04X:%02X %04X-%04X %d
\n
"
,
len
+=
sprintf
(
buffer
+
len
,
"%-16s %04X:%02X %04X-%04X %d
\n
"
,
iface
->
dev
->
name
,
ntohs
(
iface
->
address
.
s_net
),
iface
->
address
.
s_node
,
ntohs
(
iface
->
nets
.
nr_firstnet
),
...
...
@@ -1049,7 +1053,8 @@ static int atalk_rt_get_info(char *buffer, char **start, off_t offset,
if
(
atrtr_default
.
dev
)
{
rt
=
&
atrtr_default
;
len
+=
sprintf
(
buffer
+
len
,
"Default %04X:%02X %-4d %s
\n
"
,
len
+=
sprintf
(
buffer
+
len
,
"Default %04X:%02X %-4d %s
\n
"
,
ntohs
(
rt
->
gateway
.
s_net
),
rt
->
gateway
.
s_node
,
rt
->
flags
,
rt
->
dev
->
name
);
}
...
...
@@ -1092,7 +1097,7 @@ static int atalk_rt_get_info(char *buffer, char **start, off_t offset,
unsigned
short
atalk_checksum
(
struct
ddpehdr
*
ddp
,
int
len
)
{
unsigned
long
sum
=
0
;
/* Assume unsigned long is >16 bits */
unsigned
char
*
data
=
(
unsigned
char
*
)
ddp
;
unsigned
char
*
data
=
(
unsigned
char
*
)
ddp
;
len
-=
4
;
/* skip header 4 bytes */
data
+=
4
;
...
...
@@ -1108,7 +1113,7 @@ unsigned short atalk_checksum(struct ddpehdr *ddp, int len)
data
++
;
}
/* Use 0xFFFF for 0. 0 itself means none */
return
sum
?
htons
((
unsigned
short
)
sum
)
:
0xFFFF
;
return
sum
?
htons
((
unsigned
short
)
sum
)
:
0xFFFF
;
}
/*
...
...
@@ -1140,9 +1145,12 @@ static int atalk_create(struct socket *sock, int protocol)
sock_init_data
(
sock
,
sk
);
/* Checksums on by default */
sk
->
zapped
=
1
;
out:
return
rc
;
outsk:
sk_free
(
sk
);
decmod:
MOD_DEC_USE_COUNT
;
out:
return
rc
;
outsk:
sk_free
(
sk
);
decmod:
MOD_DEC_USE_COUNT
;
goto
out
;
}
...
...
@@ -1158,13 +1166,17 @@ static int atalk_release(struct socket *sock)
sk
->
dead
=
1
;
sock
->
sk
=
NULL
;
atalk_destroy_socket
(
sk
);
out:
return
0
;
out:
return
0
;
}
/*
* Pick a source port when one is not given. If we can
* find a suitable free one, we insert the socket into
* the tables using it.
/**
* atalk_pick_and_bind_port - Pick a source port when one is not given
* @sk - socket to insert into the tables
* @sat - address to search for
*
* Pick a source port when one is not given. If we can find a suitable free
* one, we insert the socket into the tables using it.
*
* This whole operation must be atomic.
*/
...
...
@@ -1197,12 +1209,12 @@ static int atalk_pick_and_bind_port(struct sock *sk, struct sockaddr_at *sat)
retval
=
0
;
goto
out
;
try_next_port:
;
try_next_port:
;
}
retval
=
-
EBUSY
;
out:
spin_unlock_bh
(
&
atalk_sockets_lock
);
out:
spin_unlock_bh
(
&
atalk_sockets_lock
);
return
retval
;
}
...
...
@@ -1210,21 +1222,20 @@ static int atalk_autobind(struct sock *sk)
{
struct
atalk_sock
*
at
=
at_sk
(
sk
);
struct
sockaddr_at
sat
;
int
n
;
struct
at_addr
*
ap
=
atalk_find_primary
();
int
n
=
-
EADDRNOTAVAIL
;
if
(
!
ap
||
ap
->
s_net
==
htons
(
ATADDR_ANYNET
))
return
-
EADDRNOTAVAIL
;
goto
out
;
at
->
src_net
=
sat
.
sat_addr
.
s_net
=
ap
->
s_net
;
at
->
src_node
=
sat
.
sat_addr
.
s_node
=
ap
->
s_node
;
n
=
atalk_pick_and_bind_port
(
sk
,
&
sat
);
if
(
n
<
0
)
return
n
;
if
(
!
n
)
sk
->
zapped
=
0
;
return
0
;
out:
return
n
;
}
/* Set the address 'our end' of the connection */
...
...
@@ -1355,7 +1366,12 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
return
0
;
}
/*
/**
* atalk_rcv - Receive a packet (in skb) from device dev
* @skb - packet received
* @dev - network device where the packet comes from
* @pt - packet type
*
* Receive a packet (in skb) from device dev. This has come from the SNAP
* decoder, and on entry skb->h.raw is the DDP header, skb->len is the DDP
* header, skb->len is the DDP length. The physical headers have been
...
...
@@ -1365,7 +1381,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
static
int
atalk_rcv
(
struct
sk_buff
*
skb
,
struct
net_device
*
dev
,
struct
packet_type
*
pt
)
{
struct
ddpehdr
*
ddp
=
(
void
*
)
skb
->
h
.
raw
;
struct
ddpehdr
*
ddp
=
(
void
*
)
skb
->
h
.
raw
;
struct
sock
*
sock
;
struct
atalk_iface
*
atif
;
struct
sockaddr_at
tosat
;
...
...
@@ -1442,6 +1458,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
rt
=
atrtr_find
(
&
ta
);
if
(
!
rt
||
ddphv
.
deh_hops
==
DDP_MAXHOPS
)
goto
freeit
;
/* FIXME: use skb->cb to be able to use shared skbs */
ddphv
.
deh_hops
++
;
/*
...
...
@@ -1454,10 +1471,12 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
}
/* Fix up skb->len field */
skb_trim
(
skb
,
min_t
(
unsigned
int
,
origlen
,
rt
->
dev
->
hard_header_len
+
ddp_dl
->
header_length
+
ddphv
.
deh_len
));
skb_trim
(
skb
,
min_t
(
unsigned
int
,
origlen
,
(
rt
->
dev
->
hard_header_len
+
ddp_dl
->
header_length
+
ddphv
.
deh_len
)));
/* Mend the byte order */
/* FIXME: use skb->cb to be able to use shared skbs */
*
((
__u16
*
)
ddp
)
=
ntohs
(
*
((
__u16
*
)
&
ddphv
));
/*
...
...
@@ -1515,7 +1534,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
#endif
/*
* Which socket - atalk_search_socket() looks for a *full match*
* of the <net,
node,
port> tuple.
* of the <net,
node,
port> tuple.
*/
tosat
.
sat_addr
.
s_net
=
ddp
->
deh_dnet
;
tosat
.
sat_addr
.
s_node
=
ddp
->
deh_dnode
;
...
...
@@ -1530,9 +1549,11 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
if
(
sock_queue_rcv_skb
(
sock
,
skb
)
<
0
)
goto
freeit
;
out:
return
0
;
freeit:
kfree_skb
(
skb
);
goto
out
;
freeit:
kfree_skb
(
skb
);
out:
return
0
;
}
/*
...
...
@@ -1543,25 +1564,21 @@ out: return 0;
static
int
ltalk_rcv
(
struct
sk_buff
*
skb
,
struct
net_device
*
dev
,
struct
packet_type
*
pt
)
{
struct
ddpehdr
*
ddp
;
struct
at_addr
*
ap
;
/* Expand any short form frames */
if
(
skb
->
mac
.
raw
[
2
]
==
1
)
{
struct
ddpehdr
*
ddp
;
/* Find our address */
struct
at_addr
*
ap
=
atalk_find_dev_addr
(
dev
);
ap
=
atalk_find_dev_addr
(
dev
);
if
(
!
ap
||
skb
->
len
<
sizeof
(
struct
ddpshdr
))
{
kfree_skb
(
skb
);
return
0
;
}
if
(
!
ap
||
skb
->
len
<
sizeof
(
struct
ddpshdr
))
goto
freeit
;
/*
* The push leaves us with a ddephdr not an shdr, and
* handily the port bytes in the right place preset.
*/
skb_push
(
skb
,
sizeof
(
*
ddp
)
-
4
);
/* FIXME: use skb->cb to be able to use shared skbs */
ddp
=
(
struct
ddpehdr
*
)
skb
->
data
;
/* Now fill in the long header */
...
...
@@ -1590,6 +1607,9 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev,
skb
->
h
.
raw
=
skb
->
data
;
return
atalk_rcv
(
skb
,
dev
,
pt
);
freeit:
kfree_skb
(
skb
);
return
0
;
}
static
int
atalk_sendmsg
(
struct
socket
*
sock
,
struct
msghdr
*
msg
,
int
len
,
...
...
@@ -1762,17 +1782,16 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size,
{
struct
sock
*
sk
=
sock
->
sk
;
struct
sockaddr_at
*
sat
=
(
struct
sockaddr_at
*
)
msg
->
msg_name
;
struct
ddpehdr
*
ddp
=
NULL
;
struct
ddpehdr
*
ddp
;
int
copied
=
0
;
int
err
=
0
;
struct
ddpebits
ddphv
;
struct
sk_buff
*
skb
;
skb
=
skb_recv_datagram
(
sk
,
flags
&
~
MSG_DONTWAIT
,
struct
sk_buff
*
skb
=
skb_recv_datagram
(
sk
,
flags
&
~
MSG_DONTWAIT
,
flags
&
MSG_DONTWAIT
,
&
err
);
if
(
!
skb
)
return
err
;
/* FIXME: use skb->cb to be able to use shared skbs */
ddp
=
(
struct
ddpehdr
*
)(
skb
->
h
.
raw
);
*
((
__u16
*
)
&
ddphv
)
=
ntohs
(
*
((
__u16
*
)
ddp
));
...
...
@@ -1805,14 +1824,14 @@ static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size,
}
skb_free_datagram
(
sk
,
skb
);
/* Free the datagram. */
return
err
?
err
:
copied
;
return
err
?
:
copied
;
}
/*
* AppleTalk ioctl calls.
*/
static
int
atalk_ioctl
(
struct
socket
*
sock
,
unsigned
int
cmd
,
unsigned
long
arg
)
static
int
atalk_ioctl
(
struct
socket
*
sock
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
long
amount
=
0
;
struct
sock
*
sk
=
sock
->
sk
;
...
...
@@ -1824,14 +1843,15 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg)
if
(
amount
<
0
)
amount
=
0
;
break
;
case
TIOCINQ
:
{
/* These two are safe on a single CPU system as only
* user tasks fiddle here */
case
TIOCINQ
:
{
/*
* These two are safe on a single CPU system as only
* user tasks fiddle here
*/
struct
sk_buff
*
skb
=
skb_peek
(
&
sk
->
receive_queue
);
if
(
skb
)
amount
=
skb
->
len
-
sizeof
(
struct
ddpehdr
);
amount
=
skb
->
len
-
sizeof
(
struct
ddpehdr
);
break
;
}
case
SIOCGSTAMP
:
...
...
@@ -1854,8 +1874,7 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg)
case
SIOCATALKDIFADDR
:
case
SIOCDIFADDR
:
case
SIOCSARP
:
/* proxy AARP */
case
SIOCDARP
:
/* proxy AARP */
{
case
SIOCDARP
:
{
/* proxy AARP */
int
ret
;
rtnl_lock
();
...
...
@@ -1877,7 +1896,7 @@ static int atalk_ioctl(struct socket *sock,unsigned int cmd, unsigned long arg)
case
SIOCGIFCOUNT
:
case
SIOCGIFINDEX
:
case
SIOCGIFNAME
:
return
dev_ioctl
(
cmd
,
(
void
*
)
arg
);
return
dev_ioctl
(
cmd
,
(
void
*
)
arg
);
case
SIOCSIFMETRIC
:
case
SIOCSIFBRDADDR
:
case
SIOCGIFNETMASK
:
...
...
@@ -1899,10 +1918,7 @@ static struct net_proto_family atalk_family_ops = {
.
create
=
atalk_create
,
};
static
struct
proto_ops
SOCKOPS_WRAPPED
(
atalk_dgram_ops
)
=
{
.
family
=
PF_APPLETALK
,
.
release
=
atalk_release
,
.
bind
=
atalk_bind
,
.
connect
=
atalk_connect
,
...
...
@@ -1924,32 +1940,21 @@ static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops)=
#include <linux/smp_lock.h>
SOCKOPS_WRAP
(
atalk_dgram
,
PF_APPLETALK
);
static
struct
notifier_block
ddp_notifier
=
{
ddp_device_event
,
NULL
,
0
static
struct
notifier_block
ddp_notifier
=
{
.
notifier_call
=
ddp_device_event
,
};
struct
packet_type
ltalk_packet_type
=
{
0
,
NULL
,
ltalk_rcv
,
NULL
,
NULL
struct
packet_type
ltalk_packet_type
=
{
.
type
=
__constant_htons
(
ETH_P_LOCALTALK
),
.
func
=
ltalk_rcv
,
};
struct
packet_type
ppptalk_packet_type
=
{
0
,
NULL
,
atalk_rcv
,
NULL
,
NULL
struct
packet_type
ppptalk_packet_type
=
{
.
type
=
__constant_htons
(
ETH_P_PPPTALK
),
.
func
=
atalk_rcv
,
};
static
char
ddp_snap_id
[]
=
{
0x08
,
0x00
,
0x07
,
0x80
,
0x9B
};
static
char
ddp_snap_id
[]
=
{
0x08
,
0x00
,
0x07
,
0x80
,
0x9B
};
/* Export symbols for use by drivers when AppleTalk is a module */
EXPORT_SYMBOL
(
aarp_send_ddp
);
...
...
@@ -1959,15 +1964,12 @@ EXPORT_SYMBOL(atalk_find_dev_addr);
/* Called by proto.c on kernel start up */
static
int
__init
atalk_init
(
void
)
{
(
void
)
sock_register
(
&
atalk_family_ops
);
(
void
)
sock_register
(
&
atalk_family_ops
);
ddp_dl
=
register_snap_client
(
ddp_snap_id
,
atalk_rcv
);
if
(
!
ddp_dl
)
printk
(
KERN_CRIT
"Unable to register DDP with SNAP.
\n
"
);
ltalk_packet_type
.
type
=
htons
(
ETH_P_LOCALTALK
);
dev_add_pack
(
&
ltalk_packet_type
);
ppptalk_packet_type
.
type
=
htons
(
ETH_P_PPPTALK
);
dev_add_pack
(
&
ppptalk_packet_type
);
register_netdevice_notifier
(
&
ddp_notifier
);
...
...
net/appletalk/sysctl_net_atalk.c
View file @
8549ccb7
/*
-*- linux-c -*-
/*
* sysctl_net_atalk.c: sysctl interface to net AppleTalk subsystem.
*
* Begun April 1, 1996, Mike Shaver.
...
...
@@ -17,25 +17,59 @@ extern int sysctl_aarp_resolve_time;
#ifdef CONFIG_SYSCTL
static
ctl_table
atalk_table
[]
=
{
{
NET_ATALK_AARP_EXPIRY_TIME
,
"aarp-expiry-time"
,
&
sysctl_aarp_expiry_time
,
sizeof
(
int
),
0644
,
NULL
,
&
proc_dointvec_jiffies
},
{
NET_ATALK_AARP_TICK_TIME
,
"aarp-tick-time"
,
&
sysctl_aarp_tick_time
,
sizeof
(
int
),
0644
,
NULL
,
&
proc_dointvec_jiffies
},
{
NET_ATALK_AARP_RETRANSMIT_LIMIT
,
"aarp-retransmit-limit"
,
&
sysctl_aarp_retransmit_limit
,
sizeof
(
int
),
0644
,
NULL
,
&
proc_dointvec
},
{
NET_ATALK_AARP_RESOLVE_TIME
,
"aarp-resolve-time"
,
&
sysctl_aarp_resolve_time
,
sizeof
(
int
),
0644
,
NULL
,
&
proc_dointvec_jiffies
},
{
0
}
{
.
ctl_name
=
NET_ATALK_AARP_EXPIRY_TIME
,
.
procname
=
"aarp-expiry-time"
,
.
data
=
&
sysctl_aarp_expiry_time
,
.
maxlen
=
sizeof
(
int
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec_jiffies
,
},
{
.
ctl_name
=
NET_ATALK_AARP_TICK_TIME
,
.
procname
=
"aarp-tick-time"
,
.
data
=
&
sysctl_aarp_tick_time
,
.
maxlen
=
sizeof
(
int
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec_jiffies
,
},
{
.
ctl_name
=
NET_ATALK_AARP_RETRANSMIT_LIMIT
,
.
procname
=
"aarp-retransmit-limit"
,
.
data
=
&
sysctl_aarp_retransmit_limit
,
.
maxlen
=
sizeof
(
int
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec
,
},
{
.
ctl_name
=
NET_ATALK_AARP_RESOLVE_TIME
,
.
procname
=
"aarp-resolve-time"
,
.
data
=
&
sysctl_aarp_resolve_time
,
.
maxlen
=
sizeof
(
int
),
.
mode
=
0644
,
.
proc_handler
=
&
proc_dointvec_jiffies
,
},
{
0
},
};
static
ctl_table
atalk_dir_table
[]
=
{
{
NET_ATALK
,
"appletalk"
,
NULL
,
0
,
0555
,
atalk_table
},
{
0
}
{
.
ctl_name
=
NET_ATALK
,
.
procname
=
"appletalk"
,
.
mode
=
0555
,
.
child
=
atalk_table
,
},
{
0
},
};
static
ctl_table
atalk_root_table
[]
=
{
{
CTL_NET
,
"net"
,
NULL
,
0
,
0555
,
atalk_dir_table
},
{
0
}
{
.
ctl_name
=
CTL_NET
,
.
procname
=
"net"
,
.
mode
=
0555
,
.
child
=
atalk_dir_table
,
},
{
0
},
};
static
struct
ctl_table_header
*
atalk_table_header
;
...
...
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