net: only check perm protocol when register proto
Subsystems (2)
PATCH 1/1 net: only check perm protocol when register proto
From: Junwei Zhang <[email protected]>
the permanent protocol nodes are at the head of the list. So only need check all these nodes.
and insert the new node after the last permanent protocol node, no matter new node is permanent or not.
If the inserted proto conflicts with existing permanent protocol, then goto out_permanent immediately.
--- net/ipv4/af_inet.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
net/ipv4/af_inet.c +4 -10
@@ -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) +if ((INET_PROTOSW_PERMANENT & answer->flags) ==0 )break ; - last_perm = lh; - } - - answer =NULL ; +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
Signature · 1 line
1.8.3.1
David Miller
maintainerFrom: [email protected]
Date: Tue, 15 Sep 2015 08:14:05 +0800
Quoted 5 lines
net/ipv4/af_inet.c +0
-1@@ -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 ;
net/ipv4/af_inet.c void inet_register_protosw(struct inet_protosw *p) · line 1055
Quoted 10 lines
net/ipv4/af_inet.c +1
-4last_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) +if ((INET_PROTOSW_PERMANENT & answer->flags) ==0 )break ; - last_perm = lh;
Well, if you're going to do this, you need to fix up the indentation of that "break;" statement.
PATCH v2 1/1 net: only check perm protocol when register proto
From: Junwei Zhang <[email protected]>
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.
---
V2: Fix indentation
rewrite statement
net/ipv4/af_inet.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
net/ipv4/af_inet.c +5 -11
@@ -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
Signature · 1 line
2.1.4
From: [email protected]
Date: Fri, 18 Sep 2015 00:00:05 -0400
Quoted 8 lines
From: Junwei Zhang <[email protected]>
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,
Quoted 7 lines
If the new node conflicts with existing permanent node, return error.
Signed-off-by Martin Zhang <[email protected]>---
V2: Fix indentation
rewrite statement
Applied, thanks.