Lines Matching +full:rx +full:- +full:sched +full:- +full:sp

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * PPPoX --- Generic PPP encapsulation socket family
6 * PPPoL2TP --- PPP over L2TP (RFC 2661)
30 * over an L2TP session:-
41 * sax.pppol2tp.addr.sin_addr.s_addr = addr->sin_addr.s_addr;
42 * sax.pppol2tp.addr.sin_port = addr->sin_port;
66 #include <linux/sched.h>
83 #include <linux/ppp-ioctl.h>
114 * l2tp_session, referenced via session->priv[].
142 sk = rcu_dereference(ps->sk); in pppol2tp_session_get_sock()
161 if (session && refcount_inc_not_zero(&session->ref_count)) { in pppol2tp_sock_to_session()
163 WARN_ON_ONCE(session->magic != L2TP_SESSION_MAGIC); in pppol2tp_sock_to_session()
182 struct sock *sk = sock->sk; in pppol2tp_recvmsg()
184 err = -EIO; in pppol2tp_recvmsg()
185 if (sk->sk_state & PPPOX_BOUND) in pppol2tp_recvmsg()
193 if (len > skb->len) in pppol2tp_recvmsg()
194 len = skb->len; in pppol2tp_recvmsg()
195 else if (len < skb->len) in pppol2tp_recvmsg()
196 msg->msg_flags |= MSG_TRUNC; in pppol2tp_recvmsg()
216 sk = rcu_dereference(ps->sk); in pppol2tp_recv()
224 * constant: 0xFF is the All-Stations Address and 0x03 the Unnumbered in pppol2tp_recv()
227 if (pskb_may_pull(skb, 2) && skb->data[0] == PPP_ALLSTATIONS && in pppol2tp_recv()
228 skb->data[1] == PPP_UI) in pppol2tp_recv()
231 if (sk->sk_state & PPPOX_BOUND) { in pppol2tp_recv()
235 ppp_input(&po->chan, skb); in pppol2tp_recv()
238 atomic_long_inc(&session->stats.rx_errors); in pppol2tp_recv()
248 pr_warn_ratelimited("%s: no socket in recv\n", session->name); in pppol2tp_recv()
263 struct sock *sk = sock->sk; in pppol2tp_sendmsg()
270 error = -ENOTCONN; in pppol2tp_sendmsg()
271 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) in pppol2tp_sendmsg()
275 error = -EBADF; in pppol2tp_sendmsg()
280 tunnel = session->tunnel; in pppol2tp_sendmsg()
282 uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; in pppol2tp_sendmsg()
285 error = -ENOMEM; in pppol2tp_sendmsg()
287 uhlen + session->hdr_len + in pppol2tp_sendmsg()
301 skb->data[0] = PPP_ALLSTATIONS; in pppol2tp_sendmsg()
302 skb->data[1] = PPP_UI; in pppol2tp_sendmsg()
342 struct sock *sk = (struct sock *)chan->private; in pppol2tp_xmit()
347 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) in pppol2tp_xmit()
355 tunnel = session->tunnel; in pppol2tp_xmit()
357 uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; in pppol2tp_xmit()
361 session->hdr_len + /* L2TP header */ in pppol2tp_xmit()
368 skb->data[0] = PPP_ALLSTATIONS; in pppol2tp_xmit()
369 skb->data[1] = PPP_UI; in pppol2tp_xmit()
396 skb_queue_purge(&sk->sk_receive_queue); in pppol2tp_session_destruct()
397 skb_queue_purge(&sk->sk_write_queue); in pppol2tp_session_destruct()
405 mutex_lock(&ps->sk_lock); in pppol2tp_session_close()
406 ps->__sk = rcu_dereference_protected(ps->sk, in pppol2tp_session_close()
407 lockdep_is_held(&ps->sk_lock)); in pppol2tp_session_close()
408 RCU_INIT_POINTER(ps->sk, NULL); in pppol2tp_session_close()
409 mutex_unlock(&ps->sk_lock); in pppol2tp_session_close()
410 if (ps->__sk) { in pppol2tp_session_close()
412 rcu_assign_sk_user_data(ps->__sk, NULL); in pppol2tp_session_close()
413 sock_put(ps->__sk); in pppol2tp_session_close()
424 struct sock *sk = sock->sk; in pppol2tp_release()
431 error = -EBADF; in pppol2tp_release()
439 sk->sk_state = PPPOX_DEAD; in pppol2tp_release()
441 sock->sk = NULL; in pppol2tp_release()
482 int error = -ENOMEM; in pppol2tp_create()
492 sock->state = SS_UNCONNECTED; in pppol2tp_create()
493 sock->ops = &pppol2tp_ops; in pppol2tp_create()
495 sk->sk_backlog_rcv = pppol2tp_backlog_recv; in pppol2tp_create()
496 sk->sk_protocol = PX_PROTO_OL2TP; in pppol2tp_create()
497 sk->sk_family = PF_PPPOX; in pppol2tp_create()
498 sk->sk_state = PPPOX_NONE; in pppol2tp_create()
499 sk->sk_type = SOCK_STREAM; in pppol2tp_create()
500 sk->sk_destruct = pppol2tp_session_destruct; in pppol2tp_create()
517 seq_printf(m, " interface %s\n", ppp_dev_name(&po->chan)); in pppol2tp_show()
526 session->recv_skb = pppol2tp_recv; in pppol2tp_session_init()
527 session->session_close = pppol2tp_session_close; in pppol2tp_session_init()
529 session->show = pppol2tp_show; in pppol2tp_session_init()
532 mutex_init(&ps->sk_lock); in pppol2tp_session_init()
533 ps->owner = current->pid; in pppol2tp_session_init()
553 if (sa_v2in4->sa_protocol != PX_PROTO_OL2TP) in pppol2tp_sockaddr_get_info()
554 return -EINVAL; in pppol2tp_sockaddr_get_info()
556 info->version = 2; in pppol2tp_sockaddr_get_info()
557 info->fd = sa_v2in4->pppol2tp.fd; in pppol2tp_sockaddr_get_info()
558 info->tunnel_id = sa_v2in4->pppol2tp.s_tunnel; in pppol2tp_sockaddr_get_info()
559 info->peer_tunnel_id = sa_v2in4->pppol2tp.d_tunnel; in pppol2tp_sockaddr_get_info()
560 info->session_id = sa_v2in4->pppol2tp.s_session; in pppol2tp_sockaddr_get_info()
561 info->peer_session_id = sa_v2in4->pppol2tp.d_session; in pppol2tp_sockaddr_get_info()
569 if (sa_v3in4->sa_protocol != PX_PROTO_OL2TP) in pppol2tp_sockaddr_get_info()
570 return -EINVAL; in pppol2tp_sockaddr_get_info()
572 info->version = 3; in pppol2tp_sockaddr_get_info()
573 info->fd = sa_v3in4->pppol2tp.fd; in pppol2tp_sockaddr_get_info()
574 info->tunnel_id = sa_v3in4->pppol2tp.s_tunnel; in pppol2tp_sockaddr_get_info()
575 info->peer_tunnel_id = sa_v3in4->pppol2tp.d_tunnel; in pppol2tp_sockaddr_get_info()
576 info->session_id = sa_v3in4->pppol2tp.s_session; in pppol2tp_sockaddr_get_info()
577 info->peer_session_id = sa_v3in4->pppol2tp.d_session; in pppol2tp_sockaddr_get_info()
585 if (sa_v2in6->sa_protocol != PX_PROTO_OL2TP) in pppol2tp_sockaddr_get_info()
586 return -EINVAL; in pppol2tp_sockaddr_get_info()
588 info->version = 2; in pppol2tp_sockaddr_get_info()
589 info->fd = sa_v2in6->pppol2tp.fd; in pppol2tp_sockaddr_get_info()
590 info->tunnel_id = sa_v2in6->pppol2tp.s_tunnel; in pppol2tp_sockaddr_get_info()
591 info->peer_tunnel_id = sa_v2in6->pppol2tp.d_tunnel; in pppol2tp_sockaddr_get_info()
592 info->session_id = sa_v2in6->pppol2tp.s_session; in pppol2tp_sockaddr_get_info()
593 info->peer_session_id = sa_v2in6->pppol2tp.d_session; in pppol2tp_sockaddr_get_info()
601 if (sa_v3in6->sa_protocol != PX_PROTO_OL2TP) in pppol2tp_sockaddr_get_info()
602 return -EINVAL; in pppol2tp_sockaddr_get_info()
604 info->version = 3; in pppol2tp_sockaddr_get_info()
605 info->fd = sa_v3in6->pppol2tp.fd; in pppol2tp_sockaddr_get_info()
606 info->tunnel_id = sa_v3in6->pppol2tp.s_tunnel; in pppol2tp_sockaddr_get_info()
607 info->peer_tunnel_id = sa_v3in6->pppol2tp.d_tunnel; in pppol2tp_sockaddr_get_info()
608 info->session_id = sa_v3in6->pppol2tp.s_session; in pppol2tp_sockaddr_get_info()
609 info->peer_session_id = sa_v3in6->pppol2tp.d_session; in pppol2tp_sockaddr_get_info()
614 return -EINVAL; in pppol2tp_sockaddr_get_info()
631 return 1500 - PPPOL2TP_HEADER_OVERHEAD; in pppol2tp_tunnel_mtu()
633 return mtu - PPPOL2TP_HEADER_OVERHEAD; in pppol2tp_tunnel_mtu()
645 tunnel = l2tp_tunnel_get(net, info->tunnel_id); in pppol2tp_tunnel_get()
651 if (!info->session_id && !info->peer_session_id) { in pppol2tp_tunnel_get()
660 if (info->fd < 0) in pppol2tp_tunnel_get()
661 return ERR_PTR(-EBADF); in pppol2tp_tunnel_get()
663 error = l2tp_tunnel_create(info->fd, in pppol2tp_tunnel_get()
664 info->version, in pppol2tp_tunnel_get()
665 info->tunnel_id, in pppol2tp_tunnel_get()
666 info->peer_tunnel_id, &tcfg, in pppol2tp_tunnel_get()
671 refcount_inc(&tunnel->ref_count); in pppol2tp_tunnel_get()
683 return ERR_PTR(-ENOENT); in pppol2tp_tunnel_get()
686 if (!tunnel->sock) { in pppol2tp_tunnel_get()
688 return ERR_PTR(-ENOENT); in pppol2tp_tunnel_get()
700 struct sock *sk = sock->sk; in pppol2tp_connect()
718 return -EINVAL; in pppol2tp_connect()
727 error = -EBUSY; in pppol2tp_connect()
728 if (sk->sk_state & PPPOX_CONNECTED) in pppol2tp_connect()
732 error = -EALREADY; in pppol2tp_connect()
733 if (sk->sk_user_data) in pppol2tp_connect()
736 if (tunnel->peer_tunnel_id == 0) in pppol2tp_connect()
737 tunnel->peer_tunnel_id = info.peer_tunnel_id; in pppol2tp_connect()
739 session = l2tp_session_get(sock_net(sk), tunnel->sock, tunnel->version, in pppol2tp_connect()
744 if (session->pwtype != L2TP_PWTYPE_PPP) { in pppol2tp_connect()
745 error = -EPROTOTYPE; in pppol2tp_connect()
751 /* Using a pre-existing session is fine as long as it hasn't in pppol2tp_connect()
754 mutex_lock(&ps->sk_lock); in pppol2tp_connect()
755 if (rcu_dereference_protected(ps->sk, in pppol2tp_connect()
756 lockdep_is_held(&ps->sk_lock)) || in pppol2tp_connect()
757 ps->__sk) { in pppol2tp_connect()
758 mutex_unlock(&ps->sk_lock); in pppol2tp_connect()
759 error = -EEXIST; in pppol2tp_connect()
777 refcount_inc(&session->ref_count); in pppol2tp_connect()
779 mutex_lock(&ps->sk_lock); in pppol2tp_connect()
782 mutex_unlock(&ps->sk_lock); in pppol2tp_connect()
795 if (session->session_id == 0 && session->peer_session_id == 0) { in pppol2tp_connect()
804 po->chan.hdrlen = PPPOL2TP_L2TP_HDR_SIZE_NOSEQ; in pppol2tp_connect()
806 po->chan.private = sk; in pppol2tp_connect()
807 po->chan.ops = &pppol2tp_chan_ops; in pppol2tp_connect()
808 po->chan.mtu = pppol2tp_tunnel_mtu(tunnel); in pppol2tp_connect()
810 error = ppp_register_net_channel(sock_net(sk), &po->chan); in pppol2tp_connect()
812 mutex_unlock(&ps->sk_lock); in pppol2tp_connect()
820 rcu_assign_pointer(ps->sk, sk); in pppol2tp_connect()
821 mutex_unlock(&ps->sk_lock); in pppol2tp_connect()
829 sk->sk_state = PPPOX_CONNECTED; in pppol2tp_connect()
857 if (!tunnel->sock) { in pppol2tp_session_create()
858 error = -ENOENT; in pppol2tp_session_create()
896 struct sock *sk = sock->sk; in pppol2tp_getname()
900 error = -ENOTCONN; in pppol2tp_getname()
903 if (!(sk->sk_state & PPPOX_CONNECTED)) in pppol2tp_getname()
906 error = -EBADF; in pppol2tp_getname()
912 tunnel = session->tunnel; in pppol2tp_getname()
914 inet = inet_sk(tunnel->sock); in pppol2tp_getname()
915 if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET) { in pppol2tp_getname()
916 struct sockaddr_pppol2tp sp; in pppol2tp_getname() local
918 len = sizeof(sp); in pppol2tp_getname()
919 memset(&sp, 0, len); in pppol2tp_getname()
920 sp.sa_family = AF_PPPOX; in pppol2tp_getname()
921 sp.sa_protocol = PX_PROTO_OL2TP; in pppol2tp_getname()
922 sp.pppol2tp.fd = tunnel->fd; in pppol2tp_getname()
923 sp.pppol2tp.pid = pls->owner; in pppol2tp_getname()
924 sp.pppol2tp.s_tunnel = tunnel->tunnel_id; in pppol2tp_getname()
925 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id; in pppol2tp_getname()
926 sp.pppol2tp.s_session = session->session_id; in pppol2tp_getname()
927 sp.pppol2tp.d_session = session->peer_session_id; in pppol2tp_getname()
928 sp.pppol2tp.addr.sin_family = AF_INET; in pppol2tp_getname()
929 sp.pppol2tp.addr.sin_port = inet->inet_dport; in pppol2tp_getname()
930 sp.pppol2tp.addr.sin_addr.s_addr = inet->inet_daddr; in pppol2tp_getname()
931 memcpy(uaddr, &sp, len); in pppol2tp_getname()
933 } else if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET6) { in pppol2tp_getname()
934 struct sockaddr_pppol2tpin6 sp; in pppol2tp_getname() local
936 len = sizeof(sp); in pppol2tp_getname()
937 memset(&sp, 0, len); in pppol2tp_getname()
938 sp.sa_family = AF_PPPOX; in pppol2tp_getname()
939 sp.sa_protocol = PX_PROTO_OL2TP; in pppol2tp_getname()
940 sp.pppol2tp.fd = tunnel->fd; in pppol2tp_getname()
941 sp.pppol2tp.pid = pls->owner; in pppol2tp_getname()
942 sp.pppol2tp.s_tunnel = tunnel->tunnel_id; in pppol2tp_getname()
943 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id; in pppol2tp_getname()
944 sp.pppol2tp.s_session = session->session_id; in pppol2tp_getname()
945 sp.pppol2tp.d_session = session->peer_session_id; in pppol2tp_getname()
946 sp.pppol2tp.addr.sin6_family = AF_INET6; in pppol2tp_getname()
947 sp.pppol2tp.addr.sin6_port = inet->inet_dport; in pppol2tp_getname()
948 memcpy(&sp.pppol2tp.addr.sin6_addr, &tunnel->sock->sk_v6_daddr, in pppol2tp_getname()
949 sizeof(tunnel->sock->sk_v6_daddr)); in pppol2tp_getname()
950 memcpy(uaddr, &sp, len); in pppol2tp_getname()
951 } else if (tunnel->version == 3 && tunnel->sock->sk_family == AF_INET6) { in pppol2tp_getname()
952 struct sockaddr_pppol2tpv3in6 sp; in pppol2tp_getname() local
954 len = sizeof(sp); in pppol2tp_getname()
955 memset(&sp, 0, len); in pppol2tp_getname()
956 sp.sa_family = AF_PPPOX; in pppol2tp_getname()
957 sp.sa_protocol = PX_PROTO_OL2TP; in pppol2tp_getname()
958 sp.pppol2tp.fd = tunnel->fd; in pppol2tp_getname()
959 sp.pppol2tp.pid = pls->owner; in pppol2tp_getname()
960 sp.pppol2tp.s_tunnel = tunnel->tunnel_id; in pppol2tp_getname()
961 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id; in pppol2tp_getname()
962 sp.pppol2tp.s_session = session->session_id; in pppol2tp_getname()
963 sp.pppol2tp.d_session = session->peer_session_id; in pppol2tp_getname()
964 sp.pppol2tp.addr.sin6_family = AF_INET6; in pppol2tp_getname()
965 sp.pppol2tp.addr.sin6_port = inet->inet_dport; in pppol2tp_getname()
966 memcpy(&sp.pppol2tp.addr.sin6_addr, &tunnel->sock->sk_v6_daddr, in pppol2tp_getname()
967 sizeof(tunnel->sock->sk_v6_daddr)); in pppol2tp_getname()
968 memcpy(uaddr, &sp, len); in pppol2tp_getname()
970 } else if (tunnel->version == 3) { in pppol2tp_getname()
971 struct sockaddr_pppol2tpv3 sp; in pppol2tp_getname() local
973 len = sizeof(sp); in pppol2tp_getname()
974 memset(&sp, 0, len); in pppol2tp_getname()
975 sp.sa_family = AF_PPPOX; in pppol2tp_getname()
976 sp.sa_protocol = PX_PROTO_OL2TP; in pppol2tp_getname()
977 sp.pppol2tp.fd = tunnel->fd; in pppol2tp_getname()
978 sp.pppol2tp.pid = pls->owner; in pppol2tp_getname()
979 sp.pppol2tp.s_tunnel = tunnel->tunnel_id; in pppol2tp_getname()
980 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id; in pppol2tp_getname()
981 sp.pppol2tp.s_session = session->session_id; in pppol2tp_getname()
982 sp.pppol2tp.d_session = session->peer_session_id; in pppol2tp_getname()
983 sp.pppol2tp.addr.sin_family = AF_INET; in pppol2tp_getname()
984 sp.pppol2tp.addr.sin_port = inet->inet_dport; in pppol2tp_getname()
985 sp.pppol2tp.addr.sin_addr.s_addr = inet->inet_daddr; in pppol2tp_getname()
986 memcpy(uaddr, &sp, len); in pppol2tp_getname()
1012 dest->tx_packets = atomic_long_read(&stats->tx_packets); in pppol2tp_copy_stats()
1013 dest->tx_bytes = atomic_long_read(&stats->tx_bytes); in pppol2tp_copy_stats()
1014 dest->tx_errors = atomic_long_read(&stats->tx_errors); in pppol2tp_copy_stats()
1015 dest->rx_packets = atomic_long_read(&stats->rx_packets); in pppol2tp_copy_stats()
1016 dest->rx_bytes = atomic_long_read(&stats->rx_bytes); in pppol2tp_copy_stats()
1017 dest->rx_seq_discards = atomic_long_read(&stats->rx_seq_discards); in pppol2tp_copy_stats()
1018 dest->rx_oos_packets = atomic_long_read(&stats->rx_oos_packets); in pppol2tp_copy_stats()
1019 dest->rx_errors = atomic_long_read(&stats->rx_errors); in pppol2tp_copy_stats()
1027 if (!stats->session_id) { in pppol2tp_tunnel_copy_stats()
1028 pppol2tp_copy_stats(stats, &tunnel->stats); in pppol2tp_tunnel_copy_stats()
1035 session = l2tp_session_get(tunnel->l2tp_net, tunnel->sock, tunnel->version, in pppol2tp_tunnel_copy_stats()
1036 tunnel->tunnel_id, stats->session_id); in pppol2tp_tunnel_copy_stats()
1038 return -EBADR; in pppol2tp_tunnel_copy_stats()
1040 if (session->pwtype != L2TP_PWTYPE_PPP) { in pppol2tp_tunnel_copy_stats()
1042 return -EBADR; in pppol2tp_tunnel_copy_stats()
1045 pppol2tp_copy_stats(stats, &session->stats); in pppol2tp_tunnel_copy_stats()
1060 session = sock->sk->sk_user_data; in pppol2tp_ioctl()
1062 return -ENOTCONN; in pppol2tp_ioctl()
1064 if (WARN_ON(session->magic != L2TP_SESSION_MAGIC)) in pppol2tp_ioctl()
1065 return -EBADF; in pppol2tp_ioctl()
1068 if (!session->session_id && !session->peer_session_id) in pppol2tp_ioctl()
1069 return -ENOSYS; in pppol2tp_ioctl()
1072 return -EFAULT; in pppol2tp_ioctl()
1077 session = sock->sk->sk_user_data; in pppol2tp_ioctl()
1079 return -ENOTCONN; in pppol2tp_ioctl()
1081 if (WARN_ON(session->magic != L2TP_SESSION_MAGIC)) in pppol2tp_ioctl()
1082 return -EBADF; in pppol2tp_ioctl()
1085 if (!session->session_id && !session->peer_session_id) in pppol2tp_ioctl()
1086 return -ENOSYS; in pppol2tp_ioctl()
1089 return -EFAULT; in pppol2tp_ioctl()
1093 session = sock->sk->sk_user_data; in pppol2tp_ioctl()
1095 return -ENOTCONN; in pppol2tp_ioctl()
1097 if (WARN_ON(session->magic != L2TP_SESSION_MAGIC)) in pppol2tp_ioctl()
1098 return -EBADF; in pppol2tp_ioctl()
1101 if (!session->session_id && !session->peer_session_id) { in pppol2tp_ioctl()
1107 return -EFAULT; in pppol2tp_ioctl()
1111 session->tunnel); in pppol2tp_ioctl()
1117 pppol2tp_copy_stats(&stats, &session->stats); in pppol2tp_ioctl()
1118 stats.session_id = session->session_id; in pppol2tp_ioctl()
1120 stats.tunnel_id = session->tunnel->tunnel_id; in pppol2tp_ioctl()
1121 stats.using_ipsec = l2tp_tunnel_uses_xfrm(session->tunnel); in pppol2tp_ioctl()
1124 return -EFAULT; in pppol2tp_ioctl()
1128 return -ENOIOCTLCMD; in pppol2tp_ioctl()
1158 err = -ENOPROTOOPT; in pppol2tp_tunnel_setsockopt()
1176 err = -EINVAL; in pppol2tp_session_setsockopt()
1179 session->recv_seq = !!val; in pppol2tp_session_setsockopt()
1184 err = -EINVAL; in pppol2tp_session_setsockopt()
1187 session->send_seq = !!val; in pppol2tp_session_setsockopt()
1191 po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ : in pppol2tp_session_setsockopt()
1194 l2tp_session_set_header_len(session, session->tunnel->version, in pppol2tp_session_setsockopt()
1195 session->tunnel->encap); in pppol2tp_session_setsockopt()
1200 err = -EINVAL; in pppol2tp_session_setsockopt()
1203 session->lns_mode = !!val; in pppol2tp_session_setsockopt()
1211 session->reorder_timeout = msecs_to_jiffies(val); in pppol2tp_session_setsockopt()
1215 err = -ENOPROTOOPT; in pppol2tp_session_setsockopt()
1230 struct sock *sk = sock->sk; in pppol2tp_setsockopt()
1237 return -EINVAL; in pppol2tp_setsockopt()
1240 return -EINVAL; in pppol2tp_setsockopt()
1243 return -EFAULT; in pppol2tp_setsockopt()
1245 err = -ENOTCONN; in pppol2tp_setsockopt()
1246 if (!sk->sk_user_data) in pppol2tp_setsockopt()
1250 err = -EBADF; in pppol2tp_setsockopt()
1257 if (session->session_id == 0 && session->peer_session_id == 0) { in pppol2tp_setsockopt()
1258 tunnel = session->tunnel; in pppol2tp_setsockopt()
1284 err = -ENOPROTOOPT; in pppol2tp_tunnel_getsockopt()
1301 *val = session->recv_seq; in pppol2tp_session_getsockopt()
1305 *val = session->send_seq; in pppol2tp_session_getsockopt()
1309 *val = session->lns_mode; in pppol2tp_session_getsockopt()
1318 *val = (int)jiffies_to_msecs(session->reorder_timeout); in pppol2tp_session_getsockopt()
1322 err = -ENOPROTOOPT; in pppol2tp_session_getsockopt()
1336 struct sock *sk = sock->sk; in pppol2tp_getsockopt()
1343 return -EINVAL; in pppol2tp_getsockopt()
1346 return -EFAULT; in pppol2tp_getsockopt()
1349 return -EINVAL; in pppol2tp_getsockopt()
1353 err = -ENOTCONN; in pppol2tp_getsockopt()
1354 if (!sk->sk_user_data) in pppol2tp_getsockopt()
1358 err = -EBADF; in pppol2tp_getsockopt()
1364 if (session->session_id == 0 && session->peer_session_id == 0) { in pppol2tp_getsockopt()
1365 tunnel = session->tunnel; in pppol2tp_getsockopt()
1375 err = -EFAULT; in pppol2tp_getsockopt()
1409 if (pd->tunnel) in pppol2tp_next_tunnel()
1410 l2tp_tunnel_put(pd->tunnel); in pppol2tp_next_tunnel()
1413 pd->tunnel = l2tp_tunnel_get_next(net, &pd->tkey); in pppol2tp_next_tunnel()
1414 pd->tkey++; in pppol2tp_next_tunnel()
1417 if (!pd->tunnel || pd->tunnel->version == 2) in pppol2tp_next_tunnel()
1420 l2tp_tunnel_put(pd->tunnel); in pppol2tp_next_tunnel()
1427 if (pd->session) in pppol2tp_next_session()
1428 l2tp_session_put(pd->session); in pppol2tp_next_session()
1430 pd->session = l2tp_session_get_next(net, pd->tunnel->sock, in pppol2tp_next_session()
1431 pd->tunnel->version, in pppol2tp_next_session()
1432 pd->tunnel->tunnel_id, &pd->skey); in pppol2tp_next_session()
1433 pd->skey++; in pppol2tp_next_session()
1435 if (!pd->session) { in pppol2tp_next_session()
1436 pd->skey = 0; in pppol2tp_next_session()
1450 if (WARN_ON(!m->private)) { in pppol2tp_seq_start()
1455 pd = m->private; in pppol2tp_seq_start()
1458 if (!pd->tunnel) in pppol2tp_seq_start()
1464 if (!pd->tunnel && !pd->session) in pppol2tp_seq_start()
1487 if (pd->session) { in pppol2tp_seq_stop()
1488 l2tp_session_put(pd->session); in pppol2tp_seq_stop()
1489 pd->session = NULL; in pppol2tp_seq_stop()
1491 if (pd->tunnel) { in pppol2tp_seq_stop()
1492 l2tp_tunnel_put(pd->tunnel); in pppol2tp_seq_stop()
1493 pd->tunnel = NULL; in pppol2tp_seq_stop()
1502 tunnel->name, in pppol2tp_seq_tunnel_show()
1503 tunnel->sock ? 'Y' : 'N', in pppol2tp_seq_tunnel_show()
1504 refcount_read(&tunnel->ref_count) - 1); in pppol2tp_seq_tunnel_show()
1507 atomic_long_read(&tunnel->stats.tx_packets), in pppol2tp_seq_tunnel_show()
1508 atomic_long_read(&tunnel->stats.tx_bytes), in pppol2tp_seq_tunnel_show()
1509 atomic_long_read(&tunnel->stats.tx_errors), in pppol2tp_seq_tunnel_show()
1510 atomic_long_read(&tunnel->stats.rx_packets), in pppol2tp_seq_tunnel_show()
1511 atomic_long_read(&tunnel->stats.rx_bytes), in pppol2tp_seq_tunnel_show()
1512 atomic_long_read(&tunnel->stats.rx_errors)); in pppol2tp_seq_tunnel_show()
1518 struct l2tp_tunnel *tunnel = session->tunnel; in pppol2tp_seq_session_show()
1525 if (tunnel->sock) { in pppol2tp_seq_session_show()
1526 struct inet_sock *inet = inet_sk(tunnel->sock); in pppol2tp_seq_session_show()
1528 ip = ntohl(inet->inet_saddr); in pppol2tp_seq_session_show()
1529 port = ntohs(inet->inet_sport); in pppol2tp_seq_session_show()
1534 state = sk->sk_state; in pppol2tp_seq_session_show()
1535 user_data_ok = (session == sk->sk_user_data) ? 'Y' : 'N'; in pppol2tp_seq_session_show()
1541 seq_printf(m, " SESSION '%s' %08X/%d %04X/%04X -> %04X/%04X %d %c\n", in pppol2tp_seq_session_show()
1542 session->name, ip, port, in pppol2tp_seq_session_show()
1543 tunnel->tunnel_id, in pppol2tp_seq_session_show()
1544 session->session_id, in pppol2tp_seq_session_show()
1545 tunnel->peer_tunnel_id, in pppol2tp_seq_session_show()
1546 session->peer_session_id, in pppol2tp_seq_session_show()
1549 session->recv_seq ? 'R' : '-', in pppol2tp_seq_session_show()
1550 session->send_seq ? 'S' : '-', in pppol2tp_seq_session_show()
1551 session->lns_mode ? "LNS" : "LAC", in pppol2tp_seq_session_show()
1553 jiffies_to_msecs(session->reorder_timeout)); in pppol2tp_seq_session_show()
1555 session->nr, session->ns, in pppol2tp_seq_session_show()
1556 atomic_long_read(&session->stats.tx_packets), in pppol2tp_seq_session_show()
1557 atomic_long_read(&session->stats.tx_bytes), in pppol2tp_seq_session_show()
1558 atomic_long_read(&session->stats.tx_errors), in pppol2tp_seq_session_show()
1559 atomic_long_read(&session->stats.rx_packets), in pppol2tp_seq_session_show()
1560 atomic_long_read(&session->stats.rx_bytes), in pppol2tp_seq_session_show()
1561 atomic_long_read(&session->stats.rx_errors)); in pppol2tp_seq_session_show()
1566 seq_printf(m, " interface %s\n", ppp_dev_name(&po->chan)); in pppol2tp_seq_session_show()
1578 seq_puts(m, "TUNNEL name, user-data-ok session-count\n"); in pppol2tp_seq_show()
1579 seq_puts(m, " debug tx-pkts/bytes/errs rx-pkts/bytes/errs\n"); in pppol2tp_seq_show()
1580 seq_puts(m, " SESSION name, addr/port src-tid/sid dest-tid/sid state user-data-ok\n"); in pppol2tp_seq_show()
1582 seq_puts(m, " nr/ns tx-pkts/bytes/errs rx-pkts/bytes/errs\n"); in pppol2tp_seq_show()
1586 if (!pd->session) in pppol2tp_seq_show()
1587 pppol2tp_seq_tunnel_show(m, pd->tunnel); in pppol2tp_seq_show()
1589 pppol2tp_seq_session_show(m, pd->session); in pppol2tp_seq_show()
1612 pde = proc_create_net("pppol2tp", 0444, net->proc_net, in pppol2tp_init_net()
1615 err = -ENOMEM; in pppol2tp_init_net()
1625 remove_proc_entry("pppol2tp", net->proc_net); in pppol2tp_exit_net()