• 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.
184 struct pppol2tp_tunnel *tunnel;
210 struct sock *tunnel_sock; /* Pointer to the tunnel UDP
213 struct pppol2tp_addr tunnel_addr; /* Description of tunnel */
215 struct pppol2tp_tunnel *tunnel; /* back pointer to tunnel
242 /* The sk_user_data field of the tunnel's UDP socket. It contains info to track
249 struct workqueue_struct *wq; /* Per-tunnel work queue */
290 /* Macros to derive session/tunnel context pointers from a socket. */
303 #define SOCK_2_TUNNEL(sock, tunnel, err, errval, label, quiet) \
304 tunnel = (struct pppol2tp_tunnel *)((sock)->sk_user_data); \
305 if (!tunnel || tunnel->magic != L2TP_TUNNEL_MAGIC) { \
308 "(" #sock "=%p) tunnel=%p magic=%x\n", \
310 tunnel, tunnel ? tunnel->magic : 0); \
322 pppol2tp_session_id_hash(struct pppol2tp_tunnel *tunnel, u16 session_id)
325 return &tunnel->session_hlist[hash_long(hash_val, PPPOL2TP_HASH_BITS)];
331 pppol2tp_session_find(struct pppol2tp_tunnel *tunnel, u16 session_id)
334 pppol2tp_session_id_hash(tunnel, session_id);
392 struct pppol2tp_tunnel *tunnel = session->tunnel;
408 tunnel->stats.rx_packets++;
409 tunnel->stats.rx_bytes += length;
442 * of the UDP tunnel
549 struct pppol2tp_tunnel *tunnel;
561 SOCK_2_TUNNEL(sock, tunnel, error, 1, end, 0);
565 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
566 "%s: recv short packet (len=%d)\n", tunnel->name, skb->len);
577 if (tunnel->debug & PPPOL2TP_MSG_DATA) {
578 printk(KERN_DEBUG "%s: recv: ", tunnel->name);
595 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
596 "%s: recv short L2TP packet (len=%d)\n", tunnel->name, length);
609 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
610 "%s: recv control packet, len=%d\n", tunnel->name, length);
621 /* Extract tunnel and session ID */
628 session = pppol2tp_session_find(tunnel, session_id);
631 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
633 tunnel->name, tunnel_id, session_id);
799 struct pppol2tp_tunnel *tunnel;
803 SOCK_2_TUNNEL(sk, tunnel, err, -EBADF, end, 0);
805 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
806 "%s: received %d bytes\n", tunnel->name, len);
811 DPRINTK(tunnel->debug, "%s: packet passing to userspace\n",
812 tunnel->name);
814 tunnel->old_data_ready(sk, len);
816 DPRINTK(tunnel->debug, "%s: data packet received\n",
817 tunnel->name);
868 struct pppol2tp_tunnel *tunnel,
905 error = tunnel->old_proto->sendmsg(iocb, session->tunnel_sock, msg, total_len);
913 tunnel->stats.tx_packets++;
914 tunnel->stats.tx_bytes += error;
918 tunnel->stats.tx_errors++;
982 struct pppol2tp_tunnel *tunnel;
991 /* Get session and tunnel contexts */
993 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, error, -EBADF, end, 0);
1034 tunnel->stats.tx_errors++;
1043 tunnel->stats.tx_errors++;
1068 error = pppol2tp_udp_sock_send(iocb, session, tunnel, msg,
1095 error = send->tunnel->old_proto->sendmsg(&send->iocb,
1104 send->tunnel->stats.tx_packets++;
1105 send->tunnel->stats.tx_bytes += error;
1109 send->tunnel->stats.tx_errors++;
1157 struct pppol2tp_tunnel *tunnel;
1176 /* Get session and tunnel contexts from the socket */
1179 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, error, -EBADF, keep_go_2, 0);
1185 tunnel->stats.tx_errors++;
1247 * terminate the tunnel socket in some cases.
1282 * Use the tunnel sock info instead.
1305 tunnel->stats.tx_errors++;
1313 tunnel->stats.tx_errors++;
1341 send->tunnel = tunnel;
1355 queue_work(tunnel->wq, &send->send_task);
1369 * Session (and tunnel control) socket create/destroy.
1372 /* When the tunnel UDP socket is closed, all the attached sockets need to go
1375 static void pppol2tp_tunnel_closeall(struct pppol2tp_tunnel *tunnel)
1385 if (tunnel == NULL)
1388 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1389 "%s: closing all sessions...\n", tunnel->name);
1392 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) {
1400 write_lock_bh(&tunnel->hlist_lock);
1402 write_unlock_bh(&tunnel->hlist_lock);
1429 /* Really kill the tunnel.
1430 * Come here only when all sessions have been cleared from the tunnel.
1432 static void pppol2tp_tunnel_free(struct pppol2tp_tunnel *tunnel)
1434 struct sock *sk = tunnel->sock;
1439 list_del_init(&tunnel->list);
1441 sk->sk_prot = tunnel->old_proto;
1442 sk->sk_data_ready = tunnel->old_data_ready;
1443 sk->sk_destruct = tunnel->old_sk_destruct;
1446 flush_workqueue(tunnel->wq);
1447 destroy_workqueue(tunnel->wq);
1449 DPRINTK(tunnel->debug, "%s: MOD_DEC_USE_COUNT\n", tunnel->name);
1450 kfree(tunnel);
1456 * The tunnel context is deleted only when all session sockets have been
1461 struct pppol2tp_tunnel *tunnel;
1465 SOCK_2_TUNNEL(sk, tunnel, error, -EBADF, end, 0);
1467 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1468 "%s: closing...\n", tunnel->name);
1470 pppol2tp_tunnel_closeall(tunnel);
1490 struct pppol2tp_tunnel *tunnel;
1495 /* Don't use SOCK_2_TUNNEL() here to get the tunnel context
1496 * because the tunnel socket might have already been closed
1498 * private tunnel ptr instead.
1500 tunnel = session->tunnel;
1501 if (tunnel != NULL) {
1502 if (tunnel->magic != L2TP_TUNNEL_MAGIC) {
1504 "( tunnel=%p magic=%x )\n",
1506 tunnel, tunnel->magic);
1511 /* Delete tunnel context if this was the last session on the
1512 * tunnel. This was allocated when the first session was
1513 * created on the tunnel. See
1516 DPRINTK(tunnel->debug, "%s: session_count=%d\n",
1517 tunnel->name, atomic_read(&tunnel->session_count));
1518 if (atomic_dec_and_test(&tunnel->session_count)) {
1519 pppol2tp_tunnel_free(tunnel);
1541 struct pppol2tp_tunnel *tunnel;
1554 /* Don't use SOCK_2_TUNNEL() here to get the tunnel context
1555 * because the tunnel socket might have already been closed
1557 * private tunnel ptr instead.
1559 tunnel = session->tunnel;
1560 if (tunnel != NULL) {
1561 if (tunnel->magic == L2TP_TUNNEL_MAGIC) {
1563 write_lock_bh(&tunnel->hlist_lock);
1565 write_unlock_bh(&tunnel->hlist_lock);
1568 "( tunnel=%p magic=%x )\n",
1570 tunnel, tunnel->magic);
1657 /* Internal function to prepare a tunnel (UDP) socket to have PPPoX sockets
1666 struct pppol2tp_tunnel *tunnel;
1701 tunnel = (struct pppol2tp_tunnel *)sk->sk_user_data;
1702 if (tunnel != NULL) {
1705 if (tunnel->magic != L2TP_TUNNEL_MAGIC) {
1707 "( tunnel=%p magic=%x )\n",
1709 tunnel, tunnel->magic);
1714 ret = tunnel->sock;
1718 /* This socket is available and needs prepping. Create a new tunnel
1721 sk->sk_user_data = tunnel = kmalloc(sizeof(struct pppol2tp_tunnel), GFP_KERNEL);
1727 memset(tunnel, 0, sizeof(struct pppol2tp_tunnel));
1729 tunnel->magic = L2TP_TUNNEL_MAGIC;
1730 sprintf(&tunnel->name[0], "tunl %hu", tunnel_id);
1732 tunnel->stats.tunnel_id = tunnel_id;
1734 tunnel->debug = PPPOL2TP_DEFAULT_DEBUG_FLAGS;
1736 DPRINTK(tunnel->debug, "tunl %hu: allocated tunnel=%p, sk=%p, sock=%p\n",
1737 tunnel_id, tunnel, sk, sock);
1739 tunnel->wq = create_workqueue("kl2tpd");
1740 if (!tunnel->wq) {
1746 tunnel->old_proto = sk->sk_prot;
1747 tunnel->l2tp_proto = *sk->sk_prot;
1749 sk->sk_prot = &tunnel->l2tp_proto;
1751 tunnel->old_data_ready = sk->sk_data_ready;
1754 tunnel->old_sk_destruct = sk->sk_destruct;
1757 tunnel->sock = sk;
1760 rwlock_init(&tunnel->hlist_lock);
1762 /* Add tunnel to our list */
1763 INIT_LIST_HEAD(&tunnel->list);
1764 list_add(&tunnel->list, &pppol2tp_tunnel_list);
1766 ret = tunnel->sock;
1777 kfree(tunnel);
1852 /* connect() handler.. Attach a PPPoX socket to a tunnel UDP socket
1866 struct pppol2tp_tunnel *tunnel;
1895 /* Look up the tunnel socket and configure it if necessary */
1902 tunnel = tunnel_sock->sk_user_data;
1919 session->tunnel = tunnel;
1957 * being created to manage the tunnel. Don't add the session to the
1965 "tunl %hu: socket created for tunnel mgmt ops\n",
1974 /* Add session to the tunnel's hash list */
1975 SOCK_2_TUNNEL(tunnel_sock, tunnel, error, -EBADF, end, 0);
1976 write_lock_bh(&tunnel->hlist_lock);
1978 pppol2tp_session_id_hash(tunnel,
1980 write_unlock_bh(&tunnel->hlist_lock);
2008 atomic_inc(&tunnel->session_count);
2062 * sockets. However, in order to control kernel tunnel features, we allow
2063 * userspace to create a special "tunnel" PPPoX socket which is used for
2220 * application to retrieve session stats via a tunnel socket.
2222 static int pppol2tp_tunnel_ioctl(struct pppol2tp_tunnel *tunnel,
2226 struct sock *sk = tunnel->sock;
2231 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG,
2232 "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n", tunnel->name,
2250 pppol2tp_session_find(tunnel, stats_req.session_id);
2258 tunnel->stats.using_ipsec = (sk->sk_policy[0] || sk->sk_policy[1]) ? 1 : 0;
2260 if (copy_to_user((void __user *) arg, &tunnel->stats,
2261 sizeof(tunnel->stats))) {
2265 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2266 "%s: get L2TP stats\n", tunnel->name);
2281 * Dispatch to tunnel or session helpers depending on the socket.
2288 struct pppol2tp_tunnel *tunnel;
2307 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, err, -EBADF, end, 1);
2310 * tunnel ioctl
2314 err = pppol2tp_tunnel_ioctl(tunnel, cmd, arg);
2329 * sockets. In order to control kernel tunnel features, we allow userspace to
2330 * create a special "tunnel" PPPoX socket which is used for control only.
2338 struct pppol2tp_tunnel *tunnel,
2345 tunnel->debug = val;
2346 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2347 "%s: set debug=%x\n", tunnel->name, tunnel->debug);
2434 * Does API checks, then calls either the tunnel or session setsockopt
2436 * session or the special tunnel type.
2443 struct pppol2tp_tunnel *tunnel;
2464 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, err, -EBADF, end, 1);
2468 /* Special case: if session_id == 0x0000, treat as operation on tunnel
2472 err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val);
2484 struct pppol2tp_tunnel *tunnel,
2491 *val = tunnel->debug;
2492 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2493 "%s: get debug=%x\n", tunnel->name, tunnel->debug);
2551 * Does API checks, then calls either the tunnel or session getsockopt
2553 * or the special tunnel type.
2560 struct pppol2tp_tunnel *tunnel;
2582 /* Get the session and tunnel contexts */
2584 SOCK_2_TUNNEL(session->tunnel_sock, tunnel, err, -EBADF, end, 1);
2586 /* Special case: if session_id == 0x0000, treat as operation on tunnel */
2589 err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val);
2655 struct pppol2tp_tunnel *tunnel = NULL;
2664 tunnel = (void *)1;
2671 tunnel = list_entry(walk, struct pppol2tp_tunnel, list);
2673 sock_hold(tunnel->sock);
2677 tunnel = NULL;
2682 return tunnel;
2687 struct pppol2tp_tunnel *tunnel = v;
2698 list = &tunnel->list;
2702 tunnel = NULL;
2704 tunnel = list_entry(tmp, struct pppol2tp_tunnel, list);
2708 return tunnel;
2713 struct pppol2tp_tunnel *tunnel = v;
2717 if (tunnel != NULL)
2718 sock_put(tunnel->sock);
2725 struct pppol2tp_tunnel *tunnel = v;
2747 tunnel->name,
2748 (tunnel == tunnel->sock->sk_user_data) ? 'Y':'N',
2749 atomic_read(&tunnel->session_count),
2750 (tunnel->magic == L2TP_TUNNEL_MAGIC) ? "OK" : "BAD");
2752 tunnel->debug,
2753 tunnel->stats.tx_packets, tunnel->stats.tx_bytes,
2754 tunnel->stats.tx_errors,
2755 tunnel->stats.rx_packets, tunnel->stats.rx_bytes,
2756 tunnel->stats.rx_errors);
2758 if (tunnel->magic != L2TP_TUNNEL_MAGIC) {
2764 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[i]) {