Lines Matching refs:tunnel

27  * zero, the socket is treated as a special tunnel management socket.
151 /* Helpers to obtain tunnel/session contexts from sockets.
272 struct l2tp_tunnel *tunnel;
279 /* Get session and tunnel contexts */
285 tunnel = session->tunnel;
287 uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
349 struct l2tp_tunnel *tunnel;
355 /* Get session and tunnel contexts from the socket */
360 tunnel = session->tunnel;
362 uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
393 * Session (and tunnel control) socket create/destroy.
637 /* Rough estimation of the maximum payload size a tunnel can transmit without
642 static int pppol2tp_tunnel_mtu(const struct l2tp_tunnel *tunnel)
646 mtu = l2tp_tunnel_dst_mtu(tunnel);
657 struct l2tp_tunnel *tunnel;
662 tunnel = l2tp_tunnel_get(net, info->tunnel_id);
664 /* Special case: create tunnel context if session_id and
665 * peer_session_id is 0. Otherwise look up tunnel using supplied
666 * tunnel id.
669 if (!tunnel) {
684 &tunnel);
688 l2tp_tunnel_inc_refcount(tunnel);
689 error = l2tp_tunnel_register(tunnel, net, &tcfg);
691 kfree(tunnel);
698 /* Error if we can't find the tunnel */
699 if (!tunnel)
703 if (!tunnel->sock) {
704 l2tp_tunnel_dec_refcount(tunnel);
709 return tunnel;
712 /* connect() handler. Attach a PPPoX socket to a tunnel UDP socket
721 struct l2tp_tunnel *tunnel;
737 tunnel = pppol2tp_tunnel_get(sock_net(sk), &info, &new_tunnel);
738 if (IS_ERR(tunnel))
739 return PTR_ERR(tunnel);
753 if (tunnel->peer_tunnel_id == 0)
754 tunnel->peer_tunnel_id = info.peer_tunnel_id;
756 session = l2tp_tunnel_get_session(tunnel, info.session_id);
782 tunnel, info.session_id,
794 error = l2tp_session_register(session, tunnel);
805 * socket is being created to manage the tunnel. Just set up
822 po->chan.mtu = pppol2tp_tunnel_mtu(tunnel);
849 l2tp_tunnel_delete(tunnel);
853 l2tp_tunnel_dec_refcount(tunnel);
862 static int pppol2tp_session_create(struct net *net, struct l2tp_tunnel *tunnel,
869 /* Error if tunnel socket is not prepped */
870 if (!tunnel->sock) {
877 tunnel, session_id,
886 error = l2tp_session_register(session, tunnel);
908 struct l2tp_tunnel *tunnel;
925 tunnel = session->tunnel;
927 inet = inet_sk(tunnel->sock);
928 if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET) {
935 sp.pppol2tp.fd = tunnel->fd;
937 sp.pppol2tp.s_tunnel = tunnel->tunnel_id;
938 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id;
946 } else if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET6) {
953 sp.pppol2tp.fd = tunnel->fd;
955 sp.pppol2tp.s_tunnel = tunnel->tunnel_id;
956 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id;
961 memcpy(&sp.pppol2tp.addr.sin6_addr, &tunnel->sock->sk_v6_daddr,
962 sizeof(tunnel->sock->sk_v6_daddr));
964 } else if (tunnel->version == 3 && tunnel->sock->sk_family == AF_INET6) {
971 sp.pppol2tp.fd = tunnel->fd;
973 sp.pppol2tp.s_tunnel = tunnel->tunnel_id;
974 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id;
979 memcpy(&sp.pppol2tp.addr.sin6_addr, &tunnel->sock->sk_v6_daddr,
980 sizeof(tunnel->sock->sk_v6_daddr));
983 } else if (tunnel->version == 3) {
990 sp.pppol2tp.fd = tunnel->fd;
992 sp.pppol2tp.s_tunnel = tunnel->tunnel_id;
993 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id;
1013 * sockets. However, in order to control kernel tunnel features, we allow
1014 * userspace to create a special "tunnel" PPPoX socket which is used for
1036 struct l2tp_tunnel *tunnel)
1041 pppol2tp_copy_stats(stats, &tunnel->stats);
1046 * context of this tunnel and record the session's statistics.
1048 session = l2tp_tunnel_get_session(tunnel, stats->session_id);
1112 /* Session 0 represents the parent tunnel */
1123 session->tunnel);
1132 stats.tunnel_id = session->tunnel->tunnel_id;
1133 stats.using_ipsec = l2tp_tunnel_uses_xfrm(session->tunnel);
1150 * sockets. In order to control kernel tunnel features, we allow userspace to
1151 * create a special "tunnel" PPPoX socket which is used for control only.
1159 struct l2tp_tunnel *tunnel,
1206 l2tp_session_set_header_len(session, session->tunnel->version);
1234 * Does API checks, then calls either the tunnel or session setsockopt
1236 * session or the special tunnel type.
1243 struct l2tp_tunnel *tunnel;
1266 /* Special case: if session_id == 0x0000, treat as operation on tunnel
1269 tunnel = session->tunnel;
1270 err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val);
1283 struct l2tp_tunnel *tunnel,
1340 * Does API checks, then calls either the tunnel or session getsockopt
1342 * or the special tunnel type.
1349 struct l2tp_tunnel *tunnel;
1374 /* Special case: if session_id == 0x0000, treat as operation on tunnel */
1376 tunnel = session->tunnel;
1377 err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val);
1413 int tunnel_idx; /* current tunnel */
1414 int session_idx; /* index of session within current tunnel */
1415 struct l2tp_tunnel *tunnel;
1416 struct l2tp_session *session; /* NULL means get next tunnel */
1422 if (pd->tunnel)
1423 l2tp_tunnel_dec_refcount(pd->tunnel);
1426 pd->tunnel = l2tp_tunnel_get_nth(net, pd->tunnel_idx);
1430 if (!pd->tunnel || pd->tunnel->version == 2)
1433 l2tp_tunnel_dec_refcount(pd->tunnel);
1443 pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx);
1469 if (!pd->tunnel)
1474 /* NULL tunnel and session indicates end of list */
1475 if (!pd->tunnel && !pd->session)
1502 if (pd->tunnel) {
1503 l2tp_tunnel_dec_refcount(pd->tunnel);
1504 pd->tunnel = NULL;
1510 struct l2tp_tunnel *tunnel = v;
1513 tunnel->name,
1514 (tunnel == tunnel->sock->sk_user_data) ? 'Y' : 'N',
1515 refcount_read(&tunnel->ref_count) - 1);
1518 atomic_long_read(&tunnel->stats.tx_packets),
1519 atomic_long_read(&tunnel->stats.tx_bytes),
1520 atomic_long_read(&tunnel->stats.tx_errors),
1521 atomic_long_read(&tunnel->stats.rx_packets),
1522 atomic_long_read(&tunnel->stats.rx_bytes),
1523 atomic_long_read(&tunnel->stats.rx_errors));
1529 struct l2tp_tunnel *tunnel = session->tunnel;
1536 if (tunnel->sock) {
1537 struct inet_sock *inet = inet_sk(tunnel->sock);
1554 tunnel->tunnel_id,
1556 tunnel->peer_tunnel_id,
1598 pppol2tp_seq_tunnel_show(m, pd->tunnel);