Lines Matching full:tunnel
27 * zero, the socket is treated as a special tunnel management socket.
150 /* Helpers to obtain tunnel/session contexts from sockets.
267 struct l2tp_tunnel *tunnel; in pppol2tp_sendmsg() local
274 /* Get session and tunnel contexts */ in pppol2tp_sendmsg()
280 tunnel = session->tunnel; in pppol2tp_sendmsg()
282 uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; in pppol2tp_sendmsg()
344 struct l2tp_tunnel *tunnel; in pppol2tp_xmit() local
350 /* Get session and tunnel contexts from the socket */ in pppol2tp_xmit()
355 tunnel = session->tunnel; in pppol2tp_xmit()
357 uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0; in pppol2tp_xmit()
388 * Session (and tunnel control) socket create/destroy.
620 /* Rough estimation of the maximum payload size a tunnel can transmit without
625 static int pppol2tp_tunnel_mtu(const struct l2tp_tunnel *tunnel) in pppol2tp_tunnel_mtu() argument
629 mtu = l2tp_tunnel_dst_mtu(tunnel); in pppol2tp_tunnel_mtu()
640 struct l2tp_tunnel *tunnel; in pppol2tp_tunnel_get() local
645 tunnel = l2tp_tunnel_get(net, info->tunnel_id); in pppol2tp_tunnel_get()
647 /* Special case: create tunnel context if session_id and in pppol2tp_tunnel_get()
648 * peer_session_id is 0. Otherwise look up tunnel using supplied in pppol2tp_tunnel_get()
649 * tunnel id. in pppol2tp_tunnel_get()
652 if (!tunnel) { in pppol2tp_tunnel_get()
667 &tunnel); in pppol2tp_tunnel_get()
671 refcount_inc(&tunnel->ref_count); in pppol2tp_tunnel_get()
672 error = l2tp_tunnel_register(tunnel, net, &tcfg); in pppol2tp_tunnel_get()
674 kfree(tunnel); in pppol2tp_tunnel_get()
681 /* Error if we can't find the tunnel */ in pppol2tp_tunnel_get()
682 if (!tunnel) in pppol2tp_tunnel_get()
686 if (!tunnel->sock) { in pppol2tp_tunnel_get()
687 l2tp_tunnel_put(tunnel); in pppol2tp_tunnel_get()
692 return tunnel; in pppol2tp_tunnel_get()
695 /* connect() handler. Attach a PPPoX socket to a tunnel UDP socket
704 struct l2tp_tunnel *tunnel; in pppol2tp_connect() local
720 tunnel = pppol2tp_tunnel_get(sock_net(sk), &info, &new_tunnel); in pppol2tp_connect()
721 if (IS_ERR(tunnel)) in pppol2tp_connect()
722 return PTR_ERR(tunnel); 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()
766 tunnel, info.session_id, in pppol2tp_connect()
780 error = l2tp_session_register(session, tunnel); in pppol2tp_connect()
791 * socket is being created to manage the tunnel. Just set up in pppol2tp_connect()
808 po->chan.mtu = pppol2tp_tunnel_mtu(tunnel); in pppol2tp_connect()
836 l2tp_tunnel_delete(tunnel); in pppol2tp_connect()
840 l2tp_tunnel_put(tunnel); in pppol2tp_connect()
849 static int pppol2tp_session_create(struct net *net, struct l2tp_tunnel *tunnel, in pppol2tp_session_create() argument
856 /* Error if tunnel socket is not prepped */ in pppol2tp_session_create()
857 if (!tunnel->sock) { in pppol2tp_session_create()
864 tunnel, session_id, in pppol2tp_session_create()
873 error = l2tp_session_register(session, tunnel); in pppol2tp_session_create()
895 struct l2tp_tunnel *tunnel; in pppol2tp_getname() local
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()
922 sp.pppol2tp.fd = tunnel->fd; 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()
933 } else if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET6) { in pppol2tp_getname()
940 sp.pppol2tp.fd = tunnel->fd; 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()
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()
951 } else if (tunnel->version == 3 && tunnel->sock->sk_family == AF_INET6) { in pppol2tp_getname()
958 sp.pppol2tp.fd = tunnel->fd; 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()
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()
970 } else if (tunnel->version == 3) { in pppol2tp_getname()
977 sp.pppol2tp.fd = tunnel->fd; 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()
1000 * sockets. However, in order to control kernel tunnel features, we allow
1001 * userspace to create a special "tunnel" PPPoX socket which is used for
1002 * control only. Tunnel PPPoX sockets have session_id == 0 and simply allow
1023 struct l2tp_tunnel *tunnel) in pppol2tp_tunnel_copy_stats() argument
1028 pppol2tp_copy_stats(stats, &tunnel->stats); in pppol2tp_tunnel_copy_stats()
1033 * context of this tunnel and record the session's statistics. 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()
1100 /* Session 0 represents the parent tunnel */ in pppol2tp_ioctl()
1111 session->tunnel); 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()
1138 * sockets. In order to control kernel tunnel features, we allow userspace to
1139 * create a special "tunnel" PPPoX socket which is used for control only.
1140 * Tunnel PPPoX sockets have session_id == 0 and simply allow the user
1144 /* Tunnel setsockopt() helper.
1147 struct l2tp_tunnel *tunnel, in pppol2tp_tunnel_setsockopt() argument
1154 /* Tunnel debug flags option is deprecated */ in pppol2tp_tunnel_setsockopt()
1194 l2tp_session_set_header_len(session, session->tunnel->version, in pppol2tp_session_setsockopt()
1195 session->tunnel->encap); in pppol2tp_session_setsockopt()
1223 * Does API checks, then calls either the tunnel or session setsockopt
1225 * session or the special tunnel type.
1232 struct l2tp_tunnel *tunnel; in pppol2tp_setsockopt() local
1255 /* Special case: if session_id == 0x0000, treat as operation on tunnel in pppol2tp_setsockopt()
1258 tunnel = session->tunnel; in pppol2tp_setsockopt()
1259 err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val); in pppol2tp_setsockopt()
1269 /* Tunnel getsockopt helper. Called with sock locked.
1272 struct l2tp_tunnel *tunnel, in pppol2tp_tunnel_getsockopt() argument
1279 /* Tunnel debug flags option is deprecated */ in pppol2tp_tunnel_getsockopt()
1329 * Does API checks, then calls either the tunnel or session getsockopt
1331 * or the special tunnel type.
1338 struct l2tp_tunnel *tunnel; in pppol2tp_getsockopt() local
1363 /* Special case: if session_id == 0x0000, treat as operation on tunnel */ in pppol2tp_getsockopt()
1365 tunnel = session->tunnel; in pppol2tp_getsockopt()
1366 err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val); in pppol2tp_getsockopt()
1400 unsigned long tkey; /* lookup key of current tunnel */
1402 struct l2tp_tunnel *tunnel; member
1403 struct l2tp_session *session; /* NULL means get next tunnel */
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()
1417 if (!pd->tunnel || pd->tunnel->version == 2) in pppol2tp_next_tunnel()
1420 l2tp_tunnel_put(pd->tunnel); in pppol2tp_next_tunnel()
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()
1458 if (!pd->tunnel) in pppol2tp_seq_start()
1463 /* NULL tunnel and session indicates end of list */ in pppol2tp_seq_start()
1464 if (!pd->tunnel && !pd->session) in pppol2tp_seq_start()
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()
1499 struct l2tp_tunnel *tunnel = v; in pppol2tp_seq_tunnel_show() local
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() local
1525 if (tunnel->sock) { in pppol2tp_seq_session_show()
1526 struct inet_sock *inet = inet_sk(tunnel->sock); in pppol2tp_seq_session_show()
1543 tunnel->tunnel_id, in pppol2tp_seq_session_show()
1545 tunnel->peer_tunnel_id, in pppol2tp_seq_session_show()
1578 seq_puts(m, "TUNNEL name, user-data-ok session-count\n"); in pppol2tp_seq_show()
1587 pppol2tp_seq_tunnel_show(m, pd->tunnel); in pppol2tp_seq_show()