summaryrefslogtreecommitdiffstats
path: root/net/l2tp
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2018-08-10 07:22:01 -0400
committerDavid S. Miller <davem@davemloft.net>2018-08-11 15:13:49 -0400
commitb0e29063dcb3bf14f515f95e748b60e4bab45e7c (patch)
treed6b6aecb91a396ffad466f663d034349ce0e0773 /net/l2tp
parent528534f0deda05c668756313a22974429a9df05a (diff)
l2tp: remove pppol2tp_session_ioctl()
pppol2tp_ioctl() has everything in place for handling PPPIOCGL2TPSTATS on session sockets. We just need to copy the stats and set ->session_id. As a side effect of sharing session and tunnel code, ->using_ipsec is properly set even when the request was made using a session socket. Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/l2tp')
-rw-r--r--net/l2tp/l2tp_ppp.c50
1 files changed, 3 insertions, 47 deletions
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 2afd3ab8a551..bdfbd3ed7e14 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -1068,52 +1068,6 @@ static int pppol2tp_tunnel_copy_stats(struct pppol2tp_ioc_stats *stats,
1068 return 0; 1068 return 0;
1069} 1069}
1070 1070
1071/* Session ioctl helper.
1072 */
1073static int pppol2tp_session_ioctl(struct l2tp_session *session,
1074 unsigned int cmd, unsigned long arg)
1075{
1076 int err = 0;
1077 struct sock *sk;
1078 struct l2tp_tunnel *tunnel = session->tunnel;
1079 struct pppol2tp_ioc_stats stats;
1080
1081 l2tp_dbg(session, L2TP_MSG_CONTROL,
1082 "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n",
1083 session->name, cmd, arg);
1084
1085 sk = pppol2tp_session_get_sock(session);
1086 if (!sk)
1087 return -EBADR;
1088
1089 switch (cmd) {
1090 case PPPIOCGL2TPSTATS:
1091 err = -ENXIO;
1092 if (!(sk->sk_state & PPPOX_CONNECTED))
1093 break;
1094
1095 memset(&stats, 0, sizeof(stats));
1096 stats.tunnel_id = tunnel->tunnel_id;
1097 stats.session_id = session->session_id;
1098 pppol2tp_copy_stats(&stats, &session->stats);
1099 if (copy_to_user((void __user *) arg, &stats,
1100 sizeof(stats)))
1101 break;
1102 l2tp_info(session, L2TP_MSG_CONTROL, "%s: get L2TP stats\n",
1103 session->name);
1104 err = 0;
1105 break;
1106
1107 default:
1108 err = -ENOSYS;
1109 break;
1110 }
1111
1112 sock_put(sk);
1113
1114 return err;
1115}
1116
1117static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd, 1071static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd,
1118 unsigned long arg) 1072 unsigned long arg)
1119{ 1073{
@@ -1172,7 +1126,9 @@ static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd,
1172 1126
1173 stats.session_id = session_id; 1127 stats.session_id = session_id;
1174 } else { 1128 } else {
1175 return pppol2tp_session_ioctl(session, cmd, arg); 1129 memset(&stats, 0, sizeof(stats));
1130 pppol2tp_copy_stats(&stats, &session->stats);
1131 stats.session_id = session->session_id;
1176 } 1132 }
1177 stats.tunnel_id = session->tunnel->tunnel_id; 1133 stats.tunnel_id = session->tunnel->tunnel_id;
1178 stats.using_ipsec = l2tp_tunnel_uses_xfrm(session->tunnel); 1134 stats.using_ipsec = l2tp_tunnel_uses_xfrm(session->tunnel);