First three patches remove redundant tests and add missing "const"
qualifiers.
Fourth patch splits the conditionals found in __l2tp_ip*_bind_lookup(),
to make these functions easier to review. In the process, I found that
some corner cases were still not handled properly. So I've added the
missing tests in this patch too, because they're pretty simple and the
whole "if" statements are modified anyway.
I expect it to be easier to review this way. If not, I can split up
patch #4, post the missing tests separately to -net, and later repost
this series as pure cleanup. Just let me know.
Guillaume Nault (4):
l2tp: remove redundant addr_len check in l2tp_ip_bind()
l2tp: make __l2tp_ip*_bind_lookup() parameters 'const'
l2tp: remove useless NULL check in __l2tp_ip{,6}_bind_lookup()
l2tp: rework socket comparison in __l2tp_ip*_bind_lookup()
net/l2tp/l2tp_ip.c | 29 ++++++++++++++++++-----------
net/l2tp/l2tp_ip6.c | 30 +++++++++++++++++++-----------
2 files changed, 37 insertions(+), 22 deletions(-)
--
2.11.0
addr_len's value has already been verified at this point.
Signed-off-by: Guillaume Nault <redacted>
---
net/l2tp/l2tp_ip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
If "l2tp" was NULL, that'd mean "sk" is NULL too. This can't happen
since "sk" is returned by sk_for_each_bound().
Signed-off-by: Guillaume Nault <redacted>
---
net/l2tp/l2tp_ip.c | 3 ---
net/l2tp/l2tp_ip6.c | 3 ---
2 files changed, 6 deletions(-)
Split conditions, so that each test becomes clearer.
Also, for l2tp_ip, check if "laddr" is 0. This prevents a socket from
binding to the unspecified address when other sockets are already bound
using the same device (if any), connection ID and namespace.
Same thing for l2tp_ip6: add ipv6_addr_any(laddr) and
ipv6_addr_any(raddr) tests to ensure that an IPv6 unspecified address
passed as parameter is properly treated a wildcard.
Signed-off-by: Guillaume Nault <redacted>
---
net/l2tp/l2tp_ip.c | 24 +++++++++++++++++-------
net/l2tp/l2tp_ip6.c | 25 ++++++++++++++++++-------
2 files changed, 35 insertions(+), 14 deletions(-)
First three patches remove redundant tests and add missing "const"
qualifiers.
Fourth patch splits the conditionals found in __l2tp_ip*_bind_lookup(),
to make these functions easier to review. In the process, I found that
some corner cases were still not handled properly. So I've added the
missing tests in this patch too, because they're pretty simple and the
whole "if" statements are modified anyway.
I expect it to be easier to review this way. If not, I can split up
patch #4, post the missing tests separately to -net, and later repost
this series as pure cleanup. Just let me know.