mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 06:04:23 +08:00
l2tp: use IDR for all session lookups
Add generic session getter which uses IDR. Replace all users of l2tp_tunnel_get_session which uses the per-tunnel session list to use the generic getter. Signed-off-by: James Chapman <jchapman@katalix.com> Reviewed-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c37e0138ca
commit
5f77c18ea5
@ -316,6 +316,16 @@ struct l2tp_session *l2tp_v2_session_get(const struct net *net, u16 tunnel_id, u
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(l2tp_v2_session_get);
|
||||
|
||||
struct l2tp_session *l2tp_session_get(const struct net *net, struct sock *sk, int pver,
|
||||
u32 tunnel_id, u32 session_id)
|
||||
{
|
||||
if (pver == L2TP_HDR_VER_2)
|
||||
return l2tp_v2_session_get(net, tunnel_id, session_id);
|
||||
else
|
||||
return l2tp_v3_session_get(net, sk, session_id);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(l2tp_session_get);
|
||||
|
||||
struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth)
|
||||
{
|
||||
int hash;
|
||||
|
@ -232,6 +232,8 @@ struct l2tp_session *l2tp_tunnel_get_session(struct l2tp_tunnel *tunnel,
|
||||
|
||||
struct l2tp_session *l2tp_v3_session_get(const struct net *net, struct sock *sk, u32 session_id);
|
||||
struct l2tp_session *l2tp_v2_session_get(const struct net *net, u16 tunnel_id, u16 session_id);
|
||||
struct l2tp_session *l2tp_session_get(const struct net *net, struct sock *sk, int pver,
|
||||
u32 tunnel_id, u32 session_id);
|
||||
struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth);
|
||||
struct l2tp_session *l2tp_session_get_by_ifname(const struct net *net,
|
||||
const char *ifname);
|
||||
|
@ -61,7 +61,8 @@ static struct l2tp_session *l2tp_nl_session_get(struct genl_info *info)
|
||||
session_id = nla_get_u32(info->attrs[L2TP_ATTR_SESSION_ID]);
|
||||
tunnel = l2tp_tunnel_get(net, tunnel_id);
|
||||
if (tunnel) {
|
||||
session = l2tp_tunnel_get_session(tunnel, session_id);
|
||||
session = l2tp_session_get(net, tunnel->sock, tunnel->version,
|
||||
tunnel_id, session_id);
|
||||
l2tp_tunnel_dec_refcount(tunnel);
|
||||
}
|
||||
}
|
||||
@ -635,7 +636,8 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
|
||||
&cfg);
|
||||
|
||||
if (ret >= 0) {
|
||||
session = l2tp_tunnel_get_session(tunnel, session_id);
|
||||
session = l2tp_session_get(net, tunnel->sock, tunnel->version,
|
||||
tunnel_id, session_id);
|
||||
if (session) {
|
||||
ret = l2tp_session_notify(&l2tp_nl_family, info, session,
|
||||
L2TP_CMD_SESSION_CREATE);
|
||||
|
@ -753,7 +753,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
|
||||
if (tunnel->peer_tunnel_id == 0)
|
||||
tunnel->peer_tunnel_id = info.peer_tunnel_id;
|
||||
|
||||
session = l2tp_tunnel_get_session(tunnel, info.session_id);
|
||||
session = l2tp_session_get(sock_net(sk), tunnel->sock, tunnel->version,
|
||||
info.tunnel_id, info.session_id);
|
||||
if (session) {
|
||||
drop_refcnt = true;
|
||||
|
||||
@ -1045,7 +1046,8 @@ static int pppol2tp_tunnel_copy_stats(struct pppol2tp_ioc_stats *stats,
|
||||
/* If session_id is set, search the corresponding session in the
|
||||
* context of this tunnel and record the session's statistics.
|
||||
*/
|
||||
session = l2tp_tunnel_get_session(tunnel, stats->session_id);
|
||||
session = l2tp_session_get(tunnel->l2tp_net, tunnel->sock, tunnel->version,
|
||||
tunnel->tunnel_id, stats->session_id);
|
||||
if (!session)
|
||||
return -EBADR;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user