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
nexedi
linux
Commits
ba8f7fa4
Commit
ba8f7fa4
authored
Jul 27, 2002
by
Ralf Bächle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace cli / sti with spinlock for protection of protocol_list.
parent
c314fb5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
23 deletions
+35
-23
net/ax25/TODO
net/ax25/TODO
+4
-2
net/ax25/ax25_iface.c
net/ax25/ax25_iface.c
+31
-21
No files found.
net/ax25/TODO
View file @
ba8f7fa4
...
...
@@ -9,5 +9,7 @@ af_ax25.c:ax25_connect:
return sock_error(sk); /* Always set at this point */
}
Do the spinlocks ax25_list_lock, ax25_uid_lock and ax25_route_lock really
have to be interrupt safe?
Do the spinlocks ax25_list_lock, ax25_uid_lock, ax25_route_lock and
protocol_list_lock really have to be interrupt safe?
What locking will be needed for linkfail_list and listen_list?
net/ax25/ax25_iface.c
View file @
ba8f7fa4
...
...
@@ -20,6 +20,7 @@
#include <linux/in.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/timer.h>
#include <linux/string.h>
#include <linux/sockios.h>
...
...
@@ -40,6 +41,7 @@ static struct protocol_struct {
unsigned
int
pid
;
int
(
*
func
)(
struct
sk_buff
*
,
ax25_cb
*
);
}
*
protocol_list
;
static
spinlock_t
protocol_list_lock
=
SPIN_LOCK_UNLOCKED
;
static
struct
linkfail_struct
{
struct
linkfail_struct
*
next
;
...
...
@@ -69,31 +71,29 @@ int ax25_protocol_register(unsigned int pid, int (*func)(struct sk_buff *, ax25_
protocol
->
pid
=
pid
;
protocol
->
func
=
func
;
save_flags
(
flags
);
cli
();
spin_lock_irqsave
(
&
protocol_list_lock
,
flags
);
protocol
->
next
=
protocol_list
;
protocol_list
=
protocol
;
restore_flags
(
flags
);
spin_unlock_irqrestore
(
&
protocol_list_lock
,
flags
);
return
1
;
}
void
ax25_protocol_release
(
unsigned
int
pid
)
{
struct
protocol_struct
*
s
,
*
protocol
=
protocol_list
;
struct
protocol_struct
*
s
,
*
protocol
;
unsigned
long
flags
;
if
(
protocol
==
NULL
)
spin_lock_irqsave
(
&
protocol_list_lock
,
flags
);
protocol
=
protocol_list
;
if
(
protocol
==
NULL
)
{
spin_unlock_irqrestore
(
&
protocol_list_lock
,
flags
);
return
;
save_flags
(
flags
);
cli
();
}
if
(
protocol
->
pid
==
pid
)
{
protocol_list
=
protocol
->
next
;
restore_flags
(
flags
);
spin_unlock_irqrestore
(
&
protocol_list_lock
,
flags
);
kfree
(
protocol
);
return
;
}
...
...
@@ -102,15 +102,14 @@ void ax25_protocol_release(unsigned int pid)
if
(
protocol
->
next
->
pid
==
pid
)
{
s
=
protocol
->
next
;
protocol
->
next
=
protocol
->
next
->
next
;
restore_flags
(
flags
);
spin_unlock_irqrestore
(
&
protocol_list_lock
,
flags
);
kfree
(
s
);
return
;
}
protocol
=
protocol
->
next
;
}
restore_flags
(
flags
);
spin_unlock_irqrestore
(
&
protocol_list_lock
,
flags
);
}
int
ax25_linkfail_register
(
void
(
*
func
)(
ax25_cb
*
,
int
))
...
...
@@ -227,13 +226,19 @@ void ax25_listen_release(ax25_address *callsign, struct net_device *dev)
int
(
*
ax25_protocol_function
(
unsigned
int
pid
))(
struct
sk_buff
*
,
ax25_cb
*
)
{
int
(
*
res
)(
struct
sk_buff
*
,
ax25_cb
*
)
=
NULL
;
struct
protocol_struct
*
protocol
;
unsigned
long
flags
;
spin_lock_irqsave
(
&
protocol_list_lock
,
flags
);
for
(
protocol
=
protocol_list
;
protocol
!=
NULL
;
protocol
=
protocol
->
next
)
if
(
protocol
->
pid
==
pid
)
return
protocol
->
func
;
if
(
protocol
->
pid
==
pid
)
{
res
=
protocol
->
func
;
break
;
}
spin_unlock_irqrestore
(
&
protocol_list_lock
,
flags
);
return
NULL
;
return
res
;
}
int
ax25_listen_mine
(
ax25_address
*
callsign
,
struct
net_device
*
dev
)
...
...
@@ -258,11 +263,16 @@ void ax25_link_failed(ax25_cb *ax25, int reason)
int
ax25_protocol_is_registered
(
unsigned
int
pid
)
{
struct
protocol_struct
*
protocol
;
unsigned
long
flags
;
int
res
=
0
;
spin_lock_irqsave
(
&
protocol_list_lock
,
flags
);
for
(
protocol
=
protocol_list
;
protocol
!=
NULL
;
protocol
=
protocol
->
next
)
if
(
protocol
->
pid
==
pid
)
return
1
;
if
(
protocol
->
pid
==
pid
)
{
res
=
1
;
break
;
}
spin_unlock_irqrestore
(
&
protocol_list_lock
,
flags
);
return
0
;
return
res
;
}
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