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.
273 struct l2tp_tunnel *tunnel;
280 /* Get session and tunnel contexts */
286 tunnel = session->tunnel;
288 uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
350 struct l2tp_tunnel *tunnel;
356 /* Get session and tunnel contexts from the socket */
361 tunnel = session->tunnel;
363 uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
394 * Session (and tunnel control) socket create/destroy.
638 /* Rough estimation of the maximum payload size a tunnel can transmit without
643 static int pppol2tp_tunnel_mtu(const struct l2tp_tunnel *tunnel)
647 mtu = l2tp_tunnel_dst_mtu(tunnel);
658 struct l2tp_tunnel *tunnel;
663 tunnel = l2tp_tunnel_get(net, info->tunnel_id);
665 /* Special case: create tunnel context if session_id and
666 * peer_session_id is 0. Otherwise look up tunnel using supplied
667 * tunnel id.
670 if (!tunnel) {
685 &tunnel);
689 l2tp_tunnel_inc_refcount(tunnel);
690 error = l2tp_tunnel_register(tunnel, net, &tcfg);
692 kfree(tunnel);
699 /* Error if we can't find the tunnel */
700 if (!tunnel)
704 if (!tunnel->sock) {
705 l2tp_tunnel_dec_refcount(tunnel);
710 return tunnel;
713 /* connect() handler. Attach a PPPoX socket to a tunnel UDP socket
722 struct l2tp_tunnel *tunnel;
738 tunnel = pppol2tp_tunnel_get(sock_net(sk), &info, &new_tunnel);
739 if (IS_ERR(tunnel))
740 return PTR_ERR(tunnel);
754 if (tunnel->peer_tunnel_id == 0)
755 tunnel->peer_tunnel_id = info.peer_tunnel_id;
757 session = l2tp_tunnel_get_session(tunnel, info.session_id);
783 tunnel, info.session_id,
795 error = l2tp_session_register(session, tunnel);
806 * socket is being created to manage the tunnel. Just set up
823 po->chan.mtu = pppol2tp_tunnel_mtu(tunnel);
850 l2tp_tunnel_delete(tunnel);
854 l2tp_tunnel_dec_refcount(tunnel);
863 static int pppol2tp_session_create(struct net *net, struct l2tp_tunnel *tunnel,
870 /* Error if tunnel socket is not prepped */
871 if (!tunnel->sock) {
878 tunnel, session_id,
887 error = l2tp_session_register(session, tunnel);
909 struct l2tp_tunnel *tunnel;
926 tunnel = session->tunnel;
928 inet = inet_sk(tunnel->sock);
929 if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET) {
936 sp.pppol2tp.fd = tunnel->fd;
938 sp.pppol2tp.s_tunnel = tunnel->tunnel_id;
939 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id;
947 } else if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET6) {
954 sp.pppol2tp.fd = tunnel->fd;
956 sp.pppol2tp.s_tunnel = tunnel->tunnel_id;
957 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id;
962 memcpy(&sp.pppol2tp.addr.sin6_addr, &tunnel->sock->sk_v6_daddr,
963 sizeof(tunnel->sock->sk_v6_daddr));
965 } else if (tunnel->version == 3 && tunnel->sock->sk_family == AF_INET6) {
972 sp.pppol2tp.fd = tunnel->fd;
974 sp.pppol2tp.s_tunnel = tunnel->tunnel_id;
975 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id;
980 memcpy(&sp.pppol2tp.addr.sin6_addr, &tunnel->sock->sk_v6_daddr,
981 sizeof(tunnel->sock->sk_v6_daddr));
984 } else if (tunnel->version == 3) {
991 sp.pppol2tp.fd = tunnel->fd;
993 sp.pppol2tp.s_tunnel = tunnel->tunnel_id;
994 sp.pppol2tp.d_tunnel = tunnel->peer_tunnel_id;
1014 * sockets. However, in order to control kernel tunnel features, we allow
1015 * userspace to create a special "tunnel" PPPoX socket which is used for
1037 struct l2tp_tunnel *tunnel)
1042 pppol2tp_copy_stats(stats, &tunnel->stats);
1047 * context of this tunnel and record the session's statistics.
1049 session = l2tp_tunnel_get_session(tunnel, stats->session_id);
1113 /* Session 0 represents the parent tunnel */
1124 session->tunnel);
1133 stats.tunnel_id = session->tunnel->tunnel_id;
1134 stats.using_ipsec = l2tp_tunnel_uses_xfrm(session->tunnel);
1151 * sockets. In order to control kernel tunnel features, we allow userspace to
1152 * create a special "tunnel" PPPoX socket which is used for control only.
1160 struct l2tp_tunnel *tunnel,
1207 l2tp_session_set_header_len(session, session->tunnel->version);
1235 * Does API checks, then calls either the tunnel or session setsockopt
1237 * session or the special tunnel type.
1244 struct l2tp_tunnel *tunnel;
1267 /* Special case: if session_id == 0x0000, treat as operation on tunnel
1270 tunnel = session->tunnel;
1271 err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val);
1284 struct l2tp_tunnel *tunnel,
1341 * Does API checks, then calls either the tunnel or session getsockopt
1343 * or the special tunnel type.
1350 struct l2tp_tunnel *tunnel;
1375 /* Special case: if session_id == 0x0000, treat as operation on tunnel */
1377 tunnel = session->tunnel;
1378 err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val);
1414 int tunnel_idx; /* current tunnel */
1415 int session_idx; /* index of session within current tunnel */
1416 struct l2tp_tunnel *tunnel;
1417 struct l2tp_session *session; /* NULL means get next tunnel */
1423 if (pd->tunnel)
1424 l2tp_tunnel_dec_refcount(pd->tunnel);
1427 pd->tunnel = l2tp_tunnel_get_nth(net, pd->tunnel_idx);
1431 if (!pd->tunnel || pd->tunnel->version == 2)
1434 l2tp_tunnel_dec_refcount(pd->tunnel);
1444 pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx);
1470 if (!pd->tunnel)
1475 /* NULL tunnel and session indicates end of list */
1476 if (!pd->tunnel && !pd->session)
1503 if (pd->tunnel) {
1504 l2tp_tunnel_dec_refcount(pd->tunnel);
1505 pd->tunnel = NULL;
1511 struct l2tp_tunnel *tunnel = v;
1514 tunnel->name,
1515 (tunnel == tunnel->sock->sk_user_data) ? 'Y' : 'N',
1516 refcount_read(&tunnel->ref_count) - 1);
1519 atomic_long_read(&tunnel->stats.tx_packets),
1520 atomic_long_read(&tunnel->stats.tx_bytes),
1521 atomic_long_read(&tunnel->stats.tx_errors),
1522 atomic_long_read(&tunnel->stats.rx_packets),
1523 atomic_long_read(&tunnel->stats.rx_bytes),
1524 atomic_long_read(&tunnel->stats.rx_errors));
1530 struct l2tp_tunnel *tunnel = session->tunnel;
1537 if (tunnel->sock) {
1538 struct inet_sock *inet = inet_sk(tunnel->sock);
1555 tunnel->tunnel_id,
1557 tunnel->peer_tunnel_id,
1599 pppol2tp_seq_tunnel_show(m, pd->tunnel);