summaryrefslogtreecommitdiffstats
path: root/net/l2tp
diff options
context:
space:
mode:
authorGuillaume Nault <g.nault@alphalink.fr>2018-08-10 07:21:58 -0400
committerDavid S. Miller <davem@davemloft.net>2018-08-11 15:13:49 -0400
commit79e6760e64d1b69a20af4d97ead291159d4c11c2 (patch)
tree5a28c42dd33fb727f38e45ea2a25722cc60d32be /net/l2tp
parentbdd0292f96e43de46283ea0efdef8d13b4ffe895 (diff)
l2tp: handle PPPIOC[GS]MRU and PPPIOC[GS]FLAGS in pppol2tp_ioctl()
Let pppol2tp_ioctl() handle ioctl commands directly. It still relies on pppol2tp_{session,tunnel}_ioctl() for PPPIOCGL2TPSTATS. 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.c73
1 files changed, 44 insertions, 29 deletions
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index e3ed8d473d91..f4ec6b2a093e 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -1045,7 +1045,6 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1045{ 1045{
1046 int err = 0; 1046 int err = 0;
1047 struct sock *sk; 1047 struct sock *sk;
1048 int val = (int) arg;
1049 struct l2tp_tunnel *tunnel = session->tunnel; 1048 struct l2tp_tunnel *tunnel = session->tunnel;
1050 struct pppol2tp_ioc_stats stats; 1049 struct pppol2tp_ioc_stats stats;
1051 1050
@@ -1058,22 +1057,6 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
1058 return -EBADR; 1057 return -EBADR;
1059 1058
1060 switch (cmd) { 1059 switch (cmd) {
1061 case PPPIOCGMRU:
1062 case PPPIOCGFLAGS:
1063 err = -EFAULT;
1064 if (put_user(0, (int __user *)arg))
1065 break;
1066 err = 0;
1067 break;
1068
1069 case PPPIOCSMRU:
1070 case PPPIOCSFLAGS:
1071 err = -EFAULT;
1072 if (get_user(val, (int __user *)arg))
1073 break;
1074 err = 0;
1075 break;
1076
1077 case PPPIOCGL2TPSTATS: 1060 case PPPIOCGL2TPSTATS:
1078 err = -ENXIO; 1061 err = -ENXIO;
1079 if (!(sk->sk_state & PPPOX_CONNECTED)) 1062 if (!(sk->sk_state & PPPOX_CONNECTED))
@@ -1180,23 +1163,55 @@ static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd,
1180 unsigned long arg) 1163 unsigned long arg)
1181{ 1164{
1182 struct l2tp_session *session; 1165 struct l2tp_session *session;
1183 struct l2tp_tunnel *tunnel; 1166 int val;
1167
1168 switch (cmd) {
1169 case PPPIOCGMRU:
1170 case PPPIOCGFLAGS:
1171 session = sock->sk->sk_user_data;
1172 if (!session)
1173 return -ENOTCONN;
1184 1174
1185 session = sock->sk->sk_user_data; 1175 /* Not defined for tunnels */
1186 if (!session) 1176 if (!session->session_id && !session->peer_session_id)
1187 return -ENOTCONN; 1177 return -ENOSYS;
1188 1178
1189 /* Special case: if session's session_id is zero, treat ioctl as a 1179 if (put_user(0, (int __user *)arg))
1190 * tunnel ioctl 1180 return -EFAULT;
1191 */ 1181 break;
1192 if ((session->session_id == 0) && 1182
1193 (session->peer_session_id == 0)) { 1183 case PPPIOCSMRU:
1194 tunnel = session->tunnel; 1184 case PPPIOCSFLAGS:
1185 session = sock->sk->sk_user_data;
1186 if (!session)
1187 return -ENOTCONN;
1195 1188
1196 return pppol2tp_tunnel_ioctl(tunnel, cmd, arg); 1189 /* Not defined for tunnels */
1190 if (!session->session_id && !session->peer_session_id)
1191 return -ENOSYS;
1192
1193 if (get_user(val, (int __user *)arg))
1194 return -EFAULT;
1195 break;
1196
1197 case PPPIOCGL2TPSTATS:
1198 session = sock->sk->sk_user_data;
1199 if (!session)
1200 return -ENOTCONN;
1201
1202 /* Session 0 represents the parent tunnel */
1203 if (!session->session_id && !session->peer_session_id)
1204 return pppol2tp_tunnel_ioctl(session->tunnel, cmd,
1205 arg);
1206 else
1207 return pppol2tp_session_ioctl(session, cmd, arg);
1208 break;
1209
1210 default:
1211 return -ENOSYS;
1197 } 1212 }
1198 1213
1199 return pppol2tp_session_ioctl(session, cmd, arg); 1214 return 0;
1200} 1215}
1201 1216
1202/***************************************************************************** 1217/*****************************************************************************