diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2010-12-09 12:17:25 -0500 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2010-12-09 12:17:25 -0500 |
| commit | d834a9dcecae834cd6b2bc5e50e1907738d9cf6a (patch) | |
| tree | 0589d753465d3fe359ba451ba6cb7798df03aaa2 /net/ipv4/protocol.c | |
| parent | a38c5380ef9f088be9f49b6e4c5d80af8b1b5cd4 (diff) | |
| parent | f658bcfb2607bf0808966a69cf74135ce98e5c2d (diff) | |
Merge branch 'x86/amd-nb' into x86/apic-cleanups
Reason: apic cleanup series depends on x86/apic, x86/amd-nb x86/platform
Conflicts:
arch/x86/include/asm/io_apic.h
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'net/ipv4/protocol.c')
| -rw-r--r-- | net/ipv4/protocol.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c index f2d297351405..9ae5c01cd0b2 100644 --- a/net/ipv4/protocol.c +++ b/net/ipv4/protocol.c | |||
| @@ -28,8 +28,7 @@ | |||
| 28 | #include <linux/spinlock.h> | 28 | #include <linux/spinlock.h> |
| 29 | #include <net/protocol.h> | 29 | #include <net/protocol.h> |
| 30 | 30 | ||
| 31 | const struct net_protocol *inet_protos[MAX_INET_PROTOS] ____cacheline_aligned_in_smp; | 31 | const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS] __read_mostly; |
| 32 | static DEFINE_SPINLOCK(inet_proto_lock); | ||
| 33 | 32 | ||
| 34 | /* | 33 | /* |
| 35 | * Add a protocol handler to the hash tables | 34 | * Add a protocol handler to the hash tables |
| @@ -37,20 +36,10 @@ static DEFINE_SPINLOCK(inet_proto_lock); | |||
| 37 | 36 | ||
| 38 | int inet_add_protocol(const struct net_protocol *prot, unsigned char protocol) | 37 | int inet_add_protocol(const struct net_protocol *prot, unsigned char protocol) |
| 39 | { | 38 | { |
| 40 | int hash, ret; | 39 | int hash = protocol & (MAX_INET_PROTOS - 1); |
| 41 | 40 | ||
| 42 | hash = protocol & (MAX_INET_PROTOS - 1); | 41 | return !cmpxchg((const struct net_protocol **)&inet_protos[hash], |
| 43 | 42 | NULL, prot) ? 0 : -1; | |
| 44 | spin_lock_bh(&inet_proto_lock); | ||
| 45 | if (inet_protos[hash]) { | ||
| 46 | ret = -1; | ||
| 47 | } else { | ||
| 48 | inet_protos[hash] = prot; | ||
| 49 | ret = 0; | ||
| 50 | } | ||
| 51 | spin_unlock_bh(&inet_proto_lock); | ||
| 52 | |||
| 53 | return ret; | ||
| 54 | } | 43 | } |
| 55 | EXPORT_SYMBOL(inet_add_protocol); | 44 | EXPORT_SYMBOL(inet_add_protocol); |
| 56 | 45 | ||
| @@ -60,18 +49,10 @@ EXPORT_SYMBOL(inet_add_protocol); | |||
| 60 | 49 | ||
| 61 | int inet_del_protocol(const struct net_protocol *prot, unsigned char protocol) | 50 | int inet_del_protocol(const struct net_protocol *prot, unsigned char protocol) |
| 62 | { | 51 | { |
| 63 | int hash, ret; | 52 | int ret, hash = protocol & (MAX_INET_PROTOS - 1); |
| 64 | |||
| 65 | hash = protocol & (MAX_INET_PROTOS - 1); | ||
| 66 | 53 | ||
| 67 | spin_lock_bh(&inet_proto_lock); | 54 | ret = (cmpxchg((const struct net_protocol **)&inet_protos[hash], |
| 68 | if (inet_protos[hash] == prot) { | 55 | prot, NULL) == prot) ? 0 : -1; |
| 69 | inet_protos[hash] = NULL; | ||
| 70 | ret = 0; | ||
| 71 | } else { | ||
| 72 | ret = -1; | ||
| 73 | } | ||
| 74 | spin_unlock_bh(&inet_proto_lock); | ||
| 75 | 56 | ||
| 76 | synchronize_net(); | 57 | synchronize_net(); |
| 77 | 58 | ||
