aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunwei Zhang <martinbj2008@gmail.com>2015-09-18 00:00:05 -0400
committerDavid S. Miller <davem@davemloft.net>2015-09-17 21:02:59 -0700
commitf6c53334d6c6ac7088c2e7e70ff2941bfb33f52e (patch)
treec93d338e62e226a6bb75b27383521d133ae24ae0
parent4b1b865e4e97e336316f30e32af36d71e98bdabc (diff)
downloadlinux-stericsson-f6c53334d6c6ac7088c2e7e70ff2941bfb33f52e.tar.gz
net: only check perm protocol when register proto
The permanent protocol nodes are at the head of the list, So only need check all these nodes. No matter the new node is permanent or not, insert the new node after the last permanent protocol node, If the new node conflicts with existing permanent node, return error. Signed-off-by: Martin Zhang <martinbj2008@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/af_inet.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1d0c3adb6f34..8a556643b874 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1043,22 +1043,16 @@ void inet_register_protosw(struct inet_protosw *p)
goto out_illegal;
/* If we are trying to override a permanent protocol, bail. */
- answer = NULL;
last_perm = &inetsw[p->type];
list_for_each(lh, &inetsw[p->type]) {
answer = list_entry(lh, struct inet_protosw, list);
-
/* Check only the non-wild match. */
- if (INET_PROTOSW_PERMANENT & answer->flags) {
- if (protocol == answer->protocol)
- break;
- last_perm = lh;
- }
-
- answer = NULL;
+ if ((INET_PROTOSW_PERMANENT & answer->flags) == 0)
+ break;
+ if (protocol == answer->protocol)
+ goto out_permanent;
+ last_perm = lh;
}
- if (answer)
- goto out_permanent;
/* Add the new entry after the last permanent entry if any, so that
* the new entry does not override a permanent entry when matched with