• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/net/

Lines Matching refs:tunnel

37  * zero, the socket is treated as a special tunnel management socket.
185 struct pppol2tp_tunnel *tunnel;
211 struct sock *tunnel_sock; /* Pointer to the tunnel UDP
214 struct pppol2tp_addr tunnel_addr; /* Description of tunnel */
216 struct pppol2tp_tunnel *tunnel; /* back pointer to tunnel
243 /* The sk_user_data field of the tunnel's UDP socket. It contains info to track
250 struct workqueue_struct *wq; /* Per-tunnel work queue */
291 /* Macros to derive session/tunnel context pointers from a socket. */
304 #define SOCK_2_TUNNEL(sock, tunnel, err, errval, label, quiet) \
305 tunnel = (struct pppol2tp_tunnel *)((sock)->sk_user_data); \
306 if (!tunnel || tunnel->magic != L2TP_TUNNEL_MAGIC) { \
309 "(" #sock "=%p) tunnel=%p magic=%x\n", \
311 tunnel, tunnel ? tunnel->magic : 0); \
323 pppol2tp_session_id_hash(struct pppol2tp_tunnel *tunnel, u16 session_id)
326 return &tunnel->session_hlist[hash_long(hash_val, PPPOL2TP_HASH_BITS)];
332 pppol2tp_session_find(struct pppol2tp_tunnel *tunnel, u16 session_id)
335 pppol2tp_session_id_hash(tunnel, session_id);
393 struct pppol2tp_tunnel *tunnel = session->tunnel;
409 tunnel->stats.rx_packets++;
410 tunnel->stats.rx_bytes += length;
443 * of the UDP tunnel
555 struct pppol2tp_tunnel *tunnel;
567 SOCK_2_TUNNEL(sock, tunnel, error, 1, end, 0);
571 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
572 "%s: recv short packet (len=%d)\n", tunnel->name, skb->len);
583 if (tunnel->debug & PPPOL2TP_MSG_DATA) {
584 printk(KERN_DEBUG "%s: recv: ", tunnel->name);
601 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
602 "%s: recv short L2TP packet (len=%d)\n", tunnel->name, length);
615 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
616 "%s: recv control packet, len=%d\n", tunnel->name, length);
627 /* Extract tunnel and session ID */
634 session = pppol2tp_session_find(tunnel, session_id);
637 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
639 tunnel->name, tunnel_id, session_id);
805 struct pppol2tp_tunnel *tunnel;
809 SOCK_2_TUNNEL(sk, tunnel, err, -EBADF, end, 0);
811 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
812 "%s: received %d bytes\n", tunnel->name, len);
817 DPRINTK(tunnel->debug, "%s: packet passing to userspace\n",
818 tunnel->name);
820 tunnel->old_data_ready(sk, len);
822 DPRINTK(tunnel->debug, "%s: data packet received\n",
823 tunnel->name);
874 struct pppol2tp_tunnel *tunnel,
911 error = tunnel->old_proto->sendmsg(iocb, session->tunnel_sock, msg, total_len);
919 tunnel->stats.tx_packets++;
920 tunnel->stats.tx_bytes += error;
924 tunnel->stats.tx_errors++;
988 struct pppol2tp_tunnel *tunnel;
997 /* Get session and tunnel contexts */
999 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, error, -EBADF, end, 0);
1040 tunnel->stats.tx_errors++;
1049 tunnel->stats.tx_errors++;
1074 error = pppol2tp_udp_sock_send(iocb, session, tunnel, msg,
1101 error = send->tunnel->old_proto->sendmsg(&send->iocb,
1110 send->tunnel->stats.tx_packets++;
1111 send->tunnel->stats.tx_bytes += error;
1115 send->tunnel->stats.tx_errors++;
1185 struct pppol2tp_tunnel *tunnel;
1204 /* Get session and tunnel contexts from the socket */
1207 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, error, -EBADF, keep_go_2, 0);
1213 tunnel->stats.tx_errors++;
1280 * terminate the tunnel socket in some cases.
1325 * Use the tunnel sock info instead.
1348 tunnel->stats.tx_errors++;
1356 tunnel->stats.tx_errors++;
1384 send->tunnel = tunnel;
1398 queue_work(tunnel->wq, &send->send_task);
1412 * Session (and tunnel control) socket create/destroy.
1415 /* When the tunnel UDP socket is closed, all the attached sockets need to go
1418 static void pppol2tp_tunnel_closeall(struct pppol2tp_tunnel *tunnel)
1428 if (tunnel == NULL)
1431 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1432 "%s: closing all sessions...\n", tunnel->name);
1435 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) {
1443 write_lock_bh(&tunnel->hlist_lock);
1445 write_unlock_bh(&tunnel->hlist_lock);
1472 /* Really kill the tunnel.
1473 * Come here only when all sessions have been cleared from the tunnel.
1475 static void pppol2tp_tunnel_free(struct pppol2tp_tunnel *tunnel)
1477 struct sock *sk = tunnel->sock;
1482 list_del_init(&tunnel->list);
1484 sk->sk_prot = tunnel->old_proto;
1485 sk->sk_data_ready = tunnel->old_data_ready;
1486 sk->sk_destruct = tunnel->old_sk_destruct;
1489 flush_workqueue(tunnel->wq);
1490 destroy_workqueue(tunnel->wq);
1492 DPRINTK(tunnel->debug, "%s: MOD_DEC_USE_COUNT\n", tunnel->name);
1493 kfree(tunnel);
1499 * The tunnel context is deleted only when all session sockets have been
1504 struct pppol2tp_tunnel *tunnel;
1508 SOCK_2_TUNNEL(sk, tunnel, error, -EBADF, end, 0);
1510 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1511 "%s: closing...\n", tunnel->name);
1513 pppol2tp_tunnel_closeall(tunnel);
1533 struct pppol2tp_tunnel *tunnel;
1538 /* Don't use SOCK_2_TUNNEL() here to get the tunnel context
1539 * because the tunnel socket might have already been closed
1541 * private tunnel ptr instead.
1543 tunnel = session->tunnel;
1544 if (tunnel != NULL) {
1545 if (tunnel->magic != L2TP_TUNNEL_MAGIC) {
1547 "( tunnel=%p magic=%x )\n",
1549 tunnel, tunnel->magic);
1554 /* Delete tunnel context if this was the last session on the
1555 * tunnel. This was allocated when the first session was
1556 * created on the tunnel. See
1559 DPRINTK(tunnel->debug, "%s: session_count=%d\n",
1560 tunnel->name, atomic_read(&tunnel->session_count));
1561 if (atomic_dec_and_test(&tunnel->session_count)) {
1562 pppol2tp_tunnel_free(tunnel);
1584 struct pppol2tp_tunnel *tunnel;
1597 /* Don't use SOCK_2_TUNNEL() here to get the tunnel context
1598 * because the tunnel socket might have already been closed
1600 * private tunnel ptr instead.
1602 tunnel = session->tunnel;
1603 if (tunnel != NULL) {
1604 if (tunnel->magic == L2TP_TUNNEL_MAGIC) {
1606 write_lock_bh(&tunnel->hlist_lock);
1608 write_unlock_bh(&tunnel->hlist_lock);
1611 "( tunnel=%p magic=%x )\n",
1613 tunnel, tunnel->magic);
1704 /* Internal function to prepare a tunnel (UDP) socket to have PPPoX sockets
1713 struct pppol2tp_tunnel *tunnel;
1748 tunnel = (struct pppol2tp_tunnel *)sk->sk_user_data;
1749 if (tunnel != NULL) {
1752 if (tunnel->magic != L2TP_TUNNEL_MAGIC) {
1754 "( tunnel=%p magic=%x )\n",
1756 tunnel, tunnel->magic);
1761 ret = tunnel->sock;
1765 /* This socket is available and needs prepping. Create a new tunnel
1768 sk->sk_user_data = tunnel = kmalloc(sizeof(struct pppol2tp_tunnel), GFP_KERNEL);
1774 memset(tunnel, 0, sizeof(struct pppol2tp_tunnel));
1776 tunnel->magic = L2TP_TUNNEL_MAGIC;
1777 sprintf(&tunnel->name[0], "tunl %hu", tunnel_id);
1779 tunnel->stats.tunnel_id = tunnel_id;
1781 tunnel->debug = PPPOL2TP_DEFAULT_DEBUG_FLAGS;
1783 DPRINTK(tunnel->debug, "tunl %hu: allocated tunnel=%p, sk=%p, sock=%p\n",
1784 tunnel_id, tunnel, sk, sock);
1786 tunnel->wq = create_workqueue("kl2tpd");
1787 if (!tunnel->wq) {
1793 tunnel->old_proto = sk->sk_prot;
1794 tunnel->l2tp_proto = *sk->sk_prot;
1796 sk->sk_prot = &tunnel->l2tp_proto;
1798 tunnel->old_data_ready = sk->sk_data_ready;
1801 tunnel->old_sk_destruct = sk->sk_destruct;
1804 tunnel->sock = sk;
1807 rwlock_init(&tunnel->hlist_lock);
1809 /* Add tunnel to our list */
1810 INIT_LIST_HEAD(&tunnel->list);
1811 list_add(&tunnel->list, &pppol2tp_tunnel_list);
1813 ret = tunnel->sock;
1824 kfree(tunnel);
1904 /* connect() handler.. Attach a PPPoX socket to a tunnel UDP socket
1918 struct pppol2tp_tunnel *tunnel;
1947 /* Look up the tunnel socket and configure it if necessary */
1954 tunnel = tunnel_sock->sk_user_data;
1971 session->tunnel = tunnel;
2009 * being created to manage the tunnel. Don't add the session to the
2017 "tunl %hu: socket created for tunnel mgmt ops\n",
2026 /* Add session to the tunnel's hash list */
2027 SOCK_2_TUNNEL(tunnel_sock, tunnel, error, -EBADF, end, 0);
2028 write_lock_bh(&tunnel->hlist_lock);
2030 pppol2tp_session_id_hash(tunnel,
2032 write_unlock_bh(&tunnel->hlist_lock);
2060 atomic_inc(&tunnel->session_count);
2114 * sockets. However, in order to control kernel tunnel features, we allow
2115 * userspace to create a special "tunnel" PPPoX socket which is used for
2272 * application to retrieve session stats via a tunnel socket.
2274 static int pppol2tp_tunnel_ioctl(struct pppol2tp_tunnel *tunnel,
2278 struct sock *sk = tunnel->sock;
2283 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG,
2284 "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n", tunnel->name,
2302 pppol2tp_session_find(tunnel, stats_req.session_id);
2310 tunnel->stats.using_ipsec = (sk->sk_policy[0] || sk->sk_policy[1]) ? 1 : 0;
2312 if (copy_to_user((void __user *) arg, &tunnel->stats,
2313 sizeof(tunnel->stats))) {
2317 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2318 "%s: get L2TP stats\n", tunnel->name);
2333 * Dispatch to tunnel or session helpers depending on the socket.
2340 struct pppol2tp_tunnel *tunnel;
2359 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, err, -EBADF, end, 1);
2362 * tunnel ioctl
2366 err = pppol2tp_tunnel_ioctl(tunnel, cmd, arg);
2381 * sockets. In order to control kernel tunnel features, we allow userspace to
2382 * create a special "tunnel" PPPoX socket which is used for control only.
2390 struct pppol2tp_tunnel *tunnel,
2397 tunnel->debug = val;
2398 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2399 "%s: set debug=%x\n", tunnel->name, tunnel->debug);
2486 * Does API checks, then calls either the tunnel or session setsockopt
2488 * session or the special tunnel type.
2495 struct pppol2tp_tunnel *tunnel;
2516 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, err, -EBADF, end, 1);
2520 /* Special case: if session_id == 0x0000, treat as operation on tunnel
2524 err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val);
2536 struct pppol2tp_tunnel *tunnel,
2543 *val = tunnel->debug;
2544 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2545 "%s: get debug=%x\n", tunnel->name, tunnel->debug);
2603 * Does API checks, then calls either the tunnel or session getsockopt
2605 * or the special tunnel type.
2612 struct pppol2tp_tunnel *tunnel;
2634 /* Get the session and tunnel contexts */
2636 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, err, -EBADF, end, 1);
2638 /* Special case: if session_id == 0x0000, treat as operation on tunnel */
2641 err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val);
2707 struct pppol2tp_tunnel *tunnel = NULL;
2716 tunnel = (void *)1;
2723 tunnel = list_entry(walk, struct pppol2tp_tunnel, list);
2725 sock_hold(tunnel->sock);
2729 tunnel = NULL;
2734 return tunnel;
2739 struct pppol2tp_tunnel *tunnel = v;
2750 list = &tunnel->list;
2754 tunnel = NULL;
2756 tunnel = list_entry(tmp, struct pppol2tp_tunnel, list);
2760 return tunnel;
2765 struct pppol2tp_tunnel *tunnel = v;
2769 if (tunnel != NULL)
2770 sock_put(tunnel->sock);
2777 struct pppol2tp_tunnel *tunnel = v;
2799 tunnel->name,
2800 (tunnel == tunnel->sock->sk_user_data) ? 'Y':'N',
2801 atomic_read(&tunnel->session_count),
2802 (tunnel->magic == L2TP_TUNNEL_MAGIC) ? "OK" : "BAD");
2804 tunnel->debug,
2805 tunnel->stats.tx_packets, tunnel->stats.tx_bytes,
2806 tunnel->stats.tx_errors,
2807 tunnel->stats.rx_packets, tunnel->stats.rx_bytes,
2808 tunnel->stats.rx_errors);
2810 if (tunnel->magic != L2TP_TUNNEL_MAGIC) {
2816 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[i]) {